]> git.sesse.net Git - movit/blob - footer.frag
Add some asserts to EffectChain::execute_phase, so that we do not inadvertedly insert...
[movit] / footer.frag
1 // GLSL is pickier than the C++ preprocessor in if-testing for undefined
2 // tokens; do some fixups here to keep it happy.
3
4 #ifndef YCBCR_OUTPUT_PLANAR
5 #define YCBCR_OUTPUT_PLANAR 0
6 #endif
7
8 #ifndef YCBCR_OUTPUT_SPLIT_Y_AND_CBCR
9 #define YCBCR_OUTPUT_SPLIT_Y_AND_CBCR 0
10 #endif
11
12 #ifndef SECOND_YCBCR_OUTPUT_PLANAR
13 #define SECOND_YCBCR_OUTPUT_PLANAR 0
14 #endif
15
16 #ifndef SECOND_YCBCR_OUTPUT_SPLIT_Y_AND_CBCR
17 #define SECOND_YCBCR_OUTPUT_SPLIT_Y_AND_CBCR 0
18 #endif
19
20 #ifndef SECOND_YCBCR_OUTPUT_INTERLEAVED
21 #define SECOND_YCBCR_OUTPUT_INTERLEAVED 0
22 #endif
23
24 #ifndef YCBCR_ALSO_OUTPUT_RGBA
25 #define YCBCR_ALSO_OUTPUT_RGBA 0
26 #endif
27
28 #ifndef SQUARE_ROOT_TRANSFORMATION
29 #define SQUARE_ROOT_TRANSFORMATION 0
30 #endif
31
32 #if YCBCR_OUTPUT_PLANAR
33 out vec4 Y, Cb, Cr;
34 #elif YCBCR_OUTPUT_SPLIT_Y_AND_CBCR
35 out vec4 Y, Chroma;
36 #else
37 out vec4 FragColor;  // Y'CbCr or RGBA.
38 #endif
39
40 #if SECOND_YCBCR_OUTPUT_PLANAR
41 out vec4 Y2, Cb2, Cr2;
42 #elif SECOND_YCBCR_OUTPUT_SPLIT_Y_AND_CBCR
43 out vec4 Y2, Chroma2;
44 #elif SECOND_YCBCR_OUTPUT_INTERLEAVED
45 out vec4 YCbCr2;
46 #endif
47
48 #if YCBCR_ALSO_OUTPUT_RGBA
49 out vec4 RGBA;
50 #endif
51
52 void main()
53 {
54 #if YCBCR_ALSO_OUTPUT_RGBA
55         vec4 color[2] = INPUT(tc);
56         vec4 color0 = color[0];
57         vec4 color1 = color[1];
58 #else
59         vec4 color0 = INPUT(tc);
60 #endif
61
62 #if SQUARE_ROOT_TRANSFORMATION
63         // Make sure we don't give negative values to sqrt.
64         color0.rgb = sqrt(max(color0.rgb, 0.0));
65 #endif
66
67 #if YCBCR_OUTPUT_PLANAR
68         Y = color0.rrra;
69         Cb = color0.ggga;
70         Cr = color0.bbba;
71 #elif YCBCR_OUTPUT_SPLIT_Y_AND_CBCR
72         Y = color0.rrra;
73         Chroma = color0.gbba;
74 #else
75         FragColor = color0;
76 #endif
77
78         // Exactly the same, just with other outputs.
79         // (GLSL does not allow arrays of outputs.)
80 #if SECOND_YCBCR_OUTPUT_PLANAR
81         Y2 = color0.rrra;
82         Cb2 = color0.ggga;
83         Cr2 = color0.bbba;
84 #elif SECOND_YCBCR_OUTPUT_SPLIT_Y_AND_CBCR
85         Y2 = color0.rrra;
86         Chroma2 = color0.gbba;
87 #elif SECOND_YCBCR_OUTPUT_INTERLEAVED
88         YCbCr2 = color0;
89 #endif
90
91 #if YCBCR_ALSO_OUTPUT_RGBA
92         RGBA = color1;
93 #endif
94 }