git: c8ddf6fc600d - main - multimedia/x265: update 4.2 -> 4.3

From: Gleb Popov <arrowd_at_FreeBSD.org>
Date: Sat, 10 Oct 2026 13:01:45 UTC
The branch main has been updated by arrowd:

URL: https://cgit.FreeBSD.org/ports/commit/?id=c8ddf6fc600d7a0922a170d8d3ad850d2281ff0a

commit c8ddf6fc600d7a0922a170d8d3ad850d2281ff0a
Author:     Mikhail Teterin <mi@FreeBSD.org>
AuthorDate: 2026-10-06 04:18:46 +0000
Commit:     Gleb Popov <arrowd@FreeBSD.org>
CommitDate: 2026-10-10 13:01:14 +0000

    multimedia/x265: update 4.2 -> 4.3
    
    Upstream changes:
    
      * New: LoongArch64 support; foveated encoding (--fovea-gaze,
        --fovea-delta, --fovea-sigma, --fovea-gaze-file), which spends
        fewer bits away from a gaze point; selective, noise-based MCSTF
        (--selective-mcstf, --mcstf-ref-range).
      * MCSTF reworked: multi-threaded motion estimation and bilateral
        filtering, AVX2 kernels (about 2x faster with threading).
      * More AArch64 Neon/SVE/SVE2 optimizations; early-exit diamond
        search in threaded ME.
      * Fixes for ASAN/UBSAN and TSAN findings, threaded-ME and MCSTF
        crashes, --pools thread counts, scenecut with --bframes 0, a
        bitstream error with VUI timing info disabled, and CPU-feature
        detection on FreeBSD (elf_aux_info).
      * API: the temporalFilterStrength and searchRangeForLayer[012]
        fields are gone from x265_param; X265_BUILD is now 217.
    
    https://github.com/Multicorewareinc/x265/blob/4.3/doc/reST/releasenotes.rst
    
    The project has moved to GitHub; distfiles are now published as
    release assets there.
    
    While here, pull in the fixes committed upstream since 4.3: a crash
    when x265 is run without arguments, uninitialized DTS fields,
    out-of-range mvd values in the bitstream, a motion-search offset
    error for small rectangular PUs, recon-file bit-depth handling in
    multi-lib builds, repeated x265_encoder_headers() calls accumulating
    NALs, stack underflows in the AArch64 and RISC-V intra filters, an
    AArch64 execute-only fix, __atomic builtins (fixing 32-bit builds),
    and removal of a 25% AArch64 slowdown caused by a mutex added in 4.3.
    
    The version string now counts these on top of the release and names
    the newest of them: 4.3+14-d978725.
    
    Also make x265_param_free() accept NULL. With SVT-HEVC enabled, every
    CLI error exit crashed: the CLI frees its parameters, clears the
    pointer, and then hands the NULL to x265_param_free() a second time.
    
    And build the 10- and 12-bit libraries with the same VMAF setting as
    the main one. ENABLE_LIBVMAF changes the layout of x265_api, so with
    the VMAF option on, encoding at those depths with --csv called through
    a NULL pointer and crashed.
    
    PR:             299194
    Co-Authored-By: Claude Opus 5.5 <effort=high>
---
 multimedia/x265/Makefile                           | 35 ++++++++++++++++--
 multimedia/x265/distinfo                           | 34 ++++++++++++++++--
 multimedia/x265/files/patch-source_CMakeLists.txt  | 41 +++++++---------------
 .../x265/files/patch-source_common_param.cpp       | 14 ++++++++
 multimedia/x265/pkg-plist                          |  2 +-
 5 files changed, 91 insertions(+), 35 deletions(-)

diff --git a/multimedia/x265/Makefile b/multimedia/x265/Makefile
index 632f71bd4536..aa23b751b477 100644
--- a/multimedia/x265/Makefile
+++ b/multimedia/x265/Makefile
@@ -1,10 +1,26 @@
 PORTNAME=	x265
-PORTVERSION=	4.2
+PORTVERSION=	4.3
 CATEGORIES=	multimedia
-MASTER_SITES=	https://bitbucket.org/multicoreware/x265_git/downloads/ \
+MASTER_SITES=	https://github.com/Multicorewareinc/x265/releases/download/${PORTVERSION}/ \
 		http://ftp.videolan.org/pub/videolan/x265/
 DISTNAME=	${PORTNAME}_${PORTVERSION}
 
+PATCH_SITES=	https://github.com/Multicorewareinc/x265/commit/
+PATCHFILES=	fbd43389ed39b8623bdf081fae3020d96052d962.patch:-p1 \
+		9ddc216defd1fa85535cb91456a9f6c09a2c3abc.patch:-p1 \
+		ff33e3e2ce1af2ceee94958c7273e3b1d083d5e5.patch:-p1 \
+		62728cd0c696655f34972b47cff1e1e77d84e426.patch:-p1 \
+		d0418793c134fe943098f5f0700ae87fcd4c8557.patch:-p1 \
+		98eec4057fc20850b59ed292b3f13ddeefc2f93f.patch:-p1 \
+		f0179ac2ea69d349de0b20848d0431971d8db3b9.patch:-p1 \
+		ae31887b575154ca64164153b9802a92cacd9387.patch:-p1 \
+		93b4b94f8d4ac1808e715766b180932948e671a6.patch:-p1 \
+		e761edf5ecd1260237766bb7b7b2583e933d5ffb.patch:-p1 \
+		a0468d239fbfa659641ce6085aa9b63977a5785d.patch:-p1 \
+		ea8b761899ecf91cbd4f8b83e85d8444b1b94c80.patch:-p1 \
+		688efad6e96d755188cb08fbe9e16822e1cfa3f1.patch:-p1 \
+		d978725394991e13a07a8002e0ff8b7d01eea08a.patch:-p1
+
 MAINTAINER=	ports@virtual-estates.net
 COMMENT=	H.265/High Efficiency Video Coding (HEVC) format
 WWW=		https://www.x265.org/
@@ -74,7 +90,10 @@ CMAKE_ARGS+=	-DHIGH_BIT_DEPTH:BOOL=true
 CMAKE_ARGS+=	-DENABLE_ASSEMBLY:BOOL=false
 .endif
 
-CMAKE_OTHER_ARGS=	${CMAKE_ARGS:C/.*-D_END_CUSTOM_OPTIONS=1 +//W}
+# ENABLE_LIBVMAF changes the layout of x265_api, so the libraries for
+# the other depths must agree with the main one about it.
+CMAKE_OTHER_ARGS=	${CMAKE_ARGS:M*VMAF*} \
+			${CMAKE_ARGS:C/.*-D_END_CUSTOM_OPTIONS=1 +//W}
 
 .if ${PORT_OPTIONS:MDEBUG}
 CFLAGS:=	${CFLAGS:N-O*} -O0 -g
@@ -127,6 +146,16 @@ CMAKE_ARGS+=	${OTHER_DEPTHS:C/HI([0-9]+)P/-DLINKED_\1BIT:BOOL=true/}
 
 CMAKE_ARGS+=	-DENABLE_SHARED:BOOL=true
 
+.if !empty(PATCHFILES)
+# Make the version string count the upstream commits applied on top of
+# the release, and name the most recent of them.
+post-patch:
+	${REINPLACE_CMD} -E \
+	    -e 's/^(releasetagdistance: ).*/\1${PATCHFILES:[#]}/' \
+	    -e 's/^(repositorychangeset: ).*/\1${PATCHFILES:[-1]:C/^(.......).*/\1/}/' \
+	    ${WRKSRC:H}/x265Version.txt
+.endif
+
 do-test:
 .if ${PORT_OPTIONS:MHI8P} || ${ARCH} != i386
 	${WRKDIR}/.build/test/TestBench
diff --git a/multimedia/x265/distinfo b/multimedia/x265/distinfo
index f50338b1775e..16c33b66ee25 100644
--- a/multimedia/x265/distinfo
+++ b/multimedia/x265/distinfo
@@ -1,3 +1,31 @@
-TIMESTAMP = 1789380574
-SHA256 (x265_4.2.tar.gz) = 40b1ea0453e0309f0eba934e0ddf533f8f6295966679e8894e8f1c1c8d5e1210
-SIZE (x265_4.2.tar.gz) = 1833442
+TIMESTAMP = 1791256346
+SHA256 (x265_4.3.tar.gz) = 83c53e4c8bbb8f1e33ed59e10a7d621d1d7801ca853910c3eb41f038b8ffb121
+SIZE (x265_4.3.tar.gz) = 2052112
+SHA256 (fbd43389ed39b8623bdf081fae3020d96052d962.patch) = df9a6bc6d6975ef395dc2cf3a321a8c4aef41b20b4b2823d7f67c60c97bfe3fa
+SIZE (fbd43389ed39b8623bdf081fae3020d96052d962.patch) = 788
+SHA256 (9ddc216defd1fa85535cb91456a9f6c09a2c3abc.patch) = 2c215285def2e23fce319f5a4bbecf10dd1480593ba9524d25cefbe5dcf66869
+SIZE (9ddc216defd1fa85535cb91456a9f6c09a2c3abc.patch) = 1930
+SHA256 (ff33e3e2ce1af2ceee94958c7273e3b1d083d5e5.patch) = 4ce46dce054aa0280f652b8ac104df16e98ccb0015f404159f7fefd425a42df8
+SIZE (ff33e3e2ce1af2ceee94958c7273e3b1d083d5e5.patch) = 3345
+SHA256 (62728cd0c696655f34972b47cff1e1e77d84e426.patch) = 1e8670be8be79ee508becd81c8891ef2b0c111ff77b8afb8a4bca88a12f219c2
+SIZE (62728cd0c696655f34972b47cff1e1e77d84e426.patch) = 1991
+SHA256 (d0418793c134fe943098f5f0700ae87fcd4c8557.patch) = e77227264adb75773790beb006f557d6b09b31a1f5298d83efe8468dcd4f2c21
+SIZE (d0418793c134fe943098f5f0700ae87fcd4c8557.patch) = 2597
+SHA256 (98eec4057fc20850b59ed292b3f13ddeefc2f93f.patch) = 466fc516462b5ca8544b2ea7571d04e2019de085866a6d153bb06f2d324936be
+SIZE (98eec4057fc20850b59ed292b3f13ddeefc2f93f.patch) = 661
+SHA256 (f0179ac2ea69d349de0b20848d0431971d8db3b9.patch) = 7cb38724acea92ab2c23f1a12da088779f40d75a365bcfcbb8b16f8e7c8e120d
+SIZE (f0179ac2ea69d349de0b20848d0431971d8db3b9.patch) = 2551
+SHA256 (ae31887b575154ca64164153b9802a92cacd9387.patch) = bd88620849133df200e6de27305033370b528d2d3ecf36d261427abd780aee5f
+SIZE (ae31887b575154ca64164153b9802a92cacd9387.patch) = 3562
+SHA256 (93b4b94f8d4ac1808e715766b180932948e671a6.patch) = 62ad5353f4780d83b00c3899920d26bd5b73e6b97d017e7227d4c41f537d7ffc
+SIZE (93b4b94f8d4ac1808e715766b180932948e671a6.patch) = 8704
+SHA256 (e761edf5ecd1260237766bb7b7b2583e933d5ffb.patch) = dcc9383309d9f7aa033e50e6b5177722b0deb93f3be0b5978aef646dcef9fffb
+SIZE (e761edf5ecd1260237766bb7b7b2583e933d5ffb.patch) = 14810
+SHA256 (a0468d239fbfa659641ce6085aa9b63977a5785d.patch) = accdc8b38781bfe15766d9dc002ec963c41fc4ad9f31ae94192039d805ed1e9c
+SIZE (a0468d239fbfa659641ce6085aa9b63977a5785d.patch) = 1378
+SHA256 (ea8b761899ecf91cbd4f8b83e85d8444b1b94c80.patch) = 86663a79fba819f08c29916b4296f01166754a66174e4aa1f371970ea585db96
+SIZE (ea8b761899ecf91cbd4f8b83e85d8444b1b94c80.patch) = 1182
+SHA256 (688efad6e96d755188cb08fbe9e16822e1cfa3f1.patch) = e0b332f688e1caec528da8a74ee4aff20f56d5b37ee2819eedfbb64732785634
+SIZE (688efad6e96d755188cb08fbe9e16822e1cfa3f1.patch) = 995
+SHA256 (d978725394991e13a07a8002e0ff8b7d01eea08a.patch) = 3565a245c5e1d6fe4a814d8b1f69526227c0788a35ff8d4fa3c374556227fa9c
+SIZE (d978725394991e13a07a8002e0ff8b7d01eea08a.patch) = 1505
diff --git a/multimedia/x265/files/patch-source_CMakeLists.txt b/multimedia/x265/files/patch-source_CMakeLists.txt
index 962a2a7a58d1..9dfab79f548f 100644
--- a/multimedia/x265/files/patch-source_CMakeLists.txt
+++ b/multimedia/x265/files/patch-source_CMakeLists.txt
@@ -1,44 +1,30 @@
---- source/CMakeLists.txt	2023-10-22 22:08:10.704150000 -0400
-+++ source/CMakeLists.txt	2023-10-22 22:10:02.947579000 -0400
-@@ -45,5 +45,5 @@
+--- source/CMakeLists.txt	2026-07-31 07:16:44.000000000 -0400
++++ source/CMakeLists.txt	2026-10-05 22:51:45.000000000 -0400
+@@ -48,5 +48,5 @@
  endif()
  set(X86_ALIASES x86 i386 i686 x86_64 amd64)
 -set(ARM_ALIASES armv6l armv7l)
 +set(ARM_ALIASES armv6l armv7l armv7)
  set(ARM64_ALIASES arm64 arm64e aarch64)
- list(FIND X86_ALIASES "${SYSPROC}" X86MATCH)
-@@ -122,6 +122,7 @@
-     option(ENABLE_LIBVMAF "Enable VMAF" OFF)
+ set(RISCV64_ALIASES riscv64)
+@@ -196,4 +196,5 @@
      if(ENABLE_LIBVMAF)
          add_definitions(-DENABLE_LIBVMAF)
 +        include_directories(${VMAF_INCLUDE_DIR})
      endif()
- endif(UNIX)
- 
-@@ -474,7 +475,7 @@ if(POWER)
-     # IBM Power8
-     option(ENABLE_ALTIVEC "Enable ALTIVEC profiling instrumentation" ON)
-     if(ENABLE_ALTIVEC)
--        add_definitions(-DHAVE_ALTIVEC=1 -maltivec -mabi=altivec)
-+        add_definitions(-DHAVE_ALTIVEC=1 -maltivec)
-         add_definitions(-flax-vector-conversions -fpermissive)
-     else()
-         add_definitions(-DHAVE_ALTIVEC=0)
-@@ -593,12 +594,6 @@
+     if(X64)
+@@ -1085,10 +1086,4 @@
+         LIBRARY DESTINATION ${LIB_INSTALL_DIR}
          ARCHIVE DESTINATION ${LIB_INSTALL_DIR})
- endif()
- 
+-endif()
+-
 -if(SVTHEVC_FOUND)
 -    install(FILES "${SVT_HEVC_INCLUDE_DIR}/EbApi.h" DESTINATION include)
 -    install(FILES "${SVT_HEVC_INCLUDE_DIR}/EbErrorCodes.h" DESTINATION include)
 -    install(FILES "${SVT_HEVC_LIBRARY}" 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(MSVC_IDE)
-@@ -650,7 +645,10 @@
-     if(EXTRA_LIB)
+ endif()
+ 
+@@ -1152,5 +1147,8 @@
          target_link_libraries(x265-shared ${EXTRA_LIB})
      endif()
 -	 target_link_libraries(x265-shared ${PLATFORM_LIBS})
@@ -48,4 +34,3 @@
 +	target_link_libraries(x265-shared ${PLATFORM_LIBS})
      if(SVTHEVC_FOUND)
          target_link_libraries(x265-shared ${SVT_HEVC_LIBRARY})
-     endif(SVTHEVC_FOUND)
diff --git a/multimedia/x265/files/patch-source_common_param.cpp b/multimedia/x265/files/patch-source_common_param.cpp
new file mode 100644
index 000000000000..f1cd9f188cbe
--- /dev/null
+++ b/multimedia/x265/files/patch-source_common_param.cpp
@@ -0,0 +1,14 @@
+Tolerate a NULL argument, as free(3) does.  With SVT-HEVC enabled the
+function dereferences p->svtHevcParam, so every CLI error exit crashed:
+CLIOptions::destroy() already frees the param and sets it to NULL, and
+main() then calls param_free() on it again.
+
+--- source/common/param.cpp	2026-07-31 07:16:44.000000000 -0400
++++ source/common/param.cpp	2026-10-05 23:03:50.000000000 -0400
+@@ -104,4 +104,6 @@
+ void x265_param_free(x265_param* p)
+ {
++    if (!p)
++        return;
+     x265_zone_free(p);
+ #ifdef SVT_HEVC
diff --git a/multimedia/x265/pkg-plist b/multimedia/x265/pkg-plist
index 2504140d91ce..a8c5822c9b6b 100644
--- a/multimedia/x265/pkg-plist
+++ b/multimedia/x265/pkg-plist
@@ -6,5 +6,5 @@ lib/libhdr10plus.a
 lib/libhdr10plus.so
 lib/libx265.a
 lib/libx265.so
-lib/libx265.so.216
+lib/libx265.so.217
 libdata/pkgconfig/x265.pc