From 0b11eba96a63cacacc5e946950bbea7e700b419b Mon Sep 17 00:00:00 2001 From: Matthew Waters Date: Wed, 2 Dec 2015 22:40:06 +1100 Subject: [PATCH] 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 --- gst-libs/gst/gl/gstglcolorconvert.c | 9 +++++---- 1 file changed, 5 insertions(+), 4 deletions(-) diff --git a/gst-libs/gst/gl/gstglcolorconvert.c b/gst-libs/gst/gl/gstglcolorconvert.c index f4fd547fd4..e01770019b 100644 --- a/gst-libs/gst/gl/gstglcolorconvert.c +++ b/gst-libs/gst/gl/gstglcolorconvert.c @@ -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"