[Mesa-dev] [PATCH] st/va: enable vbr rate control for vaapi encode

Andy Furniss adf.lists at gmail.com
Sun Sep 25 10:45:38 UTC 2016


Leo Liu wrote:
>
>
> On 09/07/2016 03:02 AM, Christian König wrote:
>> Am 06.09.2016 um 22:39 schrieb boyuan.zhang at amd.com:
>>> From: Boyuan Zhang <boyuan.zhang at amd.com>
>>>
>>> This patch enables variable bit-rate for vaapi encoding. According to
>>> va.h,
>>> target bit-rate equals to maximum bit-rate multiplies by
>>> target_percentage.
>>>
>>> Signed-off-by: Boyuan Zhang <boyuan.zhang at amd.com>
>>
>> That was astonishing simple to fix :)

Bit late on this but I am not sure this is VBR as it's constrained and
that has it's own setting.

Maybe I am taking too much notice of what libx264/broadcast encoders do,
but it would be good if VCE could throw way more bits at IDR frames as
they really need it to avoid pulsing with default gop 30.

Of course I don't know how things work/what's possible.

The names help of course but not always eg. what is -

peak_bits_picture_fraction seems to be always 0.

and

rate_ctrl.vbv_buf_lv 0 or 48 is this some level in a spec, or is it
initial buffer fullness for vbv?

One issue I found and sent a patch for is the bitrate calc can overflow.

Generally as a user asking for a rate and getting 70% seems a bit
strange anyway but maybe that's a different discussion.

https://patchwork.freedesktop.org/patch/112040/

>>
>> Patch is Reviewed-by: Christian König <christian.koenig at amd.com>.
>>
>> Leo do you want to push it or should I take care of this?
>
> I will take care of it.
>
> Regards,
> Leo
>
>>
>> Regards,
>> Christian.
>>
>>> ---
>>>   src/gallium/state_trackers/va/config.c  | 2 +-
>>>   src/gallium/state_trackers/va/picture.c | 2 +-
>>>   2 files changed, 2 insertions(+), 2 deletions(-)
>>>
>>> diff --git a/src/gallium/state_trackers/va/config.c
>>> b/src/gallium/state_trackers/va/config.c
>>> index 84bf913..4052316 100644
>>> --- a/src/gallium/state_trackers/va/config.c
>>> +++ b/src/gallium/state_trackers/va/config.c
>>> @@ -120,7 +120,7 @@ vlVaGetConfigAttributes(VADriverContextP ctx,
>>> VAProfile profile, VAEntrypoint en
>>>            value = VA_RT_FORMAT_YUV420;
>>>            break;
>>>         case VAConfigAttribRateControl:
>>> -         value = VA_RC_CQP | VA_RC_CBR;
>>> +         value = VA_RC_CQP | VA_RC_CBR | VA_RC_VBR;
>>>            break;
>>>         default:
>>>            value = VA_ATTRIB_NOT_SUPPORTED;
>>> diff --git a/src/gallium/state_trackers/va/picture.c
>>> b/src/gallium/state_trackers/va/picture.c
>>> index a283e83..7f3d96d 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;
>>> +      context->desc.h264enc.rate_ctrl.target_bitrate =
>>> 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);
>>
>>
>> _______________________________________________
>> mesa-dev mailing list
>> mesa-dev at lists.freedesktop.org
>> https://lists.freedesktop.org/mailman/listinfo/mesa-dev
>
> _______________________________________________
> mesa-dev mailing list
> mesa-dev at lists.freedesktop.org
> https://lists.freedesktop.org/mailman/listinfo/mesa-dev



More information about the mesa-dev mailing list