[vlc-commits] [Git][videolan/vlc][master] 2 commits: x265: fix API signature with x265 4.1

Steve Lhomme (@robUx4) gitlab at videolan.org
Thu Jan 16 10:41:00 UTC 2025



Steve Lhomme pushed to branch master at VideoLAN / VLC


Commits:
1e6808b2 by Steve Lhomme at 2025-01-16T10:10:55+00:00
x265: fix API signature with x265 4.1

They changed the API in c69c113960834400545bc4bce2830ff51dcb86b3
And then reverted it in
78e5b703b186fe184bf91bb37df82f64059b3f61

The X265_BUILD is how you can tell the x265 version(s). But they didn't change
the values in these commits.

- X265_BUILD was 210 when the API was changed
- X265_BUILD was 214 when the API was reverted

- - - - -
611f6f8d by Steve Lhomme at 2025-01-16T10:10:55+00:00
contrib: x265: update to 4.1

- - - - -


6 changed files:

- + contrib/src/x265/0001-use-OpenFileMappingW-instead-of-OpenFileMappingA.patch
- − contrib/src/x265/0002-do-not-copy-.pdb-files-that-don-t-exist.patch
- contrib/src/x265/0003-add-patch-to-enable-detect512.patch
- contrib/src/x265/SHA512SUMS
- contrib/src/x265/rules.mak
- modules/codec/x265.c


Changes:

=====================================
contrib/src/x265/0001-use-OpenFileMappingW-instead-of-OpenFileMappingA.patch
=====================================
@@ -0,0 +1,64 @@
+From 65ed1f91133be6af7a8403db50e103c005272004 Mon Sep 17 00:00:00 2001
+From: Steve Lhomme <robux4 at ycbcr.xyz>
+Date: Mon, 13 Jan 2025 12:53:41 +0100
+Subject: [PATCH] use OpenFileMappingW instead of OpenFileMappingA
+
+And use the corresponding UWP apps in UWP builds.
+---
+ source/common/ringmem.cpp | 27 +++++++++++++++++++++++----
+ 1 file changed, 23 insertions(+), 4 deletions(-)
+
+diff --git a/source/common/ringmem.cpp b/source/common/ringmem.cpp
+index cfd44e83d..8d60f5193 100644
+--- a/source/common/ringmem.cpp
++++ b/source/common/ringmem.cpp
+@@ -135,11 +135,25 @@ namespace X265_NS {
+             int32_t shrMemSize = (itemSize * itemCnt + sizeof(ShrMemCtrl) + RINGMEM_ALLIGNMENT - 1) & ~(RINGMEM_ALLIGNMENT - 1);
+ 
+ #ifdef _WIN32
+-            HANDLE h = OpenFileMappingA(FILE_MAP_WRITE | FILE_MAP_READ, FALSE, nameBuf);
++            wchar_t nameBuf_utf16[MAX_PATH * 2];
++
++            void *pool;
++            if (MultiByteToWideChar(CP_UTF8, MB_ERR_INVALID_CHARS, nameBuf, -1, nameBuf_utf16, sizeof(nameBuf_utf16)/sizeof(wchar_t)))
++                pool = NULL;
++            else
++            {
++#if WINAPI_FAMILY_PARTITION(WINAPI_PARTITION_DESKTOP)
++            HANDLE h = OpenFileMappingW(FILE_MAP_WRITE | FILE_MAP_READ, FALSE, nameBuf_utf16);
++#else
++            HANDLE h = OpenFileMappingFromApp(FILE_MAP_WRITE | FILE_MAP_READ, FALSE, nameBuf_utf16);
++#endif
+             if (!h)
+             {
+-                h = CreateFileMappingA(INVALID_HANDLE_VALUE, NULL, PAGE_READWRITE, 0, shrMemSize, nameBuf);
+-
++#if WINAPI_FAMILY_PARTITION(WINAPI_PARTITION_DESKTOP)
++                h = CreateFileMappingW(INVALID_HANDLE_VALUE, NULL, PAGE_READWRITE, 0, shrMemSize, nameBuf_utf16);
++#else
++                h = CreateFileMappingFromApp(INVALID_HANDLE_VALUE, NULL, PAGE_READWRITE, shrMemSize, nameBuf_utf16);
++#endif
+                 if (!h)
+                 {
+                     return false;
+@@ -148,11 +162,16 @@ namespace X265_NS {
+                 newCreated = true;
+             }
+ 
+-            void *pool = MapViewOfFile(h, FILE_MAP_ALL_ACCESS, 0, 0, 0);
++#if WINAPI_FAMILY_PARTITION(WINAPI_PARTITION_DESKTOP)
++            pool = MapViewOfFile(h, FILE_MAP_ALL_ACCESS, 0, 0, 0);
++#else
++            pool = MapViewOfFileFromApp(h, FILE_MAP_ALL_ACCESS, 0, 0);
++#endif
+ 
+             ///< should not close the handle here, otherwise the OpenFileMapping would fail
+             //CloseHandle(h);
+             m_handle = h;
++            }
+ 
+             if (!pool)
+             {
+-- 
+2.45.0.windows.1
+


=====================================
contrib/src/x265/0002-do-not-copy-.pdb-files-that-don-t-exist.patch deleted
=====================================
@@ -1,25 +0,0 @@
-From 0a77b8c80bc3ae6b10fa159102dc78d1b0fc6918 Mon Sep 17 00:00:00 2001
-From: Steve Lhomme <robux4 at ycbcr.xyz>
-Date: Fri, 18 May 2018 16:32:17 +0200
-Subject: [PATCH 2/3] do not copy .pdb files that don't exist
-
----
- source/CMakeLists.txt | 2 +-
- 1 file changed, 1 insertion(+), 1 deletion(-)
-
-diff --git a/source/CMakeLists.txt b/source/CMakeLists.txt
-index 0ea2487c7..f6649ced1 100644
---- a/source/CMakeLists.txt
-+++ b/source/CMakeLists.txt
-@@ -554,7 +554,7 @@ if(ENABLE_HDR10_PLUS)
-         ARCHIVE DESTINATION ${LIB_INSTALL_DIR})
- endif()
- install(FILES x265.h "${PROJECT_BINARY_DIR}/x265_config.h" DESTINATION include)
--if((WIN32 AND ENABLE_CLI) OR (WIN32 AND ENABLE_SHARED))
-+if((WIN32 AND ENABLE_CLI AND MSVC_IDE) OR (WIN32 AND ENABLE_SHARED AND MSVC_IDE))
-     if(MSVC_IDE)
-         install(FILES "${PROJECT_BINARY_DIR}/Debug/x265.pdb" DESTINATION ${BIN_INSTALL_DIR} CONFIGURATIONS Debug)
-         install(FILES "${PROJECT_BINARY_DIR}/RelWithDebInfo/x265.pdb" DESTINATION ${BIN_INSTALL_DIR} CONFIGURATIONS RelWithDebInfo)
--- 
-2.45.0.windows.1
-


=====================================
contrib/src/x265/0003-add-patch-to-enable-detect512.patch
=====================================
@@ -1,4 +1,4 @@
-From 84f315deced14f7541fb68a637391bd6eaab9f6c Mon Sep 17 00:00:00 2001
+From 7b037292f0b2b2662c572d4ed659e3ebd8dba89a Mon Sep 17 00:00:00 2001
 From: rego21 <miguelfrego at gmail.com>
 Date: Sun, 20 Mar 2022 23:27:21 +0100
 Subject: [PATCH 3/3] add patch to enable detect512
@@ -9,10 +9,10 @@ Enables detect512 for all architectures
  1 file changed, 5 insertions(+), 4 deletions(-)
 
 diff --git a/source/common/cpu.cpp b/source/common/cpu.cpp
-index 0681ff55b..fa687da7c 100644
+index ae0907890..99cdc3e92 100644
 --- a/source/common/cpu.cpp
 +++ b/source/common/cpu.cpp
-@@ -110,6 +110,11 @@ const cpu_name_t cpu_names[] =
+@@ -128,6 +128,11 @@ const cpu_name_t cpu_names[] =
      { "", 0 },
  };
  
@@ -24,7 +24,7 @@ index 0681ff55b..fa687da7c 100644
  #if X265_ARCH_X86
  
  extern "C" {
-@@ -123,10 +128,6 @@ uint64_t PFX(cpu_xgetbv)(int xcr);
+@@ -141,10 +146,6 @@ uint64_t PFX(cpu_xgetbv)(int xcr);
  #pragma warning(disable: 4309) // truncation of constant value
  #endif
  
@@ -32,9 +32,9 @@ index 0681ff55b..fa687da7c 100644
 -{
 -    return(enable512);
 -}
+ 
  uint32_t cpu_detect(bool benableavx512 )
  {
- 
 -- 
 2.45.0.windows.1
 


=====================================
contrib/src/x265/SHA512SUMS
=====================================
@@ -1 +1 @@
-270818c7fd84947fde371e32bef225c1880cfb0bcd95378d95b51f50577a134d7cd585fcdfa43b103a24d76c5ad826b09509a07eb9e208e8f2b56f2f77365cf3  x265_2.9.tar.gz
+5af5b958ff507f96a52813a6b72847c9fbc555bf95af287ae7f011055338266fb647dfea3b7789730c7f5c746f7e6cb7d9395ba10cbe43eb5034d3ed99730c3f  x265_4.1.tar.gz


=====================================
contrib/src/x265/rules.mak
=====================================
@@ -1,7 +1,7 @@
 # x265
 
 #X265_GITURL := https://github.com/videolan/x265
-X265_VERSION := 2.9
+X265_VERSION := 4.1
 X265_SNAPURL := https://bitbucket.org/multicoreware/x265_git/downloads/x265_$(X265_VERSION).tar.gz
 
 ifdef BUILD_ENCODERS
@@ -31,9 +31,9 @@ $(TARBALLS)/x265_$(X265_VERSION).tar.gz:
 x265: x265_$(X265_VERSION).tar.gz .sum-x265
 	$(UNPACK)
 	$(APPLY) $(SRC)/x265/0001-fix-ldl-linking-error-of-x265.patch
-	$(APPLY) $(SRC)/x265/0002-do-not-copy-.pdb-files-that-don-t-exist.patch
 	$(APPLY) $(SRC)/x265/0003-add-patch-to-enable-detect512.patch
 	$(APPLY) $(SRC)/x265/0001-api-use-LoadLibraryExA-instead-of-LoadLibraryA.patch
+	$(APPLY) $(SRC)/x265/0001-use-OpenFileMappingW-instead-of-OpenFileMappingA.patch
 	$(APPLY) $(SRC)/x265/0001-threadpool-disable-group-affinity-in-UWP-builds.patch
 	$(APPLY) $(SRC)/x265/0001-Fix-libunwind-static-linking-on-Android-toolchains.patch
 	$(call pkg_static,"source/x265.pc.in")
@@ -46,6 +46,5 @@ X265_CONF := -DENABLE_SHARED=OFF -DENABLE_CLI=OFF
 	$(CMAKECLEAN)
 	$(HOSTVARS_CMAKE) $(CMAKE) -S $</source $(X265_CONF)
 	+$(CMAKEBUILD)
-	sed -e s/'[^ ]*clang_rt[^ ]*'//g -i.orig "$(BUILD_DIR)/x265.pc"
 	$(CMAKEINSTALL)
 	touch $@


=====================================
modules/codec/x265.c
=====================================
@@ -39,6 +39,9 @@
 #ifndef X265_MAX_FRAME_THREADS
 # define X265_MAX_FRAME_THREADS 16
 #endif
+#if X265_BUILD > 210 && X265_BUILD <= 214
+#define X265_OUTPUT_ARRAY 1
+#endif
 
 /*****************************************************************************
  * Module descriptor
@@ -70,7 +73,7 @@ static block_t *Encode(encoder_t *p_enc, picture_t *p_pict)
     x265_picture pic;
 
     x265_picture_init(&p_sys->param, &pic);
-#ifdef MAX_SCALABLE_LAYERS
+#ifdef X265_OUTPUT_ARRAY
     /* Handle API changes for scalable layers output in x265 4.0 */
     x265_picture *pics[MAX_SCALABLE_LAYERS] = {NULL};
     pics[0] = &pic;
@@ -91,7 +94,7 @@ static block_t *Encode(encoder_t *p_enc, picture_t *p_pict)
 
     x265_nal *nal;
     uint32_t i_nal = 0;
-#ifdef MAX_SCALABLE_LAYERS
+#ifdef X265_OUTPUT_ARRAY
     x265_encoder_encode(p_sys->h, &nal, &i_nal,
                         likely(p_pict) ? &pic : NULL, pics);
 #else



View it on GitLab: https://code.videolan.org/videolan/vlc/-/compare/e28d4cba0993012c3d72f2f341914124528e3f82...611f6f8df3af121f2d0b2554ff999bd5a29b63bc

-- 
View it on GitLab: https://code.videolan.org/videolan/vlc/-/compare/e28d4cba0993012c3d72f2f341914124528e3f82...611f6f8df3af121f2d0b2554ff999bd5a29b63bc
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