From 2da979831ec3b1a8d993eb6f2d3999c5810c4d67 Mon Sep 17 00:00:00 2001 From: Matthew Waters Date: Wed, 21 May 2014 10:26:21 +1000 Subject: [PATCH] gl/upload: switch the 'master' texture for YUY2, UYVY From d4bcef3204709159713ff1630978ecac0bd91dc9 on, using a RGBA texture to hold the data causes the glmemory to have half width and a scaling of [2, 1]. Using a LA texture solves this problem however cannot be attached to the framebuffer for copying into a RGBA texture. Which will be solved by moving to EXT_texture_rg. https://bugzilla.gnome.org/show_bug.cgi?id=728890 --- gst-libs/gst/gl/gstglcolorconvert.c | 16 ++++++++-------- gst-libs/gst/gl/gstglmemory.c | 7 +------ gst-libs/gst/gl/gstglupload.c | 2 +- 3 files changed, 10 insertions(+), 15 deletions(-) diff --git a/gst-libs/gst/gl/gstglcolorconvert.c b/gst-libs/gst/gl/gstglcolorconvert.c index f9055be8cf..588205700a 100644 --- a/gst-libs/gst/gl/gstglcolorconvert.c +++ b/gst-libs/gst/gl/gstglcolorconvert.c @@ -727,12 +727,12 @@ _YUV_to_RGB (GstGLColorConvert * convert) info->frag_prog = g_strdup_printf (frag_YUY2_UYVY_to_RGB, 'r', 'g', 'a', pixel_order[0], pixel_order[1], pixel_order[2], pixel_order[3]); info->in_n_textures = 1; - info->shader_tex_names[1] = "Ytex"; - info->shader_tex_names[0] = "UVtex"; + info->shader_tex_names[0] = "Ytex"; + info->shader_tex_names[1] = "UVtex"; convert->priv->scratch = (GstGLMemory *) gst_gl_memory_alloc (convert->context, - GST_VIDEO_GL_TEXTURE_TYPE_LUMINANCE_ALPHA, - GST_VIDEO_INFO_WIDTH (&convert->in_info), + GST_VIDEO_GL_TEXTURE_TYPE_RGBA, + GST_VIDEO_INFO_COMP_WIDTH (&convert->in_info, 1), GST_VIDEO_INFO_HEIGHT (&convert->in_info), GST_VIDEO_INFO_PLANE_STRIDE (&convert->in_info, 0)); break; @@ -754,12 +754,12 @@ _YUV_to_RGB (GstGLColorConvert * convert) info->frag_prog = g_strdup_printf (frag_YUY2_UYVY_to_RGB, 'a', 'r', 'b', pixel_order[0], pixel_order[1], pixel_order[2], pixel_order[3]); info->in_n_textures = 1; - info->shader_tex_names[1] = "Ytex"; - info->shader_tex_names[0] = "UVtex"; + info->shader_tex_names[0] = "Ytex"; + info->shader_tex_names[1] = "UVtex"; convert->priv->scratch = (GstGLMemory *) gst_gl_memory_alloc (convert->context, - GST_VIDEO_GL_TEXTURE_TYPE_LUMINANCE_ALPHA, - GST_VIDEO_INFO_WIDTH (&convert->in_info), + GST_VIDEO_GL_TEXTURE_TYPE_RGBA, + GST_VIDEO_INFO_COMP_WIDTH (&convert->in_info, 1), GST_VIDEO_INFO_HEIGHT (&convert->in_info), GST_VIDEO_INFO_PLANE_STRIDE (&convert->in_info, 0)); break; diff --git a/gst-libs/gst/gl/gstglmemory.c b/gst-libs/gst/gl/gstglmemory.c index 8d6fed194c..45d4c1cf1a 100644 --- a/gst-libs/gst/gl/gstglmemory.c +++ b/gst-libs/gst/gl/gstglmemory.c @@ -208,7 +208,7 @@ gst_gl_texture_type_from_format (GstVideoFormat v_format, guint plane) break; case GST_VIDEO_FORMAT_YUY2: case GST_VIDEO_FORMAT_UYVY: - return GST_VIDEO_GL_TEXTURE_TYPE_RGBA; + return GST_VIDEO_GL_TEXTURE_TYPE_LUMINANCE_ALPHA; break; case GST_VIDEO_FORMAT_NV12: case GST_VIDEO_FORMAT_NV21: @@ -233,11 +233,6 @@ gst_gl_texture_type_from_format (GstVideoFormat v_format, guint plane) static inline guint _get_plane_width (GstVideoInfo * info, guint plane) { - if (GST_VIDEO_INFO_FORMAT (info) == GST_VIDEO_FORMAT_YUY2 - || GST_VIDEO_INFO_FORMAT (info) == GST_VIDEO_FORMAT_UYVY) { - return GST_VIDEO_INFO_COMP_WIDTH (info, 1); - } - if (GST_VIDEO_INFO_IS_YUV (info)) /* For now component width and plane width are the same and the * plane-component mapping matches diff --git a/gst-libs/gst/gl/gstglupload.c b/gst-libs/gst/gl/gstglupload.c index 3c5a5ffdbe..fb87153f44 100644 --- a/gst-libs/gst/gl/gstglupload.c +++ b/gst-libs/gst/gl/gstglupload.c @@ -287,7 +287,7 @@ gst_gl_upload_perform_with_buffer (GstGLUpload * upload, GstBuffer * buffer, upload->out_tex = (GstGLMemory *) gst_gl_memory_alloc (upload->context, GST_VIDEO_GL_TEXTURE_TYPE_RGBA, GST_VIDEO_INFO_WIDTH (&upload->in_info), GST_VIDEO_INFO_HEIGHT (&upload->in_info), - GST_VIDEO_INFO_PLANE_STRIDE (&upload->in_info, 0)); + 4 * GST_VIDEO_INFO_WIDTH (&upload->in_info)); GST_LOG_OBJECT (upload, "Attempting upload with GstGLMemory"); for (i = 0; i < GST_VIDEO_INFO_N_PLANES (&upload->in_info); i++) {