diff --git a/src/gallium/state_trackers/va/picture.c b/src/gallium/state_trackers/va/picture.c index a8102a4..121d558 100644 --- a/src/gallium/state_trackers/va/picture.c +++ b/src/gallium/state_trackers/va/picture.c @@ -121,12 +121,26 @@ getEncParamPreset(vlVaContext *context) 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; + if (context->desc.h264enc.rate_ctrl.frame_rate_num > 1000) { + context->desc.h264enc.rate_ctrl.frame_rate_den = 1001; + context->desc.h264enc.rate_ctrl.target_bits_picture = + context->desc.h264enc.rate_ctrl.target_bitrate / + (context->desc.h264enc.rate_ctrl.frame_rate_num / 1000); + context->desc.h264enc.rate_ctrl.peak_bits_picture_integer = + context->desc.h264enc.rate_ctrl.peak_bitrate / + (context->desc.h264enc.rate_ctrl.frame_rate_num / 1000); + } else { + context->desc.h264enc.rate_ctrl.frame_rate_den = 1; + 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; } @@ -353,7 +367,6 @@ handleVAEncSequenceParameterBufferType(vlVaDriver *drv, vlVaContext *context, vl } context->desc.h264enc.gop_size = h264->intra_idr_period; context->desc.h264enc.rate_ctrl.frame_rate_num = h264->time_scale / 2; - context->desc.h264enc.rate_ctrl.frame_rate_den = 1; return VA_STATUS_SUCCESS; }