diff mbox series

[FFmpeg-devel] bug report in QSV's QVBR rate control

Message ID CAHWoho1SH7cdrUC2wnSWfZs2bqSQBG95h8p0ocZRkx9rKoF3SQ@mail.gmail.com
State New
Headers show
Series [FFmpeg-devel] bug report in QSV's QVBR rate control
Related show

Checks

Context Check Description
andriy/default pending
andriy/configure warning Failed to apply patch

Commit Message

Makoto KIMURA Sept. 2, 2020, 2:34 a.m. UTC
Hi,

I found a bug in libavcodec/qsvenc.c. You know, QSV has several
bitrate control modes (CBR, VBR, .. and so on). The bug is bitrate
setting in QVBR.

In the original code, bitrate value is set in "mfx.MaxKbps". Actually,
it must be "mfx.TargetKbps". As a result, FFmpeg's QVBR always works
in quite low bitrate (ignoring user set bitrate value).
Here is the patch for ffmpeg-4.3.1. (Since MaxKbos has no effects or
side-effects in QVBR, we can leave it as is.)

Best regards

     case MFX_RATECONTROL_CQP:
@@ -652,6 +654,10 @@
 #endif
     }
diff mbox series

Patch

diff --strip-trailing-cr -uNr ffmpeg-4.3.1.orig/libavcodec/qsvenc.c
ffmpeg-4.3.1/libavcodec/qsvenc.c
--- ffmpeg-4.3.1.orig/libavcodec/qsvenc.c   2020-07-11 19:39:30.000000000 +0900
+++ ffmpeg-4.3.1/libavcodec/qsvenc.c    2020-08-03 19:29:41.317275300 +0900
@@ -616,8 +616,10 @@ 
         q->param.mfx.MaxKbps          = max_bitrate_kbps /
brc_param_multiplier;
         q->param.mfx.BRCParamMultiplier = brc_param_multiplier;
 #if QSV_HAVE_QVBR
-        if (q->param.mfx.RateControlMethod == MFX_RATECONTROL_QVBR)
+        if (q->param.mfx.RateControlMethod == MFX_RATECONTROL_QVBR) {
+            q->param.mfx.TargetKbps = q->param.mfx.MaxKbps;
             q->extco3.QVBRQuality = av_clip(avctx->global_quality, 0, 51);
+        }
 #endif
         break;