From 63c854c64bb2f9051655c325804826eb40b106fc Mon Sep 17 00:00:00 2001 From: Seungha Yang Date: Sat, 11 Mar 2023 01:58:01 +0900 Subject: [PATCH] vadisplay_win32: Query profiles and entry points on init Depending on driver, display can be initialized but fails on query calls. Part-of: --- .../gst-libs/gst/va/gstvadisplay_win32.cpp | 41 +++++++++++++++++-- 1 file changed, 38 insertions(+), 3 deletions(-) diff --git a/subprojects/gst-plugins-bad/gst-libs/gst/va/gstvadisplay_win32.cpp b/subprojects/gst-plugins-bad/gst-libs/gst/va/gstvadisplay_win32.cpp index bb7f551281..16c13516c3 100644 --- a/subprojects/gst-plugins-bad/gst-libs/gst/va/gstvadisplay_win32.cpp +++ b/subprojects/gst-plugins-bad/gst-libs/gst/va/gstvadisplay_win32.cpp @@ -44,6 +44,7 @@ #include #include #include +#include /* *INDENT-OFF* */ using namespace Microsoft::WRL; @@ -239,6 +240,12 @@ gst_va_display_win32_new (const gchar * adapter_luid) DXGI_ADAPTER_DESC desc; gint64 adapter_luid_i64; gchar *desc_str; + gint max_profiles, max_entry_points; + gint num_profiles; + VAStatus status; + VADisplay dpy; + std::vector < VAEntrypoint > entry_points; + std::vector < VAProfile > profiles; g_return_val_if_fail (adapter_luid != nullptr, nullptr); @@ -280,12 +287,40 @@ gst_va_display_win32_new (const gchar * adapter_luid) "path", adapter_luid, "adapter-luid", adapter_luid_i64, "device-id", desc.DeviceId, "vendor-id", desc.VendorId, nullptr); self->desc = desc_str; - if (!gst_va_display_initialize (GST_VA_DISPLAY (self))) { - gst_object_unref (self); - return nullptr; + if (!gst_va_display_initialize (GST_VA_DISPLAY (self))) + goto error; + + /* Validate device */ + dpy = gst_va_display_get_va_dpy (GST_VA_DISPLAY (self)); + + max_profiles = vaMaxNumProfiles (dpy); + if (max_profiles <= 0) + goto error; + + max_entry_points = vaMaxNumEntrypoints (dpy); + if (max_entry_points <= 0) + goto error; + + profiles.resize (max_profiles); + + status = vaQueryConfigProfiles (dpy, &profiles[0], &num_profiles); + if (status != VA_STATUS_SUCCESS || num_profiles <= 0) + goto error; + + entry_points.resize (max_entry_points); + for (guint i = 0; i < num_profiles; i++) { + gint num_entry_poinits; + status = vaQueryConfigEntrypoints (dpy, profiles[i], &entry_points[0], + &num_entry_poinits); + if (status != VA_STATUS_SUCCESS) + goto error; } gst_object_ref_sink (self); return GST_VA_DISPLAY (self); + +error: + gst_object_unref (self); + return nullptr; }