amd/vpelib: Refactor norm factor logic

Moved norm factor logic out of moveable CM.

Reviewed-by: Roy Chan <Roy.Chan@amd.com>
Acked-by: Alan Liu <haoping.liu@amd.com>
Signed-off-by: Jesse Agate <Jesse.Agate@amd.com>
Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/27239>
This commit is contained in:
Agate, Jesse 2024-01-08 18:10:47 -05:00 committed by Marge Bot
parent e0863dbb74
commit 039b1e0a1e

View file

@ -59,6 +59,20 @@ static bool color_update_input_cs(struct vpe_priv *vpe_priv, enum color_space in
static bool is_ycbcr(enum color_space in_cs);
static void get_shaper_norm_factor(struct vpe_tonemap_params *tm_params,
struct stream_ctx *stream_ctx, uint32_t *shaper_norm_factor)
{
if (tm_params->shaper_tf == VPE_TF_PQ_NORMALIZED) {
if (tm_params->input_pq_norm_factor == 0) {
*shaper_norm_factor = stream_ctx->stream.hdr_metadata.max_mastering;
} else {
*shaper_norm_factor = tm_params->input_pq_norm_factor;
}
} else {
*shaper_norm_factor = HDR_PEAK_WHITE;
}
}
static bool is_ycbcr(enum color_space in_cs)
{
if ((in_cs == COLOR_SPACE_YCBCR601) || (in_cs == COLOR_SPACE_YCBCR601_LIMITED) ||
@ -781,7 +795,7 @@ enum vpe_status vpe_color_update_movable_cm(
if (stream_ctx->update_3dlut) {
uint32_t pq_norm_factor;
uint32_t shaper_norm_factor;
struct vpe_color_space tm_out_cs;
enum color_space out_lut_cs;
enum color_transfer_func tf;
@ -824,15 +838,10 @@ enum vpe_status vpe_color_update_movable_cm(
//Blendgam is updated by output vpe_update_output_gamma_sequence
if (param->streams[stream_idx].tm_params.shaper_tf == VPE_TF_PQ_NORMALIZED)
if (!param->streams[stream_idx].tm_params.input_pq_norm_factor)
pq_norm_factor = stream_ctx->stream.hdr_metadata.max_mastering;
else
pq_norm_factor = param->streams[stream_idx].tm_params.input_pq_norm_factor;
else
pq_norm_factor = HDR_PEAK_WHITE;
get_shaper_norm_factor(
&param->streams[stream_idx].tm_params, stream_ctx, &shaper_norm_factor);
vpe_color_tm_update_hdr_mult(SHAPER_EXP_MAX_IN, pq_norm_factor,
vpe_color_tm_update_hdr_mult(SHAPER_EXP_MAX_IN, shaper_norm_factor,
&stream_ctx->lut3d_func->hdr_multiplier, enable_3dlut);
vpe_color_update_shaper(SHAPER_EXP_MAX_IN, stream_ctx->in_shaper_func, enable_3dlut);