]> git.sesse.net Git - movit/blobdiff - footer.frag
Fix an issue where a (cached) shader program could be used from multiple
[movit] / footer.frag
index 04c8e7c0eb370f226181cd81b4712a718ecdec47..339ef7bbb335887fd36f4d209f03d3dfb6247618 100644 (file)
@@ -1,3 +1,22 @@
+// GLSL is pickier than the C++ preprocessor in if-testing for undefined
+// tokens; do some fixups here to keep it happy.
+
+#ifndef YCBCR_OUTPUT_PLANAR
+#define YCBCR_OUTPUT_PLANAR 0
+#endif
+
+#ifndef YCBCR_OUTPUT_SPLIT_Y_AND_CBCR
+#define YCBCR_OUTPUT_SPLIT_Y_AND_CBCR 0
+#endif
+
+#ifndef YCBCR_ALSO_OUTPUT_RGBA
+#define YCBCR_ALSO_OUTPUT_RGBA 0
+#endif
+
+#ifndef SQUARE_ROOT_TRANSFORMATION
+#define SQUARE_ROOT_TRANSFORMATION 0
+#endif
+
 #if YCBCR_OUTPUT_PLANAR
 out vec4 Y;
 out vec4 Cb;
@@ -23,6 +42,11 @@ void main()
        vec4 color0 = INPUT(tc);
 #endif
 
+#if SQUARE_ROOT_TRANSFORMATION
+       // Make sure we don't give negative values to sqrt.
+       color0.rgb = sqrt(max(color0.rgb, 0.0));
+#endif
+
 #if YCBCR_OUTPUT_PLANAR
        Y = color0.rrra;
        Cb = color0.ggga;