summaryrefslogtreecommitdiffstats
path: root/video/out/gl_video_shaders.glsl
diff options
context:
space:
mode:
authorwm4 <wm4@nowhere>2013-05-01 23:59:00 +0200
committerwm4 <wm4@nowhere>2013-05-04 01:32:50 +0200
commit872aefaa1521a8cf70c6e14f3356e9d00ed7efa3 (patch)
tree4f04a63b9c31d71a326a112004e8d8e213e739e4 /video/out/gl_video_shaders.glsl
parent16d40828aecf4028acadeeecaf0294756298f970 (diff)
downloadmpv-872aefaa1521a8cf70c6e14f3356e9d00ed7efa3.tar.bz2
mpv-872aefaa1521a8cf70c6e14f3356e9d00ed7efa3.tar.xz
vo_opengl: XYZ input support
Useful for the j2k decoder. Matrix taken from http://www.brucelindbloom.com/index.html?Eqn_RGB_XYZ_Matrix.html (XYZ to sRGB, whitepoint D65) Gamma conversion follows what libswscale does (2.6 in, 2.2 out). If linear RGB is used internally for scaling, the gamma conversion will be undone by setting the exponent to 1. Unfortunately, the two gamma values don't compensate each others exactly (2.2 vs. 1/0.45=2.22...), so output is a little bit incorrect in sRGB or color-managed mode. But for now try hard to match libswscale output, which may or may not be correct.
Diffstat (limited to 'video/out/gl_video_shaders.glsl')
-rw-r--r--video/out/gl_video_shaders.glsl8
1 files changed, 6 insertions, 2 deletions
diff --git a/video/out/gl_video_shaders.glsl b/video/out/gl_video_shaders.glsl
index 2f10e5fdf6..b968cb2c87 100644
--- a/video/out/gl_video_shaders.glsl
+++ b/video/out/gl_video_shaders.glsl
@@ -122,6 +122,7 @@ uniform sampler3D lut_3d;
uniform sampler2D dither;
uniform mat4x3 colormatrix;
uniform vec3 inv_gamma;
+uniform float input_gamma;
uniform float conv_gamma;
uniform float dither_quantization;
uniform float dither_multiply;
@@ -351,11 +352,14 @@ void main() {
// wrong for 9/10 bit input
color.gb = vec2(128.0/255.0);
#endif
+#ifdef USE_INPUT_GAMMA
+ color = pow(color, vec3(input_gamma));
+#endif
#ifdef USE_COLORMATRIX
color = mat3(colormatrix) * color + colormatrix[3];
#endif
-#ifdef USE_LINEAR_CONV
- color = pow(color, vec3(1.0/0.45));
+#ifdef USE_CONV_GAMMA
+ color = pow(color, vec3(conv_gamma));
#endif
#ifdef USE_LINEAR_CONV_INV
// Convert from linear RGB to gamma RGB before putting it through the 3D-LUT