gl: add support for Y412_LE / Y412_BE format
authorHaihao Xiang <haihao.xiang@intel.com>
Wed, 1 Apr 2020 05:55:50 +0000 (13:55 +0800)
committerHaihao Xiang <haihao.xiang@intel.com>
Wed, 1 Apr 2020 05:55:50 +0000 (13:55 +0800)
Reuse Y410 code for Y412_LE / Y412_BE except gl format. The gl format is
RGBA16 for Y412_LE / Y412_BE.

Sample pipeline:
gst-launch-1.0 videotestsrc ! video/x-raw,format=Y412_LE ! glimagesink

gst-libs/gst/gl/gstglcolorconvert.c
gst-libs/gst/gl/gstglcolorconvert.h
gst-libs/gst/gl/gstglformat.c
gst-libs/gst/gl/gstglmemory.h

index 1315804..76f5c2e 100644 (file)
@@ -953,6 +953,14 @@ _init_supported_formats (GstGLContext * context, gboolean output,
     _append_value_string_list (supported_formats, "Y212_BE", NULL);
 #endif
   }
+
+  if (!context || gst_gl_format_is_supported (context, GST_GL_RGBA16)) {
+#if G_BYTE_ORDER == G_LITTLE_ENDIAN
+    _append_value_string_list (supported_formats, "Y412_LE", NULL);
+#else
+    _append_value_string_list (supported_formats, "Y412_BE", NULL);
+#endif
+  }
 }
 
 /* copies the given caps */
@@ -1545,6 +1553,8 @@ _get_n_textures (GstVideoFormat v_format)
     case GST_VIDEO_FORMAT_Y210:
     case GST_VIDEO_FORMAT_Y212_LE:
     case GST_VIDEO_FORMAT_Y212_BE:
+    case GST_VIDEO_FORMAT_Y412_LE:
+    case GST_VIDEO_FORMAT_Y412_BE:
       return 1;
     case GST_VIDEO_FORMAT_NV12:
     case GST_VIDEO_FORMAT_NV21:
@@ -1650,6 +1660,8 @@ _YUV_to_RGB (GstGLColorConvert * convert)
         info->shader_tex_names[0] = "tex";
         break;
       case GST_VIDEO_FORMAT_Y410:
+      case GST_VIDEO_FORMAT_Y412_LE:
+      case GST_VIDEO_FORMAT_Y412_BE:
         info->templ = &templ_AYUV_to_RGB;
         info->frag_body = g_strdup_printf (templ_AYUV_to_RGB_BODY, "yxz", 'w',
             pixel_order[0], pixel_order[1], pixel_order[2], pixel_order[3]);
@@ -1801,6 +1813,8 @@ _RGB_to_YUV (GstGLColorConvert * convert)
       info->out_n_textures = 1;
       break;
     case GST_VIDEO_FORMAT_Y410:
+    case GST_VIDEO_FORMAT_Y412_LE:
+    case GST_VIDEO_FORMAT_Y412_BE:
       alpha = _is_RGBx (in_format) ? "1.0" : "texel.a";
       info->templ = &templ_RGB_to_AYUV;
       info->frag_body = g_strdup_printf (templ_RGB_to_AYUV_BODY, pixel_order[0],
index 0bad541..00954d6 100644 (file)
@@ -89,9 +89,10 @@ struct _GstGLColorConvertClass
  */
 #if G_BYTE_ORDER == G_LITTLE_ENDIAN
 #define COLOR_CONVERT_EXT_FORMATS \
-    ", BGR10A2_LE, RGB10A2_LE, P010_10LE, P012_LE, P016_LE, Y212_LE"
+    ", BGR10A2_LE, RGB10A2_LE, P010_10LE, P012_LE, P016_LE, Y212_LE, Y412_LE"
 #else
-#define COLOR_CONVERT_EXT_FORMATS ", P010_10BE, P012_BE, P016_BE, Y212_BE"
+#define COLOR_CONVERT_EXT_FORMATS \
+    ", P010_10BE, P012_BE, P016_BE, Y212_BE, Y412_BE"
 #endif
 
 #define GST_GL_COLOR_CONVERT_FORMATS "{ RGBA, RGB, RGBx, BGR, BGRx, BGRA, xRGB, " \
index 04ec26c..6cfdd91 100644 (file)
@@ -217,6 +217,9 @@ gst_gl_format_from_video_info (GstGLContext * context, GstVideoInfo * vinfo,
     case GST_VIDEO_FORMAT_Y212_LE:
     case GST_VIDEO_FORMAT_Y212_BE:
       return GST_GL_RG16;
+    case GST_VIDEO_FORMAT_Y412_LE:
+    case GST_VIDEO_FORMAT_Y412_BE:
+      return GST_GL_RGBA16;
     default:
       n_plane_components = 4;
       g_assert_not_reached ();
index cab6271..95062e6 100644 (file)
@@ -52,9 +52,10 @@ GType gst_gl_memory_allocator_get_type(void);
  */
 #if G_BYTE_ORDER == G_LITTLE_ENDIAN
 #define MEMORY_VIDEO_EXT_FORMATS \
-    ", BGR10A2_LE, RGB10A2_LE, P010_10LE, P012_LE, P016_LE, Y212_LE"
+    ", BGR10A2_LE, RGB10A2_LE, P010_10LE, P012_LE, P016_LE, Y212_LE, Y412_LE"
 #else
-#define MEMORY_VIDEO_EXT_FORMATS ", P010_10BE, P012_BE, P016_BE, Y212_BE"
+#define MEMORY_VIDEO_EXT_FORMATS \
+    ", P010_10BE, P012_BE, P016_BE, Y212_BE, Y412_BE"
 #endif
 
 #define GST_GL_MEMORY_VIDEO_FORMATS_STR \