Repository navigation
Releases
AvsAffinity v1.1.0
AvsAffinity v1.1.0
Core Changes
- Per-instance affinity tracking & restoration: Replaced
thread_localstate with per-filter-instance thread tracking (std::shared_mutex+DuplicateHandle), restoring previous thread affinity masks whenPinWorkerThreadsis destroyed. - AviSynth+ multithreading: Added
SetCacheHints(CACHE_GET_MTMODE)returningMT_NICE_FILTERto avoid unintendedPrefetch()serialization. - Topology & input handling: Guarded
DetectPCoreMaskagainstSize == 0and Processor Group 1+ cores (Group == 0), validatedParseAffinityMaskviaerrno/endptr, treatedmask=""as auto-detect, and added[strictPrime]btoSetProcessAffinity.
Build, Testing & Docs
- 64-bit VS 2022+ focus: Removed
Win32and legacy toolset configs fromAvsAffinity.vcxproj, switched to$(DefaultPlatformToolset), and fixed CMakeARM64(/vmg /Zc:preprocessor) and resource compiler architecture defines. - Verification: Updated
tests/Test-AvsAffinity.ps1to requireAviSynth.dllupfront (with-SkipRuntimefor CI), parse PE export tables directly, and run an AviSynth+ P/Invoke frame test. - Artifacts: Prebuilt
x64andARM64binaries with SHA-256 checksums.
AvsAffinity v1.0.0: CPU Core Affinity Filter for AviSynth+
AvsAffinity v1.0.0 Release Notes
Initial public release of AvsAffinity, an open-source AviSynth+ clip filter that enforces CPU Performance core (P-core) thread affinity for multi-threaded Prefetch() pipelines across hybrid processor topologies.
Technical Overview
On hybrid processor topologies (e.g. Intel Alder/Raptor/Arrow Lake, Snapdragon ARM64, AMD Zen 4c/5c), the Windows thread scheduler can migrate compute-intensive video worker threads onto low-IPC Efficiency cores (E-cores). For real-time frame interpolation (e.g. 24 fps -> 60 fps) and heavy video filtering, this migration introduces frame presentation jitter, increased 1% low frame latency, and pipeline starvation.
AvsAffinity solves this problem at the AviSynth clip filter level:
- Worker Confinement: Uses Win32
SetThreadAffinityMaskon worker threads duringGetFrame()traversal with thread-local caching, executing exactly once per worker thread lifetime. - Preserved Host Concurrency: Host media player threads—including audio decoding, UI event loops, DXVA video acceleration, and Direct3D swapchain presentation—remain unconstrained and free to run on Efficiency cores.
- Zero State Leakage: Thread affinity terminates automatically with the AviSynth environment upon playlist transitions or file close events.
- Homogeneous Processor Bypass: When executed on processors with uniform core efficiency (e.g. Intel N100 all-E-core CPUs, standard AMD Ryzen CCDs, Snapdragon X Elite),
EfficiencyClassis identical across all logical processors. The filter detects this and executes a safe no-op (mask = 0x0) without error or modification to system affinity.
Filter Interface
PinWorkerThreads(clip c, string "mask", bool "strictPrime", bool "debug")
Intercepts GetFrame() to isolate executing AviSynth+ worker threads to Performance cores.
mask(optional, default""): Hexadecimal (e.g."0x00FF") or decimal bitmask. If omitted, discovered automatically viaGetLogicalProcessorInformationEx.strictPrime(optional, defaultfalse): On 3-tier CPUs (such as Snapdragon 8cx Gen 3 with Cortex-X1 Prime cores), restricts threads strictly to the highest efficiency tier whentrue. Whenfalse, includes all cores above baseline efficiency.debug(optional, defaultfalse): Outputs topology discovery and thread pinning events viaOutputDebugStringA.
GetPCoreMask(bool "strictPrime") -> string
Introspection function returning the detected Performance core bitmask as a hexadecimal string (e.g. "0x00FF" or "0x0" on homogeneous CPUs).
SetProcessAffinity(string "mask") -> bool
Utility function setting the global process affinity mask for command-line batch encoding pipelines (ffmpeg, avs2pipemod).
Recommended Integration Pattern
# Frame interpolation / filtering pipeline
super = MSuper(pel=1, hpad=16, vpad=16)
bvec = MAnalyse(super, isb=true, blksize=16)
fvec = MAnalyse(super, isb=false, blksize=16)
last = MFlowFps(super, bvec, fvec, num=60, den=1)
# Isolate lookahead worker threads to P-cores (with backward-compatible fallback)
last = FunctionExists("PinWorkerThreads") ? last.PinWorkerThreads() : last
# Lookahead concurrency pool
Prefetch(8, 4)
Release Artifacts & Dedicated Checksums
| Package | Architecture | Checksum Manifest |
|---|---|---|
AvsAffinity-v1.0.0-win-x64.zip |
Windows x86-64 | AvsAffinity-v1.0.0-win-x64.sha256 |
AvsAffinity-v1.0.0-win-arm64.zip |
Windows ARM64 (AArch64) | AvsAffinity-v1.0.0-win-arm64.sha256 |
AvsAffinity-v1.0.0-windows.zip |
Universal Bundle (x64 + ARM64) |
AvsAffinity-v1.0.0-windows.sha256 |
Integrity Verification (PowerShell)
# Verify an individual archive against its companion checksum file
$hash = (Get-FileHash AvsAffinity-v1.0.0-win-x64.zip -Algorithm SHA256).Hash.ToLower()
$expected = (Get-Content AvsAffinity-v1.0.0-win-x64.sha256).Split(' *')[0].ToLower()
if ($hash -eq $expected) { Write-Host "Checksum Verified" -ForegroundColor Green }