diff options
author | nand <git@nand.wakku.to> | 2014-02-11 19:20:48 +0100 |
---|---|---|
committer | wm4 <wm4@nowhere> | 2014-02-12 22:00:42 +0100 |
commit | 55f4b592d1696e270cd9f1ec6ab6e7102c737115 (patch) | |
tree | 177426bee65752065be7579447396d59a01f0a01 /video/out | |
parent | 958455ac39d1f1d4958416265a586efb7debfdfa (diff) | |
download | mpv-55f4b592d1696e270cd9f1ec6ab6e7102c737115.tar.bz2 mpv-55f4b592d1696e270cd9f1ec6ab6e7102c737115.tar.xz |
vo_opengl: make :srgb decompand the BT.709 values correctly
This is the same issue as addressed by 257d9f1, except this time for
the :srgb option as well. (257d9f1 only addressed :icc-profile)
The conditions of the srgb_compand mix() call are also flipped to
prevent an off-by-one error.
Diffstat (limited to 'video/out')
-rw-r--r-- | video/out/gl_video_shaders.glsl | 17 |
1 files changed, 15 insertions, 2 deletions
diff --git a/video/out/gl_video_shaders.glsl b/video/out/gl_video_shaders.glsl index af966905a0..8f15508b17 100644 --- a/video/out/gl_video_shaders.glsl +++ b/video/out/gl_video_shaders.glsl @@ -45,8 +45,14 @@ #if __VERSION__ >= 130 vec3 srgb_compand(vec3 v) { - return mix(1.055 * pow(v, vec3(1.0/2.4)) - vec3(0.055), v * 12.92, - lessThanEqual(v, vec3(0.0031308))); + return mix(v * 12.92, 1.055 * pow(v, vec3(1.0/2.4)) - vec3(0.055), + lessThanEqual(vec3(0.0031308), v)); +} + +vec3 bt709_expand(vec3 v) +{ + return mix(v / 4.5, pow((v + vec3(0.099))/1.099, vec3(1/0.45)), + lessThanEqual(vec3(0.0812), v)); } #endif @@ -384,6 +390,13 @@ void main() { color = texture3D(lut_3d, color).rgb; #endif #ifdef USE_SRGB + // Go from "linear" (0.45) to BT.709 to true linear to sRGB +#ifndef USE_3DLUT + // Unless we are using a 3DLUT, in which case USE_LINEAR_CONV_INV + // already triggered earlier. + color = pow(color, vec3(0.45)); +#endif + color = bt709_expand(color.rgb); color.rgb = srgb_compand(color.rgb); #endif #ifdef USE_DITHER |