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);
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.
18 #if Y_CB_CR_SAME_TEXTURE
19 ycbcr = tex2D(PREFIX(tex_y), tc).xyz;
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;
26 ycbcr.y = tex2D(PREFIX(tex_cbcr), tc + PREFIX(cb_offset)).x;
27 ycbcr.z = tex2D(PREFIX(tex_cbcr), tc + PREFIX(cr_offset)).x;
30 ycbcr.y = tex2D(PREFIX(tex_cb), tc + PREFIX(cb_offset)).x;
31 ycbcr.z = tex2D(PREFIX(tex_cr), tc + PREFIX(cr_offset)).x;
35 ycbcr -= PREFIX(offset);
38 rgba.rgb = PREFIX(inv_ycbcr_matrix) * ycbcr;