From ed6a5765339caafd84cc107189e5a3265beb3fa7 Mon Sep 17 00:00:00 2001 From: "Kovac, Krunoslav" Date: Fri, 6 Feb 2026 14:11:01 -0500 Subject: [PATCH] amd/vpelib: Apply external CSC [WHY] 3x4 matrix passed in as part of 3DLUT compound. Due to HW limitations of coeffs, hdr_mult may need to be used. Acked-by: Chuanyu Tseng Signed-off-by: Krunoslav Kovac Part-of: --- src/amd/vpelib/src/core/color.c | 11 ++++++----- src/amd/vpelib/src/core/inc/color.h | 4 ++-- src/amd/vpelib/src/core/vpelib.c | 2 +- 3 files changed, 9 insertions(+), 8 deletions(-) diff --git a/src/amd/vpelib/src/core/color.c b/src/amd/vpelib/src/core/color.c index 0ad89352f20..33865afdb2f 100644 --- a/src/amd/vpelib/src/core/color.c +++ b/src/amd/vpelib/src/core/color.c @@ -34,6 +34,7 @@ #include "3dlut_builder.h" #include "shaper_builder.h" #include "geometric_scaling.h" +#include "conversion.h" static void color_check_input_cm_update(struct vpe_priv *vpe_priv, struct stream_ctx *stream_ctx, const struct vpe_color_space *vcs, const struct vpe_color_adjust *adjustments, @@ -702,15 +703,15 @@ enum vpe_status vpe_color_update_color_space_and_tf( return status; } -enum vpe_status vpe_color_tm_update_hdr_mult(uint16_t shaper_in_exp_max, uint32_t peak_white, - struct fixed31_32 *hdr_multiplier, bool enable3dlut, bool is_fp16) +enum vpe_status vpe_color_tm_update_hdr_mult( + uint32_t peak_white, struct fixed31_32 *hdr_multiplier, bool enable3dlut, bool is_g10) { if (enable3dlut) { struct fixed31_32 shaper_in_gain; struct fixed31_32 pq_norm_gain; - shaper_in_gain = vpe_fixpt_from_int((long long)1 << shaper_in_exp_max); - if (is_fp16) { + shaper_in_gain = vpe_fixpt_from_int((long long)1 << SHAPER_EXP_MAX_IN); + if (is_g10) { *hdr_multiplier = vpe_fixpt_div_int(shaper_in_gain, CCCS_NORM); } else { // HDRMULT = 2^shaper_in_exp_max*(1/PQ(x)) @@ -859,7 +860,7 @@ enum vpe_status vpe_color_update_movable_cm( // Update the HDR multiplier based on the shaper normalization factor and other // parameters. - vpe_color_tm_update_hdr_mult(SHAPER_EXP_MAX_IN, shaper_norm_factor, + vpe_color_tm_update_hdr_mult(shaper_norm_factor, &stream_ctx->lut3d_func->hdr_multiplier, enable_3dlut, stream_ctx->stream.surface_info.cs.tf == VPE_TF_G10); diff --git a/src/amd/vpelib/src/core/inc/color.h b/src/amd/vpelib/src/core/inc/color.h index ed1274a1819..9ebd4d7d913 100644 --- a/src/amd/vpelib/src/core/inc/color.h +++ b/src/amd/vpelib/src/core/inc/color.h @@ -275,8 +275,8 @@ void vpe_convert_full_range_color_enum(enum color_space *cs); enum vpe_status vpe_color_update_whitepoint( const struct vpe_priv *vpe_priv, const struct vpe_build_param *param); -enum vpe_status vpe_color_tm_update_hdr_mult(uint16_t shaper_in_exp_max, uint32_t peak_white, - struct fixed31_32 *hdr_multiplier, bool enable_3dlut, bool is_fp16); +enum vpe_status vpe_color_tm_update_hdr_mult( + uint32_t peak_white, struct fixed31_32 *hdr_multiplier, bool enable_3dlut, bool is_fp16); enum vpe_status vpe_color_build_shaper_cs(const struct vpe_tonemap_params *tm_params, struct vpe_surface_info *surface_info, struct vpe_color_space *tm_out_cs); diff --git a/src/amd/vpelib/src/core/vpelib.c b/src/amd/vpelib/src/core/vpelib.c index eb8160656d8..4a3dcba54ea 100644 --- a/src/amd/vpelib/src/core/vpelib.c +++ b/src/amd/vpelib/src/core/vpelib.c @@ -553,7 +553,7 @@ enum vpe_status vpe_check_support( } - if (status == VPE_STATUS_OK) { + if (status == VPE_STATUS_OK) { // output checking - check per asic support status = vpe_check_output_support(vpe, param); if (status != VPE_STATUS_OK) {