X-Git-Url: https://git.sesse.net/?a=blobdiff_plain;f=ycbcr_input.frag;fp=ycbcr_input.frag;h=13e44b071398b986bb2a9037f27fed2016a65645;hb=9dcbd93164611ea111cc29519c18193d4f571ac1;hp=0000000000000000000000000000000000000000;hpb=ef82f39846c48a654b63797b78bf8b0b8935d348;p=movit diff --git a/ycbcr_input.frag b/ycbcr_input.frag new file mode 100644 index 0000000..13e44b0 --- /dev/null +++ b/ycbcr_input.frag @@ -0,0 +1,23 @@ +uniform sampler2D PREFIX(tex_y); +uniform sampler2D PREFIX(tex_cb); +uniform sampler2D PREFIX(tex_cr); + +vec4 FUNCNAME(vec2 tc) { + // OpenGL's origin is bottom-left, but most graphics software assumes + // a top-left origin. Thus, for inputs that come from the user, + // we flip the y coordinate. + tc.y = 1.0 - tc.y; + + vec3 ycbcr; + ycbcr.x = texture2D(PREFIX(tex_y), tc).x; + ycbcr.y = texture2D(PREFIX(tex_cb), tc + PREFIX(chroma_offset)).x; + ycbcr.z = texture2D(PREFIX(tex_cr), tc + PREFIX(chroma_offset)).x; + + ycbcr -= PREFIX(offset); + ycbcr *= PREFIX(scale); + + vec4 rgba; + rgba.rgb = PREFIX(inv_ycbcr_matrix) * ycbcr; + rgba.a = 1.0; + return rgba; +}