Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
14 commits
Select commit Hold shift + click to select a range
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
49 changes: 46 additions & 3 deletions CLAUDE.md
Original file line number Diff line number Diff line change
Expand Up @@ -3937,8 +3937,8 @@ QTGMC's denoiser falls back to DFTTest.
`_tierFiles` entry).
- **Verified:** macOS arm64 and x64 (Rosetta) builds give the old builds'
output byte for byte; the Windows DLLs build and export the init symbol
but can only be run in CI. DFTTest's own output varies between processes
(its `FFTW_PATIENT` planning, both builds alike; task #101).
but can only be run in CI. DFTTest's planning is task #101's (next
section).
- `vapoursynth_integration_test.dart`'s `per-thread buffer maps (task #98)`
group checks the markers (from deps 1.18.0-rc3) and the patches and
scripts (push gate), and runs graphs of 1000 instances of each plus
Expand All @@ -3948,6 +3948,49 @@ QTGMC's denoiser falls back to DFTTest.
for `thread::id`. A locked map (BM3D r12's `GetThreadBuffer`) is fine
(docs/reports/task-98-per-thread-buffer-maps).

### DFTTest plans with FFTW_ESTIMATE (task #101)

DFTTest planned its four FFTs (`dfttestCreate`) with `FFTW_PATIENT`, which
times candidate plans **in each process**; plans round floats differently,
so the same script gave one of several pictures depending on the process,
and a preview and its encode (two processes) could disagree. FFT3DFilter's
`measure=1` was the same fault (task #80). DFTTest has **no argument** that
picks the planner, so:

- **`Scripts/patches/dfttest-bc5e018-fftw-estimate.patch`, applied after
task #98's thread-safety patch on every platform** (its context is that
patch's name line; it applies to bc5e018 and yuygfgg's e6f580a alike),
plans with `FFTW_ESTIMATE` (one plan per machine, in every process) and
appends `; FFTW_ESTIMATE, task #101` to the plugin's name. All three
`download-deps-*` scripts require that marker (`DFTTEST_MARKER`,
`$DftMarker`) as well as task #98's, so a thread-safe build that still
plans with PATIENT is rebuilt, never shipped. No template change: there is
nothing to pass.
- **Measured:** on every x86 machine (Linux, Windows and Intel Mac
runners, macOS x64 under Rosetta) the 3D plans (`tbsize` > 1: the Noise Reduction method,
QTGMC's dfttest denoiser and knlmeanscl fallback, TD2 postFFT 3) gave 2-3
pictures in 20-30 fresh processes, 1-2 levels apart in at most 0.13% of
samples; the 2D plans (`tbsize=1`, havsfunc's prefilters) and Apple
Silicon never did. ESTIMATE: one picture everywhere, no measurable speed
cost, and no FFTW problem shared with FFT3DFilter's
(docs/reports/task-101-dfttest-fftw-planning).
- **DCTFilter stays `FFTW_PATIENT`** (the user's decision in task #96); its
8x8 r2r plans are a different FFTW problem from DFTTest's and
FFT3DFilter's.
- **Before adding a plugin that uses FFTW, look for per-process planning:**
`FFTW_MEASURE`, `FFTW_PATIENT` or `FFTW_EXHAUSTIVE` in its source (or a
`measure`-style argument defaulting to them) means a preview can differ
from its encode. FFTW also reuses a more patient plan made earlier in the
process for a later ESTIMATE request of the same problem, so one such call
can undo the others.
- `vapoursynth_integration_test.dart`'s `dfttest FFTW planning (task #101)`
group checks the marker and that a second process filters exactly as the
first (from deps 1.18.0-rc4), and the patch and scripts (push gate);
`integration_dfttest_determinism_test.dart` (heavy) checks six previews
and the lossless encode agree sample for sample for the Noise Reduction
DFTTest method, QTGMC's dfttest denoiser and TemporalDegrain2 postFFT 3
(with its FFT3DFilter spatial pass).

## Debugging Tips

1. **Worker crashes**: Run worker standalone with `--config` to isolate
Expand Down Expand Up @@ -4465,4 +4508,4 @@ Full write-ups (root causes, measurements) for each entry are in
| 1.15.0 | 2026-11-03 | **Issue #144**: KNLMeansCL moves to Jaded Encoding Thaumaturgy's fork **v1.3** on every platform (Windows: PyPI wheel, replacing Khanattila's 2018 v1.1.1 zip, which refused 10-bit 4:2:0; macOS/Linux: the `v1.3` tag, replacing unpinned master, which gave unrepeatable results on Apple's OpenCL). Both meson patchers learn v1.3's assigned `run_command` include probe. Published as the tested `deps-v1.15.0-rc1` bundles with only the version changed |
| 1.16.0 | 2026-11-09 | **vszip 22.1.0 → 24.0.0** on every platform (CPU `NLMeans` for Noise Reduction's NLMeans (CPU) and the vine dehalo; macOS x64 sdist now built with Zig 0.17.0). Adds **SangNom** r45 (PyPI wheels; MIT source, GPL-2.0 binaries) on every platform for Anti-aliasing's SangNom method. Both single-file on x64 (no AVX), so `_tierFiles` is unchanged. **rc2: the AI models leave the bundle** — RIFE 4.26's (now the `frame-rate-rife` add-on) and the Real-ESRGAN anime / Real-CUGAN ones (now `upscale-anime`); the plugins stay, and their probes run stand-in models. Published as the tested `deps-v1.16.0-rc2` bundles with only the version changed (`Scripts/promote-deps-rc.py`) |
| 1.17.0 | rc1 2026-11-15, rc2 2026-11-16, rc3 2026-11-17 | **Task #36**: macOS arm64 libdvdread built from 6.1.3 source (patched to find a user's libdvdcss in `/opt/homebrew/lib`, `/usr/local/lib`, `/opt/local/lib`) instead of Homebrew's bottle, which linked `/opt/homebrew/opt/libdvdcss/…` and failed to load on Macs without it; macOS x64 gets the same patched build. Absolute build-machine rpaths stripped from libvapoursynth, vapoursynth.abi3.so, libfftw3f*, libboost_charconv, bm3d, dctfilter and mvtools (inert: nothing used `@rpath`). Windows and Linux binaries unchanged; libdvdread is now a required file on every platform. **rc2** (task #45): macOS x64 FFmpeg evermeet 9.0.1 → martin-riedl 9.0.2 (build 1789931006, pinned by SHA-256), which has SVT-AV1, so AV1 output works on Intel Macs; x264/x265/MP3 bitstreams change there, native codecs byte-identical. **rc3** (task #60): **Bifrost** v3.0 → **4.0** from its PyPI wheels on every platform (was the v3.0 tag's `bifrost.c` built from source on macOS/Linux, v3.0's 7z on Windows), under the same file names; v3.0 left chroma past the last whole 4x4 block uninitialised (different output run to run at width 98, 720x486), v4.0 initialises it and runs at 8–16 bits natively. No AVX, so `_tierFiles` unchanged |
| 1.18.0 | rc1 2026-11-19, rc2 2026-11-20, rc3 2026-11-22 | **Task #62**: FFT3DFilter built from source at R2 with `patches/fft3dfilter-r2-determinism.patch` on every platform (Windows: Zig cross-compile replacing the R2 release DLL; macOS arm64: replacing yuygfgg's prebuilt), so its output no longer differs from run to run. One build for both x64 tiers; file names unchanged. **Task #68**: vspipe R78 with upstream's frame-done count fix (`patches/vapoursynth-r78-vspipe-frame-done-count.patch`, 4ff3f8a0) on every platform (Windows: Zig build replacing the wheel's `vspipe.exe`), so a one-frame preview can no longer be torn down under its last frame's callback (SIGSEGV). VapourSynth stays R78: R80 dropped API 3, which 12 bundled plugins need. **rc2** (task #80): the FFT3DFilter patch also makes `measure=0` (FFTW_ESTIMATE) the default; FFTW_MEASURE timed its plans per process, so on x86 two processes (a preview and its encode) could filter differently. File names unchanged. **rc3** (task #82): havsfunc patch 8, LUTDeCrawl/LUTDeRainbow's mask ANDs as `Expr 'x y min'` instead of Python Lut2 tables, bit-identical (10-bit preview with both on: ~18 s → 0.33 s on an M1). Also **task #96**: DCTFilter built from source at r3.2 with `patches/dctfilter-r3.2-thread-safety.patch` (upstream's c924a7a) on every platform (Windows: Zig build replacing the r2 release DLL; macOS x64: replacing Stefan-Olt's r2.1; macOS arm64/Linux: pinned, were unpinned HEAD, the same code). r2/r2.1 aborted about one run in a hundred under threads (0xC0000409 on Windows). Same output sample for sample; file names unchanged. Also **task #98**: DFTTest (bc5e018; macOS arm64 yuygfgg's fork e6f580a), LGhost r1, CTMF r5, TCanny 14ac2ce and (macOS arm64, Linux) EEDI3m r10 built from source with `patches/<plugin>-<ver>-thread-safety.patch`, which locks their per-thread buffer maps (aborts with `unordered_map::at` / 0xC0000409) and marks the plugin's name; replaces the Windows release DLLs, Stefan-Olt's macOS prebuilts, yuygfgg's arm64 DFTTest and Stefan-Olt's Linux x64 LGhost. Same output (macOS measured); file names unchanged. macOS arm64's FFmpeg is now pinned to martin-riedl build 1789931890 (9.0.2, the binary rc2 shipped) after `latest` moved to 9.1. Also **task #103**: Linux VapourSynth's statically linked zimg (R78's `subprojects/zimg.wrap`, `revision = HEAD`) pinned to 67e06032 / graphengine cb5b2ce1, what rc2's build cloned; rc3's first Linux build had cloned master's `e2e43d09` and aborted in every resize ("double free or corruption"), so rc3's Linux assets were replaced with the pinned build |
| 1.18.0 | rc1 2026-11-19, rc2 2026-11-20, rc3 2026-11-22, rc4 (pending) | **Task #62**: FFT3DFilter built from source at R2 with `patches/fft3dfilter-r2-determinism.patch` on every platform (Windows: Zig cross-compile replacing the R2 release DLL; macOS arm64: replacing yuygfgg's prebuilt), so its output no longer differs from run to run. One build for both x64 tiers; file names unchanged. **Task #68**: vspipe R78 with upstream's frame-done count fix (`patches/vapoursynth-r78-vspipe-frame-done-count.patch`, 4ff3f8a0) on every platform (Windows: Zig build replacing the wheel's `vspipe.exe`), so a one-frame preview can no longer be torn down under its last frame's callback (SIGSEGV). VapourSynth stays R78: R80 dropped API 3, which 12 bundled plugins need. **rc2** (task #80): the FFT3DFilter patch also makes `measure=0` (FFTW_ESTIMATE) the default; FFTW_MEASURE timed its plans per process, so on x86 two processes (a preview and its encode) could filter differently. File names unchanged. **rc3** (task #82): havsfunc patch 8, LUTDeCrawl/LUTDeRainbow's mask ANDs as `Expr 'x y min'` instead of Python Lut2 tables, bit-identical (10-bit preview with both on: ~18 s → 0.33 s on an M1). Also **task #96**: DCTFilter built from source at r3.2 with `patches/dctfilter-r3.2-thread-safety.patch` (upstream's c924a7a) on every platform (Windows: Zig build replacing the r2 release DLL; macOS x64: replacing Stefan-Olt's r2.1; macOS arm64/Linux: pinned, were unpinned HEAD, the same code). r2/r2.1 aborted about one run in a hundred under threads (0xC0000409 on Windows). Same output sample for sample; file names unchanged. Also **task #98**: DFTTest (bc5e018; macOS arm64 yuygfgg's fork e6f580a), LGhost r1, CTMF r5, TCanny 14ac2ce and (macOS arm64, Linux) EEDI3m r10 built from source with `patches/<plugin>-<ver>-thread-safety.patch`, which locks their per-thread buffer maps (aborts with `unordered_map::at` / 0xC0000409) and marks the plugin's name; replaces the Windows release DLLs, Stefan-Olt's macOS prebuilts, yuygfgg's arm64 DFTTest and Stefan-Olt's Linux x64 LGhost. Same output (macOS measured); file names unchanged. macOS arm64's FFmpeg is now pinned to martin-riedl build 1789931890 (9.0.2, the binary rc2 shipped) after `latest` moved to 9.1. Also **task #103**: Linux VapourSynth's statically linked zimg (R78's `subprojects/zimg.wrap`, `revision = HEAD`) pinned to 67e06032 / graphengine cb5b2ce1, what rc2's build cloned; rc3's first Linux build had cloned master's `e2e43d09` and aborted in every resize ("double free or corruption"), so rc3's Linux assets were replaced with the pinned build. **rc4** (task #101): `patches/dfttest-bc5e018-fftw-estimate.patch`, applied after task #98's, makes DFTTest plan with FFTW_ESTIMATE instead of FFTW_PATIENT (PATIENT timed its plans per process, so on x86 a preview and its encode could differ by 1-2 levels); marker `FFTW_ESTIMATE, task #101` in its name. File names unchanged |
32 changes: 22 additions & 10 deletions Scripts/download-deps-linux.sh
Original file line number Diff line number Diff line change
Expand Up @@ -845,16 +845,27 @@ build_plugin() {
# of this script) is removed so build_plugin builds it again, and the script
# fails if the marker is missing afterwards. Keep the pins in step with
# download-deps-macos.sh and download-deps-windows.ps1.
# Task #101: DFTTest also takes patches/dfttest-bc5e018-fftw-estimate.patch,
# applied after the thread-safety one (its context is that patch's name line),
# which plans with FFTW_ESTIMATE instead of FFTW_PATIENT (PATIENT timed its
# plans per process, so a preview and its encode could filter differently)
# and adds DFTTEST_MARKER to the name: drop_unpatched / require_patched take
# it as a second marker for libdfttest.so.
TASK98_MARKER="locked per-thread buffers, task #98"
drop_unpatched() { # <plugin file>
if [ -f "$PLUGINS_DIR/$1" ] && ! grep -aqF "$TASK98_MARKER" "$PLUGINS_DIR/$1"; then
echo " $1 predates task #98's thread-safety patch; rebuilding it"
DFTTEST_MARKER="FFTW_ESTIMATE, task #101"
has_markers() { # <plugin file> [extra marker]
grep -aqF "$TASK98_MARKER" "$PLUGINS_DIR/$1" 2>/dev/null || return 1
[ -z "${2:-}" ] || grep -aqF "$2" "$PLUGINS_DIR/$1" 2>/dev/null
}
drop_unpatched() { # <plugin file> [extra marker]
if [ -f "$PLUGINS_DIR/$1" ] && ! has_markers "$1" "${2:-}"; then
echo " $1 predates its patches (task #98${2:+, $2}); rebuilding it"
rm -f "$PLUGINS_DIR/$1"
fi
}
require_patched() { # <plugin file>
if ! grep -aqF "$TASK98_MARKER" "$PLUGINS_DIR/$1" 2>/dev/null; then
echo " ERROR: $1 is missing or lacks task #98's thread-safety patch" >&2
require_patched() { # <plugin file> [extra marker]
if ! has_markers "$1" "${2:-}"; then
echo " ERROR: $1 is missing or lacks its patches (task #98${2:+, $2})" >&2
exit 1
fi
}
Expand Down Expand Up @@ -1028,14 +1039,15 @@ else
echo " fmtconv already exists, skipping"
fi

# DFTTest (FFT-based denoising), pinned with task #98's patch.
drop_unpatched "libdfttest.so"
# DFTTest (FFT-based denoising), pinned with task #98's patch and then task
# #101's FFTW_ESTIMATE patch, in that order.
drop_unpatched "libdfttest.so" "$DFTTEST_MARKER"
build_plugin "dfttest" \
"https://github.com/HomeOfVapourSynthEvolution/VapourSynth-DFTTest.git" \
"libdfttest.so" \
"$(task98_patch dfttest-bc5e018-thread-safety.patch) && $PLUGIN_BUILD_ENV meson setup build --buildtype=release && ninja -C build" \
"$(task98_patch dfttest-bc5e018-thread-safety.patch) && $(task98_patch dfttest-bc5e018-fftw-estimate.patch) && $PLUGIN_BUILD_ENV meson setup build --buildtype=release && ninja -C build" \
"$DFTTEST_COMMIT"
require_patched "libdfttest.so"
require_patched "libdfttest.so" "$DFTTEST_MARKER"

# TTempSmooth (core.ttmpsm.TTempSmooth - used by havsfunc MCTemporalDenoise)
build_plugin "ttempsmooth" \
Expand Down
44 changes: 33 additions & 11 deletions Scripts/download-deps-macos.sh
Original file line number Diff line number Diff line change
Expand Up @@ -1003,7 +1003,13 @@ PYEOF
# download-deps-windows.ps1. DFTTest on arm64 is yuygfgg's fork (bc5e018 + an
# sse2neon port of the SSE2 kernels), which the bundle has always shipped
# prebuilt: upstream's scalar path gives a different picture there.
# Task #101: DFTTest also takes patches/dfttest-bc5e018-fftw-estimate.patch,
# applied after the thread-safety one (its context is that patch's name line),
# which plans with FFTW_ESTIMATE instead of FFTW_PATIENT (PATIENT timed its
# plans per process, so a preview and its encode could filter differently)
# and adds DFTTEST_MARKER to the name, required here like TASK98_MARKER.
TASK98_MARKER="locked per-thread buffers, task #98"
DFTTEST_MARKER="FFTW_ESTIMATE, task #101"
DFTTEST_COMMIT="bc5e0186a7f309556f20a8e9502f2238e39179b8" # r7 + 2; no later tag
DFTTEST_ARM64_COMMIT="e6f580aac37d3f8900c2a52b154ce75bf629c9bd" # yuygfgg/VapourSynth-DFTTest
LGHOST_TAG="r1"
Expand Down Expand Up @@ -1825,12 +1831,24 @@ fi
# sse2neon SSE2 kernels with its own -Ofast. Hidden visibility, as meson builds
# them: exported template code is merged by dyld with any other image's copy.
FFTW_INC="$(brew --prefix fftw)/include"
build_task98_plugin() { # <Dir> <repo> <ref> <patch> <out dylib> <arm64 sources> <arm64 flags> [libs...]
local dir="$1" repo="$2" ref="$3" patch="$4" out="$5" arm_sources="$6" arm_flags="$7"
# Every marker a build of <out dylib> must carry: TASK98_MARKER, and for
# DFTTest also DFTTEST_MARKER (task #101), so a thread-safe build that still
# plans with FFTW_PATIENT is rebuilt, never shipped.
task98_has_markers() { # <dylib path>
grep -aqF "$TASK98_MARKER" "$1" 2>/dev/null || return 1
if [ "$(basename "$1")" = libdfttest.dylib ]; then
grep -aqF "$DFTTEST_MARKER" "$1" 2>/dev/null || return 1
fi
return 0
}
# <patches> is a space-separated list under patches/, applied in order; the
# build fails if any of them does not apply.
build_task98_plugin() { # <Dir> <repo> <ref> <patches> <out dylib> <arm64 sources> <arm64 flags> [libs...]
local dir="$1" repo="$2" ref="$3" patches="$4" out="$5" arm_sources="$6" arm_flags="$7"
shift 7
local libs=("$@")
cd "$BUILD_DIR"
if [ "$FORCE" = false ] && grep -aqF "$TASK98_MARKER" "$PLUGINS_DIR/$out" 2>/dev/null; then
if [ "$FORCE" = false ] && task98_has_markers "$PLUGINS_DIR/$out"; then
echo " $dir (patched, task #98) already exists, skipping"
return 0
fi
Expand All @@ -1842,10 +1860,13 @@ build_task98_plugin() { # <Dir> <repo> <ref> <patch> <out dylib> <arm64 sources
echo " ERROR: could not fetch $dir at $ref" >&2
exit 1
fi
(cd "$src" && git apply "$SCRIPT_DIR/patches/$patch") || {
echo " ERROR: patches/$patch did not apply to $dir $ref - re-check the patch." >&2
exit 1
}
local patch
for patch in $patches; do
(cd "$src" && git apply "$SCRIPT_DIR/patches/$patch") || {
echo " ERROR: patches/$patch did not apply to $dir $ref - re-check the patch." >&2
exit 1
}
done
local upper
upper=$(echo "$dir" | tr '[:lower:]' '[:upper:]')
local cxx=(c++ -std=c++17 -O3 -fPIC -fvisibility=hidden -fno-math-errno -fno-trapping-math
Expand Down Expand Up @@ -1884,8 +1905,8 @@ build_task98_plugin() { # <Dir> <repo> <ref> <patch> <out dylib> <arm64 sources
install_name_tool -change "$ref" "@loader_path/../../lib/$(basename "$ref")" "$PLUGINS_DIR/$out"
done
codesign -s - -f "$PLUGINS_DIR/$out" 2>/dev/null || true
grep -aqF "$TASK98_MARKER" "$PLUGINS_DIR/$out" || {
echo " ERROR: $out lacks the task #98 marker" >&2
task98_has_markers "$PLUGINS_DIR/$out" || {
echo " ERROR: $out lacks the task #98 marker (or, for DFTTest, task #101's)" >&2
exit 1
}
echo " Built $dir -> $out"
Expand All @@ -1894,12 +1915,13 @@ build_task98_plugin() { # <Dir> <repo> <ref> <patch> <out dylib> <arm64 sources

if [ "$ARCH" = "arm64" ]; then
build_task98_plugin DFTTest https://github.com/yuygfgg/VapourSynth-DFTTest.git \
"$DFTTEST_ARM64_COMMIT" dfttest-bc5e018-thread-safety.patch libdfttest.dylib \
"$DFTTEST_ARM64_COMMIT" "dfttest-bc5e018-thread-safety.patch dfttest-bc5e018-fftw-estimate.patch" libdfttest.dylib \
"DFTTest.cpp DFTTest_SSE2.cpp VCL2/instrset_detect.cpp" "-Ofast -ftree-vectorize" \
"$LIB_DIR/libfftw3f.3.dylib" "$LIB_DIR/libfftw3f_threads.3.dylib"
else
build_task98_plugin DFTTest https://github.com/HomeOfVapourSynthEvolution/VapourSynth-DFTTest.git \
"$DFTTEST_COMMIT" dfttest-bc5e018-thread-safety.patch libdfttest.dylib "" "" \
"$DFTTEST_COMMIT" "dfttest-bc5e018-thread-safety.patch dfttest-bc5e018-fftw-estimate.patch" \
libdfttest.dylib "" "" \
"$LIB_DIR/libfftw3f.3.dylib" "$LIB_DIR/libfftw3f_threads.3.dylib"
fi
build_task98_plugin LGhost https://github.com/HomeOfVapourSynthEvolution/VapourSynth-LGhost.git \
Expand Down
Loading
Loading