From 258ed5d471334ef756563a5384540c063697f3b3 Mon Sep 17 00:00:00 2001 From: Niklas Haas Date: Thu, 3 Jan 2019 01:40:08 +0100 Subject: vo_gpu: tone map before gamut mapping Gamut mapping can take very bright out-of-gamut colors into the negatives, which completely destroys the color balance (which tone mapping tries its best to preserve). --- video/out/gpu/video_shaders.c | 9 ++++----- 1 file changed, 4 insertions(+), 5 deletions(-) diff --git a/video/out/gpu/video_shaders.c b/video/out/gpu/video_shaders.c index 806f0e17dd..07ac0b940f 100644 --- a/video/out/gpu/video_shaders.c +++ b/video/out/gpu/video_shaders.c @@ -784,6 +784,10 @@ void pass_color_map(struct gl_shader_cache *sc, bool is_linear, if (need_ootf) pass_ootf(sc, src.light, src.sig_peak); + // Tone map to prevent clipping due to excessive brightness + if (src.sig_peak > dst.sig_peak) + pass_tone_map(sc, src.sig_peak, dst.sig_peak, opts); + // Adapt to the right colorspace if necessary if (src.primaries != dst.primaries) { struct mp_csp_primaries csp_src = mp_get_csp_primaries(src.primaries), @@ -794,11 +798,6 @@ void pass_color_map(struct gl_shader_cache *sc, bool is_linear, GLSL(color.rgb = cms_matrix * color.rgb;) } - // Tone map to prevent clipping when the source signal peak exceeds the - // encodable range or we've reduced the gamut - if (src.sig_peak > dst.sig_peak) - pass_tone_map(sc, src.sig_peak, dst.sig_peak, opts); - if (need_ootf) pass_inverse_ootf(sc, dst.light, dst.sig_peak); -- cgit v1.2.3