Skip to content

perf(filter): optimize perspective, lenscorrection, defish0r, and c0rners remap kernels - #345

Open
Quantum-Quasar wants to merge 4 commits into
dyne:masterfrom
Quantum-Quasar:perf/spatial-remap-wave3
Open

Quantum-Quasar wants to merge 4 commits into
dyne:masterfrom
Quantum-Quasar:perf/spatial-remap-wave3

Conversation

@Quantum-Quasar

Copy link
Copy Markdown

Summary

Bit-exact (max_abs_diff = 0) CPU rendering optimizations for four geometric remapping and distortion plugins:

  • perspective & lenscorrection: Cache dirty-tracked int32_t coordinate remap tables across frames when parameters are unchanged (avoiding per-frame floating-point transforms and lrint() libm calls), plus memset zero-fill in perspective.
  • defish0r & c0rners (interp.h): Devirtualize remap32() outside the pixel loop (eliminating per-pixel indirect function pointer calls), replace per-pixel floorf/ceilf/roundf libm calls with exact inline integer truncation/adjustment, and vectorize NN, Bilinear, Bicubic Smooth (Aitken-Neville), and Bicubic Sharp (Helmut Dersch) across all 4 RGBA channels with SSE2 __m128.

Benchmarks (3-Run Median, 1080p & 4K RGBA8888, GCC 12.2.0 Release)

Plugin / Mode 1080p Base 1080p Opt 1080p Speedup 4K Base 4K Opt 4K Speedup MaxDiff
perspective 10.028 ms 1.286 ms 7.8× 43.083 ms 11.335 ms 3.8× 0
lenscorrection 7.627 ms 1.675 ms 4.6× 43.551 ms 16.310 ms 2.7× 0
c0rners (Bicubic Smooth) 227.099 ms 64.893 ms 3.5× 905.519 ms 266.645 ms 3.4× 0
c0rners (Bilinear) 36.119 ms 10.921 ms 3.3× 146.989 ms 44.111 ms 3.3× 0
defish0r (Bicubic Smooth) 251.742 ms 74.714 ms 3.4× 1007.315 ms 292.057 ms 3.4× 0
defish0r (Bilinear) 40.235 ms 13.468 ms 3.0× 174.186 ms 52.103 ms 3.3× 0
defish0r (Bicubic Sharp) 117.903 ms 66.129 ms 1.8× 476.525 ms 263.422 ms 1.8× 0

Verification

  • Verified max_abs_diff = 0 against baseline .so builds on both 1080p and 4K RGBA frames across 3 consecutive frames.
  • Clean Release build with zero compiler warnings.

This branch has not been deployed

No deployments
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant