[FFmpeg-cvslog] avformat/segment: Access AVStream more directly

Andreas Rheinhardt git at videolan.org
Sat May 23 08:34:51 EEST 2020


ffmpeg | branch: master | Andreas Rheinhardt <andreas.rheinhardt at gmail.com> | Sun May 17 02:36:46 2020 +0200| [a6828034e031b574d41d4359e4ea7961d7ca45d5] | committer: Andreas Rheinhardt

avformat/segment: Access AVStream more directly

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>

> http://git.videolan.org/gitweb.cgi/ffmpeg.git/?a=commit;h=a6828034e031b574d41d4359e4ea7961d7ca45d5
---

 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;



More information about the ffmpeg-cvslog mailing list