gl: add support for Y212_LE / Y212_BE format
authorHaihao Xiang <haihao.xiang@intel.com>
Mon, 30 Mar 2020 06:37:26 +0000 (14:37 +0800)
committerHaihao Xiang <haihao.xiang@intel.com>
Wed, 1 Apr 2020 05:55:11 +0000 (13:55 +0800)
Because the color value is stored in MSB, so we can reuse the
Y210 code for P012_LE / P012_BE

Sample pipeline:
gst-launch-1.0 videotestsrc ! video/x-raw,format=Y212_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 4e33937..1315804 100644 (file)
@@ -945,8 +945,14 @@ _init_supported_formats (GstGLContext * context, gboolean output,
 #endif
   }
 
-  if (!context || (gst_gl_format_is_supported (context, GST_GL_RG16)))
+  if (!context || (gst_gl_format_is_supported (context, GST_GL_RG16))) {
     _append_value_string_list (supported_formats, "Y210", NULL);
+#if G_BYTE_ORDER == G_LITTLE_ENDIAN
+    _append_value_string_list (supported_formats, "Y212_LE", NULL);
+#else
+    _append_value_string_list (supported_formats, "Y212_BE", NULL);
+#endif
+  }
 }
 
 /* copies the given caps */
@@ -1537,6 +1543,8 @@ _get_n_textures (GstVideoFormat v_format)
     case GST_VIDEO_FORMAT_RGB10A2_LE:
     case GST_VIDEO_FORMAT_Y410:
     case GST_VIDEO_FORMAT_Y210:
+    case GST_VIDEO_FORMAT_Y212_LE:
+    case GST_VIDEO_FORMAT_Y212_BE:
       return 1;
     case GST_VIDEO_FORMAT_NV12:
     case GST_VIDEO_FORMAT_NV21:
@@ -1691,6 +1699,8 @@ _YUV_to_RGB (GstGLColorConvert * convert)
         break;
       }
       case GST_VIDEO_FORMAT_Y210:
+      case GST_VIDEO_FORMAT_Y212_LE:
+      case GST_VIDEO_FORMAT_Y212_BE:
       {
         info->templ = &templ_YUY2_UYVY_to_RGB;
         info->frag_body =
@@ -1821,6 +1831,8 @@ _RGB_to_YUV (GstGLColorConvert * convert)
       break;
     case GST_VIDEO_FORMAT_YUY2:
     case GST_VIDEO_FORMAT_Y210:
+    case GST_VIDEO_FORMAT_Y212_LE:
+    case GST_VIDEO_FORMAT_Y212_BE:
       info->templ = &templ_RGB_to_YUY2_UYVY;
       info->frag_body = g_strdup_printf (templ_RGB_to_YUY2_UYVY_BODY,
           pixel_order[0], pixel_order[1], pixel_order[2], pixel_order[3],
index 7563db6..0bad541 100644 (file)
@@ -88,9 +88,10 @@ struct _GstGLColorConvertClass
  * The currently supported formats that can be converted
  */
 #if G_BYTE_ORDER == G_LITTLE_ENDIAN
-#define COLOR_CONVERT_EXT_FORMATS ", BGR10A2_LE, RGB10A2_LE, P010_10LE, P012_LE, P016_LE"
+#define COLOR_CONVERT_EXT_FORMATS \
+    ", BGR10A2_LE, RGB10A2_LE, P010_10LE, P012_LE, P016_LE, Y212_LE"
 #else
-#define COLOR_CONVERT_EXT_FORMATS ", P010_10BE, P012_BE, P016_BE"
+#define COLOR_CONVERT_EXT_FORMATS ", P010_10BE, P012_BE, P016_BE, Y212_BE"
 #endif
 
 #define GST_GL_COLOR_CONVERT_FORMATS "{ RGBA, RGB, RGBx, BGR, BGRx, BGRA, xRGB, " \
index af8eb4c..04ec26c 100644 (file)
@@ -214,6 +214,8 @@ gst_gl_format_from_video_info (GstGLContext * context, GstVideoInfo * vinfo,
     case GST_VIDEO_FORMAT_P016_BE:
       return plane == 0 ? GST_GL_R16 : GST_GL_RG16;
     case GST_VIDEO_FORMAT_Y210:
+    case GST_VIDEO_FORMAT_Y212_LE:
+    case GST_VIDEO_FORMAT_Y212_BE:
       return GST_GL_RG16;
     default:
       n_plane_components = 4;
index 3c84cce..cab6271 100644 (file)
@@ -51,9 +51,10 @@ GType gst_gl_memory_allocator_get_type(void);
  * List of video formats that are supported by #GstGLMemory
  */
 #if G_BYTE_ORDER == G_LITTLE_ENDIAN
-#define MEMORY_VIDEO_EXT_FORMATS ", BGR10A2_LE, RGB10A2_LE, P010_10LE, P012_LE, P016_LE"
+#define MEMORY_VIDEO_EXT_FORMATS \
+    ", BGR10A2_LE, RGB10A2_LE, P010_10LE, P012_LE, P016_LE, Y212_LE"
 #else
-#define MEMORY_VIDEO_EXT_FORMATS ", P010_10BE, P012_BE, P016_BE"
+#define MEMORY_VIDEO_EXT_FORMATS ", P010_10BE, P012_BE, P016_BE, Y212_BE"
 #endif
 
 #define GST_GL_MEMORY_VIDEO_FORMATS_STR \