[FFmpeg-cvslog] avformat/oggdec: Factor free_stream out

Michael Niedermayer git at videolan.org
Thu Mar 2 04:13:54 EET 2017


ffmpeg | branch: master | Michael Niedermayer <michael at niedermayer.cc> | Tue Feb 28 15:16:23 2017 +0100| [fb6fa48fce3a09a30403326973f03f0343c6e24a] | committer: Michael Niedermayer

avformat/oggdec: Factor free_stream out

Signed-off-by: Michael Niedermayer <michael at niedermayer.cc>

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

 libavformat/oggdec.c | 23 ++++++++++++++++-------
 1 file changed, 16 insertions(+), 7 deletions(-)

diff --git a/libavformat/oggdec.c b/libavformat/oggdec.c
index 64a8826..98cd0f5 100644
--- a/libavformat/oggdec.c
+++ b/libavformat/oggdec.c
@@ -63,6 +63,21 @@ static int64_t ogg_calc_pts(AVFormatContext *s, int idx, int64_t *dts);
 static int ogg_new_stream(AVFormatContext *s, uint32_t serial);
 static int ogg_restore(AVFormatContext *s);
 
+static void free_stream(AVFormatContext *s, int i)
+{
+    struct ogg *ogg = s->priv_data;
+    struct ogg_stream *stream = &ogg->streams[i];
+
+    av_freep(&stream->buf);
+    if (stream->codec &&
+        stream->codec->cleanup) {
+        stream->codec->cleanup(s, i);
+    }
+
+    av_freep(&stream->private);
+    av_freep(&stream->new_metadata);
+}
+
 //FIXME We could avoid some structure duplication
 static int ogg_save(AVFormatContext *s)
 {
@@ -662,13 +677,7 @@ static int ogg_read_close(AVFormatContext *s)
     int i;
 
     for (i = 0; i < ogg->nstreams; i++) {
-        av_freep(&ogg->streams[i].buf);
-        if (ogg->streams[i].codec &&
-            ogg->streams[i].codec->cleanup) {
-            ogg->streams[i].codec->cleanup(s, i);
-        }
-        av_freep(&ogg->streams[i].private);
-        av_freep(&ogg->streams[i].new_metadata);
+        free_stream(s, i);
     }
 
     ogg->nstreams = 0;



More information about the ffmpeg-cvslog mailing list