diff options
author | Matthew Waters <matthew@centricular.com> | 2014-10-07 22:50:22 +1100 |
---|---|---|
committer | Matthew Waters <matthew@centricular.com> | 2014-10-07 23:07:13 +1100 |
commit | 9468f73d40e2e19cee49595c954f25bea7146a39 (patch) | |
tree | e824d71bf5c4b26737136fa575b9b33ece99784e | |
parent | da094d5fd9bd40779abe26bb8cb6e57ecf789ae6 (diff) | |
download | gstreamer-plugins-bad-9468f73d40e2e19cee49595c954f25bea7146a39.tar.gz |
glcolrconvert: fix YUY2 download
- The shader was outputing the wrong values compared with raw
videotestsrc.
- deal with the texture edge properly.
- properly sample the 2x1 rectangle for the u and v values
- don't double sample the y value
-rw-r--r-- | gst-libs/gst/gl/gstglcolorconvert.c | 39 |
1 files changed, 23 insertions, 16 deletions
diff --git a/gst-libs/gst/gl/gstglcolorconvert.c b/gst-libs/gst/gl/gstglcolorconvert.c index aaba1d8f1..8ca585bf4 100644 --- a/gst-libs/gst/gl/gstglcolorconvert.c +++ b/gst-libs/gst/gl/gstglcolorconvert.c @@ -326,25 +326,32 @@ static const gchar frag_RGB_to_YUY2_UYVY[] = "void main(void) {\n" " vec4 texel1, texel2;\n" " vec2 texel3;\n" - " float fx, fy, y1, y2, u, v;\n" + " float fx, dx, fy, y, u, u1, u2, v, v1, v2;\n" + " float inorder = mod (v_texcoord.x * width, 2.0);\n" " fx = v_texcoord.x;\n" + " dx = 1.0 / width;\n" + " if (v_texcoord.x >= (1.0 - 0.5 * dx) || (v_texcoord.x > 0.5 * dx && inorder < 1.0)) {\n" + " dx = -dx;\n" + " }\n" " fy = v_texcoord.y;\n" - " float inorder = mod (v_texcoord.x * width, 2.0);\n" - " texel1 = texture2D(tex, vec2(fx, fy)).%c%c%c%c;\n" - " texel2 = texture2D(tex, vec2(fx+1.0 / width, fy)).%c%c%c%c;\n" - " y1 = dot(texel1.rgb, coeff1);\n" - " y2 = dot(texel2.rgb, coeff1);\n" - " u = dot(texel1.rgb, coeff2);\n" - " v = dot(texel1.rgb, coeff3);\n" - " y1 += offset.x;\n" - " y2 += offset.x;\n" - " u += offset.y;\n" - " v += offset.z;\n" + " texel1 = texture2D(tex, vec2(fx, fy)).%c%c%c%c;\n" + " texel2 = texture2D(tex, vec2(fx + dx, fy)).%c%c%c%c;\n" + " y = dot(texel1.rgb, coeff1);\n" + " u1 = dot(texel1.rgb, coeff2);\n" + " u2 = dot(texel2.rgb, coeff2);\n" + " v1 = dot(texel1.rgb, coeff3);\n" + " v2 = dot(texel2.rgb, coeff3);\n" + " y += offset.x;\n" + " u1 += offset.y;\n" + " u2 += offset.y;\n" + " v1 += offset.z;\n" + " v2 += offset.z;\n" + " u = (u1 + u2) / 2.0;\n" + " v = (v1 + v2) / 2.0;\n" + " texel3.r = y;\n" " if (inorder < 1.0) {\n" - " texel3.r = %s;\n" " texel3.g = %s;\n" " } else {\n" - " texel3.r = %s;\n" " texel3.g = %s;\n" " }\n" " gl_FragColor = vec4(texel3.r, texel3.g, 0.0, 0.0);\n" @@ -831,14 +838,14 @@ _RGB_to_YUV (GstGLColorConvert * convert) info->frag_prog = g_strdup_printf (frag_RGB_to_YUY2_UYVY, pixel_order[0], pixel_order[1], pixel_order[2], pixel_order[3], pixel_order[0], pixel_order[1], pixel_order[2], pixel_order[3], - "y1", "u", "y2", "v"); + "u", "v"); info->out_n_textures = 1; break; case GST_VIDEO_FORMAT_UYVY: info->frag_prog = g_strdup_printf (frag_RGB_to_YUY2_UYVY, pixel_order[0], pixel_order[1], pixel_order[2], pixel_order[3], pixel_order[0], pixel_order[1], pixel_order[2], pixel_order[3], - "u", "y1", "v", "y2"); + "u", "v"); info->out_n_textures = 1; break; default: |