From 2703f41da6d4ca71ccbc96427a486f68851d82dd Mon Sep 17 00:00:00 2001 From: Seungha Yang Date: Mon, 24 Jun 2024 01:41:03 +0900 Subject: [PATCH] d3d12: Add NV16, NV61, and NV24 format support Can reuse NV12 shader for the formats Part-of: --- .../gst-libs/gst/d3d12/gstd3d12-private.h | 2 +- .../gst-libs/gst/d3d12/gstd3d12converter.cpp | 8 +++++++- .../gst-libs/gst/d3d12/gstd3d12format.cpp | 9 ++++++--- .../gst-libs/gst/d3dshader/gstd3dshadercache.cpp | 6 ++++++ 4 files changed, 20 insertions(+), 5 deletions(-) diff --git a/subprojects/gst-plugins-bad/gst-libs/gst/d3d12/gstd3d12-private.h b/subprojects/gst-plugins-bad/gst-libs/gst/d3d12/gstd3d12-private.h index d620b8d893..ddacf2d084 100644 --- a/subprojects/gst-plugins-bad/gst-libs/gst/d3d12/gstd3d12-private.h +++ b/subprojects/gst-plugins-bad/gst-libs/gst/d3d12/gstd3d12-private.h @@ -52,7 +52,7 @@ "A444_16LE, A444_12LE, A444_10LE, A444, " \ "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, " \ - "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" /* pre/post processing required formats */ diff --git a/subprojects/gst-plugins-bad/gst-libs/gst/d3d12/gstd3d12converter.cpp b/subprojects/gst-plugins-bad/gst-libs/gst/d3d12/gstd3d12converter.cpp index e5de00fdde..1cffe9864e 100644 --- a/subprojects/gst-plugins-bad/gst-libs/gst/d3d12/gstd3d12converter.cpp +++ b/subprojects/gst-plugins-bad/gst-libs/gst/d3d12/gstd3d12converter.cpp @@ -1265,6 +1265,8 @@ gst_d3d12_converter_update_dest_rect (GstD3D12Converter * self) case GST_VIDEO_FORMAT_A422_10LE: case GST_VIDEO_FORMAT_A422_12LE: 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].TopLeftY = priv->viewport[0].TopLeftY; 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_12LE: 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++) { priv->viewport[i] = priv->viewport[0]; priv->scissor_rect[i] = priv->scissor_rect[0]; @@ -1594,6 +1597,9 @@ gst_d3d12_converter_calculate_border_color (GstD3D12Converter * self) break; case GST_VIDEO_FORMAT_NV12: 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_P012_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][2] = 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][1] = converted[1]; } else { diff --git a/subprojects/gst-plugins-bad/gst-libs/gst/d3d12/gstd3d12format.cpp b/subprojects/gst-plugins-bad/gst-libs/gst/d3d12/gstd3d12format.cpp index d9b6bc90d8..7702a79a9d 100644 --- a/subprojects/gst-plugins-bad/gst-libs/gst/d3d12/gstd3d12format.cpp +++ b/subprojects/gst-plugins-bad/gst-libs/gst/d3d12/gstd3d12format.cpp @@ -282,8 +282,10 @@ static const GstD3D12Format g_format_map[] = { FormatBuilder::NotSupported(GST_VIDEO_FORMAT_GBR_10BE), FormatBuilder::Planar (GST_VIDEO_FORMAT_GBR_10LE, DXGI_FORMAT_R16_UNORM), - FormatBuilder::NotSupported(GST_VIDEO_FORMAT_NV16), - FormatBuilder::NotSupported(GST_VIDEO_FORMAT_NV24), + FormatBuilder::YuvSemiPlanar (GST_VIDEO_FORMAT_NV16, + 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_A420_10BE), 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::PlanarFull (GST_VIDEO_FORMAT_A444_10LE, 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::YuvSemiPlanar (GST_VIDEO_FORMAT_P010_10LE, DXGI_FORMAT_P010, DXGI_FORMAT_R16_UNORM, DXGI_FORMAT_R16G16_UNORM), diff --git a/subprojects/gst-plugins-bad/gst-libs/gst/d3dshader/gstd3dshadercache.cpp b/subprojects/gst-plugins-bad/gst-libs/gst/d3dshader/gstd3dshadercache.cpp index 8fca4455b5..cee1f92709 100644 --- a/subprojects/gst-plugins-bad/gst-libs/gst/d3dshader/gstd3dshadercache.cpp +++ b/subprojects/gst-plugins-bad/gst-libs/gst/d3dshader/gstd3dshadercache.cpp @@ -651,8 +651,11 @@ conv_ps_make_input (GstVideoFormat format, gboolean premul) case GST_VIDEO_FORMAT_P010_10LE: case GST_VIDEO_FORMAT_P012_LE: case GST_VIDEO_FORMAT_P016_LE: + case GST_VIDEO_FORMAT_NV16: + case GST_VIDEO_FORMAT_NV24: return "NV12"; case GST_VIDEO_FORMAT_NV21: + case GST_VIDEO_FORMAT_NV61: return "NV21"; case GST_VIDEO_FORMAT_YUV9: 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_P012_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::CHROMA, "ChromaNV12"}); break; case GST_VIDEO_FORMAT_NV21: + case GST_VIDEO_FORMAT_NV61: ret.push_back({PS_OUTPUT::LUMA, "Luma"}); ret.push_back({PS_OUTPUT::CHROMA, "ChromaNV21"}); break;