]> git.sesse.net Git - movit/blob - ycbcr_422interleaved_input.frag
Hard-assert on something that has bitten me too many times now.
[movit] / ycbcr_422interleaved_input.frag
1 // Implicit uniforms:
2 // uniform sampler2D PREFIX(tex_y);
3 // uniform sampler2D PREFIX(tex_cbcr);
4
5 vec4 FUNCNAME(vec2 tc) {
6         // OpenGL's origin is bottom-left, but most graphics software assumes
7         // a top-left origin. Thus, for inputs that come from the user,
8         // we flip the y coordinate.
9         tc.y = 1.0 - tc.y;
10
11         vec3 ycbcr;
12         ycbcr.x = tex2D(PREFIX(tex_y), tc).y;
13 #if CB_CR_OFFSETS_EQUAL
14         vec2 tc_cbcr = tc;
15         tc_cbcr.x += PREFIX(cb_offset_x);
16         ycbcr.yz = tex2D(PREFIX(tex_cbcr), tc_cbcr).xz;
17 #else
18         vec2 tc_cb = tc;
19         tc_cb.x += PREFIX(cb_offset_x);
20         ycbcr.y = tex2D(PREFIX(tex_cbcr), tc_cb).x;
21
22         vec2 tc_cr = tc;
23         tc_cr.x += PREFIX(cr_offset_x);
24         ycbcr.z = tex2D(PREFIX(tex_cbcr), tc_cr).z;
25 #endif
26
27         ycbcr -= PREFIX(offset);
28
29         vec4 rgba;
30         rgba.rgb = PREFIX(inv_ycbcr_matrix) * ycbcr;
31         rgba.a = 1.0;
32         return rgba;
33 }