summaryrefslogtreecommitdiffstats
path: root/video/out
diff options
context:
space:
mode:
authorNiklas Haas <git@haasn.xyz>2019-01-03 01:40:08 +0100
committerJan Ekström <jeebjp@gmail.com>2019-02-18 01:54:06 +0200
commit258ed5d471334ef756563a5384540c063697f3b3 (patch)
tree73dea0e8f5917c7861d7054955f3b53d70cc91c4 /video/out
parent677ae4f8fe5c9896bc7b7b174e75400c15afc146 (diff)
downloadmpv-258ed5d471334ef756563a5384540c063697f3b3.tar.bz2
mpv-258ed5d471334ef756563a5384540c063697f3b3.tar.xz
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).
Diffstat (limited to 'video/out')
-rw-r--r--video/out/gpu/video_shaders.c9
1 files 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);