[FFmpeg-devel] [PATCH 2/2] lavf/vaapi_encode: fix to set the default max bitrate for AVC VBR

Pengfei Qu Pengfei.Qu at intel.com
Mon Mar 12 07:38:10 EET 2018


    And for VBR mode, generally the max bit rate is bigger than the taraget
    bitrate. For CBR mode, the max bitrate is same as the target bitrate.
     when there is no specfic setting for the max bit rate parameter,
    here the default value 95% is used to caculate the default max bitrate accordingly.

Signed-off-by: Pengfei Qu <Pengfei.Qu at intel.com>
---
 libavcodec/vaapi_encode.c | 4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)

diff --git a/libavcodec/vaapi_encode.c b/libavcodec/vaapi_encode.c
index 78347d4..47110cf 100644
--- a/libavcodec/vaapi_encode.c
+++ b/libavcodec/vaapi_encode.c
@@ -1164,8 +1164,8 @@ static av_cold int vaapi_encode_init_rate_control(AVCodecContext *avctx)
     } else {
         if (avctx->rc_max_rate < avctx->bit_rate) {
             // Max rate is unset or invalid, just use the normal bitrate.
-            rc_bits_per_second   = avctx->bit_rate;
-            rc_target_percentage = 100;
+            rc_target_percentage = 95;
+            rc_bits_per_second   = (unsigned long)(avctx->bit_rate * 100.0 / rc_target_percentage);
         } else {
             rc_bits_per_second   = avctx->rc_max_rate;
             rc_target_percentage = (unsigned long)(avctx->bit_rate * 100) / rc_bits_per_second;
-- 
2.9.3



More information about the ffmpeg-devel mailing list