summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authornand <git@nand.wakku.to>2014-02-11 19:20:48 +0100
committerwm4 <wm4@nowhere>2014-02-12 22:34:44 +0100
commit19caba0794853da1730ccbfe8088be6050f2405a (patch)
tree5f8548d5045d21ff1af25e9338c1b87440ca0b18
parent391546c52fb2cfd716eb3059d939d0f245b57d24 (diff)
downloadmpv-19caba0794853da1730ccbfe8088be6050f2405a.tar.bz2
mpv-19caba0794853da1730ccbfe8088be6050f2405a.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.
-rw-r--r--video/out/gl_video_shaders.glsl17
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