summaryrefslogtreecommitdiff
path: root/gst-libs
diff options
context:
space:
mode:
authorMatthew Waters <matthew@centricular.com>2016-02-02 13:51:18 +1100
committerMatthew Waters <matthew@centricular.com>2016-02-02 14:55:10 +1100
commitcb08d13e458e1c5a2b0d5ef96326f7e11effd5c7 (patch)
treedda4343ef4d3ac3d1a6ab8adf5b9b4f7a5d98465 /gst-libs
parentc8bd74fa9a81398f57d976c478d2043f30188684 (diff)
downloadgstreamer-plugins-bad-cb08d13e458e1c5a2b0d5ef96326f7e11effd5c7.tar.gz
glcolorconvert: fix YUY2/UYVY,rectangle->RGB conversion
1.0 / width does not offset by one pixel in rectangular textures (which use unnormalized coordinates). Provide the actual pixel offset as a uniform to the shader.
Diffstat (limited to 'gst-libs')
-rw-r--r--gst-libs/gst/gl/gstglcolorconvert.c24
1 files changed, 19 insertions, 5 deletions
diff --git a/gst-libs/gst/gl/gstglcolorconvert.c b/gst-libs/gst/gl/gstglcolorconvert.c
index 0cbd412a9..b6d706a68 100644
--- a/gst-libs/gst/gl/gstglcolorconvert.c
+++ b/gst-libs/gst/gl/gstglcolorconvert.c
@@ -127,7 +127,9 @@ static const gfloat from_rgb_bt709_vcoeff[] = { 0.440654, -0.400285, -0.040370 }
"uniform vec2 tex_scale1;\n" \
"uniform vec2 tex_scale2;\n" \
"uniform float width;\n" \
- "uniform float height;\n"
+ "uniform float height;\n" \
+ "uniform float poffset_x;\n" \
+ "uniform float poffset_y;\n"
#define MAX_FUNCTIONS 4
@@ -316,10 +318,11 @@ static const struct shader_templ templ_YUY2_UYVY_to_RGB =
"vec4 rgba, uv_texel;\n"
"vec3 yuv;\n"
/* FIXME: should get the sampling right... */
- "float dx1 = -1.0 / width;\n"
+ "float dx1 = -poffset_x;\n"
"float dx2 = 0.0;\n"
"yuv.x = texture2D(Ytex, texcoord * tex_scale0).%c;\n"
- "float inorder = mod (texcoord.x * width, 2.0);\n"
+ /* v_texcoord are normalized, texcoord may not be e.g. rectangle textures */
+ "float inorder = mod (v_texcoord.x * width, 2.0);\n"
"if (inorder < 1.0) {\n"
" dx2 = -dx1;\n"
" dx1 = 0.0;\n"
@@ -340,9 +343,10 @@ static const struct shader_templ templ_RGB_to_YUY2_UYVY =
"vec4 texel1, texel2;\n"
"vec3 yuv, yuv1, yuv2;\n"
"float fx, dx, fy;\n"
- "float inorder = mod (texcoord.x * width, 2.0);\n"
+ /* v_texcoord are normalized, texcoord may not be e.g. rectangle textures */
+ "float inorder = mod (v_texcoord.x * width, 2.0);\n"
"fx = texcoord.x;\n"
- "dx = 1.0 / width;\n"
+ "dx = poffset_x;\n"
"if (inorder > 1.0) {\n"
" dx = -dx;\n"
"}\n"
@@ -2113,6 +2117,16 @@ _init_convert (GstGLColorConvert * convert)
gst_gl_shader_set_uniform_1f (convert->shader, "height",
GST_VIDEO_INFO_HEIGHT (&convert->in_info));
+ if (convert->priv->from_texture_target == GST_GL_TEXTURE_TARGET_RECTANGLE) {
+ gst_gl_shader_set_uniform_1f (convert->shader, "poffset_x", 1.);
+ gst_gl_shader_set_uniform_1f (convert->shader, "poffset_y", 1.);
+ } else {
+ gst_gl_shader_set_uniform_1f (convert->shader, "poffset_x",
+ 1. / (gfloat) GST_VIDEO_INFO_WIDTH (&convert->in_info));
+ gst_gl_shader_set_uniform_1f (convert->shader, "poffset_y",
+ 1. / (gfloat) GST_VIDEO_INFO_HEIGHT (&convert->in_info));
+ }
+
if (info->chroma_sampling[0] > 0.0f && info->chroma_sampling[1] > 0.0f) {
gst_gl_shader_set_uniform_2fv (convert->shader, "chroma_sampling", 1,
info->chroma_sampling);