diff options
author | Niklas Haas <git@haasn.dev> | 2023-10-31 20:41:19 +0100 |
---|---|---|
committer | Niklas Haas <github-daiK1o@haasn.dev> | 2023-11-08 00:55:39 +0100 |
commit | 293fe9d74a376534ec3ef14164618925cdd8c7eb (patch) | |
tree | ce27ce95dd8beb86d34d66567fd0082ca8fe35cb /video | |
parent | c798f663439d57abfbe87ed3b9432c946f91f2bc (diff) | |
download | mpv-293fe9d74a376534ec3ef14164618925cdd8c7eb.tar.bz2 mpv-293fe9d74a376534ec3ef14164618925cdd8c7eb.tar.xz |
vo_gpu_next: add --target-gamut option
Fixes: https://github.com/mpv-player/mpv/issues/12777
Diffstat (limited to 'video')
-rw-r--r-- | video/out/gpu/video.c | 1 | ||||
-rw-r--r-- | video/out/gpu/video.h | 1 | ||||
-rw-r--r-- | video/out/vo_gpu_next.c | 7 |
3 files changed, 9 insertions, 0 deletions
diff --git a/video/out/gpu/video.c b/video/out/gpu/video.c index fcf11b2e31..0f48261389 100644 --- a/video/out/gpu/video.c +++ b/video/out/gpu/video.c @@ -374,6 +374,7 @@ const struct m_sub_options gl_video_conf = { M_RANGE(10, 10000)}, {"target-contrast", OPT_CHOICE(target_contrast, {"auto", 0}, {"inf", -1}), M_RANGE(10, 1000000)}, + {"target-gamut", OPT_CHOICE_C(target_gamut, mp_csp_prim_names)}, {"tone-mapping", OPT_CHOICE(tone_map.curve, {"auto", TONE_MAPPING_AUTO}, {"clip", TONE_MAPPING_CLIP}, diff --git a/video/out/gpu/video.h b/video/out/gpu/video.h index c5e4463437..411d336a21 100644 --- a/video/out/gpu/video.h +++ b/video/out/gpu/video.h @@ -138,6 +138,7 @@ struct gl_video_opts { int target_trc; int target_peak; int target_contrast; + int target_gamut; struct gl_tone_map_opts tone_map; bool correct_downscaling; bool linear_downscaling; diff --git a/video/out/vo_gpu_next.c b/video/out/vo_gpu_next.c index 299d080c37..d0da4ebef6 100644 --- a/video/out/vo_gpu_next.c +++ b/video/out/vo_gpu_next.c @@ -791,6 +791,13 @@ static void apply_target_options(struct priv *p, struct pl_frame *target) target->color.hdr.max_luma = opts->target_peak; if (!target->color.hdr.min_luma) apply_target_contrast(p, &target->color); + if (opts->target_gamut) { + // Ensure resulting gamut still fits inside container + const struct pl_raw_primaries *gamut, *container; + gamut = pl_raw_primaries_get(mp_prim_to_pl(opts->target_gamut)); + container = pl_raw_primaries_get(target->color.primaries); + target->color.hdr.prim = pl_primaries_clip(gamut, container); + } if (opts->dither_depth > 0) { struct pl_bit_encoding *tbits = &target->repr.bits; tbits->color_depth += opts->dither_depth - tbits->sample_depth; |