summaryrefslogtreecommitdiffstats
path: root/video/out
diff options
context:
space:
mode:
authorKacper Michajłow <kasper93@gmail.com>2023-04-23 22:49:33 +0200
committerNiklas Haas <github-daiK1o@haasn.dev>2023-05-13 17:08:37 +0200
commit9e716d63033c31d01cf9fca1e55e5388b6a8bba3 (patch)
tree24ac48209d83c66b998952d31dc40e90382a857f /video/out
parent8343b3bded5eb9c7ef1eb42c79888b40a55261d2 (diff)
downloadmpv-9e716d63033c31d01cf9fca1e55e5388b6a8bba3.tar.bz2
mpv-9e716d63033c31d01cf9fca1e55e5388b6a8bba3.tar.xz
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
Diffstat (limited to 'video/out')
-rw-r--r--video/out/gpu/lcms.c1
-rw-r--r--video/out/gpu/lcms.h1
-rw-r--r--video/out/vo_gpu_next.c18
3 files changed, 16 insertions, 4 deletions
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,