diff mbox series

[FFmpeg-devel,15/35] fftools/ffmpeg: move freeing 2pass input stats to a better place

Message ID 20220616195534.5278-15-anton@khirnov.net
State Accepted
Commit dceccd4aebe92179f748ab71e048a927968c5b5a
Headers show
Series [FFmpeg-devel,01/35] fftools/ffmpeg_mux: add private muxer context | expand

Checks

Context Check Description
andriy/make_x86 success Make finished
andriy/make_fate_x86 success Make fate finished

Commit Message

Anton Khirnov June 16, 2022, 7:55 p.m. UTC
The current placement of this free is historical - it used to be
followed by avcodec_close(), since removed.

The proper place for freeing the stats is currently right before the
encoder context itself is freed.
---
 fftools/ffmpeg.c | 5 ++---
 1 file changed, 2 insertions(+), 3 deletions(-)
diff mbox series

Patch

diff --git a/fftools/ffmpeg.c b/fftools/ffmpeg.c
index 7496ca1dc6..f60013eace 100644
--- a/fftools/ffmpeg.c
+++ b/fftools/ffmpeg.c
@@ -588,6 +588,8 @@  static void ffmpeg_cleanup(int ret)
         av_dict_free(&ost->sws_dict);
         av_dict_free(&ost->swr_opts);
 
+        if (ost->enc_ctx)
+            av_freep(&ost->enc_ctx->stats_in);
         avcodec_free_context(&ost->enc_ctx);
         avcodec_parameters_free(&ost->ref_par);
 
@@ -4351,9 +4353,6 @@  static int transcode(void)
     /* close each encoder */
     for (i = 0; i < nb_output_streams; i++) {
         ost = output_streams[i];
-        if (ost->encoding_needed) {
-            av_freep(&ost->enc_ctx->stats_in);
-        }
         total_packets_written += ost->packets_written;
         if (!ost->packets_written && (abort_on_flags & ABORT_ON_FLAG_EMPTY_OUTPUT_STREAM)) {
             av_log(NULL, AV_LOG_FATAL, "Empty output on stream %d.\n", i);