From 1479e1ef822492198c17bcdae9e3fb1ab7ab930e Mon Sep 17 00:00:00 2001 From: Hyunjun Ko Date: Wed, 12 Nov 2025 15:32:17 +0100 Subject: [PATCH] anv/video: rework for handling alternative quantizer for vp9 decoding. including prep-work for handling segmentation features. Signed-off-by: Hyunjun Ko Acked-by: Lionel Landwerlin Part-of: --- src/intel/vulkan/anv_private.h | 1 + src/intel/vulkan/anv_video.c | 15 +-------------- src/intel/vulkan/genX_cmd_video.c | 23 ++++++++++++++++++++++- 3 files changed, 24 insertions(+), 15 deletions(-) diff --git a/src/intel/vulkan/anv_private.h b/src/intel/vulkan/anv_private.h index 8d1be9374ec..f6256046fbd 100644 --- a/src/intel/vulkan/anv_private.h +++ b/src/intel/vulkan/anv_private.h @@ -6583,6 +6583,7 @@ void anv_update_vp9_tables(struct anv_cmd_buffer *cmd, const StdVideoVP9Segmentation *seg); void anv_calculate_qmul(const struct VkVideoDecodeVP9PictureInfoKHR *vp9_pic, + uint32_t qyac, uint32_t seg_id, int16_t *ptr); diff --git a/src/intel/vulkan/anv_video.c b/src/intel/vulkan/anv_video.c index c22a166947a..16699ac6c47 100644 --- a/src/intel/vulkan/anv_video.c +++ b/src/intel/vulkan/anv_video.c @@ -1319,27 +1319,14 @@ anv_update_vp9_tables(struct anv_cmd_buffer *cmd, void anv_calculate_qmul(const struct VkVideoDecodeVP9PictureInfoKHR *vp9_pic, + uint32_t qyac, uint32_t seg_id, int16_t *ptr) { const StdVideoDecodeVP9PictureInfo *std_pic = vp9_pic->pStdPictureInfo; - const StdVideoVP9Segmentation *segmentation = std_pic->pSegmentation; uint32_t bpp_index = std_pic->pColorConfig->BitDepth > 8 ? 1 : 0; - uint32_t qyac; - - if (std_pic->flags.segmentation_enabled && segmentation->FeatureEnabled[seg_id]) { - if (segmentation->flags.segmentation_abs_or_delta_update) { - /* FIXME. which lvl needs to be picked */ - qyac = segmentation->FeatureData[seg_id][0] & 0xff; - } else { - qyac = (std_pic->base_q_idx + segmentation->FeatureData[seg_id][0]) & 0xff; - } - } else { - qyac = std_pic->base_q_idx & 0xff; - } - uint32_t qydc = (qyac + std_pic->delta_q_y_dc) & 0xff; uint32_t quvdc = (qyac + std_pic->delta_q_uv_dc) & 0xff; uint32_t quvac = (qyac + std_pic->delta_q_uv_ac) & 0xff; diff --git a/src/intel/vulkan/genX_cmd_video.c b/src/intel/vulkan/genX_cmd_video.c index 6a0f4108f93..b0269d5356e 100644 --- a/src/intel/vulkan/genX_cmd_video.c +++ b/src/intel/vulkan/genX_cmd_video.c @@ -2713,6 +2713,15 @@ anv_av1_decode_video(struct anv_cmd_buffer *cmd_buffer, } #endif +enum vp9_seg_lvl_features +{ + VP9_SEG_LVL_ALT_Q = 0, /* Use alternate Quantizer */ + VP9_SEG_LVL_ALT_L = 1, /* Use alternate loop filter value */ + VP9_SEG_LVL_REF_FRAME = 2, /* Optional Segment reference frame */ + VP9_SEG_LVL_SKIP = 3, /* Optional Segment (0,0) + skip mode */ + VP9_SEG_LVL_MAX = 4 /* Number of segment features */ +}; + static uint8_t anv_vp9_get_ref_idx(const struct VkVideoDecodeInfoKHR *frame_info, int slot_id) { @@ -3218,10 +3227,22 @@ anv_vp9_decode_video(struct anv_cmd_buffer *cmd_buffer, for (uint32_t i = 0; i < num_segments; i++) { anv_batch_emit(&cmd_buffer->batch, GENX(HCP_VP9_SEGMENT_STATE), seg) { + uint32_t qyac = std_pic->base_q_idx; + seg.SegmentID = i; + if (std_pic->flags.segmentation_enabled && segmentation) { + u_foreach_bit(val, segmentation->FeatureEnabled[i]) { + if (val == VP9_SEG_LVL_ALT_Q) { + qyac = segmentation->FeatureData[i][val]; + if (!segmentation->flags.segmentation_abs_or_delta_update) + qyac += std_pic->base_q_idx; + } + } + } + int16_t qmul[2][2] = { 0, }; - anv_calculate_qmul(vp9_pic_info, i, (int16_t *)qmul); + anv_calculate_qmul(vp9_pic_info, qyac, i, (int16_t *)qmul); seg.LumaDCQuantScale = qmul[0][0]; seg.LumaACQuantScale = qmul[0][1];