d3d12: Add NV16, NV61, and NV24 format support

Can reuse NV12 shader for the formats

Part-of: <https://gitlab.freedesktop.org/gstreamer/gstreamer/-/merge_requests/7093>
This commit is contained in:
Seungha Yang 2024-06-24 01:41:03 +09:00
parent bb0f95a67f
commit 2703f41da6
4 changed files with 20 additions and 5 deletions

View file

@ -52,7 +52,7 @@
"A444_16LE, A444_12LE, A444_10LE, A444, " \ "A444_16LE, A444_12LE, A444_10LE, A444, " \
"A422_16LE, A422_12LE, A422_10LE, A422, A420_16LE, A420_12LE, A420_10LE, A420, " \ "A422_16LE, A422_12LE, A422_10LE, A422, A420_16LE, A420_12LE, A420_10LE, A420, " \
"GBR_16LE, Y444_12LE, GBR_12LE, I422_12LE, I420_12LE, Y444_10LE, GBR_10LE, " \ "GBR_16LE, Y444_12LE, GBR_12LE, I422_12LE, I420_12LE, Y444_10LE, GBR_10LE, " \
"I422_10LE, I420_10LE, Y444, BGRP, GBR, RGBP, xBGR, xRGB, Y42B, NV21, " \ "I422_10LE, I420_10LE, Y444, BGRP, GBR, RGBP, xBGR, xRGB, Y42B, NV24, NV16, NV61, NV21, " \
"I420, YV12, Y41B, YUV9, YVU9, GRAY16_LE, GRAY8" "I420, YV12, Y41B, YUV9, YVU9, GRAY16_LE, GRAY8"
/* pre/post processing required formats */ /* pre/post processing required formats */

View file

@ -1265,6 +1265,8 @@ gst_d3d12_converter_update_dest_rect (GstD3D12Converter * self)
case GST_VIDEO_FORMAT_A422_10LE: case GST_VIDEO_FORMAT_A422_10LE:
case GST_VIDEO_FORMAT_A422_12LE: case GST_VIDEO_FORMAT_A422_12LE:
case GST_VIDEO_FORMAT_A422_16LE: case GST_VIDEO_FORMAT_A422_16LE:
case GST_VIDEO_FORMAT_NV16:
case GST_VIDEO_FORMAT_NV61:
priv->viewport[1].TopLeftX = priv->viewport[0].TopLeftX / 2; priv->viewport[1].TopLeftX = priv->viewport[0].TopLeftX / 2;
priv->viewport[1].TopLeftY = priv->viewport[0].TopLeftY; priv->viewport[1].TopLeftY = priv->viewport[0].TopLeftY;
priv->viewport[1].Width = priv->viewport[0].Width / 2; priv->viewport[1].Width = priv->viewport[0].Width / 2;
@ -1297,6 +1299,7 @@ gst_d3d12_converter_update_dest_rect (GstD3D12Converter * self)
case GST_VIDEO_FORMAT_A444_10LE: case GST_VIDEO_FORMAT_A444_10LE:
case GST_VIDEO_FORMAT_A444_12LE: case GST_VIDEO_FORMAT_A444_12LE:
case GST_VIDEO_FORMAT_A444_16LE: case GST_VIDEO_FORMAT_A444_16LE:
case GST_VIDEO_FORMAT_NV24:
for (guint i = 1; i < GST_VIDEO_INFO_N_PLANES (&priv->out_info); i++) { for (guint i = 1; i < GST_VIDEO_INFO_N_PLANES (&priv->out_info); i++) {
priv->viewport[i] = priv->viewport[0]; priv->viewport[i] = priv->viewport[0];
priv->scissor_rect[i] = priv->scissor_rect[0]; priv->scissor_rect[i] = priv->scissor_rect[0];
@ -1594,6 +1597,9 @@ gst_d3d12_converter_calculate_border_color (GstD3D12Converter * self)
break; break;
case GST_VIDEO_FORMAT_NV12: case GST_VIDEO_FORMAT_NV12:
case GST_VIDEO_FORMAT_NV21: case GST_VIDEO_FORMAT_NV21:
case GST_VIDEO_FORMAT_NV16:
case GST_VIDEO_FORMAT_NV61:
case GST_VIDEO_FORMAT_NV24:
case GST_VIDEO_FORMAT_P010_10LE: case GST_VIDEO_FORMAT_P010_10LE:
case GST_VIDEO_FORMAT_P012_LE: case GST_VIDEO_FORMAT_P012_LE:
case GST_VIDEO_FORMAT_P016_LE: case GST_VIDEO_FORMAT_P016_LE:
@ -1601,7 +1607,7 @@ gst_d3d12_converter_calculate_border_color (GstD3D12Converter * self)
priv->clear_color[0][1] = 0; priv->clear_color[0][1] = 0;
priv->clear_color[0][2] = 0; priv->clear_color[0][2] = 0;
priv->clear_color[0][3] = 1.0; priv->clear_color[0][3] = 1.0;
if (format == GST_VIDEO_FORMAT_NV21) { if (format == GST_VIDEO_FORMAT_NV21 || format == GST_VIDEO_FORMAT_NV61) {
priv->clear_color[1][0] = converted[2]; priv->clear_color[1][0] = converted[2];
priv->clear_color[1][1] = converted[1]; priv->clear_color[1][1] = converted[1];
} else { } else {

View file

@ -282,8 +282,10 @@ static const GstD3D12Format g_format_map[] = {
FormatBuilder::NotSupported(GST_VIDEO_FORMAT_GBR_10BE), FormatBuilder::NotSupported(GST_VIDEO_FORMAT_GBR_10BE),
FormatBuilder::Planar (GST_VIDEO_FORMAT_GBR_10LE, FormatBuilder::Planar (GST_VIDEO_FORMAT_GBR_10LE,
DXGI_FORMAT_R16_UNORM), DXGI_FORMAT_R16_UNORM),
FormatBuilder::NotSupported(GST_VIDEO_FORMAT_NV16), FormatBuilder::YuvSemiPlanar (GST_VIDEO_FORMAT_NV16,
FormatBuilder::NotSupported(GST_VIDEO_FORMAT_NV24), DXGI_FORMAT_UNKNOWN, DXGI_FORMAT_R8_UNORM, DXGI_FORMAT_R8G8_UNORM),
FormatBuilder::YuvSemiPlanar (GST_VIDEO_FORMAT_NV24,
DXGI_FORMAT_UNKNOWN, DXGI_FORMAT_R8_UNORM, DXGI_FORMAT_R8G8_UNORM),
FormatBuilder::NotSupported(GST_VIDEO_FORMAT_NV12_64Z32), FormatBuilder::NotSupported(GST_VIDEO_FORMAT_NV12_64Z32),
FormatBuilder::NotSupported(GST_VIDEO_FORMAT_A420_10BE), FormatBuilder::NotSupported(GST_VIDEO_FORMAT_A420_10BE),
FormatBuilder::PlanarFull (GST_VIDEO_FORMAT_A420_10LE, FormatBuilder::PlanarFull (GST_VIDEO_FORMAT_A420_10LE,
@ -294,7 +296,8 @@ static const GstD3D12Format g_format_map[] = {
FormatBuilder::NotSupported(GST_VIDEO_FORMAT_A444_10BE), FormatBuilder::NotSupported(GST_VIDEO_FORMAT_A444_10BE),
FormatBuilder::PlanarFull (GST_VIDEO_FORMAT_A444_10LE, FormatBuilder::PlanarFull (GST_VIDEO_FORMAT_A444_10LE,
DXGI_FORMAT_R16_UNORM), DXGI_FORMAT_R16_UNORM),
FormatBuilder::NotSupported(GST_VIDEO_FORMAT_NV61), FormatBuilder::YuvSemiPlanar (GST_VIDEO_FORMAT_NV61,
DXGI_FORMAT_UNKNOWN, DXGI_FORMAT_R8_UNORM, DXGI_FORMAT_R8G8_UNORM),
FormatBuilder::NotSupported(GST_VIDEO_FORMAT_P010_10BE), FormatBuilder::NotSupported(GST_VIDEO_FORMAT_P010_10BE),
FormatBuilder::YuvSemiPlanar (GST_VIDEO_FORMAT_P010_10LE, FormatBuilder::YuvSemiPlanar (GST_VIDEO_FORMAT_P010_10LE,
DXGI_FORMAT_P010, DXGI_FORMAT_R16_UNORM, DXGI_FORMAT_R16G16_UNORM), DXGI_FORMAT_P010, DXGI_FORMAT_R16_UNORM, DXGI_FORMAT_R16G16_UNORM),

View file

@ -651,8 +651,11 @@ conv_ps_make_input (GstVideoFormat format, gboolean premul)
case GST_VIDEO_FORMAT_P010_10LE: case GST_VIDEO_FORMAT_P010_10LE:
case GST_VIDEO_FORMAT_P012_LE: case GST_VIDEO_FORMAT_P012_LE:
case GST_VIDEO_FORMAT_P016_LE: case GST_VIDEO_FORMAT_P016_LE:
case GST_VIDEO_FORMAT_NV16:
case GST_VIDEO_FORMAT_NV24:
return "NV12"; return "NV12";
case GST_VIDEO_FORMAT_NV21: case GST_VIDEO_FORMAT_NV21:
case GST_VIDEO_FORMAT_NV61:
return "NV21"; return "NV21";
case GST_VIDEO_FORMAT_YUV9: case GST_VIDEO_FORMAT_YUV9:
case GST_VIDEO_FORMAT_Y41B: case GST_VIDEO_FORMAT_Y41B:
@ -797,10 +800,13 @@ conv_ps_make_output (GstVideoFormat format, gboolean premul)
case GST_VIDEO_FORMAT_P010_10LE: case GST_VIDEO_FORMAT_P010_10LE:
case GST_VIDEO_FORMAT_P012_LE: case GST_VIDEO_FORMAT_P012_LE:
case GST_VIDEO_FORMAT_P016_LE: case GST_VIDEO_FORMAT_P016_LE:
case GST_VIDEO_FORMAT_NV16:
case GST_VIDEO_FORMAT_NV24:
ret.push_back({PS_OUTPUT::LUMA, "Luma"}); ret.push_back({PS_OUTPUT::LUMA, "Luma"});
ret.push_back({PS_OUTPUT::CHROMA, "ChromaNV12"}); ret.push_back({PS_OUTPUT::CHROMA, "ChromaNV12"});
break; break;
case GST_VIDEO_FORMAT_NV21: case GST_VIDEO_FORMAT_NV21:
case GST_VIDEO_FORMAT_NV61:
ret.push_back({PS_OUTPUT::LUMA, "Luma"}); ret.push_back({PS_OUTPUT::LUMA, "Luma"});
ret.push_back({PS_OUTPUT::CHROMA, "ChromaNV21"}); ret.push_back({PS_OUTPUT::CHROMA, "ChromaNV21"});
break; break;