[vlc-commits] [Git][videolan/vlc][master] 3 commits: contrib: x265: remove win32 pkg-config patch

Felix Paul Kühne (@fkuehne) gitlab at videolan.org
Sun Jun 11 01:28:34 UTC 2023



Felix Paul Kühne pushed to branch master at VideoLAN / VLC


Commits:
93ae46a2 by Steve Lhomme at 2023-06-11T00:20:57+00:00
contrib: x265: remove win32 pkg-config patch

It builds without it and if we needed pthread, we would need to depend on
winpthread. #16389 mentions dlsym but the code uses the Windows API.
It also uses CreateThread() so it likely doesn't depend on winpthreads
anymore.

Reverts f9ecbd07dd0100e2251a1523a961f8677da0d400.

- - - - -
216224c0 by Steve Lhomme at 2023-06-11T00:20:57+00:00
contrib: x265: enable build for UWP

It needs a bit of patching but the main functionalities should be there.

- - - - -
7ea69dcc by Steve Lhomme at 2023-06-11T00:20:57+00:00
contrib: mingw64: allow LoadLibraryEx flags in Win10 19H1 UWP

- - - - -


6 changed files:

- + contrib/src/mingw64/0001-headers-enabled-LoadLibraryEx-flags-in-Win10-19H1-UW.patch
- contrib/src/mingw64/rules.mak
- + contrib/src/x265/0001-api-use-LoadLibraryExA-instead-of-LoadLibraryA.patch
- + contrib/src/x265/0001-threadpool-disable-group-affinity-in-UWP-builds.patch
- contrib/src/x265/rules.mak
- − contrib/src/x265/x265-pkg-libs.patch


Changes:

=====================================
contrib/src/mingw64/0001-headers-enabled-LoadLibraryEx-flags-in-Win10-19H1-UW.patch
=====================================
@@ -0,0 +1,78 @@
+From 6dd0fae912ee08193a28670f51a3f1a6292b4c55 Mon Sep 17 00:00:00 2001
+From: Steve Lhomme <robux4 at ycbcr.xyz>
+Date: Mon, 5 Jun 2023 16:41:53 +0200
+Subject: [PATCH] headers: enabled LoadLibraryEx flags in Win10 19H1 UWP builds
+
+---
+ mingw-w64-headers/include/libloaderapi.h | 48 ++++++++++++------------
+ 1 file changed, 24 insertions(+), 24 deletions(-)
+
+diff --git a/mingw-w64-headers/include/libloaderapi.h b/mingw-w64-headers/include/libloaderapi.h
+index 6a84aa1c9..51837f122 100644
+--- a/mingw-w64-headers/include/libloaderapi.h
++++ b/mingw-w64-headers/include/libloaderapi.h
+@@ -50,30 +50,6 @@ extern "C" {
+ #define RESOURCE_ENUM_MODULE_EXACT (0x0010)
+ 
+ #define SUPPORT_LANG_NUMBER 32
+-
+-#define DONT_RESOLVE_DLL_REFERENCES 0x1
+-#define LOAD_LIBRARY_AS_DATAFILE 0x2
+-#define LOAD_WITH_ALTERED_SEARCH_PATH 0x8
+-#define LOAD_IGNORE_CODE_AUTHZ_LEVEL 0x10
+-#define LOAD_LIBRARY_AS_IMAGE_RESOURCE 0x20
+-#define LOAD_LIBRARY_AS_DATAFILE_EXCLUSIVE 0x40
+-#define LOAD_LIBRARY_REQUIRE_SIGNED_TARGET 0x80
+-#define LOAD_LIBRARY_SEARCH_DLL_LOAD_DIR 0x100
+-#define LOAD_LIBRARY_SEARCH_APPLICATION_DIR 0x200
+-#define LOAD_LIBRARY_SEARCH_USER_DIRS 0x400
+-#define LOAD_LIBRARY_SEARCH_SYSTEM32 0x800
+-#define LOAD_LIBRARY_SEARCH_DEFAULT_DIRS 0x1000
+-
+-#if (NTDDI_VERSION >= NTDDI_WIN10_RS1)
+-#define LOAD_LIBRARY_SAFE_CURRENT_DIRS 0x00002000
+-#define LOAD_LIBRARY_SEARCH_SYSTEM32_NO_FORWARDER 0x00004000
+-#else
+-#define LOAD_LIBRARY_SEARCH_SYSTEM32_NO_FORWARDER LOAD_LIBRARY_SEARCH_SYSTEM32
+-#endif
+-
+-#if (NTDDI_VERSION >= NTDDI_WIN10_RS2)
+-#define LOAD_LIBRARY_OS_INTEGRITY_CONTINUITY 0x00008000
+-#endif
+ #endif /* WINAPI_PARTITION_DESKTOP */
+ 
+ #define GET_MODULE_HANDLE_EX_FLAG_PIN (0x1)
+@@ -162,6 +138,30 @@ typedef const REDIRECTION_DESCRIPTOR *PCREDIRECTION_DESCRIPTOR;
+ #endif
+ 
+ #if WINAPI_FAMILY_PARTITION (WINAPI_PARTITION_DESKTOP) || NTDDI_VERSION >= NTDDI_WIN10_19H1
++#define DONT_RESOLVE_DLL_REFERENCES 0x1
++#define LOAD_LIBRARY_AS_DATAFILE 0x2
++#define LOAD_WITH_ALTERED_SEARCH_PATH 0x8
++#define LOAD_IGNORE_CODE_AUTHZ_LEVEL 0x10
++#define LOAD_LIBRARY_AS_IMAGE_RESOURCE 0x20
++#define LOAD_LIBRARY_AS_DATAFILE_EXCLUSIVE 0x40
++#define LOAD_LIBRARY_REQUIRE_SIGNED_TARGET 0x80
++#define LOAD_LIBRARY_SEARCH_DLL_LOAD_DIR 0x100
++#define LOAD_LIBRARY_SEARCH_APPLICATION_DIR 0x200
++#define LOAD_LIBRARY_SEARCH_USER_DIRS 0x400
++#define LOAD_LIBRARY_SEARCH_SYSTEM32 0x800
++#define LOAD_LIBRARY_SEARCH_DEFAULT_DIRS 0x1000
++
++#if (NTDDI_VERSION >= NTDDI_WIN10_RS1)
++#define LOAD_LIBRARY_SAFE_CURRENT_DIRS 0x00002000
++#define LOAD_LIBRARY_SEARCH_SYSTEM32_NO_FORWARDER 0x00004000
++#else
++#define LOAD_LIBRARY_SEARCH_SYSTEM32_NO_FORWARDER LOAD_LIBRARY_SEARCH_SYSTEM32
++#endif
++
++#if (NTDDI_VERSION >= NTDDI_WIN10_RS2)
++#define LOAD_LIBRARY_OS_INTEGRITY_CONTINUITY 0x00008000
++#endif
++
+   WINBASEAPI HRSRC WINAPI FindResourceExW (HMODULE hModule, LPCWSTR lpType, LPCWSTR lpName, WORD wLanguage);
+   WINBASEAPI HMODULE WINAPI GetModuleHandleA (LPCSTR lpModuleName);
+   WINBASEAPI HMODULE WINAPI GetModuleHandleW (LPCWSTR lpModuleName);
+-- 
+2.37.3.windows.1
+


=====================================
contrib/src/mingw64/rules.mak
=====================================
@@ -66,6 +66,7 @@ mingw64: mingw-w64-v$(MINGW64_VERSION).tar.bz2 .sum-mingw64
 	$(APPLY) $(SRC)/mingw64/0008-crt-add-api-ms-core-registry-def-files.patch
 	$(APPLY) $(SRC)/mingw64/0009-headers-enable-some-Registry-API-calls-in-Win10-19H1.patch
 	$(APPLY) $(SRC)/mingw64/0010-headers-allow-Get-SetHandleInformation-in-Win10-19H1.patch
+	$(APPLY) $(SRC)/mingw64/0001-headers-enabled-LoadLibraryEx-flags-in-Win10-19H1-UW.patch
 	$(MOVE)
 
 .mingw64: mingw64


=====================================
contrib/src/x265/0001-api-use-LoadLibraryExA-instead-of-LoadLibraryA.patch
=====================================
@@ -0,0 +1,47 @@
+From 2c465c6112734c6879d789dd6d679205b3ae7a17 Mon Sep 17 00:00:00 2001
+From: Steve Lhomme <robux4 at ycbcr.xyz>
+Date: Wed, 7 Jun 2023 10:36:43 +0200
+Subject: [PATCH 1/2] api: use LoadLibraryExA instead of LoadLibraryA
+
+They were introduced in XP but only LoadLibraryExA is allowed in
+Universal Windows Platform 19H1 builds.
+
+Using LOAD_LIBRARY_SEARCH_DEFAULT_DIRS is equivalent to the behavior
+of LoadLibraryA.
+---
+ source/encoder/api.cpp | 8 ++++----
+ 1 file changed, 4 insertions(+), 4 deletions(-)
+
+diff --git a/source/encoder/api.cpp b/source/encoder/api.cpp
+index 10031d109..46d84a75c 100644
+--- a/source/encoder/api.cpp
++++ b/source/encoder/api.cpp
+@@ -720,10 +720,10 @@ const x265_api* x265_api_get(int bitDepth)
+             g_recursion++;
+ 
+ #if _WIN32
+-        HMODULE h = LoadLibraryA(libname);
++        HMODULE h = LoadLibraryExA(libname, NULL, LOAD_LIBRARY_SEARCH_DEFAULT_DIRS);
+         if (!h)
+         {
+-            h = LoadLibraryA(multilibname);
++            h = LoadLibraryExA(multilibname, NULL, LOAD_LIBRARY_SEARCH_DEFAULT_DIRS);
+             reqDepth = bitDepth;
+         }
+         if (h)
+@@ -813,10 +813,10 @@ const x265_api* x265_api_query(int bitDepth, int apiVersion, int* err)
+             g_recursion++;
+ 
+ #if _WIN32
+-        HMODULE h = LoadLibraryA(libname);
++        HMODULE h = LoadLibraryExA(libname, NULL, LOAD_LIBRARY_SEARCH_DEFAULT_DIRS);
+         if (!h)
+         {
+-            h = LoadLibraryA(multilibname);
++            h = LoadLibraryExA(multilibname, NULL, LOAD_LIBRARY_SEARCH_DEFAULT_DIRS);
+             reqDepth = bitDepth;
+         }
+         if (h)
+-- 
+2.37.3.windows.1
+


=====================================
contrib/src/x265/0001-threadpool-disable-group-affinity-in-UWP-builds.patch
=====================================
@@ -0,0 +1,109 @@
+From d5f07f19fba444a2639cd93ddae0b2556d6fbb7e Mon Sep 17 00:00:00 2001
+From: Steve Lhomme <robux4 at ycbcr.xyz>
+Date: Wed, 7 Jun 2023 10:39:09 +0200
+Subject: [PATCH] threadpool: disable group affinity in UWP builds
+
+GetNumaNodeProcessorMaskEx() is not allowed in any UWP builds.
+---
+ source/common/threadpool.cpp | 14 +++++++-------
+ source/common/threadpool.h   | 11 ++++++++++-
+ 2 files changed, 17 insertions(+), 8 deletions(-)
+
+diff --git a/source/common/threadpool.cpp b/source/common/threadpool.cpp
+index 91e82a24e..ab0b3b76a 100644
+--- a/source/common/threadpool.cpp
++++ b/source/common/threadpool.cpp
+@@ -71,7 +71,7 @@
+ # define strcasecmp _stricmp
+ #endif
+ 
+-#if defined(_WIN32_WINNT) && _WIN32_WINNT >= _WIN32_WINNT_WIN7
++#ifdef USE_WIN32_AFFINITY
+ const uint64_t m1 = 0x5555555555555555; //binary: 0101...
+ const uint64_t m2 = 0x3333333333333333; //binary: 00110011..
+ const uint64_t m3 = 0x0f0f0f0f0f0f0f0f; //binary:  4 zeros,  4 ones ...
+@@ -262,14 +262,14 @@ ThreadPool* ThreadPool::allocThreadPools(x265_param* p, int& numPools, bool isTh
+     int numNumaNodes = X265_MIN(getNumaNodeCount(), MAX_NODE_NUM);
+     bool bNumaSupport = false;
+ 
+-#if defined(_WIN32_WINNT) && _WIN32_WINNT >= _WIN32_WINNT_WIN7 
++#ifdef USE_WIN32_AFFINITY
+     bNumaSupport = true;
+ #elif HAVE_LIBNUMA
+     bNumaSupport = numa_available() >= 0;
+ #endif
+ 
+ 
+-#if defined(_WIN32_WINNT) && _WIN32_WINNT >= _WIN32_WINNT_WIN7
++#ifdef USE_WIN32_AFFINITY
+     PGROUP_AFFINITY groupAffinityPointer = new GROUP_AFFINITY;
+     for (int i = 0; i < numNumaNodes; i++)
+     {
+@@ -475,7 +475,7 @@ bool ThreadPool::create(int numThreads, int maxProviders, uint64_t nodeMask)
+ {
+     X265_CHECK(numThreads <= MAX_POOL_THREADS, "a single thread pool cannot have more than MAX_POOL_THREADS threads\n");
+ 
+-#if defined(_WIN32_WINNT) && _WIN32_WINNT >= _WIN32_WINNT_WIN7 
++#ifdef USE_WIN32_AFFINITY
+     memset(&m_groupAffinity, 0, sizeof(GROUP_AFFINITY));
+     for (int i = 0; i < getNumaNodeCount(); i++)
+     {
+@@ -568,7 +568,7 @@ void ThreadPool::setCurrentThreadAffinity()
+ 
+ void ThreadPool::setThreadNodeAffinity(void *numaMask)
+ {
+-#if defined(_WIN32_WINNT) && _WIN32_WINNT >= _WIN32_WINNT_WIN7 
++#ifdef USE_WIN32_AFFINITY
+     UNREFERENCED_PARAMETER(numaMask);
+     GROUP_AFFINITY groupAffinity;
+     memset(&groupAffinity, 0, sizeof(GROUP_AFFINITY));
+@@ -597,7 +597,7 @@ void ThreadPool::setThreadNodeAffinity(void *numaMask)
+ /* static */
+ int ThreadPool::getNumaNodeCount()
+ {
+-#if defined(_WIN32_WINNT) && _WIN32_WINNT >= _WIN32_WINNT_WIN7 
++#ifdef USE_WIN32_AFFINITY
+     ULONG num = 1;
+     if (GetNumaHighestNodeNumber(&num))
+         num++;
+@@ -615,7 +615,7 @@ int ThreadPool::getNumaNodeCount()
+ /* static */
+ int ThreadPool::getCpuCount()
+ {
+-#if defined(_WIN32_WINNT) && _WIN32_WINNT >= _WIN32_WINNT_WIN7
++#ifdef USE_WIN32_AFFINITY
+     enum { MAX_NODE_NUM = 127 };
+     int cpus = 0;
+     int numNumaNodes = X265_MIN(getNumaNodeCount(), MAX_NODE_NUM);
+diff --git a/source/common/threadpool.h b/source/common/threadpool.h
+index 867539f3a..d295a02bd 100644
+--- a/source/common/threadpool.h
++++ b/source/common/threadpool.h
+@@ -44,6 +44,15 @@ static const sleepbitmap_t ALL_POOL_THREADS = (sleepbitmap_t)-1;
+ enum { MAX_POOL_THREADS = sizeof(sleepbitmap_t) * 8 };
+ enum { INVALID_SLICE_PRIORITY = 10 }; // a value larger than any X265_TYPE_* macro
+ 
++#if defined(_WIN32_WINNT) && _WIN32_WINNT >= _WIN32_WINNT_WIN7
++#include <winapifamily.h>
++# if WINAPI_FAMILY_PARTITION(WINAPI_PARTITION_DESKTOP)
++// GetNumaNodeProcessorMaskEx is not available in UWP apps
++#  define USE_WIN32_AFFINITY 1
++# endif
++#endif
++
++
+ // Frame level job providers. FrameEncoder and Lookahead derive from
+ // this class and implement findJob()
+ class JobProvider
+@@ -84,7 +93,7 @@ public:
+     int           m_numProviders;
+     int           m_numWorkers;
+     void*         m_numaMask; // node mask in linux, cpu mask in windows
+-#if defined(_WIN32_WINNT) && _WIN32_WINNT >= _WIN32_WINNT_WIN7 
++#ifdef USE_WIN32_AFFINITY
+     GROUP_AFFINITY m_groupAffinity;
+ #endif
+     bool          m_isActive;
+-- 
+2.37.3.windows.1
+


=====================================
contrib/src/x265/rules.mak
=====================================
@@ -6,10 +6,14 @@ X265_SNAPURL := https://bitbucket.org/multicoreware/x265_git/downloads/x265_$(X2
 
 ifdef BUILD_ENCODERS
 ifdef GPL
-ifndef HAVE_WINSTORE # FIXME uses too many forbidden APIs
 PKGS += x265
 endif
 endif
+
+DEPS_x265 :=
+ifdef HAVE_WINSTORE
+# x265 uses LoadLibraryEx
+DEPS_x265 += alloweduwp $(DEPS_alloweduwp)
 endif
 
 ifeq ($(call need_pkg,"x265 >= 0.6"),)
@@ -29,10 +33,9 @@ x265: x265_$(X265_VERSION).tar.gz .sum-x265
 	$(APPLY) $(SRC)/x265/x265-ldl-linking.patch
 	$(APPLY) $(SRC)/x265/x265-no-pdb-install.patch
 	$(APPLY) $(SRC)/x265/x265-enable-detect512.patch
+	$(APPLY) $(SRC)/x265/0001-api-use-LoadLibraryExA-instead-of-LoadLibraryA.patch
+	$(APPLY) $(SRC)/x265/0001-threadpool-disable-group-affinity-in-UWP-builds.patch
 	$(call pkg_static,"source/x265.pc.in")
-ifndef HAVE_WIN32
-	$(APPLY) $(SRC)/x265/x265-pkg-libs.patch
-endif
 	$(MOVE)
 
 X265_CONF := -DENABLE_SHARED=OFF -DENABLE_CLI=OFF


=====================================
contrib/src/x265/x265-pkg-libs.patch deleted
=====================================
@@ -1,10 +0,0 @@
-diff -Nru x265.orig/source/x265.pc.in x265/source/x265.pc.in
---- x265.orig/source/x265.pc.in	2016-08-06 17:04:25.925985965 +0300
-+++ x265/source/x265.pc.in	2016-08-06 17:07:06.548987568 +0300
-@@ -7,5 +7,5 @@
- Description: H.265/HEVC video encoder
- Version: @X265_LATEST_TAG@
- Cflags: -I${includedir}
--Libs:  -L${libdir} -lx265  @PRIVATE_LIBS@
-+Libs:  -L${libdir} -lx265  @PRIVATE_LIBS@ -ldl -lpthread
- Requires:  



View it on GitLab: https://code.videolan.org/videolan/vlc/-/compare/44c21ece4eaddb534af720c8610999843fe400b0...7ea69dccac21ba737f1389403efb3989a096d457

-- 
View it on GitLab: https://code.videolan.org/videolan/vlc/-/compare/44c21ece4eaddb534af720c8610999843fe400b0...7ea69dccac21ba737f1389403efb3989a096d457
You're receiving this email because of your account on code.videolan.org.


VideoLAN code repository instance


More information about the vlc-commits mailing list