]> git.sesse.net Git - movit/blob - ycbcr_input.frag
Fix some small whitespace errors in SingleResamplePassEffect.
[movit] / ycbcr_input.frag
1 // Implicit uniforms:
2 // uniform sampler2D PREFIX(tex_y);
3 // uniform sampler2D PREFIX(tex_cbcr);  // If CB_CR_SAME_TEXTURE.
4 // uniform sampler2D PREFIX(tex_cb);    // If not CB_CR_SAME_TEXTURE.
5 // uniform sampler2D PREFIX(tex_cr);    // If not CB_CR_SAME_TEXTURE.
6 // uniform mat3 PREFIX(ycbcr_matrix);
7 // uniform vec3 PREFIX(offset);
8 // uniform vec2 PREFIX(cb_offset);
9 // uniform vec2 PREFIX(cr_offset);
10
11 vec4 FUNCNAME(vec2 tc) {
12         // OpenGL's origin is bottom-left, but most graphics software assumes
13         // a top-left origin. Thus, for inputs that come from the user,
14         // we flip the y coordinate.
15         tc.y = 1.0 - tc.y;
16
17         vec3 ycbcr;
18 #if Y_CB_CR_SAME_TEXTURE
19         ycbcr = tex2D(PREFIX(tex_y), tc).xyz;
20 #else
21         ycbcr.x = tex2D(PREFIX(tex_y), tc).x;
22   #if CB_CR_SAME_TEXTURE
23     #if CB_CR_OFFSETS_EQUAL
24         ycbcr.yz = tex2D(PREFIX(tex_cbcr), tc + PREFIX(cb_offset)).xy;
25     #else
26         ycbcr.y = tex2D(PREFIX(tex_cbcr), tc + PREFIX(cb_offset)).x;
27         ycbcr.z = tex2D(PREFIX(tex_cbcr), tc + PREFIX(cr_offset)).x;
28     #endif
29   #else
30         ycbcr.y = tex2D(PREFIX(tex_cb), tc + PREFIX(cb_offset)).x;
31         ycbcr.z = tex2D(PREFIX(tex_cr), tc + PREFIX(cr_offset)).x;
32   #endif
33 #endif
34
35         ycbcr -= PREFIX(offset);
36
37         vec4 rgba;
38         rgba.rgb = PREFIX(inv_ycbcr_matrix) * ycbcr;
39         rgba.a = 1.0;
40         return rgba;
41 }