From 0f614ca05a99b0d1d60adc9b2ece00cd5e69b3ab Mon Sep 17 00:00:00 2001 From: nyanmisaka Date: Sun, 19 Jul 2026 22:13:21 +0800 Subject: [PATCH] Fix loading nvEncodeAPI.dll in winarm64 build Signed-off-by: nyanmisaka --- ...codeAPI-dll-for-native-Windows-ARM64.patch | 34 +++++++++++++++++++ .../50-mingw-w64-ffnvcodec-headers/PKGBUILD | 12 +++++-- 2 files changed, 44 insertions(+), 2 deletions(-) create mode 100644 msys2/PKGBUILD/50-mingw-w64-ffnvcodec-headers/01-Load-nvEncodeAPI-dll-for-native-Windows-ARM64.patch diff --git a/msys2/PKGBUILD/50-mingw-w64-ffnvcodec-headers/01-Load-nvEncodeAPI-dll-for-native-Windows-ARM64.patch b/msys2/PKGBUILD/50-mingw-w64-ffnvcodec-headers/01-Load-nvEncodeAPI-dll-for-native-Windows-ARM64.patch new file mode 100644 index 000000000..61a0cb002 --- /dev/null +++ b/msys2/PKGBUILD/50-mingw-w64-ffnvcodec-headers/01-Load-nvEncodeAPI-dll-for-native-Windows-ARM64.patch @@ -0,0 +1,34 @@ +From 15ee32753c92faddbabbff11676779618fc6db7e Mon Sep 17 00:00:00 2001 +From: Diego de Souza +Date: Fri, 26 Jun 2026 22:59:03 +0200 +Subject: [PATCH] Load nvEncodeAPI.dll for native Windows ARM64 + +On Windows on Arm, nvEncodeAPI.dll is an Arm64X dispatch proxy. +It routes native ARM64 callers to nvEncodeAPIa64.dll and x64 or +ARM64EC callers to nvEncodeAPI64.dll. + +Select the proxy for native ARM64 builds while preserving the existing +library name for other 64-bit Windows targets. + +Signed-off-by: Diego de Souza +--- + include/ffnvcodec/dynlink_loader.h | 6 +++++- + 1 file changed, 5 insertions(+), 1 deletion(-) + +diff --git a/include/ffnvcodec/dynlink_loader.h b/include/ffnvcodec/dynlink_loader.h +index 6d6a0ec..1be0dbf 100644 +--- a/include/ffnvcodec/dynlink_loader.h ++++ b/include/ffnvcodec/dynlink_loader.h +@@ -50,7 +50,11 @@ + # define CUDA_LIBNAME "nvcuda.dll" + # define NVCUVID_LIBNAME "nvcuvid.dll" + # if defined(_WIN64) || defined(__CYGWIN64__) +-# define NVENC_LIBNAME "nvEncodeAPI64.dll" ++# if defined(_M_ARM64) || defined(__aarch64__) ++# define NVENC_LIBNAME "nvEncodeAPI.dll" ++# else ++# define NVENC_LIBNAME "nvEncodeAPI64.dll" ++# endif + # else + # define NVENC_LIBNAME "nvEncodeAPI.dll" + # endif diff --git a/msys2/PKGBUILD/50-mingw-w64-ffnvcodec-headers/PKGBUILD b/msys2/PKGBUILD/50-mingw-w64-ffnvcodec-headers/PKGBUILD index a1841a1b1..8042bfcb0 100644 --- a/msys2/PKGBUILD/50-mingw-w64-ffnvcodec-headers/PKGBUILD +++ b/msys2/PKGBUILD/50-mingw-w64-ffnvcodec-headers/PKGBUILD @@ -12,8 +12,10 @@ url=https://github.com/FFmpeg/nv-codec-headers.git license=('spdx:MIT') makedepends=("git") _tag=451da99614412a7f9526ef301a5ee0c7a6f9ad76 -source=(git+https://github.com/FFmpeg/nv-codec-headers.git#tag=${_tag}) -sha256sums=('SKIP') +source=("git+https://github.com/FFmpeg/nv-codec-headers.git#tag=${_tag}" + "01-Load-nvEncodeAPI-dll-for-native-Windows-ARM64.patch") +sha256sums=('SKIP' + '43c248049c16e207635a9e56a26365b26014d2dc2d7c0e0688aa09ad649208f9') export MINGW_TOOLCHAIN_PREFIX="${MINGW_PREFIX}" export FF_MINGW_PREFIX="${MINGW_TOOLCHAIN_PREFIX}/ffbuild" @@ -24,6 +26,12 @@ pkgver() { git describe --tags | sed 's/^n//' } +prepare() { + cd nv-codec-headers + + patch -p1 -i "${srcdir}/01-Load-nvEncodeAPI-dll-for-native-Windows-ARM64.patch" +} + build() { make PREFIX=${FF_MINGW_PREFIX} -C nv-codec-headers sed -n '4,25p' nv-codec-headers/include/ffnvcodec/nvEncodeAPI.h > LICENSE # Extract license