glcolorconvert: improve RGBA->YUY2/UYVY conversion shader

We should only average the chroma samples not the luma sample.

https://bugzilla.gnome.org/show_bug.cgi?id=758904
This commit is contained in:
Matthew Waters 2015-12-02 22:40:06 +11:00 committed by Tim-Philipp Müller
parent 8ab57b5b23
commit bb7422e91b

View file

@ -343,15 +343,16 @@ static const struct shader_templ templ_RGB_to_YUY2_UYVY =
"float inorder = mod (texcoord.x * width, 2.0);\n"
"fx = texcoord.x;\n"
"dx = 1.0 / width;\n"
"if (texcoord.x >= (1.0 - 0.5 * dx) || (texcoord.x > 0.5 * dx && inorder < 1.0)) {\n"
"if (inorder > 1.0) {\n"
" dx = -dx;\n"
"}\n"
"fy = texcoord.y;\n"
"texel1 = texture2D(tex, vec2(fx, fy)).%c%c%c%c;\n"
"texel2 = texture2D(tex, vec2(fx + dx, fy)).%c%c%c%c;\n"
"yuv1 = rgb_to_yuv (texel1.rgb, offset, coeff1, coeff2, coeff3);"
"yuv2 = rgb_to_yuv (texel2.rgb, offset, coeff1, coeff2, coeff3);"
"yuv = (yuv1 + yuv2) / 2.0;\n"
"yuv1 = rgb_to_yuv (texel1.rgb, offset, coeff1, coeff2, coeff3);\n"
"yuv2 = rgb_to_yuv (texel2.rgb, offset, coeff1, coeff2, coeff3);\n"
"yuv.x = yuv1.x;\n"
"yuv.yz = (yuv1.yz + yuv2.yz) * 0.5;\n"
"if (inorder < 1.0) {\n"
" gl_FragColor = vec4(yuv.%c, yuv.%c, 0.0, 0.0);\n"
"} else {\n"