From fca7e5aa23ac37870a16a75bfd567b3a5a25f2de Mon Sep 17 00:00:00 2001 From: Seungha Yang Date: Mon, 24 Jun 2024 23:30:24 +0900 Subject: [PATCH] video: convertframe: Add support for d3d12 conversion Use d3d12convert in case of d3d12 memory Part-of: --- .../gst-libs/gst/video/convertframe.c | 26 ++++++++++++++----- 1 file changed, 20 insertions(+), 6 deletions(-) diff --git a/subprojects/gst-plugins-base/gst-libs/gst/video/convertframe.c b/subprojects/gst-plugins-base/gst-libs/gst/video/convertframe.c index fd14c6b4f4..2ece4a632d 100644 --- a/subprojects/gst-plugins-base/gst-libs/gst/video/convertframe.c +++ b/subprojects/gst-plugins-base/gst-libs/gst/video/convertframe.c @@ -138,7 +138,7 @@ fail: static GstElement * build_convert_frame_pipeline_d3d11 (GstElement ** src_element, GstElement ** sink_element, GstCaps * from_caps, GstCaps * to_caps, - GError ** err) + gboolean is_d3d12, GError ** err) { GstElement *pipeline = NULL; GstElement *appsrc = NULL; @@ -148,10 +148,17 @@ build_convert_frame_pipeline_d3d11 (GstElement ** src_element, GstElement *enc = NULL; GstElement *appsink = NULL; GError *error = NULL; + const gchar *d3d_conv_name = "d3d11convert"; + const gchar *d3d_download_name = "d3d11download"; + + if (is_d3d12) { + d3d_conv_name = "d3d12convert"; + d3d_download_name = "d3d12download"; + } if (!create_element ("appsrc", &appsrc, &error) || - !create_element ("d3d11convert", &d3d11_convert, &error) || - !create_element ("d3d11download", &d3d11_download, &error) || + !create_element (d3d_conv_name, &d3d11_convert, &error) || + !create_element (d3d_download_name, &d3d11_download, &error) || !create_element ("videoconvert", &convert, &error) || !create_element ("appsink", &appsink, &error)) { GST_ERROR ("Could not create element"); @@ -224,9 +231,16 @@ build_convert_frame_pipeline (GstElement ** src_element, GstCapsFeatures *features; features = gst_caps_get_features (from_caps, 0); - if (features && gst_caps_features_contains (features, "memory:D3D11Memory")) { - return build_convert_frame_pipeline_d3d11 (src_element, sink_element, - from_caps, to_caps, err); + if (features && !gst_caps_features_is_any (features)) { + gboolean is_d3d11 = + gst_caps_features_contains (features, "memory:D3D11Memory"); + gboolean is_d3d12 = + gst_caps_features_contains (features, "memory:D3D12Memory"); + + if (is_d3d11 || is_d3d12) { + return build_convert_frame_pipeline_d3d11 (src_element, sink_element, + from_caps, to_caps, is_d3d12, err); + } } #ifdef HAVE_GL if (features &&