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

Andreas Rheinhardt andreas.rheinhardt at gmail.com
Fri May 22 04:43:32 EEST 2020


Andreas Rheinhardt:
> by storing s->streams[i] in a pointer instead of constantly using
> s->streams[i]->...
> 
> Signed-off-by: Andreas Rheinhardt <andreas.rheinhardt at 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


More information about the ffmpeg-devel mailing list