From 9e716d63033c31d01cf9fca1e55e5388b6a8bba3 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Kacper=20Michaj=C5=82ow?= Date: Sun, 23 Apr 2023 22:49:33 +0200 Subject: vo_gpu_next: allow to use ICC profile luminance value Also while at it respect target-peak option when ICC profile is used. Fixes #11449 --- video/out/vo_gpu_next.c | 18 ++++++++++++++---- 1 file changed, 14 insertions(+), 4 deletions(-) (limited to 'video/out/vo_gpu_next.c') diff --git a/video/out/vo_gpu_next.c b/video/out/vo_gpu_next.c index 8416f4f2f7..4f93681097 100644 --- a/video/out/vo_gpu_next.c +++ b/video/out/vo_gpu_next.c @@ -798,10 +798,6 @@ static void apply_target_options(struct priv *p, struct pl_frame *target) target->lut = p->target_lut.lut; target->lut_type = p->target_lut.type; -#ifdef PL_HAVE_LCMS - target->profile = p->icc_profile; -#endif - // Colorspace overrides const struct gl_video_opts *opts = p->opts_cache->opts; if (p->output_levels) @@ -818,6 +814,20 @@ static void apply_target_options(struct priv *p, struct pl_frame *target) tbits->color_depth += opts->dither_depth - tbits->sample_depth; tbits->sample_depth = opts->dither_depth; } + +#ifdef PL_HAVE_LCMS + target->profile = p->icc_profile; + + if (opts->icc_opts->icc_use_luma) { + // Use detected luminance + p->icc.max_luma = 0; + } else { + // Use HDR levels if available, fall back to default luminance + p->icc.max_luma = target->color.hdr.max_luma; + if (!p->icc.max_luma) + p->icc.max_luma = pl_icc_default_params.max_luma; + } +#endif } static void apply_crop(struct pl_frame *frame, struct mp_rect crop, -- cgit v1.2.3