gl: add support for RGBP and BGRP formats
authorHaihao Xiang <haihao.xiang@intel.com>
Mon, 10 May 2021 06:43:23 +0000 (14:43 +0800)
committerHaihao Xiang <haihao.xiang@intel.com>
Tue, 11 May 2021 04:24:41 +0000 (12:24 +0800)
gst-launch-1.0 videotestsrc ! video/x-raw,format=RGBP ! glimagesink
gst-launch-1.0 videotestsrc ! video/x-raw,format=BGRP ! glimagesink

Part-of: <https://gitlab.freedesktop.org/gstreamer/gst-plugins-base/-/merge_requests/1141>

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 51a33fc..b86029b 100644 (file)
@@ -964,8 +964,9 @@ _init_supported_formats (GstGLContext * context, gboolean output,
 
   /* Always supported input formats or output with multiple draw buffers */
   if (!output || (!context || context->gl_vtable->DrawBuffers))
-    _append_value_string_list (supported_formats, "GBRA", "GBR", "Y444",
-        "I420", "YV12", "Y42B", "Y41B", "NV12", "NV21", "NV16", "NV61", NULL);
+    _append_value_string_list (supported_formats, "GBRA", "GBR", "RGBP", "BGRP",
+        "Y444", "I420", "YV12", "Y42B", "Y41B", "NV12", "NV21", "NV16", "NV61",
+        NULL);
 
   /* Requires reading from a RG/LA framebuffer... */
   if (!context || (USING_GLES3 (context) || USING_OPENGL (context)))
@@ -1468,6 +1469,8 @@ _is_planar_rgb (GstVideoFormat v_format)
 {
   switch (v_format) {
     case GST_VIDEO_FORMAT_GBR:
+    case GST_VIDEO_FORMAT_RGBP:
+    case GST_VIDEO_FORMAT_BGRP:
     case GST_VIDEO_FORMAT_GBR_10BE:
     case GST_VIDEO_FORMAT_GBR_10LE:
     case GST_VIDEO_FORMAT_GBRA:
@@ -1530,6 +1533,10 @@ _RGB_pixel_order (const gchar * expected, const gchar * wanted)
     gchar *temp = expect;
     expect = g_strndup ("rgba", 4);
     g_free (temp);
+  } else if (strcmp (expect, "rgbp") == 0 || strcmp (expect, "bgrp") == 0) {
+    gchar *temp = expect;
+    expect = g_strndup (temp, 3);
+    g_free (temp);
   }
 
   if (strcmp (want, "rgb16") == 0 || strcmp (want, "bgr16") == 0) {
@@ -1645,6 +1652,8 @@ _get_n_textures (GstVideoFormat v_format)
     case GST_VIDEO_FORMAT_Y41B:
     case GST_VIDEO_FORMAT_YV12:
     case GST_VIDEO_FORMAT_GBR:
+    case GST_VIDEO_FORMAT_RGBP:
+    case GST_VIDEO_FORMAT_BGRP:
       return 3;
     case GST_VIDEO_FORMAT_GBRA:
       return 4;
index b626ca5..7962652 100644 (file)
@@ -100,7 +100,7 @@ struct _GstGLColorConvertClass
  * The currently supported formats that can be converted
  */
 #define GST_GL_COLOR_CONVERT_FORMATS "{ RGBA, RGB, RGBx, BGR, BGRx, BGRA, xRGB, " \
-                               "xBGR, ARGB, ABGR, GBRA, GBR, Y444, I420, YV12, Y42B, " \
+                               "xBGR, ARGB, ABGR, GBRA, GBR, RGBP, BGRP, Y444, I420, YV12, Y42B, " \
                                "Y41B, NV12, NV21, NV16, NV61, YUY2, UYVY, Y210, AYUV, " \
                                "VUYA, Y410, GRAY8, GRAY16_LE, GRAY16_BE, " \
                                "RGB16, BGR16, ARGB64 " \
index 66ffa80..192ff4f 100644 (file)
@@ -221,6 +221,8 @@ gst_gl_format_from_video_info (GstGLContext * context,
     case GST_VIDEO_FORMAT_Y412_BE:
       return GST_GL_RGBA16;
     case GST_VIDEO_FORMAT_GBR:
+    case GST_VIDEO_FORMAT_RGBP:
+    case GST_VIDEO_FORMAT_BGRP:
     case GST_VIDEO_FORMAT_GBRA:
       return GST_GL_R8;
     default:
index e70707f..7cffca9 100644 (file)
@@ -62,7 +62,7 @@ GType gst_gl_memory_allocator_get_type(void);
  * List of video formats that are supported by #GstGLMemory
  */
 #define GST_GL_MEMORY_VIDEO_FORMATS_STR \
-    "{ RGBA, BGRA, RGBx, BGRx, ARGB, ABGR, xRGB, xBGR, GBRA, GBR, RGB, BGR, RGB16, BGR16, " \
+    "{ RGBA, BGRA, RGBx, BGRx, ARGB, ABGR, xRGB, xBGR, GBRA, GBR, RGBP, BGRP, RGB, BGR, RGB16, BGR16, " \
     "AYUV, VUYA, Y410, I420, YV12, NV12, NV21, NV16, NV61, YUY2, UYVY, Y210, Y41B, " \
     "Y42B, Y444, GRAY8, GRAY16_LE, GRAY16_BE, ARGB64" \
     GST_GL_MEMORY_VIDEO_EXT_FORMATS "}"