From 23261bccbba84abb1334ffc4dea0514f74a5f2af Mon Sep 17 00:00:00 2001 From: Seungha Yang Date: Fri, 21 Oct 2022 23:20:47 +0900 Subject: [PATCH] qsv: Enable MinGW toolchain support Use PCRE regex method to work around (likely) GCC std::regex bug, and enable building for non-MSVC Part-of: --- .../vpl/mfx_dispatcher_vpl_config.cpp | 31 +++++++++++++++++++ .../sys/qsv/libmfx/meson.build | 2 +- .../gst-plugins-bad/sys/qsv/meson.build | 11 ------- 3 files changed, 32 insertions(+), 12 deletions(-) diff --git a/subprojects/gst-plugins-bad/sys/qsv/libmfx/dispatcher/vpl/mfx_dispatcher_vpl_config.cpp b/subprojects/gst-plugins-bad/sys/qsv/libmfx/dispatcher/vpl/mfx_dispatcher_vpl_config.cpp index c6e1224088..7eb8353875 100644 --- a/subprojects/gst-plugins-bad/sys/qsv/libmfx/dispatcher/vpl/mfx_dispatcher_vpl_config.cpp +++ b/subprojects/gst-plugins-bad/sys/qsv/libmfx/dispatcher/vpl/mfx_dispatcher_vpl_config.cpp @@ -1515,15 +1515,27 @@ bool ConfigCtxVPL::CheckLowLatencyConfig(std::list configCtxList return bLowLatency; } +#include + bool ConfigCtxVPL::ParseDeviceIDx86(mfxChar *cDeviceID, mfxU32 &deviceID, mfxU32 &adapterIdx) { std::string strDevID(cDeviceID); + // XXX: std::regex is crashing on Windows + gcc +#if 0 std::regex reDevIDAll("[0-9a-fA-F]+/[0-9]+"); std::regex reDevIDMin("[0-9a-fA-F]+"); +#else + static const gchar *reDevIDAll = "[0-9a-fA-F]+/[0-9]+"; + static const gchar *reDevIDMin = "[0-9a-fA-F]+"; + + if (!cDeviceID) + return false; +#endif deviceID = DEVICE_ID_UNKNOWN; adapterIdx = ADAPTER_IDX_UNKNOWN; bool bHasAdapterIdx = false; +#if 0 if (std::regex_match(strDevID, reDevIDAll)) { // check for DeviceID in format "devID/adapterIdx" // devID = hex value @@ -1539,6 +1551,25 @@ bool ConfigCtxVPL::ParseDeviceIDx86(mfxChar *cDeviceID, mfxU32 &deviceID, mfxU32 // invalid format return false; } +#else + if (g_regex_match_simple(reDevIDAll, cDeviceID, + (GRegexCompileFlags)0, (GRegexMatchFlags)0)) { + // check for DeviceID in format "devID/adapterIdx" + // devID = hex value + // adapterIdx = decimal integer + bHasAdapterIdx = true; + } + else if (g_regex_match_simple(reDevIDMin, cDeviceID, + (GRegexCompileFlags)0, (GRegexMatchFlags)0)) { + // check for DeviceID in format "devID" + // (no adpaterIdx) + bHasAdapterIdx = false; + } + else { + // invalid format + return false; + } +#endif // get deviceID (value before the slash, if present) try { diff --git a/subprojects/gst-plugins-bad/sys/qsv/libmfx/meson.build b/subprojects/gst-plugins-bad/sys/qsv/libmfx/meson.build index 78c4fcf6ed..ab75be4f5f 100644 --- a/subprojects/gst-plugins-bad/sys/qsv/libmfx/meson.build +++ b/subprojects/gst-plugins-bad/sys/qsv/libmfx/meson.build @@ -78,7 +78,7 @@ libmfx_static = static_library('libmfx-static', libmfx_sources, c_args : libmfx_extra_args, cpp_args : libmfx_extra_args, - dependencies : libmfx_extra_deps, + dependencies : libmfx_extra_deps + [gst_dep], include_directories : libmfx_incl, override_options: ['werror=false'], ) diff --git a/subprojects/gst-plugins-bad/sys/qsv/meson.build b/subprojects/gst-plugins-bad/sys/qsv/meson.build index fb850adb7b..527c340e27 100644 --- a/subprojects/gst-plugins-bad/sys/qsv/meson.build +++ b/subprojects/gst-plugins-bad/sys/qsv/meson.build @@ -32,17 +32,6 @@ endif qsv_platform_deps = [] if host_system == 'windows' - # TODO: We can cross-compile this plugin using MinGW but there's an issue. - # Re-enable cross-compile once it's investigated and addressed - # https://gitlab.freedesktop.org/gstreamer/cerbero/-/merge_requests/854 - if cc.get_id() != 'msvc' - if qsv_option.enabled() - error('qsv plugin supports only MSVC build') - else - subdir_done() - endif - endif - if not gstd3d11_dep.found() if qsv_option.enabled() error('The qsv was enabled explicitly, but required d3d11 was not found')