aboutsummaryrefslogtreecommitdiffstats
path: root/src/gallium/state_trackers/va
diff options
context:
space:
mode:
authorAndy Furniss <[email protected]>2017-01-29 14:22:31 +0000
committerChristian König <[email protected]>2017-03-06 14:04:24 +0100
commit012b6d3fe7937d1624f906351b2ba555d9e7e112 (patch)
tree79f75666bc9256a61cdda06a6b8feb7293f13c67 /src/gallium/state_trackers/va
parentf3dc318464b786c2696e650e7c69984b5453624b (diff)
st/va encode handle ntsc framerate rate control
Tested with ffmpeg and gst-vaapi. Without this bits per frame is set way too low for fractional framerates. v2: Mark Thompson: simplify calculation. Use float. Signed-off-by: Andy Furniss <[email protected]> Acked-by: Christian König <[email protected]>
Diffstat (limited to 'src/gallium/state_trackers/va')
-rw-r--r--src/gallium/state_trackers/va/picture.c19
1 files changed, 13 insertions, 6 deletions
diff --git a/src/gallium/state_trackers/va/picture.c b/src/gallium/state_trackers/va/picture.c
index 82584eafc56..53bb9eb9e32 100644
--- a/src/gallium/state_trackers/va/picture.c
+++ b/src/gallium/state_trackers/va/picture.c
@@ -119,14 +119,21 @@ 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;
+ if (context->desc.h264enc.rate_ctrl.frame_rate_num == 0 ||
+ context->desc.h264enc.rate_ctrl.frame_rate_den == 0) {
+ context->desc.h264enc.rate_ctrl.frame_rate_num = 30;
+ 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.target_bitrate *
+ ((float)context->desc.h264enc.rate_ctrl.frame_rate_den /
+ 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.rate_ctrl.peak_bitrate *
+ ((float)context->desc.h264enc.rate_ctrl.frame_rate_den /
+ 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;
}
@@ -362,7 +369,7 @@ handleVAEncSequenceParameterBufferType(vlVaDriver *drv, vlVaContext *context, vl
context->gop_coeff = VL_VA_ENC_GOP_COEFF;
context->desc.h264enc.gop_size = h264->intra_idr_period * context->gop_coeff;
context->desc.h264enc.rate_ctrl.frame_rate_num = h264->time_scale / 2;
- context->desc.h264enc.rate_ctrl.frame_rate_den = 1;
+ context->desc.h264enc.rate_ctrl.frame_rate_den = h264->num_units_in_tick;
return VA_STATUS_SUCCESS;
}