cconvYV12.c revision 6035a3d1ce01a78c316578f23393c0b7edca0548
6035a3d1ce01a78c316578f23393c0b7edca0548vboxsync#extension GL_ARB_texture_rectangle : enable
6035a3d1ce01a78c316578f23393c0b7edca0548vboxsync
6035a3d1ce01a78c316578f23393c0b7edca0548vboxsyncuniform sampler2DRect uSrcTex;
6035a3d1ce01a78c316578f23393c0b7edca0548vboxsyncuniform sampler2DRect uVTex;
6035a3d1ce01a78c316578f23393c0b7edca0548vboxsyncuniform sampler2DRect uUTex;
6035a3d1ce01a78c316578f23393c0b7edca0548vboxsync
6035a3d1ce01a78c316578f23393c0b7edca0548vboxsyncfloat splitBGRA(vec4 color, float coord);
6035a3d1ce01a78c316578f23393c0b7edca0548vboxsyncvoid cconvApplyAYUV(vec4 color);
6035a3d1ce01a78c316578f23393c0b7edca0548vboxsync/* texture internalFormat: GL_LUMINANCE
6035a3d1ce01a78c316578f23393c0b7edca0548vboxsync * size: width X height
6035a3d1ce01a78c316578f23393c0b7edca0548vboxsync * data format: GL_LUMINANCE
6035a3d1ce01a78c316578f23393c0b7edca0548vboxsync *
6035a3d1ce01a78c316578f23393c0b7edca0548vboxsync/* YV12-rgb888 conversion shader */
6035a3d1ce01a78c316578f23393c0b7edca0548vboxsyncvoid cconvYV12(vec2 srcCoord)
6035a3d1ce01a78c316578f23393c0b7edca0548vboxsync{
6035a3d1ce01a78c316578f23393c0b7edca0548vboxsync vec4 clrY = texture2DRect(uSrcTex, srcCoord);
6035a3d1ce01a78c316578f23393c0b7edca0548vboxsync vec4 clrV = texture2DRect(uVTex, vec2(gl_TexCoord[2]));
6035a3d1ce01a78c316578f23393c0b7edca0548vboxsync vec4 clrU = texture2DRect(uUTex, vec2(gl_TexCoord[3]));
6035a3d1ce01a78c316578f23393c0b7edca0548vboxsync float y = splitBGRA(clrY, srcCoord.x);
6035a3d1ce01a78c316578f23393c0b7edca0548vboxsync float v = splitBGRA(clrV, gl_TexCoord[2].x);
6035a3d1ce01a78c316578f23393c0b7edca0548vboxsync float u = splitBGRA(clrU, gl_TexCoord[3].x);
6035a3d1ce01a78c316578f23393c0b7edca0548vboxsync
6035a3d1ce01a78c316578f23393c0b7edca0548vboxsync /* convert it to AYUV (for the GL_BGRA_EXT texture this is mapped as follows:
6035a3d1ce01a78c316578f23393c0b7edca0548vboxsync * A -> B
6035a3d1ce01a78c316578f23393c0b7edca0548vboxsync * Y -> G
6035a3d1ce01a78c316578f23393c0b7edca0548vboxsync * U -> R
6035a3d1ce01a78c316578f23393c0b7edca0548vboxsync * V -> A */
6035a3d1ce01a78c316578f23393c0b7edca0548vboxsync cconvApplyAYUV(vec4(u, y, 0.0, v));
6035a3d1ce01a78c316578f23393c0b7edca0548vboxsync// gl_FragColor = vec4(clrY.r,clrY.r,clrY.r,1.0);
6035a3d1ce01a78c316578f23393c0b7edca0548vboxsync}