diff mbox series

[FFmpeg-devel,18/22] fftools/ffmpeg: remove a cleanup block at the end of transcode()

Message ID 20221014101548.3486-5-anton@khirnov.net
State Accepted
Commit fe304c069487685734844e7e882589d56768d025
Headers show
Series [FFmpeg-devel,01/13] fftools/ffmpeg_mux: do not unref a NULL packet | expand

Checks

Context Check Description
yinshiyou/make_loongarch64 success Make finished
yinshiyou/make_fate_loongarch64 success Make fate finished
andriy/make_x86 success Make finished
andriy/make_fate_x86 success Make fate finished

Commit Message

Anton Khirnov Oct. 14, 2022, 10:15 a.m. UTC
Some of it is already duplicated in ost_free() - those parts can be just
dropped(). The rest is moved to ost_free(), as it properly belongs
there.
---
 fftools/ffmpeg.c | 29 +++++++++++------------------
 1 file changed, 11 insertions(+), 18 deletions(-)
diff mbox series

Patch

diff --git a/fftools/ffmpeg.c b/fftools/ffmpeg.c
index b98065d2a0..4e9ea731ff 100644
--- a/fftools/ffmpeg.c
+++ b/fftools/ffmpeg.c
@@ -509,6 +509,14 @@  static void ost_free(OutputStream **post)
     if (!ost)
         return;
 
+    if (ost->logfile) {
+        if (fclose(ost->logfile))
+            av_log(NULL, AV_LOG_ERROR,
+                   "Error closing logfile, loss of information possible: %s\n",
+                   av_err2str(AVERROR(errno)));
+        ost->logfile = NULL;
+    }
+
     av_bsf_free(&ost->bsf_ctx);
 
     av_frame_free(&ost->filtered_frame);
@@ -521,6 +529,9 @@  static void ost_free(OutputStream **post)
     av_expr_free(ost->forced_keyframes_pexpr);
     av_freep(&ost->avfilter);
     av_freep(&ost->logfile_prefix);
+    av_freep(&ost->forced_kf_pts);
+    av_freep(&ost->apad);
+    av_freep(&ost->disposition);
 
 #if FFMPEG_OPT_MAP_CHANNEL
     av_freep(&ost->audio_channels_map);
@@ -4033,24 +4044,6 @@  static int transcode(void)
  fail:
     free_input_threads();
 
-        for (OutputStream *ost = ost_iter(NULL); ost; ost = ost_iter(ost)) {
-            if (ost) {
-                if (ost->logfile) {
-                    if (fclose(ost->logfile))
-                        av_log(NULL, AV_LOG_ERROR,
-                               "Error closing logfile, loss of information possible: %s\n",
-                               av_err2str(AVERROR(errno)));
-                    ost->logfile = NULL;
-                }
-                av_freep(&ost->forced_kf_pts);
-                av_freep(&ost->apad);
-                av_freep(&ost->disposition);
-                av_dict_free(&ost->encoder_opts);
-                av_dict_free(&ost->sws_dict);
-                av_dict_free(&ost->swr_opts);
-            }
-        }
-
     return ret;
 }