From 39aca8a096d669644892a15e64ca31f08b5ca6f7 Mon Sep 17 00:00:00 2001 From: Seungha Yang Date: Tue, 19 Sep 2023 21:40:22 +0900 Subject: [PATCH] d3d11vp9dec: Fix critical warning Don't query GPU vendor using null device. Part-of: --- .../sys/d3d11/gstd3d11pluginutils.cpp | 40 ++++++++++++------- .../sys/d3d11/gstd3d11pluginutils.h | 2 + .../sys/d3d11/gstd3d11vp9dec.cpp | 2 +- 3 files changed, 28 insertions(+), 16 deletions(-) diff --git a/subprojects/gst-plugins-bad/sys/d3d11/gstd3d11pluginutils.cpp b/subprojects/gst-plugins-bad/sys/d3d11/gstd3d11pluginutils.cpp index 3d111d2df4..cd57031170 100644 --- a/subprojects/gst-plugins-bad/sys/d3d11/gstd3d11pluginutils.cpp +++ b/subprojects/gst-plugins-bad/sys/d3d11/gstd3d11pluginutils.cpp @@ -127,24 +127,11 @@ gst_d3d11_is_windows_8_or_greater (void) } GstD3D11DeviceVendor -gst_d3d11_get_device_vendor (GstD3D11Device * device) +gst_d3d11_get_device_vendor_from_id (guint vendor_id) { - guint device_id = 0; - guint vendor_id = 0; - gchar *desc = NULL; GstD3D11DeviceVendor vendor = GST_D3D11_DEVICE_VENDOR_UNKNOWN; - g_return_val_if_fail (GST_IS_D3D11_DEVICE (device), - GST_D3D11_DEVICE_VENDOR_UNKNOWN); - - g_object_get (device, "device-id", &device_id, "vendor-id", &vendor_id, - "description", &desc, NULL); - switch (vendor_id) { - case 0: - if (device_id == 0 && desc && g_strrstr (desc, "SraKmd")) - vendor = GST_D3D11_DEVICE_VENDOR_XBOX; - break; case 0x1002: case 0x1022: vendor = GST_D3D11_DEVICE_VENDOR_AMD; @@ -162,9 +149,32 @@ gst_d3d11_get_device_vendor (GstD3D11Device * device) break; } + return vendor; +} + +GstD3D11DeviceVendor +gst_d3d11_get_device_vendor (GstD3D11Device * device) +{ + guint device_id = 0; + guint vendor_id = 0; + gchar *desc = nullptr; + GstD3D11DeviceVendor vendor = GST_D3D11_DEVICE_VENDOR_UNKNOWN; + + g_return_val_if_fail (GST_IS_D3D11_DEVICE (device), + GST_D3D11_DEVICE_VENDOR_UNKNOWN); + + g_object_get (device, "device-id", &device_id, "vendor-id", &vendor_id, + "description", &desc, nullptr); + + if (device_id == 0 && desc && g_strrstr (desc, "SraKmd")) + vendor = GST_D3D11_DEVICE_VENDOR_XBOX; + g_free (desc); - return vendor; + if (vendor != GST_D3D11_DEVICE_VENDOR_UNKNOWN) + return vendor; + + return gst_d3d11_get_device_vendor_from_id (vendor_id); } gboolean diff --git a/subprojects/gst-plugins-bad/sys/d3d11/gstd3d11pluginutils.h b/subprojects/gst-plugins-bad/sys/d3d11/gstd3d11pluginutils.h index fb09e9eb17..07b99bda92 100644 --- a/subprojects/gst-plugins-bad/sys/d3d11/gstd3d11pluginutils.h +++ b/subprojects/gst-plugins-bad/sys/d3d11/gstd3d11pluginutils.h @@ -57,6 +57,8 @@ gboolean gst_d3d11_is_windows_8_or_greater (void); GstD3D11DeviceVendor gst_d3d11_get_device_vendor (GstD3D11Device * device); +GstD3D11DeviceVendor gst_d3d11_get_device_vendor_from_id (guint vendor_id); + gboolean gst_d3d11_hdr_meta_data_to_dxgi (GstVideoMasteringDisplayInfo * minfo, GstVideoContentLightLevel * cll, DXGI_HDR_METADATA_HDR10 * dxgi_hdr10); diff --git a/subprojects/gst-plugins-bad/sys/d3d11/gstd3d11vp9dec.cpp b/subprojects/gst-plugins-bad/sys/d3d11/gstd3d11vp9dec.cpp index 67886eda22..2e25eee2c9 100644 --- a/subprojects/gst-plugins-bad/sys/d3d11/gstd3d11vp9dec.cpp +++ b/subprojects/gst-plugins-bad/sys/d3d11/gstd3d11vp9dec.cpp @@ -137,7 +137,7 @@ gst_d3d11_vp9_dec_open (GstVideoDecoder * decoder) * reliable, since 1b means that it's supported and 0b indicates it may not be * supported. Because some GPUs can support it even if the bit 12 is not * set, do filtering by vendor for now (AMD and Intel looks fine) */ - if (gst_d3d11_get_device_vendor (self->device) == + if (gst_d3d11_get_device_vendor_from_id (cdata->vendor_id) == GST_D3D11_DEVICE_VENDOR_NVIDIA) { gst_vp9_decoder_set_non_keyframe_format_change_support (vp9dec, FALSE); }