From e2f95ad296d665891cf455030094e1e9d20d4b43 Mon Sep 17 00:00:00 2001 From: Hyunjun Ko Date: Fri, 16 Jun 2023 14:40:23 +0900 Subject: [PATCH] vulkan/video: keep delta weight and offsets of predicted weight tables in h265 slice parsing Signed-off-by: Hyunjun Ko Reviewed-by: Dave Airlie Part-of: --- src/vulkan/runtime/vk_video.c | 31 +++++++++++++++++-------------- src/vulkan/runtime/vk_video.h | 7 +++++++ 2 files changed, 24 insertions(+), 14 deletions(-) diff --git a/src/vulkan/runtime/vk_video.c b/src/vulkan/runtime/vk_video.c index 2c456e3..6920d9d 100644 --- a/src/vulkan/runtime/vk_video.c +++ b/src/vulkan/runtime/vk_video.c @@ -456,19 +456,20 @@ h265_pred_weight_table(struct vk_video_h265_slice_params *params, for (i = 0; i < params->num_ref_idx_l0_active; ++i) { if (params->luma_weight_l0_flag[i]) { - unsigned delta_luma_weight_l0 = vl_rbsp_se(rbsp); - params->luma_weight_l0[i] = (1 << params->luma_log2_weight_denom) + delta_luma_weight_l0; + params->delta_luma_weight_l0[i] = vl_rbsp_se(rbsp); + params->luma_weight_l0[i] = (1 << params->luma_log2_weight_denom) + params->delta_luma_weight_l0[i]; params->luma_offset_l0[i] = vl_rbsp_se(rbsp); } if (params->chroma_weight_l0_flag[i]) { for (j = 0; j < 2; j++) { - unsigned delta_chroma_weight_l0 = vl_rbsp_se(rbsp); - unsigned delta_chroma_offset_l0 = vl_rbsp_se(rbsp); + params->delta_chroma_weight_l0[i][j] = vl_rbsp_se(rbsp); + params->delta_chroma_offset_l0[i][j] = vl_rbsp_se(rbsp); - params->chroma_weight_l0[i][j] = (1 << params->chroma_log2_weight_denom) + delta_chroma_weight_l0; - params->chroma_offset_l0[i][j] = delta_chroma_offset_l0 - - ((128 * params->chroma_weight_l0[i][j]) >> params->chroma_log2_weight_denom) + 128; + params->chroma_weight_l0[i][j] = + (1 << params->chroma_log2_weight_denom) + params->delta_chroma_weight_l0[i][j]; + params->chroma_offset_l0[i][j] = CLAMP(params->delta_chroma_offset_l0[i][j] - + ((128 * params->chroma_weight_l0[i][j]) >> params->chroma_log2_weight_denom) + 128, -128, 127); } } else { for (j = 0; j < 2; j++) { @@ -497,19 +498,21 @@ h265_pred_weight_table(struct vk_video_h265_slice_params *params, for (i = 0; i < params->num_ref_idx_l1_active; ++i) { if (params->luma_weight_l1_flag[i]) { - unsigned delta_luma_weight_l1 = vl_rbsp_se(rbsp); - params->luma_weight_l1[i] = (1 << params->luma_log2_weight_denom) + delta_luma_weight_l1; + params->delta_luma_weight_l1[i] = vl_rbsp_se(rbsp); + params->luma_weight_l1[i] = + (1 << params->luma_log2_weight_denom) + params->delta_luma_weight_l1[i]; params->luma_offset_l1[i] = vl_rbsp_se(rbsp); } if (params->chroma_weight_l1_flag[i]) { for (j = 0; j < 2; j++) { - unsigned delta_chroma_weight_l1 = vl_rbsp_se(rbsp); - unsigned delta_chroma_offset_l1 = vl_rbsp_se(rbsp); + params->delta_chroma_weight_l1[i][j] = vl_rbsp_se(rbsp); + params->delta_chroma_offset_l1[i][j] = vl_rbsp_se(rbsp); - params->chroma_weight_l1[i][j] = (1 << params->chroma_log2_weight_denom) + delta_chroma_weight_l1; - params->chroma_offset_l1[i][j] = delta_chroma_offset_l1 - - ((128 * params->chroma_weight_l1[i][j]) >> params->chroma_log2_weight_denom) + 128; + params->chroma_weight_l1[i][j] = + (1 << params->chroma_log2_weight_denom) + params->delta_chroma_weight_l1[i][j]; + params->chroma_offset_l1[i][j] = CLAMP(params->delta_chroma_offset_l1[i][j] - + ((128 * params->chroma_weight_l1[i][j]) >> params->chroma_log2_weight_denom) + 128, -128, 127); } } else { for (j = 0; j < 2; j++) { diff --git a/src/vulkan/runtime/vk_video.h b/src/vulkan/runtime/vk_video.h index d266339..29fb905 100644 --- a/src/vulkan/runtime/vk_video.h +++ b/src/vulkan/runtime/vk_video.h @@ -152,6 +152,13 @@ struct vk_video_h265_slice_params { uint8_t chroma_weight_l1_flag[16]; int16_t chroma_weight_l1[16][2]; int16_t chroma_offset_l1[16][2]; + + int8_t delta_luma_weight_l0[16]; + int8_t delta_luma_weight_l1[16]; + int8_t delta_chroma_weight_l0[16][2]; + int8_t delta_chroma_weight_l1[16][2]; + int16_t delta_chroma_offset_l0[16][2]; + int16_t delta_chroma_offset_l1[16][2]; }; void -- 2.7.4