glcolorconvert: convert xRGB into ARGB properly
authorMatthew Waters <matthew@centricular.com>
Tue, 30 Sep 2014 04:46:14 +0000 (14:46 +1000)
committerTim-Philipp Müller <tim@centricular.com>
Sat, 9 Dec 2017 19:31:47 +0000 (19:31 +0000)
The alpha channel might not be the last component so check which one
it is in and clobber that one instead.

gst-libs/gst/gl/gstglcolorconvert.c

index 552e1c1..abe92fa 100644 (file)
@@ -673,8 +673,17 @@ _RGB_to_RGB (GstGLColorConvert * convert)
 
   info->in_n_textures = 1;
   info->out_n_textures = 1;
-  if (_is_RGBx (in_format))
-    alpha = g_strdup_printf ("t.%c = 1.0;", pixel_order[3]);
+  if (_is_RGBx (in_format)) {
+    int i;
+    char input_alpha_channel = 'a';
+    for (i = 0; i < GST_VIDEO_MAX_PLANES; i++) {
+      if (in_format_str[i] == 'X' || in_format_str[i] == 'x') {
+        input_alpha_channel = _index_to_shader_swizzle (i);
+        break;
+      }
+    }
+    alpha = g_strdup_printf ("t.%c = 1.0;", input_alpha_channel);
+  }
   info->frag_prog = g_strdup_printf (frag_REORDER, alpha ? alpha : "",
       pixel_order[0], pixel_order[1], pixel_order[2], pixel_order[3]);
   info->shader_tex_names[0] = "tex";