From add2bf50cd2a368f9bf011ecb387e7ba4aeef4a7 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Kacper=20Michaj=C5=82ow?= Date: Fri, 10 Oct 2025 05:46:36 +0200 Subject: [PATCH] mp_image: use pl_color_space_nominal_luma_ex() to set nominal csp peak --- video/mp_image.c | 18 +++++++++--------- 1 file changed, 9 insertions(+), 9 deletions(-) diff --git a/video/mp_image.c b/video/mp_image.c index 30326e42fc..ce7cd00802 100644 --- a/video/mp_image.c +++ b/video/mp_image.c @@ -1016,15 +1016,15 @@ void mp_image_params_guess_csp(struct mp_image_params *params) params->color.transfer = PL_COLOR_TRC_UNKNOWN; } - if (!params->color.hdr.max_luma) { - if (params->color.transfer == PL_COLOR_TRC_HLG) { - params->color.hdr.max_luma = 1000; // reference display - } else { - // If the signal peak is unknown, we're forced to pick the TRC's - // nominal range as the signal peak to prevent clipping - params->color.hdr.max_luma = pl_color_transfer_nominal_peak(params->color.transfer) * MP_REF_WHITE; - } - } + // If the signal peak is unknown, we're forced to pick the TRC's + // nominal range as the signal peak to prevent clipping + pl_color_space_nominal_luma_ex(pl_nominal_luma_params( + .color = ¶ms->color, + .metadata = PL_HDR_METADATA_HDR10, + .scaling = PL_HDR_NORM, + .out_min = NULL, + .out_max = ¶ms->color.hdr.max_luma, + )); if (!pl_color_space_is_hdr(¶ms->color)) { // Some clips have leftover HDR metadata after conversion to SDR, so to