[FFmpeg-devel] [PATCH 11/33] fftools/ffmpeg_mux_init: move allocation out of prologue

Anton Khirnov anton at khirnov.net
Thu Jul 13 13:55:31 EEST 2023


ost_add() has a very large variable declaration prologue, performing
"active" actions that can fail in there is confusing.
---
 fftools/ffmpeg_mux_init.c | 3 ++-
 1 file changed, 2 insertions(+), 1 deletion(-)

diff --git a/fftools/ffmpeg_mux_init.c b/fftools/ffmpeg_mux_init.c
index 8e640610cd..bd4c0a9f97 100644
--- a/fftools/ffmpeg_mux_init.c
+++ b/fftools/ffmpeg_mux_init.c
@@ -987,13 +987,14 @@ static OutputStream *ost_add(Muxer *mux, const OptionsContext *o,
     MuxStream     *ms;
     OutputStream *ost;
     const AVCodec *enc;
-    AVStream *st = avformat_new_stream(oc, NULL);
+    AVStream *st;
     int ret = 0;
     const char *bsfs = NULL, *time_base = NULL;
     char *filters = NULL, *next, *codec_tag = NULL;
     double qscale = -1;
     int i;
 
+    st = avformat_new_stream(oc, NULL);
     if (!st)
         report_and_exit(AVERROR(ENOMEM));
 
-- 
2.40.1



More information about the ffmpeg-devel mailing list