From: Boyuan Zhang Date: Thu, 21 Jul 2016 23:40:21 +0000 (-0400) Subject: st/va: add function to handle misc param type frame rate X-Git-Url: https://git.libre-soc.org/?a=commitdiff_plain;h=71da1354d7ce836af5081b109e1487b32348f7f4;p=mesa.git st/va: add function to handle misc param type frame rate Frame rate can be passed to driver either through VAEncSequenceParameterBufferType or VAEncMiscParameterTypeFrameRate. Previous code only implement the former one, which is used by Gstreamer-Vaapi. Now adding implementation for VAEncMiscParameterTypeFrameRate. Also adding default frame rate as 30 just in case application never provides frame rate information to driver. Signed-off-by: Boyuan Zhang --- diff --git a/src/gallium/state_trackers/va/picture.c b/src/gallium/state_trackers/va/picture.c index 4abf1555819..b18745273c1 100644 --- a/src/gallium/state_trackers/va/picture.c +++ b/src/gallium/state_trackers/va/picture.c @@ -117,6 +117,13 @@ getEncParamPreset(vlVaContext *context) context->desc.h264enc.rate_ctrl.fill_data_enable = 1; context->desc.h264enc.rate_ctrl.enforce_hrd = 1; context->desc.h264enc.enable_vui = false; + if (context->desc.h264enc.rate_ctrl.frame_rate_num == 0) + context->desc.h264enc.rate_ctrl.frame_rate_num = 30; + context->desc.h264enc.rate_ctrl.target_bits_picture = + context->desc.h264enc.rate_ctrl.target_bitrate / context->desc.h264enc.rate_ctrl.frame_rate_num; + context->desc.h264enc.rate_ctrl.peak_bits_picture_integer = + context->desc.h264enc.rate_ctrl.peak_bitrate / context->desc.h264enc.rate_ctrl.frame_rate_num; + context->desc.h264enc.rate_ctrl.peak_bits_picture_fraction = 0; context->desc.h264enc.ref_pic_mode = 0x00000201; } @@ -319,15 +326,18 @@ handleVAEncMiscParameterTypeRateControl(vlVaContext *context, VAEncMiscParameter context->desc.h264enc.rate_ctrl.vbv_buffer_size = MIN2((context->desc.h264enc.rate_ctrl.target_bitrate * 2.75), 2000000); else context->desc.h264enc.rate_ctrl.vbv_buffer_size = context->desc.h264enc.rate_ctrl.target_bitrate; - context->desc.h264enc.rate_ctrl.target_bits_picture = - context->desc.h264enc.rate_ctrl.target_bitrate / context->desc.h264enc.rate_ctrl.frame_rate_num; - context->desc.h264enc.rate_ctrl.peak_bits_picture_integer = - context->desc.h264enc.rate_ctrl.peak_bitrate / context->desc.h264enc.rate_ctrl.frame_rate_num; - context->desc.h264enc.rate_ctrl.peak_bits_picture_fraction = 0; return VA_STATUS_SUCCESS; } +static VAStatus +handleVAEncMiscParameterTypeFrameRate(vlVaContext *context, VAEncMiscParameterBuffer *misc) +{ + VAEncMiscParameterFrameRate *fr = (VAEncMiscParameterFrameRate *)misc->data; + context->desc.h264enc.rate_ctrl.frame_rate_num = fr->framerate; + return VA_STATUS_SUCCESS; +} + static VAStatus handleVAEncSequenceParameterBufferType(vlVaDriver *drv, vlVaContext *context, vlVaBuffer *buf) { @@ -357,6 +367,10 @@ handleVAEncMiscParameterBufferType(vlVaContext *context, vlVaBuffer *buf) vaStatus = handleVAEncMiscParameterTypeRateControl(context, misc); break; + case VAEncMiscParameterTypeFrameRate: + vaStatus = handleVAEncMiscParameterTypeFrameRate(context, misc); + break; + default: break; }