diff mbox

[FFmpeg-devel,1/3] avformat/hls: Factor copying stream info to a separate function

Message ID 1478468655-2874-2-git-send-email-anssi.hannula@iki.fi
State Accepted
Headers show

Commit Message

Anssi Hannula Nov. 6, 2016, 9:44 p.m. UTC
Signed-off-by: Anssi Hannula <anssi.hannula@iki.fi>
---

 libavformat/hls.c | 18 +++++++++++-------
 1 file changed, 11 insertions(+), 7 deletions(-)

Comments

Andreas Cadhalpun Nov. 6, 2016, 10:32 p.m. UTC | #1
On 06.11.2016 22:44, Anssi Hannula wrote:
> Signed-off-by: Anssi Hannula <anssi.hannula@iki.fi>
> ---
> 
>  libavformat/hls.c | 18 +++++++++++-------
>  1 file changed, 11 insertions(+), 7 deletions(-)
> 
> diff --git a/libavformat/hls.c b/libavformat/hls.c
> index 3c09dd8..6fb652c 100644
> --- a/libavformat/hls.c
> +++ b/libavformat/hls.c
> @@ -1528,6 +1528,16 @@ static void add_stream_to_programs(AVFormatContext *s, struct playlist *pls, AVS
>          av_dict_set_int(&stream->metadata, "variant_bitrate", bandwidth, 0);
>  }
>  
> +static void set_stream_info_from_input_stream(AVStream *st, struct playlist *pls, AVStream *ist)
> +{
> +    avcodec_parameters_copy(st->codecpar, ist->codecpar);
> +
> +    if (pls->is_id3_timestamped) /* custom timestamps via id3 */
> +        avpriv_set_pts_info(st, 33, 1, MPEG_TIME_BASE);
> +    else
> +        avpriv_set_pts_info(st, ist->pts_wrap_bits, ist->time_base.num, ist->time_base.den);
> +}
> +
>  /* add new subdemuxer streams to our context, if any */
>  static int update_streams_from_subdemuxer(AVFormatContext *s, struct playlist *pls)
>  {
> @@ -1540,13 +1550,7 @@ static int update_streams_from_subdemuxer(AVFormatContext *s, struct playlist *p
>              return AVERROR(ENOMEM);
>  
>          st->id = pls->index;
> -
> -        avcodec_parameters_copy(st->codecpar, ist->codecpar);
> -
> -        if (pls->is_id3_timestamped) /* custom timestamps via id3 */
> -            avpriv_set_pts_info(st, 33, 1, MPEG_TIME_BASE);
> -        else
> -            avpriv_set_pts_info(st, ist->pts_wrap_bits, ist->time_base.num, ist->time_base.den);
> +        set_stream_info_from_input_stream(st, pls, ist);
>  
>          dynarray_add(&pls->main_streams, &pls->n_main_streams, st);
>  
> 

OK.

Best regards,
Andreas
diff mbox

Patch

diff --git a/libavformat/hls.c b/libavformat/hls.c
index 3c09dd8..6fb652c 100644
--- a/libavformat/hls.c
+++ b/libavformat/hls.c
@@ -1528,6 +1528,16 @@  static void add_stream_to_programs(AVFormatContext *s, struct playlist *pls, AVS
         av_dict_set_int(&stream->metadata, "variant_bitrate", bandwidth, 0);
 }
 
+static void set_stream_info_from_input_stream(AVStream *st, struct playlist *pls, AVStream *ist)
+{
+    avcodec_parameters_copy(st->codecpar, ist->codecpar);
+
+    if (pls->is_id3_timestamped) /* custom timestamps via id3 */
+        avpriv_set_pts_info(st, 33, 1, MPEG_TIME_BASE);
+    else
+        avpriv_set_pts_info(st, ist->pts_wrap_bits, ist->time_base.num, ist->time_base.den);
+}
+
 /* add new subdemuxer streams to our context, if any */
 static int update_streams_from_subdemuxer(AVFormatContext *s, struct playlist *pls)
 {
@@ -1540,13 +1550,7 @@  static int update_streams_from_subdemuxer(AVFormatContext *s, struct playlist *p
             return AVERROR(ENOMEM);
 
         st->id = pls->index;
-
-        avcodec_parameters_copy(st->codecpar, ist->codecpar);
-
-        if (pls->is_id3_timestamped) /* custom timestamps via id3 */
-            avpriv_set_pts_info(st, 33, 1, MPEG_TIME_BASE);
-        else
-            avpriv_set_pts_info(st, ist->pts_wrap_bits, ist->time_base.num, ist->time_base.den);
+        set_stream_info_from_input_stream(st, pls, ist);
 
         dynarray_add(&pls->main_streams, &pls->n_main_streams, st);