anv/video: rework for handling alternative quantizer for vp9 decoding.

including prep-work for handling segmentation features.

Signed-off-by: Hyunjun Ko <zzoon@igalia.com>
Acked-by: Lionel Landwerlin <lionel.g.landwerlin@intel.com>
Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/38418>
This commit is contained in:
Hyunjun Ko
2025-11-12 15:32:17 +01:00
committed by Marge Bot
parent 8827123fef
commit 1479e1ef82
3 changed files with 24 additions and 15 deletions
+1
View File
@@ -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);
+1 -14
View File
@@ -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;
+22 -1
View File
@@ -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];