diff --git a/DOCS/interface-changes.rst b/DOCS/interface-changes.rst index a842b7a155..8b9ef25e63 100644 --- a/DOCS/interface-changes.rst +++ b/DOCS/interface-changes.rst @@ -27,6 +27,10 @@ Interface changes :: --- mpv 0.36.0 --- + - Target luminance value is now also applied when ICC profile is used. + `--icc-use-luma` has been added to use ICC profile luminance value. + If target luminance and ICC luminance is not used, old behavior apply, + defaulting to 203 nits. (Only applies for `--vo=gpu-next`) - `playlist/N/title` gets set upon opening the file if it wasn't already set and a title is available. - add the `--vo=kitty` video output driver, as well as the options diff --git a/DOCS/man/options.rst b/DOCS/man/options.rst index f366bc995d..f3e0b99767 100644 --- a/DOCS/man/options.rst +++ b/DOCS/man/options.rst @@ -6674,6 +6674,9 @@ them. value ``inf`` causes the BT.1886 curve to be treated as a pure power gamma 2.4 function. +``--icc-use-luma`` + Use ICC profile luminance value. (Only for ``--vo=gpu-next``) + ``--lut=`` Specifies a custom LUT (in Adobe .cube format) to apply to the colors as part of color conversion. The exact interpretation depends on the value diff --git a/video/out/gpu/lcms.c b/video/out/gpu/lcms.c index be65dc965e..52345c4b9c 100644 --- a/video/out/gpu/lcms.c +++ b/video/out/gpu/lcms.c @@ -506,6 +506,7 @@ const struct m_sub_options mp_icc_conf = { {"icc-force-contrast", OPT_CHOICE(contrast, {"no", 0}, {"inf", -1}), M_RANGE(0, 1000000)}, {"icc-3dlut-size", OPT_STRING_VALIDATE(size_str, validate_3dlut_size_opt)}, + {"icc-use-luma", OPT_BOOL(icc_use_luma)}, {"3dlut-size", OPT_REPLACED("icc-3dlut-size")}, {"icc-contrast", OPT_REMOVED("see icc-force-contrast")}, {0} diff --git a/video/out/gpu/lcms.h b/video/out/gpu/lcms.h index 442c829333..7effc718f2 100644 --- a/video/out/gpu/lcms.h +++ b/video/out/gpu/lcms.h @@ -18,6 +18,7 @@ struct mp_icc_opts { char *size_str; int intent; int contrast; + bool icc_use_luma; }; struct lut3d { 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,