diff mbox series

[FFmpeg-devel,1/6] avformat/segment: Access AVStream more directly

Message ID 20200517231319.13067-1-andreas.rheinhardt@gmail.com
State Accepted
Commit a6828034e031b574d41d4359e4ea7961d7ca45d5
Headers show
Series [FFmpeg-devel,1/6] avformat/segment: Access AVStream more directly
Related show

Checks

Context Check Description
andriy/default pending
andriy/make success Make finished
andriy/make_fate success Make fate finished

Commit Message

Andreas Rheinhardt May 17, 2020, 11:13 p.m. UTC
by storing s->streams[i] in a pointer instead of constantly using
s->streams[i]->...

Signed-off-by: Andreas Rheinhardt <andreas.rheinhardt@gmail.com>
---
 libavformat/segment.c | 17 ++++++++---------
 1 file changed, 8 insertions(+), 9 deletions(-)

Comments

Andreas Rheinhardt May 22, 2020, 1:43 a.m. UTC | #1
Andreas Rheinhardt:
> by storing s->streams[i] in a pointer instead of constantly using
> s->streams[i]->...
> 
> Signed-off-by: Andreas Rheinhardt <andreas.rheinhardt@gmail.com>
> ---
>  libavformat/segment.c | 17 ++++++++---------
>  1 file changed, 8 insertions(+), 9 deletions(-)
> 
> diff --git a/libavformat/segment.c b/libavformat/segment.c
> index 32c09827eb..7e8bd65976 100644
> --- a/libavformat/segment.c
> +++ b/libavformat/segment.c
> @@ -162,12 +162,11 @@ static int segment_mux_init(AVFormatContext *s)
>      oc->flags              = s->flags;
>  
>      for (i = 0; i < s->nb_streams; i++) {
> -        AVStream *st;
> -        AVCodecParameters *ipar, *opar;
> +        AVStream *st, *ist = s->streams[i];
> +        AVCodecParameters *ipar = ist->codecpar, *opar;
>  
>          if (!(st = avformat_new_stream(oc, NULL)))
>              return AVERROR(ENOMEM);
> -        ipar = s->streams[i]->codecpar;
>          opar = st->codecpar;
>          avcodec_parameters_copy(opar, ipar);
>          if (!oc->oformat->codec_tag ||
> @@ -177,16 +176,16 @@ static int segment_mux_init(AVFormatContext *s)
>          } else {
>              opar->codec_tag = 0;
>          }
> -        st->sample_aspect_ratio = s->streams[i]->sample_aspect_ratio;
> -        st->time_base = s->streams[i]->time_base;
> -        st->avg_frame_rate = s->streams[i]->avg_frame_rate;
> +        st->sample_aspect_ratio = ist->sample_aspect_ratio;
> +        st->time_base           = ist->time_base;
> +        st->avg_frame_rate      = ist->avg_frame_rate;
>  #if FF_API_LAVF_AVCTX
>  FF_DISABLE_DEPRECATION_WARNINGS
> -        if (s->streams[i]->codecpar->codec_tag == MKTAG('t','m','c','d'))
> -            st->codec->time_base = s->streams[i]->codec->time_base;
> +        if (ipar->codec_tag == MKTAG('t','m','c','d'))
> +            st->codec->time_base = ist->codec->time_base;
>  FF_ENABLE_DEPRECATION_WARNINGS
>  #endif
> -        av_dict_copy(&st->metadata, s->streams[i]->metadata, 0);
> +        av_dict_copy(&st->metadata, ist->metadata, 0);
>      }
>  
>      return 0;
> 
Will apply this patchset tomorrow unless there are objections.

- Andreas
Andreas Rheinhardt May 23, 2020, 5:36 a.m. UTC | #2
Andreas Rheinhardt:
> Andreas Rheinhardt:
>> by storing s->streams[i] in a pointer instead of constantly using
>> s->streams[i]->...
>>
>> Signed-off-by: Andreas Rheinhardt <andreas.rheinhardt@gmail.com>
>> ---
>>  libavformat/segment.c | 17 ++++++++---------
>>  1 file changed, 8 insertions(+), 9 deletions(-)
>>
>> diff --git a/libavformat/segment.c b/libavformat/segment.c
>> index 32c09827eb..7e8bd65976 100644
>> --- a/libavformat/segment.c
>> +++ b/libavformat/segment.c
>> @@ -162,12 +162,11 @@ static int segment_mux_init(AVFormatContext *s)
>>      oc->flags              = s->flags;
>>  
>>      for (i = 0; i < s->nb_streams; i++) {
>> -        AVStream *st;
>> -        AVCodecParameters *ipar, *opar;
>> +        AVStream *st, *ist = s->streams[i];
>> +        AVCodecParameters *ipar = ist->codecpar, *opar;
>>  
>>          if (!(st = avformat_new_stream(oc, NULL)))
>>              return AVERROR(ENOMEM);
>> -        ipar = s->streams[i]->codecpar;
>>          opar = st->codecpar;
>>          avcodec_parameters_copy(opar, ipar);
>>          if (!oc->oformat->codec_tag ||
>> @@ -177,16 +176,16 @@ static int segment_mux_init(AVFormatContext *s)
>>          } else {
>>              opar->codec_tag = 0;
>>          }
>> -        st->sample_aspect_ratio = s->streams[i]->sample_aspect_ratio;
>> -        st->time_base = s->streams[i]->time_base;
>> -        st->avg_frame_rate = s->streams[i]->avg_frame_rate;
>> +        st->sample_aspect_ratio = ist->sample_aspect_ratio;
>> +        st->time_base           = ist->time_base;
>> +        st->avg_frame_rate      = ist->avg_frame_rate;
>>  #if FF_API_LAVF_AVCTX
>>  FF_DISABLE_DEPRECATION_WARNINGS
>> -        if (s->streams[i]->codecpar->codec_tag == MKTAG('t','m','c','d'))
>> -            st->codec->time_base = s->streams[i]->codec->time_base;
>> +        if (ipar->codec_tag == MKTAG('t','m','c','d'))
>> +            st->codec->time_base = ist->codec->time_base;
>>  FF_ENABLE_DEPRECATION_WARNINGS
>>  #endif
>> -        av_dict_copy(&st->metadata, s->streams[i]->metadata, 0);
>> +        av_dict_copy(&st->metadata, ist->metadata, 0);
>>      }
>>  
>>      return 0;
>>
> Will apply this patchset tomorrow unless there are objections.
> 
> - Andreas
> 
Applied.

- Andreas
diff mbox series

Patch

diff --git a/libavformat/segment.c b/libavformat/segment.c
index 32c09827eb..7e8bd65976 100644
--- a/libavformat/segment.c
+++ b/libavformat/segment.c
@@ -162,12 +162,11 @@  static int segment_mux_init(AVFormatContext *s)
     oc->flags              = s->flags;
 
     for (i = 0; i < s->nb_streams; i++) {
-        AVStream *st;
-        AVCodecParameters *ipar, *opar;
+        AVStream *st, *ist = s->streams[i];
+        AVCodecParameters *ipar = ist->codecpar, *opar;
 
         if (!(st = avformat_new_stream(oc, NULL)))
             return AVERROR(ENOMEM);
-        ipar = s->streams[i]->codecpar;
         opar = st->codecpar;
         avcodec_parameters_copy(opar, ipar);
         if (!oc->oformat->codec_tag ||
@@ -177,16 +176,16 @@  static int segment_mux_init(AVFormatContext *s)
         } else {
             opar->codec_tag = 0;
         }
-        st->sample_aspect_ratio = s->streams[i]->sample_aspect_ratio;
-        st->time_base = s->streams[i]->time_base;
-        st->avg_frame_rate = s->streams[i]->avg_frame_rate;
+        st->sample_aspect_ratio = ist->sample_aspect_ratio;
+        st->time_base           = ist->time_base;
+        st->avg_frame_rate      = ist->avg_frame_rate;
 #if FF_API_LAVF_AVCTX
 FF_DISABLE_DEPRECATION_WARNINGS
-        if (s->streams[i]->codecpar->codec_tag == MKTAG('t','m','c','d'))
-            st->codec->time_base = s->streams[i]->codec->time_base;
+        if (ipar->codec_tag == MKTAG('t','m','c','d'))
+            st->codec->time_base = ist->codec->time_base;
 FF_ENABLE_DEPRECATION_WARNINGS
 #endif
-        av_dict_copy(&st->metadata, s->streams[i]->metadata, 0);
+        av_dict_copy(&st->metadata, ist->metadata, 0);
     }
 
     return 0;