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.kim...@gmail.com
_______________________________________________
ffmpeg-devel mailing list
ffmpeg-devel@ffmpeg.org
https://ffmpeg.org/mailman/listinfo/ffmpeg-devel

To unsubscribe, visit link above, or email
ffmpeg-devel-requ...@ffmpeg.org with subject "unsubscribe".

Reply via email to