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.
7 vec4 FUNCNAME(vec2 tc) {
8 // OpenGL's origin is bottom-left, but most graphics software assumes
9 // a top-left origin. Thus, for inputs that come from the user,
10 // we flip the y coordinate.
14 ycbcr.x = tex2D(PREFIX(tex_y), tc).x;
15 #if CB_CR_SAME_TEXTURE
16 #if CB_CR_OFFSETS_EQUAL
17 ycbcr.yz = tex2D(PREFIX(tex_cbcr), tc + PREFIX(cb_offset)).xy;
19 ycbcr.y = tex2D(PREFIX(tex_cbcr), tc + PREFIX(cb_offset)).x;
20 ycbcr.z = tex2D(PREFIX(tex_cbcr), tc + PREFIX(cr_offset)).x;
23 ycbcr.y = tex2D(PREFIX(tex_cb), tc + PREFIX(cb_offset)).x;
24 ycbcr.z = tex2D(PREFIX(tex_cr), tc + PREFIX(cr_offset)).x;
27 ycbcr -= PREFIX(offset);
30 rgba.rgb = PREFIX(inv_ycbcr_matrix) * ycbcr;