[FFmpeg-devel] [PATCH 1/2] vaapi_encode: ensure correct VBR bitrate is used in h264 SPS

Aman Gupta ffmpeg at tmm1.net
Tue Aug 13 03:25:37 EEST 2019


From: Aman Gupta <aman at tmm1.net>

This is a regression from 2562dd9e7831743ba6dc5680501fb7d26a2ec62c
which surfaces a pathological bug in the Intel Broxton/CherryView
hardware encoders, causing very low bitrates to be generated
whenever VBR mode is used.

/cc intel/intel-vaapi-driver#480

Signed-off-by: Aman Gupta <aman at tmm1.net>
---
 libavcodec/vaapi_encode.c | 3 +++
 1 file changed, 3 insertions(+)

diff --git a/libavcodec/vaapi_encode.c b/libavcodec/vaapi_encode.c
index e69b59fa37..231efba6cc 100644
--- a/libavcodec/vaapi_encode.c
+++ b/libavcodec/vaapi_encode.c
@@ -1665,6 +1665,9 @@ rc_mode_found:
     ctx->va_rc_mode  = rc_mode->va_mode;
     ctx->va_bit_rate = rc_bits_per_second;
 
+    if (ctx->va_rc_mode == VA_RC_VBR)
+        ctx->va_bit_rate = rc_bits_per_second * rc_target_percentage / 100;
+
     av_log(avctx, AV_LOG_VERBOSE, "RC mode: %s.\n", rc_mode->name);
     if (rc_attr.value == VA_ATTRIB_NOT_SUPPORTED) {
         // This driver does not want the RC mode attribute to be set.
-- 
2.20.1



More information about the ffmpeg-devel mailing list