[Mesa-dev] [PATCH] st/va Avoid VBR bitrate calculation overflow

Andy Furniss adf.lists at gmail.com
Sun Sep 25 19:29:50 UTC 2016


VBR bitrate calc needs 64 bits at high rates.

Signed-off-by: Andy Furniss <adf.lists at gmail.com>
---
 src/gallium/state_trackers/va/picture.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/src/gallium/state_trackers/va/picture.c b/src/gallium/state_trackers/va/picture.c
index 7f3d96d..cd2dabb 100644
--- a/src/gallium/state_trackers/va/picture.c
+++ b/src/gallium/state_trackers/va/picture.c
@@ -322,7 +322,7 @@ handleVAEncMiscParameterTypeRateControl(vlVaContext *context, VAEncMiscParameter
        PIPE_H264_ENC_RATE_CONTROL_METHOD_CONSTANT)
       context->desc.h264enc.rate_ctrl.target_bitrate = rc->bits_per_second;
    else
-      context->desc.h264enc.rate_ctrl.target_bitrate = rc->bits_per_second * rc->target_percentage / 100;
+      context->desc.h264enc.rate_ctrl.target_bitrate = (unsigned long long)rc->bits_per_second * rc->target_percentage / 100;
    context->desc.h264enc.rate_ctrl.peak_bitrate = rc->bits_per_second;
    if (context->desc.h264enc.rate_ctrl.target_bitrate < 2000000)
       context->desc.h264enc.rate_ctrl.vbv_buffer_size = MIN2((context->desc.h264enc.rate_ctrl.target_bitrate * 2.75), 2000000);
-- 
2.7.0



More information about the mesa-dev mailing list