Fix loading nvEncodeAPI.dll in winarm64 build

Signed-off-by: nyanmisaka <nst799610810@gmail.com>
This commit is contained in:
nyanmisaka
2026-07-19 22:30:08 +08:00
parent 5747543a61
commit 0f614ca05a
2 changed files with 44 additions and 2 deletions
@@ -0,0 +1,34 @@
From 15ee32753c92faddbabbff11676779618fc6db7e Mon Sep 17 00:00:00 2001
From: Diego de Souza <ddesouza@nvidia.com>
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 <ddesouza@nvidia.com>
---
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
@@ -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