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

Makoto KIMURA makoto.kimura at gmail.com
Wed Sep 2 05:34:01 EEST 2020


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

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;
     case MFX_RATECONTROL_CQP:
@@ -652,6 +654,10 @@
 #endif
     }


-- 
Makoto KIMURA
email : makoto.kimura at gmail.com


More information about the ffmpeg-devel mailing list