[FFmpeg-devel] [PATCH v2 02/71] avcodec/ratecontrol: Pass RCContext directly in ff_rate_control_uninit()

Andreas Rheinhardt andreas.rheinhardt at outlook.com
Sat May 11 23:50:26 EEST 2024


Signed-off-by: Andreas Rheinhardt <andreas.rheinhardt at outlook.com>
---
 libavcodec/mpegvideo_enc.c | 2 +-
 libavcodec/ratecontrol.c   | 5 ++---
 libavcodec/ratecontrol.h   | 2 +-
 libavcodec/snowenc.c       | 2 +-
 4 files changed, 5 insertions(+), 6 deletions(-)

diff --git a/libavcodec/mpegvideo_enc.c b/libavcodec/mpegvideo_enc.c
index b601a1a9e4..e31636d787 100644
--- a/libavcodec/mpegvideo_enc.c
+++ b/libavcodec/mpegvideo_enc.c
@@ -989,7 +989,7 @@ av_cold int ff_mpv_encode_end(AVCodecContext *avctx)
     MpegEncContext *s = avctx->priv_data;
     int i;
 
-    ff_rate_control_uninit(s);
+    ff_rate_control_uninit(&s->rc_context);
 
     ff_mpv_common_end(s);
 
diff --git a/libavcodec/ratecontrol.c b/libavcodec/ratecontrol.c
index 27017d7976..78022d80aa 100644
--- a/libavcodec/ratecontrol.c
+++ b/libavcodec/ratecontrol.c
@@ -623,7 +623,7 @@ av_cold int ff_rate_control_init(MpegEncContext *s)
         }
 
         if (init_pass2(s) < 0) {
-            ff_rate_control_uninit(s);
+            ff_rate_control_uninit(rcc);
             return -1;
         }
     }
@@ -688,9 +688,8 @@ av_cold int ff_rate_control_init(MpegEncContext *s)
     return 0;
 }
 
-av_cold void ff_rate_control_uninit(MpegEncContext *s)
+av_cold void ff_rate_control_uninit(RateControlContext *rcc)
 {
-    RateControlContext *rcc = &s->rc_context;
     emms_c();
 
     av_expr_free(rcc->rc_eq_eval);
diff --git a/libavcodec/ratecontrol.h b/libavcodec/ratecontrol.h
index 1f44b44341..a5434f5b90 100644
--- a/libavcodec/ratecontrol.h
+++ b/libavcodec/ratecontrol.h
@@ -87,8 +87,8 @@ struct MpegEncContext;
 int ff_rate_control_init(struct MpegEncContext *s);
 float ff_rate_estimate_qscale(struct MpegEncContext *s, int dry_run);
 void ff_write_pass1_stats(struct MpegEncContext *s);
-void ff_rate_control_uninit(struct MpegEncContext *s);
 int ff_vbv_update(struct MpegEncContext *s, int frame_size);
 void ff_get_2pass_fcode(struct MpegEncContext *s);
+void ff_rate_control_uninit(RateControlContext *rcc);
 
 #endif /* AVCODEC_RATECONTROL_H */
diff --git a/libavcodec/snowenc.c b/libavcodec/snowenc.c
index 43ca602762..b59dc04edc 100644
--- a/libavcodec/snowenc.c
+++ b/libavcodec/snowenc.c
@@ -2077,7 +2077,7 @@ static av_cold int encode_end(AVCodecContext *avctx)
     SnowContext *const s = &enc->com;
 
     ff_snow_common_end(s);
-    ff_rate_control_uninit(&enc->m);
+    ff_rate_control_uninit(&enc->m.rc_context);
     av_frame_free(&s->input_picture);
 
     for (int i = 0; i < MAX_REF_FRAMES; i++) {
-- 
2.40.1



More information about the ffmpeg-devel mailing list