Repository navigation
perf(filter): optimize three_point_balance, colorenhance, hueshift0r, sopsat, and sigmoidaltransfer - #341
Open
Quantum-Quasar wants to merge 5 commits into
Open
perf(filter): optimize three_point_balance, colorenhance, hueshift0r, sopsat, and sigmoidaltransfer#341Quantum-Quasar wants to merge 5 commits into
Quantum-Quasar wants to merge 5 commits into
Conversation
added 5 commits
November 26, 2026 15:08
Eliminate column-major cache thrashing (stride width*4 bytes per pixel) by switching to row-major traversal with memcpy for the unmodified split preview half. Cache stack-computed uint8 LUTs on the instance and only rebuild when color parameters change, with 4x unrolled uint32 pixel packing. Verified 0 max-abs-diff against baseline on 1080p and 4K across all preview modes (1080p ~4.2x, 4K ~14.4x).
…SSE2 Skip rebuilding the 4x256 pow() lookup tables on every frame when parameters are unchanged, store LUTs inline instead of heap-allocating, precompute weighted luma and double channel LUTs, and vectorize the Rec. 709 saturation loop 2 pixels at a time with bit-exact SSE2 double arithmetic and packed uint32 stores. Verified 0 max-abs-diff against baseline on 1080p and 4K (~2.5x).
Eliminate the redundant full-frame memcpy before applymatrix and vectorize the 3x3 floating-point color matrix multiplication and [0, 255] saturation 4 pixels at a time with SSE2. Verified 0 max-abs-diff against baseline on 1080p and 4K (~2.1-2.2x).
…th SSE2 Precompute 0.299*r, 0.587*g, 0.114*b double LUTs and a packed uint32 sigmoid RGB LUT on the instance, and vectorize the Rec. 601 luma sum 2 pixels at a time with bit-exact SSE2 double arithmetic. Verified 0 max-abs-diff against baseline on 1080p and 4K (~1.5x).
… Halley cbrtf Vectorize the entire RGB->XYZ->Oklab->LUT->XYZ->RGB pipeline 4 pixels at a time in SoA SSE2. Replace scalar libm cbrtf with a 2-iteration Halley SSE2 approximation guarded by an integer-boundary check (falling back to exact libm cbrtf only when any lane lies within 0.002 of an integer boundary), and replace scalar powf(x, 3) with exact double-precision SSE2 cubing. Verified 0 max-abs-diff against baseline on 1080p and 4K (~5.6x).
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 five color grading plugins:three_point_balance: Switch from column-major (width * 4stride) to row-major traversal, cache stack-computeduint8_t[256]LUTs with dirty tracking, and 4×-unrolluint32_tpacking.colorenhance: Add a 4-pixel SoA SSE2 Oklab pipeline with a boundary-guarded 2-iteration Halley SSE2cbrtf(falling back to libmcbrtfwithin0.002of an integer boundary for 0 max-abs-diff) and double-precision SSE2 cubing.hueshift0r: Eliminate redundant full-framememcpyand fuse into a single-pass 4-pixel SSE2 3×3 hue-rotation matrix multiply.sopsat: Cache LUTs across frames with parameter dirty-checking, precompute weighted Rec. 709 double luma/channel LUTs, and vectorize 2 pixels at a time with SSE2.sigmoidaltransfer: Precompute double-precision Rec. 601 luma LUTs + packeduint32_tsigmoid RGB LUT and vectorize 2 pixels at a time with SSE2.Benchmarks (3-Run Median, 1080p & 4K RGBA8888, GCC 12.2.0 Release)
three_point_balancecolorenhancehueshift0rsopsatsigmoidaltransferVerification
max_abs_diff = 0against baseline.sobuilds across all tested presets at 1080p and 4K.ctesttargets pass.