]> git.sesse.net Git - movit/blob - ycbcr_input.frag
A small comment fix in ColorspaceConversionEffect.
[movit] / ycbcr_input.frag
1 uniform sampler2D PREFIX(tex_y);
2 uniform sampler2D PREFIX(tex_cb);
3 uniform sampler2D PREFIX(tex_cr);
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 = texture2D(PREFIX(tex_y), tc).x;
13         ycbcr.y = texture2D(PREFIX(tex_cb), tc + PREFIX(cb_offset)).x;
14         ycbcr.z = texture2D(PREFIX(tex_cr), tc + PREFIX(cr_offset)).x;
15
16         ycbcr -= PREFIX(offset);
17         ycbcr *= PREFIX(scale);
18
19         vec4 rgba;
20         rgba.rgb = PREFIX(inv_ycbcr_matrix) * ycbcr;
21         rgba.a = 1.0;
22         return rgba;
23 }