Repository navigation
perf(filter): optimize select0r, keyspillm0pup, and alpha0ps keying/alpha plugins - #342
Open
Quantum-Quasar wants to merge 3 commits into
Open
Quantum-Quasar wants to merge 3 commits into
Quantum-Quasar wants to merge 3 commits into
Conversation
added 3 commits
November 26, 2026 15:08
…iled SSE2 Replace per-frame calloc/free of w*h*16 bytes (33 MB at 1080p, 132 MB at 4K) and 4 full-frame memory passes with an L1-resident 256-pixel stack tile. Vectorize RGB and ABI subspace selection, inversion, and all 5 alpha compositing operations 4 pixels at a time with SSE2, preserving double-precision 0.3333 ABI intensity scaling for bit-exactness. Verified 0 max-abs-diff against baseline on 1080p and 4K across all subspaces, shapes, edge modes, and alpha operations (1080p ~5.1x, 4K ~10.5x).
…ct hue-gate pruning Eliminate per-frame 41 MB/165 MB calloc/free buffers (sl and mask) for RGB-distance and transparency masks and cache the edge-mask buffer on the instance. Fuse mask evaluation, hue gating, saturation thresholding, and color ops into a single pass with SSE2 4-pixel RGB-distance fast-reject, opposite-quadrant and early sat_thres pruning, hardware double-precision sqrt (bit-exact to hypotf), and exact dot-product fast-accept/reject before atan2f. Verified 0 max-abs-diff against baseline on 1080p and 4K across all 4 mask types and all ops (1080p ~1.9x, 4K ~2.1x).
- alpha0ps_alpha0ps: cache scratch float buffers on instance, swap pointers instead of full-frame copy-back, zero only borders, vectorize shave/shrink/grow and alpha pack/unpack with SSE2, add zero-alloc fast path for NOP/threshold, and eliminate per-pixel division in checkerboard. - alpha0ps_alphagrad: shrink gradient mask from uint32 to uint8 (4x less memory), skip redundant fill_grad on op-only changes, vectorize all 5 alpha ops with SSE2. - alpha0ps_alphaspot: eliminate redundant memcpy pass by fusing into single-pass SSE2 alpha compositing, skip redundant draw on op-only changes. Verified 0 max-abs-diff across all presets on 1080p and 4K.
This branch has not been deployed
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
Bit-exact (
max_abs_diff = 0) CPU rendering optimizations for Kdenlive's core keying and alpha-channel plugins:select0r(Chroma Key Advanced): Replace per-frame 33 MB (1080p) / 132 MB (4K)calloc/freefloat buffer and 4 full-frame passes with an L1-resident 256-pixel stack tile and 4-pixel SSE2 vectorization for RGB/ABI selection, inversion, and all 5 alpha compositing ops.keyspillm0pup: Eliminate per-frame 41 MB / 165 MBcalloc/freeallocations (sl+mask), fuse pointwise masks into a zero-alloc single pass with SSE2 4-pixel RGB-distance fast-reject, cache the edge-mask buffer on the instance, replacehypotfwith bit-exact double-precision hardwaresqrt, and pruneatan2fvia earlysat_thres, opposite-quadrant rejection, and exact dot-product guards.alpha0ps(alpha0ps_alpha0ps,alpha0ps_alphagrad,alpha0ps_alphaspot): Eliminate per-frame 16 MB / 64 MBcalloc/freeand copy-back via cached buffers + pointer swapping + SSE2 stencil/pack; shrinkalphagradmask fromuint32_ttouint8_t(4× less memory) with SSE2 alpha ops; fusealphaspotmemcpy+ alpha pass into single-pass SSE2.Benchmarks (3-Run Median, 1080p & 4K RGBA8888, GCC 12.2.0 Release)
select0ralpha0ps_alpha0pskeyspillm0pupalpha0ps_alphagradalpha0ps_alphaspotVerification
max_abs_diff = 0against baseline.sobuilds across all tested modes/presets at 1080p and 4K.ctesttargets pass.