qsv: Enable MinGW toolchain support
authorSeungha Yang <seungha@centricular.com>
Fri, 21 Oct 2022 14:20:47 +0000 (23:20 +0900)
committerGStreamer Marge Bot <gitlab-merge-bot@gstreamer-foundation.org>
Mon, 24 Oct 2022 10:53:40 +0000 (10:53 +0000)
Use PCRE regex method to work around (likely) GCC std::regex bug,
and enable building for non-MSVC

Part-of: <https://gitlab.freedesktop.org/gstreamer/gstreamer/-/merge_requests/3239>

subprojects/gst-plugins-bad/sys/qsv/libmfx/dispatcher/vpl/mfx_dispatcher_vpl_config.cpp
subprojects/gst-plugins-bad/sys/qsv/libmfx/meson.build
subprojects/gst-plugins-bad/sys/qsv/meson.build

index c6e1224..7eb8353 100644 (file)
@@ -1515,15 +1515,27 @@ bool ConfigCtxVPL::CheckLowLatencyConfig(std::list<ConfigCtxVPL *> configCtxList
     return bLowLatency;
 }
 
+#include <gst/gst.h>
+
 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 {
index 78c4fcf..ab75be4 100644 (file)
@@ -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'],
 )
index fb850ad..527c340 100644 (file)
@@ -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')