summaryrefslogtreecommitdiffstats
path: root/src
diff options
context:
space:
mode:
authorBoyuan Zhang <[email protected]>2016-07-21 19:40:21 -0400
committerChristian König <[email protected]>2016-07-25 13:39:53 +0200
commit71da1354d7ce836af5081b109e1487b32348f7f4 (patch)
tree9e440fa00e92b248a19ac2b8427f0202fd477b9e /src
parent10dec2de2d9f568675d66d736b48701fa26f7b50 (diff)
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 <[email protected]>
Diffstat (limited to 'src')
-rw-r--r--src/gallium/state_trackers/va/picture.c24
1 files changed, 19 insertions, 5 deletions
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,16 +326,19 @@ 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)
{
VAEncSequenceParameterBufferH264 *h264 = (VAEncSequenceParameterBufferH264 *)buf->data;
@@ -357,6 +367,10 @@ handleVAEncMiscParameterBufferType(vlVaContext *context, vlVaBuffer *buf)
vaStatus = handleVAEncMiscParameterTypeRateControl(context, misc);
break;
+ case VAEncMiscParameterTypeFrameRate:
+ vaStatus = handleVAEncMiscParameterTypeFrameRate(context, misc);
+ break;
+
default:
break;
}