[FFmpeg-devel] [PATCH 31/57] avcodec/mpegvideo_enc: Don't update qscale unnecessarily

Andreas Rheinhardt andreas.rheinhardt at outlook.com
Wed Jun 12 16:48:27 EEST 2024


The new value will be overwritten in ff_set_qscale() below.

Signed-off-by: Andreas Rheinhardt <andreas.rheinhardt at outlook.com>
---
 libavcodec/mpegvideo_enc.c | 6 +++---
 1 file changed, 3 insertions(+), 3 deletions(-)

diff --git a/libavcodec/mpegvideo_enc.c b/libavcodec/mpegvideo_enc.c
index 6d26b2d619..125d16e694 100644
--- a/libavcodec/mpegvideo_enc.c
+++ b/libavcodec/mpegvideo_enc.c
@@ -2163,11 +2163,11 @@ static av_always_inline void encode_mb_internal(MpegEncContext *s,
         const int mb_xy = mb_x + mb_y * s->mb_stride;
 
         s->lambda = s->lambda_table[mb_xy];
-        update_qscale(s);
+        s->lambda2 = (s->lambda * s->lambda + FF_LAMBDA_SCALE / 2) >>
+                     FF_LAMBDA_SHIFT;
 
         if (!(s->mpv_flags & FF_MPV_FLAG_QP_RD)) {
-            s->qscale = s->cur_pic.qscale_table[mb_xy];
-            s->dquant = s->qscale - last_qp;
+            s->dquant = s->cur_pic.qscale_table[mb_xy] - last_qp;
 
             if (s->out_format == FMT_H263) {
                 s->dquant = av_clip(s->dquant, -2, 2);
-- 
2.40.1



More information about the ffmpeg-devel mailing list