summaryrefslogtreecommitdiff
path: root/gst-libs
diff options
context:
space:
mode:
authorMatthew Waters <ystreet00@gmail.com>2014-05-12 21:56:06 +1000
committerMatthew Waters <ystreet00@gmail.com>2014-05-12 22:10:19 +1000
commitbd3e6007101fca3016a870599f7d7c1ac0219857 (patch)
treeb637cc2abc47ef50588634b7b4bb1e95a63e3715 /gst-libs
parenta4f0fbe4c3cd1eaad53f922ac33749c517896852 (diff)
downloadgstreamer-plugins-bad-bd3e6007101fca3016a870599f7d7c1ac0219857.tar.gz
gl/convert: clobber alpha channel when needed
Needed in the conversion from padded RGB formats to formats with an alpha channel. e.g. BGRx -> ABGR, etc https://bugzilla.gnome.org/show_bug.cgi?id=729742
Diffstat (limited to 'gst-libs')
-rw-r--r--gst-libs/gst/gl/gstglcolorconvert.c14
1 files changed, 11 insertions, 3 deletions
diff --git a/gst-libs/gst/gl/gstglcolorconvert.c b/gst-libs/gst/gl/gstglcolorconvert.c
index f147c8913..c13b6a0af 100644
--- a/gst-libs/gst/gl/gstglcolorconvert.c
+++ b/gst-libs/gst/gl/gstglcolorconvert.c
@@ -133,6 +133,7 @@ static const gchar frag_REORDER[] =
"void main(void)\n"
"{\n"
" vec4 t = texture2D(tex, v_texcoord * tex_scale0);\n"
+ " %s;\n" /* clobber alpha channel? */
" gl_FragColor = vec4(t.%c, t.%c, t.%c, t.%c);\n"
"}";
@@ -698,10 +699,13 @@ _RGB_to_RGB (GstGLColorConvert * convert)
GstVideoFormat out_format = GST_VIDEO_INFO_FORMAT (&convert->out_info);
const gchar *out_format_str = gst_video_format_to_string (out_format);
gchar *pixel_order = _RGB_pixel_order (in_format_str, out_format_str);
+ const gchar *alpha = "";
info->in_n_textures = 1;
info->out_n_textures = 1;
- info->frag_prog = g_strdup_printf (frag_REORDER, pixel_order[0],
+ if (_is_RGBx (in_format))
+ alpha = "t.a = 1.0";
+ info->frag_prog = g_strdup_printf (frag_REORDER, alpha, pixel_order[0],
pixel_order[1], pixel_order[2], pixel_order[3]);
info->shader_tex_names[0] = "tex";
info->shader_scaling[0][0] = 1.0f;
@@ -892,6 +896,7 @@ _RGB_to_GRAY (GstGLColorConvert * convert)
GstVideoFormat in_format = GST_VIDEO_INFO_FORMAT (&convert->in_info);
const gchar *in_format_str = gst_video_format_to_string (in_format);
gchar *pixel_order = _RGB_pixel_order (in_format_str, "rgba");
+ const gchar *alpha = "";
info->in_n_textures = 1;
info->out_n_textures = 1;
@@ -903,9 +908,12 @@ _RGB_to_GRAY (GstGLColorConvert * convert)
info->shader_scaling[2][0] = 1.0f;
info->shader_scaling[2][1] = 1.0f;
+ if (_is_RGBx (in_format))
+ alpha = "t.a = 1.0";
+
switch (GST_VIDEO_INFO_FORMAT (&convert->out_info)) {
case GST_VIDEO_FORMAT_GRAY8:
- info->frag_prog = g_strdup_printf (frag_REORDER, pixel_order[0],
+ info->frag_prog = g_strdup_printf (frag_REORDER, alpha, pixel_order[0],
pixel_order[0], pixel_order[0], pixel_order[3]);
break;
default:
@@ -933,7 +941,7 @@ _GRAY_to_RGB (GstGLColorConvert * convert)
switch (GST_VIDEO_INFO_FORMAT (&convert->in_info)) {
case GST_VIDEO_FORMAT_GRAY8:
- info->frag_prog = g_strdup_printf (frag_REORDER, pixel_order[0],
+ info->frag_prog = g_strdup_printf (frag_REORDER, "", pixel_order[0],
pixel_order[1], pixel_order[2], pixel_order[3]);
break;
case GST_VIDEO_FORMAT_GRAY16_LE: