st/va Avoid VBR bitrate calculation overflow v2
authorAndy Furniss <adf.lists@gmail.com>
Mon, 26 Sep 2016 09:44:35 +0000 (10:44 +0100)
committerChristian König <christian.koenig@amd.com>
Tue, 27 Sep 2016 12:21:45 +0000 (14:21 +0200)
VBR bitrate calc needs 64 bits at high rates.

v2: use float.

Signed-off-by: Andy Furniss <adf.lists@gmail.com>
Reviewed-by: Christian König <christian.koenig@amd.com>
Cc: mesa-stable@lists.freedesktop.org
src/gallium/state_trackers/va/picture.c

index 7f3d96d67ab2932c9f69152eb8ace3dded8066d8..399667f8f8eb42215749bc2c7ffece295387bcf1 100644 (file)
@@ -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 = rc->bits_per_second * (rc->target_percentage / 100.0);
    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);