diff options
author | Seungha Yang <seungha@centricular.com> | 2021-06-21 17:13:33 +0900 |
---|---|---|
committer | GStreamer Marge Bot <gitlab-merge-bot@gstreamer-foundation.org> | 2021-06-23 15:35:36 +0000 |
commit | 7c94b9c4b0d70366bd016f4d2e22f06e576323cd (patch) | |
tree | 5963b3c10dbc51935036ccd0c2214e614918df21 /gst-libs | |
parent | 52a0c3659859f3f7896620042ba49bf2274a072a (diff) | |
download | gstreamer-plugins-bad-7c94b9c4b0d70366bd016f4d2e22f06e576323cd.tar.gz |
d3d11: Add support for GRAY and more YUV formats
By this commit, following formats will be newly supported by d3d11 elements
* Y444_{8, 12, 16}LE formats:
Similar to other planar formats. Such Y444 variants are not supported
by Direct3D11 natively, but we can simply map each plane by
using R8 and/or R16 texture.
* P012_LE:
It is not different from P016_LE, but defining P012 and P016 separately
for more explicit signalling. Note that DXVA uses P016 texture
for 12bits encoded bitstreams.
* GRAY:
This format is required for some codecs (e.g., AV1) if monochrome
is supported
* 4:2:0 planar 12bits (I420_12LE) and 4:2:2 planar 8, 10, 12bits
formats (Y42B, I422_10LE, and I422_12LE)
Part-of: <https://gitlab.freedesktop.org/gstreamer/gst-plugins-bad/-/merge_requests/2346>
Diffstat (limited to 'gst-libs')
-rw-r--r-- | gst-libs/gst/d3d11/gstd3d11device.cpp | 77 | ||||
-rw-r--r-- | gst-libs/gst/d3d11/gstd3d11format.h | 4 |
2 files changed, 79 insertions, 2 deletions
diff --git a/gst-libs/gst/d3d11/gstd3d11device.cpp b/gst-libs/gst/d3d11/gstd3d11device.cpp index 41d48bf98..0b03a0aa0 100644 --- a/gst-libs/gst/d3d11/gstd3d11device.cpp +++ b/gst-libs/gst/d3d11/gstd3d11device.cpp @@ -95,7 +95,7 @@ enum #define DEFAULT_ADAPTER 0 #define DEFAULT_CREATE_FLAGS 0 -#define GST_D3D11_N_FORMATS 18 +#define GST_D3D11_N_FORMATS 29 struct _GstD3D11DevicePrivate { @@ -627,6 +627,18 @@ gst_d3d11_device_setup_format_table (GstD3D11Device * self) priv->format_table[n_formats].dxgi_format = DXGI_FORMAT_UNKNOWN; n_formats++; + /* P012 is identical to P016 from runtime point of view */ + priv->format_table[n_formats].format = GST_VIDEO_FORMAT_P012_LE; + priv->format_table[n_formats].resource_format[0] = DXGI_FORMAT_R16_UNORM; + priv->format_table[n_formats].resource_format[1] = DXGI_FORMAT_R16G16_UNORM; + if (can_support_format (self, DXGI_FORMAT_P016, + D3D11_FORMAT_SUPPORT_RENDER_TARGET | + D3D11_FORMAT_SUPPORT_SHADER_SAMPLE)) + priv->format_table[n_formats].dxgi_format = DXGI_FORMAT_P016; + else + priv->format_table[n_formats].dxgi_format = DXGI_FORMAT_UNKNOWN; + n_formats++; + priv->format_table[n_formats].format = GST_VIDEO_FORMAT_P016_LE; priv->format_table[n_formats].resource_format[0] = DXGI_FORMAT_R16_UNORM; priv->format_table[n_formats].resource_format[1] = DXGI_FORMAT_R16G16_UNORM; @@ -657,6 +669,69 @@ gst_d3d11_device_setup_format_table (GstD3D11Device * self) priv->format_table[n_formats].resource_format[2] = DXGI_FORMAT_R16_UNORM; n_formats++; + priv->format_table[n_formats].format = GST_VIDEO_FORMAT_I420_12LE; + priv->format_table[n_formats].resource_format[0] = DXGI_FORMAT_R16_UNORM; + priv->format_table[n_formats].resource_format[1] = DXGI_FORMAT_R16_UNORM; + priv->format_table[n_formats].resource_format[2] = DXGI_FORMAT_R16_UNORM; + n_formats++; + + priv->format_table[n_formats].format = GST_VIDEO_FORMAT_Y42B; + priv->format_table[n_formats].resource_format[0] = DXGI_FORMAT_R8_UNORM; + priv->format_table[n_formats].resource_format[1] = DXGI_FORMAT_R8_UNORM; + priv->format_table[n_formats].resource_format[2] = DXGI_FORMAT_R8_UNORM; + n_formats++; + + priv->format_table[n_formats].format = GST_VIDEO_FORMAT_I422_10LE; + priv->format_table[n_formats].resource_format[0] = DXGI_FORMAT_R16_UNORM; + priv->format_table[n_formats].resource_format[1] = DXGI_FORMAT_R16_UNORM; + priv->format_table[n_formats].resource_format[2] = DXGI_FORMAT_R16_UNORM; + n_formats++; + + priv->format_table[n_formats].format = GST_VIDEO_FORMAT_I422_12LE; + priv->format_table[n_formats].resource_format[0] = DXGI_FORMAT_R16_UNORM; + priv->format_table[n_formats].resource_format[1] = DXGI_FORMAT_R16_UNORM; + priv->format_table[n_formats].resource_format[2] = DXGI_FORMAT_R16_UNORM; + n_formats++; + + priv->format_table[n_formats].format = GST_VIDEO_FORMAT_Y444; + priv->format_table[n_formats].resource_format[0] = DXGI_FORMAT_R8_UNORM; + priv->format_table[n_formats].resource_format[1] = DXGI_FORMAT_R8_UNORM; + priv->format_table[n_formats].resource_format[2] = DXGI_FORMAT_R8_UNORM; + n_formats++; + + priv->format_table[n_formats].format = GST_VIDEO_FORMAT_Y444_10LE; + priv->format_table[n_formats].resource_format[0] = DXGI_FORMAT_R16_UNORM; + priv->format_table[n_formats].resource_format[1] = DXGI_FORMAT_R16_UNORM; + priv->format_table[n_formats].resource_format[2] = DXGI_FORMAT_R16_UNORM; + n_formats++; + + priv->format_table[n_formats].format = GST_VIDEO_FORMAT_Y444_12LE; + priv->format_table[n_formats].resource_format[0] = DXGI_FORMAT_R16_UNORM; + priv->format_table[n_formats].resource_format[1] = DXGI_FORMAT_R16_UNORM; + priv->format_table[n_formats].resource_format[2] = DXGI_FORMAT_R16_UNORM; + n_formats++; + + priv->format_table[n_formats].format = GST_VIDEO_FORMAT_Y444_16LE; + priv->format_table[n_formats].resource_format[0] = DXGI_FORMAT_R16_UNORM; + priv->format_table[n_formats].resource_format[1] = DXGI_FORMAT_R16_UNORM; + priv->format_table[n_formats].resource_format[2] = DXGI_FORMAT_R16_UNORM; + n_formats++; + + /* GRAY */ + /* NOTE: To support conversion by using video processor, + * mark DXGI_FORMAT_{R8,R16}_UNORM formats as known dxgi_format. + * Otherwise, d3d11 elements will not try to use video processor for + * those formats */ + priv->format_table[n_formats].format = GST_VIDEO_FORMAT_GRAY8; + priv->format_table[n_formats].resource_format[0] = DXGI_FORMAT_R8_UNORM; + priv->format_table[n_formats].dxgi_format = DXGI_FORMAT_R8_UNORM; + n_formats++; + + priv->format_table[n_formats].format = GST_VIDEO_FORMAT_GRAY16_LE; + priv->format_table[n_formats].resource_format[0] = DXGI_FORMAT_R16_UNORM; + priv->format_table[n_formats].dxgi_format = DXGI_FORMAT_R16_UNORM; + n_formats++; + g_assert (n_formats == GST_D3D11_N_FORMATS); } diff --git a/gst-libs/gst/d3d11/gstd3d11format.h b/gst-libs/gst/d3d11/gstd3d11format.h index fb2980dc9..de0bb38ab 100644 --- a/gst-libs/gst/d3d11/gstd3d11format.h +++ b/gst-libs/gst/d3d11/gstd3d11format.h @@ -28,7 +28,9 @@ G_BEGIN_DECLS #define GST_D3D11_COMMON_FORMATS \ "BGRA, RGBA, RGB10A2_LE, BGRx, RGBx, VUYA, NV12, NV21, " \ - "P010_10LE, P016_LE, I420, YV12, I420_10LE" + "P010_10LE, P012_LE, P016_LE, I420, YV12, I420_10LE, I420_12LE, " \ + "Y42B, I422_10LE, I422_12LE, Y444, Y444_10LE, Y444_12LE, Y444_16LE, " \ + "GRAY8, GRAY16_LE" #define GST_D3D11_EXTRA_IN_FORMATS \ "YUY2, UYVY, VYUY, Y210, Y410" |