d3d11: Add support for BGRx and RGBx formats
authorSeungha Yang <seungha@centricular.com>
Mon, 19 Apr 2021 17:00:18 +0000 (02:00 +0900)
committerGStreamer Marge Bot <gitlab-merge-bot@gstreamer-foundation.org>
Wed, 21 Apr 2021 05:45:59 +0000 (05:45 +0000)
For such formats, we can re-use existing BGRA/RGBA implementations
but ignoring alpha channel

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

gst-libs/gst/d3d11/gstd3d11device.c
gst-libs/gst/d3d11/gstd3d11format.h
tests/check/elements/d3d11colorconvert.c

index 946732a..b6d0982 100644 (file)
@@ -494,11 +494,23 @@ gst_d3d11_device_setup_format_table (GstD3D11Device * self)
   priv->format_table[n_formats].dxgi_format = DXGI_FORMAT_B8G8R8A8_UNORM;
   n_formats++;
 
+  /* Identical to BGRA, but alpha will be ignored */
+  priv->format_table[n_formats].format = GST_VIDEO_FORMAT_BGRx;
+  priv->format_table[n_formats].resource_format[0] = DXGI_FORMAT_B8G8R8A8_UNORM;
+  priv->format_table[n_formats].dxgi_format = DXGI_FORMAT_B8G8R8A8_UNORM;
+  n_formats++;
+
   priv->format_table[n_formats].format = GST_VIDEO_FORMAT_RGBA;
   priv->format_table[n_formats].resource_format[0] = DXGI_FORMAT_R8G8B8A8_UNORM;
   priv->format_table[n_formats].dxgi_format = DXGI_FORMAT_R8G8B8A8_UNORM;
   n_formats++;
 
+  /* Identical to RGBA, but alpha will be ignored */
+  priv->format_table[n_formats].format = GST_VIDEO_FORMAT_RGBx;
+  priv->format_table[n_formats].resource_format[0] = DXGI_FORMAT_R8G8B8A8_UNORM;
+  priv->format_table[n_formats].dxgi_format = DXGI_FORMAT_R8G8B8A8_UNORM;
+  n_formats++;
+
   priv->format_table[n_formats].format = GST_VIDEO_FORMAT_RGB10A2_LE;
   priv->format_table[n_formats].resource_format[0] =
       DXGI_FORMAT_R10G10B10A2_UNORM;
index 10ae5e1..1ac521e 100644 (file)
@@ -27,7 +27,7 @@
 G_BEGIN_DECLS
 
 #define GST_D3D11_COMMON_FORMATS \
-    "BGRA, RGBA, RGB10A2_LE, VUYA, NV12, P010_10LE, P016_LE, I420, I420_10LE"
+    "BGRA, RGBA, RGB10A2_LE, BGRx, RGBx, VUYA, NV12, P010_10LE, P016_LE, I420, I420_10LE"
 
 #define GST_D3D11_EXTRA_IN_FORMATS \
     "YUY2, UYVY, VYUY, Y210, Y410"
@@ -41,7 +41,7 @@ G_BEGIN_DECLS
 #define GST_D3D11_ALL_FORMATS \
     "{ " GST_D3D11_COMMON_FORMATS " ," GST_D3D11_EXTRA_IN_FORMATS " }"
 
-#define GST_D3D11_N_FORMATS 14
+#define GST_D3D11_N_FORMATS 16
 
 struct _GstD3D11Format
 {
index fc96fa8..6cd010a 100644 (file)
@@ -187,7 +187,7 @@ GST_START_TEST (test_d3d11_color_convert_yuv_rgb)
     "VUYA", "NV12", "P010_10LE", "P016_LE", "I420", "I420_10LE"
   };
   const gchar *out_format_list[] = {
-    "BGRA", "RGBA", "RGB10A2_LE",
+    "BGRA", "RGBA", "RGB10A2_LE", "BGRx", "RGBx",
   };
 
 
@@ -210,7 +210,7 @@ GST_END_TEST;
 GST_START_TEST (test_d3d11_color_convert_rgb_yuv)
 {
   const gchar *in_format_list[] = {
-    "BGRA", "RGBA", "RGB10A2_LE",
+    "BGRA", "RGBA", "RGB10A2_LE", "BGRx", "RGBx",
   };
   const gchar *out_format_list[] = {
     "VUYA", "NV12", "P010_10LE", "P016_LE", "I420", "I420_10LE"
@@ -232,7 +232,7 @@ GST_END_TEST;
 GST_START_TEST (test_d3d11_color_convert_rgb_rgb)
 {
   const gchar *format_list[] = {
-    "BGRA", "RGBA", "RGB10A2_LE",
+    "BGRA", "RGBA", "RGB10A2_LE", "BGRx", "RGBx",
   };
 
   gint i, j;
@@ -278,7 +278,7 @@ GST_START_TEST (test_d3d11_color_convert_packed_yuv_rgb)
     "YUY2", "UYVY", "VYUY", "Y210", "Y410",
   };
   const gchar *out_format_list[] = {
-    "BGRA", "RGBA", "RGB10A2_LE",
+    "BGRA", "RGBA", "RGB10A2_LE", "BGRx", "RGBx",
   };
 
   gint i, j;