diff --git a/src/amd/vpelib/src/core/color.c b/src/amd/vpelib/src/core/color.c index c47a81b0a9d..54241327c6a 100644 --- a/src/amd/vpelib/src/core/color.c +++ b/src/amd/vpelib/src/core/color.c @@ -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( + ¶m->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);