From df914067b3e91d873fdc6412178c946a5c90a1a9 Mon Sep 17 00:00:00 2001 From: Uyanide Date: Sat, 20 Jun 2026 17:55:53 +0200 Subject: [PATCH] enable cuda (nv-codec-headers + pinned-picture fix); pkgrel 1.1, add .gitignore, regen .SRCINFO --- .SRCINFO | 9 ++++- .gitignore | 10 +++++ 0001-fix-cuda-pinned-picture-null-state.patch | 8 ++++ PKGBUILD | 38 ++++++++++++++----- 4 files changed, 55 insertions(+), 10 deletions(-) create mode 100644 .gitignore create mode 100644 0001-fix-cuda-pinned-picture-null-state.patch diff --git a/.SRCINFO b/.SRCINFO index 12a17b0..a7a5107 100644 --- a/.SRCINFO +++ b/.SRCINFO @@ -1,17 +1,24 @@ pkgbase = vmaf pkgdesc = Perceptual video quality assessment algorithm based on multi-method fusion pkgver = 3.2.0 - pkgrel = 1 + pkgrel = 1.1 url = https://github.com/Netflix/vmaf/ arch = x86_64 license = BSD-2-Clause-Patent checkdepends = vim + makedepends = cuda + makedepends = gcc15 makedepends = meson makedepends = nasm depends = glibc depends = libgcc depends = libstdc++ + optdepends = nvidia-utils: CUDA GPU acceleration source = https://github.com/Netflix/vmaf/archive/v3.2.0/vmaf-3.2.0.tar.gz + source = nv-codec-headers-1b5a81ada8874efb2af0534ffe74049c557e212d.tar.gz::https://code.ffmpeg.org/FFmpeg/nv-codec-headers/archive/1b5a81ada8874efb2af0534ffe74049c557e212d.tar.gz + source = 0001-fix-cuda-pinned-picture-null-state.patch sha256sums = a28f93f3b4fa65601be324587072e32a6a704a304ba7b1aec9b70b3f709bc1dc + sha256sums = SKIP + sha256sums = SKIP pkgname = vmaf diff --git a/.gitignore b/.gitignore new file mode 100644 index 0000000..0dc502c --- /dev/null +++ b/.gitignore @@ -0,0 +1,10 @@ +* +!.gitignore +!.nvchecker.toml +!.SRCINFO +!*.patch +!LICENSE +!LICENSES/ +!LICENSES/** +!PKGBUILD +!REUSE.toml diff --git a/0001-fix-cuda-pinned-picture-null-state.patch b/0001-fix-cuda-pinned-picture-null-state.patch new file mode 100644 index 0000000..b16c78a --- /dev/null +++ b/0001-fix-cuda-pinned-picture-null-state.patch @@ -0,0 +1,8 @@ +--- a/libvmaf/src/cuda/picture_cuda.c ++++ b/libvmaf/src/cuda/picture_cuda.c +@@ -143,6 +143,7 @@ int vmaf_cuda_picture_alloc_pinned(VmafPicture *pic, enum VmafPixelFormat pix_f + err |= vmaf_picture_priv_init(pic); + VmafPicturePrivate* priv = pic->priv; ++ priv->cuda.state = cuda_state; + priv->cuda.ctx = cuda_state->ctx; + err |= vmaf_picture_set_release_callback(pic, NULL, default_release_pinned_picture); diff --git a/PKGBUILD b/PKGBUILD index ba219ff..6ef6c88 100644 --- a/PKGBUILD +++ b/PKGBUILD @@ -2,7 +2,7 @@ pkgname=vmaf pkgver=3.2.0 -pkgrel=1 +pkgrel=1.1 pkgdesc='Perceptual video quality assessment algorithm based on multi-method fusion' arch=('x86_64') url='https://github.com/Netflix/vmaf/' @@ -11,20 +11,32 @@ depends=( 'glibc' 'libgcc' 'libstdc++') +optdepends=('nvidia-utils: CUDA GPU acceleration') makedepends=( + 'cuda' + 'gcc15' 'meson' 'nasm') checkdepends=( 'vim') -source=("https://github.com/Netflix/vmaf/archive/v${pkgver}/${pkgname}-${pkgver}.tar.gz") -sha256sums=('a28f93f3b4fa65601be324587072e32a6a704a304ba7b1aec9b70b3f709bc1dc') +_nvcodec_commit='1b5a81ada8874efb2af0534ffe74049c557e212d' +source=("https://github.com/Netflix/vmaf/archive/v${pkgver}/${pkgname}-${pkgver}.tar.gz" + "nv-codec-headers-${_nvcodec_commit}.tar.gz::https://code.ffmpeg.org/FFmpeg/nv-codec-headers/archive/${_nvcodec_commit}.tar.gz" + '0001-fix-cuda-pinned-picture-null-state.patch') +sha256sums=('a28f93f3b4fa65601be324587072e32a6a704a304ba7b1aec9b70b3f709bc1dc' + 'SKIP' + 'SKIP') + +prepare() { + patch -p1 -d "${pkgname}-${pkgver}" < 0001-fix-cuda-pinned-picture-null-state.patch +} build() { local _jobs local _max_jobs='20' - + _jobs="$(nproc)" - + # may fail to compile on a high core count system # https://github.com/Netflix/vmaf/issues/1541 if [ "$_jobs" -ge "$_max_jobs" ] @@ -32,17 +44,25 @@ build() { _jobs="$_max_jobs" printf '%s\n' "limiting the compilation jobs to ${_jobs}" fi - - arch-meson -Denable_avx512='false' "${pkgname}-${pkgver}/libvmaf" build + + export PATH="/opt/cuda/bin:$PATH" + export CUDA_HOST_COMPILER=/usr/bin/gcc-15 + # install bundled nv-codec-headers (system package lacks cuMemFreeAsync/cuMemAllocAsync) + make -C "nv-codec-headers" PREFIX="${srcdir}/nvcodec-prefix" install + export C_INCLUDE_PATH="${srcdir}/nvcodec-prefix/include:${C_INCLUDE_PATH}" + # cd into libvmaf so nvcc's hardcoded relative include paths (../src, ../include) + # resolve correctly when the build dir is a subdirectory of the source + cd "${pkgname}-${pkgver}/libvmaf" + arch-meson -Denable_avx512='false' -Denable_cuda='true' -Denable_nvcc='true' . build meson compile -C build --jobs "$_jobs" } check() { - meson test -C build + meson test -C "${pkgname}-${pkgver}/libvmaf/build" } package() { - meson install -C build --destdir "$pkgdir" + meson install -C "${pkgname}-${pkgver}/libvmaf/build" --destdir "$pkgdir" install -D -m644 "${pkgname}-${pkgver}/LICENSE" -t "${pkgdir}/usr/share/licenses/${pkgname}" cp -dr --no-preserve='ownership' "${pkgname}-${pkgver}/model" "${pkgdir}/usr/share" }