Module: Mesa Branch: staging/23.2 Commit: 8d5d8757e1887ac4d0ab1943ad051c9685ced61c URL: http://cgit.freedesktop.org/mesa/mesa/commit/?id=8d5d8757e1887ac4d0ab1943ad051c9685ced61c
Author: David Rosca <[email protected]> Date: Sat Sep 23 15:49:55 2023 +0200 frontends/va: Set default rate control values once when creating encoder Move setting the default values from getEncParamPresetH264/5 as this function is called on each frame which would result in overwriting values set by application. This fixes setting HRD parameters and max_qp/min_qp when PIPE_VIDEO_CAP_ENC_QUALITY_LEVEL is not supported. Cc: mesa-stable Reviewed-by: Ruijing Dong <[email protected]> Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/25355> (cherry picked from commit dd2ef9a0e4c706e3139f48d16fc8a617e58717d0) --- .pick_status.json | 2 +- src/gallium/frontends/va/picture_h264_enc.c | 14 +++++++------- src/gallium/frontends/va/picture_hevc_enc.c | 13 ++++++------- 3 files changed, 14 insertions(+), 15 deletions(-) diff --git a/.pick_status.json b/.pick_status.json index 8bb08a0e9b2..82f58b46caf 100644 --- a/.pick_status.json +++ b/.pick_status.json @@ -144,7 +144,7 @@ "description": "frontends/va: Set default rate control values once when creating encoder", "nominated": true, "nomination_type": 0, - "resolution": 0, + "resolution": 1, "main_sha": null, "because_sha": null, "notes": null diff --git a/src/gallium/frontends/va/picture_h264_enc.c b/src/gallium/frontends/va/picture_h264_enc.c index 28084c82cbb..a0767bdff43 100644 --- a/src/gallium/frontends/va/picture_h264_enc.c +++ b/src/gallium/frontends/va/picture_h264_enc.c @@ -187,6 +187,13 @@ vlVaHandleVAEncSequenceParameterBufferTypeH264(vlVaDriver *drv, vlVaContext *con return VA_STATUS_ERROR_ALLOCATION_FAILED; getEncParamPresetH264(context); + context->desc.h264enc.rate_ctrl[0].vbv_buffer_size = 20000000; + context->desc.h264enc.rate_ctrl[0].vbv_buf_lv = 48; + context->desc.h264enc.rate_ctrl[0].fill_data_enable = 1; + context->desc.h264enc.rate_ctrl[0].enforce_hrd = 1; + context->desc.h264enc.rate_ctrl[0].max_qp = 51; + context->desc.h264enc.rate_ctrl[0].min_qp = 0; + context->desc.h264enc.enable_vui = false; } context->desc.h264enc.intra_idr_period = @@ -359,13 +366,6 @@ vlVaHandleVAEncMiscParameterTypeHRDH264(vlVaContext *context, VAEncMiscParameter void getEncParamPresetH264(vlVaContext *context) { //rate control - context->desc.h264enc.rate_ctrl[0].vbv_buffer_size = 20000000; - context->desc.h264enc.rate_ctrl[0].vbv_buf_lv = 48; - context->desc.h264enc.rate_ctrl[0].fill_data_enable = 1; - context->desc.h264enc.rate_ctrl[0].enforce_hrd = 1; - context->desc.h264enc.rate_ctrl[0].max_qp = 51; - context->desc.h264enc.rate_ctrl[0].min_qp = 0; - context->desc.h264enc.enable_vui = false; if (context->desc.h264enc.rate_ctrl[0].frame_rate_num == 0 || context->desc.h264enc.rate_ctrl[0].frame_rate_den == 0) { context->desc.h264enc.rate_ctrl[0].frame_rate_num = 30; diff --git a/src/gallium/frontends/va/picture_hevc_enc.c b/src/gallium/frontends/va/picture_hevc_enc.c index f379007d1fc..a33c394e322 100644 --- a/src/gallium/frontends/va/picture_hevc_enc.c +++ b/src/gallium/frontends/va/picture_hevc_enc.c @@ -167,6 +167,12 @@ vlVaHandleVAEncSequenceParameterBufferTypeHEVC(vlVaDriver *drv, vlVaContext *con return VA_STATUS_ERROR_ALLOCATION_FAILED; getEncParamPresetH265(context); + context->desc.h265enc.rc.vbv_buffer_size = 20000000; + context->desc.h265enc.rc.vbv_buf_lv = 48; + context->desc.h265enc.rc.fill_data_enable = 1; + context->desc.h265enc.rc.enforce_hrd = 1; + context->desc.h265enc.rc.max_qp = 51; + context->desc.h265enc.rc.min_qp = 0; } context->desc.h265enc.seq.general_profile_idc = h265->general_profile_idc; @@ -429,13 +435,6 @@ vlVaHandleVAEncMiscParameterTypeHRDHEVC(vlVaContext *context, VAEncMiscParameter void getEncParamPresetH265(vlVaContext *context) { //rate control - context->desc.h265enc.rc.vbv_buffer_size = 20000000; - context->desc.h265enc.rc.vbv_buf_lv = 48; - context->desc.h265enc.rc.fill_data_enable = 1; - context->desc.h265enc.rc.enforce_hrd = 1; - context->desc.h265enc.rc.max_qp = 51; - context->desc.h265enc.rc.min_qp = 0; - if (context->desc.h265enc.rc.frame_rate_num == 0 || context->desc.h265enc.rc.frame_rate_den == 0) { context->desc.h265enc.rc.frame_rate_num = 30;
