Here is an update to x265 4.1.

Tested on older amd64. Needs testing on modern amd64 for IBT.

aarch64 currently crashes in the NEON code. Could someone take a
look at this? Is this xonly or something else?


Index: Makefile
===================================================================
RCS file: /cvs/ports/multimedia/x265/Makefile,v
retrieving revision 1.59
diff -u -p -u -p -r1.59 Makefile
--- Makefile    7 May 2024 15:01:27 -0000       1.59
+++ Makefile    24 Nov 2024 06:08:21 -0000
@@ -1,12 +1,12 @@
 COMMENT=       free H.265/HEVC encoder
 
-VER=           3.6
+VER=           4.1
 DISTNAME=      x265_${VER}
 PKGNAME=       x265-${VER}
 CATEGORIES=    multimedia
 SITES=         https://bitbucket.org/multicoreware/x265_git/downloads/
 
-SHARED_LIBS=   x265    24.0
+SHARED_LIBS=   x265    25.0
 
 HOMEPAGE=      https://x265.org/
 
@@ -30,10 +30,8 @@ BUILD_DEPENDS+=      devel/nasm
 
 CONFIGURE_ARGS+=-DCMAKE_ASM_YASM_FLAGS_DEBUG="-g dwarf2" \
                -DENABLE_PIC=On \
-               -DENABLE_TESTS=On
-
-CONFIGURE_ARGS+=-DX265_VERSION=${VER} \
-               -DX265_LATEST_TAG=${VER}
+               -DENABLE_TESTS=On \
+               -DGIT_ARCHETYPE=1
 
 .if ${MACHINE_ARCH} == "arm" || ${MACHINE_ARCH} == "i386"
 CONFIGURE_ARGS+=-DENABLE_ASSEMBLY=Off
Index: distinfo
===================================================================
RCS file: /cvs/ports/multimedia/x265/distinfo,v
retrieving revision 1.27
diff -u -p -u -p -r1.27 distinfo
--- distinfo    7 May 2024 15:01:27 -0000       1.27
+++ distinfo    24 Nov 2024 06:08:21 -0000
@@ -1,2 +1,2 @@
-SHA256 (x265_3.6.tar.gz) = ZjUx80HFOJ9GDXMOYuEKT8yjQoyiyhCWk4Z7xf4uKAc=
-SIZE (x265_3.6.tar.gz) = 1655889
+SHA256 (x265_4.1.tar.gz) = oxaZxqiYBrdLAVHl5qffZd5LSQUEgv5ev4pDedevjyk=
+SIZE (x265_4.1.tar.gz) = 1725279
Index: patches/patch-source_CMakeLists_txt
===================================================================
RCS file: /cvs/ports/multimedia/x265/patches/patch-source_CMakeLists_txt,v
retrieving revision 1.8
diff -u -p -u -p -r1.8 patch-source_CMakeLists_txt
--- patches/patch-source_CMakeLists_txt 7 May 2024 15:01:27 -0000       1.8
+++ patches/patch-source_CMakeLists_txt 24 Nov 2024 06:08:21 -0000
@@ -1,13 +1,29 @@
 Index: source/CMakeLists.txt
 --- source/CMakeLists.txt.orig
 +++ source/CMakeLists.txt
-@@ -523,7 +523,8 @@ if(POWER)
+@@ -88,7 +88,7 @@ elseif(ARM64MATCH GREATER "-1")
+     option(AARCH64_WARNINGS_AS_ERRORS "Build with -Werror for AArch64 
Intrinsics files" OFF)
+ 
+     option(AARCH64_RUNTIME_CPU_DETECT "Enable AArch64 run-time CPU feature 
detection" ON)
+-    if(NOT CMAKE_SYSTEM_NAME MATCHES "Linux|Darwin|Windows")
++    if(NOT CMAKE_SYSTEM_NAME MATCHES "Linux|FreeBSD|OpenBSD|Darwin|Windows")
+         set(AARCH64_RUNTIME_CPU_DETECT OFF CACHE BOOL "" FORCE)
+         message(STATUS "Run-time CPU feature detection unsupported on this 
platform")
      endif()
- endif()
+@@ -522,6 +522,16 @@ endif()
  
--include(Version) # determine X265_VERSION and X265_LATEST_TAG
-+set(X265_VERSION "unknown" CACHE STRING "")
-+set(X265_LATEST_TAG "0.0" CACHE STRING "")
- include_directories(. common encoder "${PROJECT_BINARY_DIR}")
+ if(ENABLE_ASSEMBLY)
+    add_definitions(-DENABLE_ASSEMBLY)
++endif()
++
++check_symbol_exists(getauxval sys/auxv.h HAVE_GETAUXVAL)
++if(HAVE_GETAUXVAL)
++    add_definitions(-DHAVE_GETAUXVAL=1)
++endif()
++
++check_symbol_exists(elf_aux_info sys/auxv.h HAVE_ELF_AUX_INFO)
++if(HAVE_ELF_AUX_INFO)
++    add_definitions(-DHAVE_ELF_AUX_INFO=1)
+ endif()
  
- option(ENABLE_PPA "Enable PPA profiling instrumentation" OFF)
+ option(CHECKED_BUILD "Enable run-time sanity checks (debugging)" OFF)
Index: patches/patch-source_common_aarch64_asm_S
===================================================================
RCS file: /cvs/ports/multimedia/x265/patches/patch-source_common_aarch64_asm_S,v
retrieving revision 1.4
diff -u -p -u -p -r1.4 patch-source_common_aarch64_asm_S
--- patches/patch-source_common_aarch64_asm_S   7 May 2024 15:01:27 -0000       
1.4
+++ patches/patch-source_common_aarch64_asm_S   24 Nov 2024 06:08:21 -0000
@@ -1,7 +1,7 @@
 Index: source/common/aarch64/asm.S
 --- source/common/aarch64/asm.S.orig
 +++ source/common/aarch64/asm.S
-@@ -97,6 +97,7 @@ ELF     .hidden EXTERN_ASM\name
+@@ -107,6 +107,7 @@ ELF     .hidden EXTERN_ASM\name
  ELF     .type   EXTERN_ASM\name, %function
  FUNC    .func   EXTERN_ASM\name
  EXTERN_ASM\name:
Index: patches/patch-source_common_aarch64_cpu_h
===================================================================
RCS file: patches/patch-source_common_aarch64_cpu_h
diff -N patches/patch-source_common_aarch64_cpu_h
--- /dev/null   1 Jan 1970 00:00:00 -0000
+++ patches/patch-source_common_aarch64_cpu_h   24 Nov 2024 06:08:21 -0000
@@ -0,0 +1,25 @@
+Index: source/common/aarch64/cpu.h
+--- source/common/aarch64/cpu.h.orig
++++ source/common/aarch64/cpu.h
+@@ -119,7 +119,7 @@ static inline int aarch64_get_cpu_flags()
+     return flags;
+ }
+ 
+-#elif defined(__linux__)
++#elif HAVE_GETAUXVAL || HAVE_ELF_AUX_INFO
+ 
+ #include <sys/auxv.h>
+ 
+@@ -133,10 +133,10 @@ static inline int aarch64_get_cpu_flags()
+     int flags = 0;
+ 
+ #if HAVE_NEON_DOTPROD || HAVE_SVE
+-    unsigned long hwcap = getauxval(AT_HWCAP);
++    unsigned long hwcap = x265_getauxval(AT_HWCAP);
+ #endif
+ #if HAVE_NEON_I8MM || HAVE_SVE2
+-    unsigned long hwcap2 = getauxval(AT_HWCAP2);
++    unsigned long hwcap2 = x265_getauxval(AT_HWCAP2);
+ #endif
+ 
+ #if HAVE_NEON
Index: patches/patch-source_common_cpu_cpp
===================================================================
RCS file: patches/patch-source_common_cpu_cpp
diff -N patches/patch-source_common_cpu_cpp
--- /dev/null   1 Jan 1970 00:00:00 -0000
+++ patches/patch-source_common_cpu_cpp 24 Nov 2024 06:08:21 -0000
@@ -0,0 +1,74 @@
+Index: source/common/cpu.cpp
+--- source/common/cpu.cpp.orig
++++ source/common/cpu.cpp
+@@ -31,6 +31,9 @@
+ #include "cpu.h"
+ #include "common.h"
+ 
++#if HAVE_GETAUXVAL || HAVE_ELF_AUX_INFO
++#include <sys/auxv.h>
++#endif
+ #if MACOS || SYS_FREEBSD
+ #include <sys/types.h>
+ #include <sys/sysctl.h>
+@@ -41,7 +44,7 @@
+ #include <machine/cpu.h>
+ #endif
+ 
+-#if X265_ARCH_ARM && !defined(HAVE_NEON)
++#if X265_ARCH_ARM && !defined(HAVE_NEON) && !(HAVE_GETAUXVAL || 
HAVE_ELF_AUX_INFO)
+ #include <signal.h>
+ #include <setjmp.h>
+ static sigjmp_buf jmpbuf;
+@@ -128,6 +131,22 @@ const cpu_name_t cpu_names[] =
+     { "", 0 },
+ };
+ 
++unsigned long x265_getauxval(unsigned long type)
++{
++#if HAVE_GETAUXVAL
++    return getauxval(type);
++#elif HAVE_ELF_AUX_INFO
++    unsigned long aux = 0;
++    int ret = elf_aux_info(type, &aux, sizeof(aux));
++    if (ret != 0)
++        errno = ret;
++    return aux;
++#else
++    errno = ENOSYS;
++    return 0;
++#endif
++}
++
+ #if X265_ARCH_X86
+ 
+ extern "C" {
+@@ -348,6 +367,8 @@ void PFX(cpu_neon_test)(void);
+ int PFX(cpu_fast_neon_mrc_test)(void);
+ }
+ 
++#define X265_ARM_HWCAP_NEON (1U << 12)
++
+ uint32_t cpu_detect(bool benableavx512)
+ {
+     int flags = 0;
+@@ -355,6 +376,11 @@ uint32_t cpu_detect(bool benableavx512)
+ #if HAVE_ARMV6
+     flags |= X265_CPU_ARMV6;
+ 
++#if HAVE_GETAUXVAL || HAVE_ELF_AUX_INFO
++    unsigned long hwcap = x265_getauxval(AT_HWCAP);
++
++    if (hwcap & X265_ARM_HWCAP_NEON) flags |= X265_CPU_NEON;
++#else
+     // don't do this hack if compiled with -mfpu=neon
+ #if !HAVE_NEON
+     static void (* oldsig)(int);
+@@ -372,6 +398,7 @@ uint32_t cpu_detect(bool benableavx512)
+ #endif // if !HAVE_NEON
+ 
+     flags |= X265_CPU_NEON;
++#endif
+ 
+     // fast neon -> arm (Cortex-A9) detection relies on user access to the
+     // cycle counter; this assumes ARMv7 performance counters.
Index: patches/patch-source_common_cpu_h
===================================================================
RCS file: patches/patch-source_common_cpu_h
diff -N patches/patch-source_common_cpu_h
--- /dev/null   1 Jan 1970 00:00:00 -0000
+++ patches/patch-source_common_cpu_h   24 Nov 2024 06:08:21 -0000
@@ -0,0 +1,12 @@
+Index: source/common/cpu.h
+--- source/common/cpu.h.orig
++++ source/common/cpu.h
+@@ -48,6 +48,8 @@ extern "C" void PFX(safe_intel_cpu_indicator_init)(voi
+ #define x265_emms() PFX(cpu_emms)()
+ #endif
+ 
++unsigned long x265_getauxval(unsigned long);
++
+ namespace X265_NS {
+ uint32_t cpu_detect(bool);
+ bool detect512();

Reply via email to