[FFmpeg-devel] [PATCH v2 05/11] avformat/mux: Refactor muxer deinit from av_write_trailer
sebechlebskyjan at gmail.com
sebechlebskyjan at gmail.com
Thu Aug 11 15:39:49 EEST 2016
From: Jan Sebechlebsky <sebechlebskyjan at gmail.com>
Move muxer deinitialization and private resources freeing
in a separate static function free_muxer(AVFormatContext*).
Signed-off-by: Jan Sebechlebsky <sebechlebskyjan at gmail.com>
---
No changes since the last version, just rebased because
of changes in previous patch.
libavformat/mux.c | 31 ++++++++++++++++++++-----------
1 file changed, 20 insertions(+), 11 deletions(-)
diff --git a/libavformat/mux.c b/libavformat/mux.c
index 3ae924c..45f1401 100644
--- a/libavformat/mux.c
+++ b/libavformat/mux.c
@@ -1197,9 +1197,27 @@ fail:
return ret;
}
+static void deinit_muxer(AVFormatContext *s)
+{
+ int i;
+
+ if (s->oformat->deinit)
+ s->oformat->deinit(s);
+
+ for (i = 0; i < s->nb_streams; i++) {
+ av_freep(&s->streams[i]->priv_data);
+ av_freep(&s->streams[i]->index_entries);
+ }
+
+ if (s->oformat->priv_class)
+ av_opt_free(s->priv_data);
+
+ av_freep(&s->priv_data);
+}
+
int av_write_trailer(AVFormatContext *s)
{
- int ret, i;
+ int ret;
for (;; ) {
AVPacket pkt;
@@ -1244,20 +1262,11 @@ fail:
if (ret == AVERROR(EAGAIN))
return ret;
- if (s->oformat->deinit)
- s->oformat->deinit(s);
-
if (s->pb)
avio_flush(s->pb);
if (ret == 0)
ret = s->pb ? s->pb->error : 0;
- for (i = 0; i < s->nb_streams; i++) {
- av_freep(&s->streams[i]->priv_data);
- av_freep(&s->streams[i]->index_entries);
- }
- if (s->oformat->priv_class)
- av_opt_free(s->priv_data);
- av_freep(&s->priv_data);
+ deinit_muxer(s);
return ret;
}
--
1.9.1
More information about the ffmpeg-devel
mailing list