mirror of
https://github.com/opencv/opencv.git
synced 2026-09-11 04:43:22 -05:00
imgproc: optimize PyrDownVecH<uchar,int,3> using v_load_deinterleave - #29811 **Summary:** - buildPyramid on Windows-ARM64 (1920×1080, 8UC3) was ~7× slower than x64. - Root cause: PyrDownVecH<uchar,int,3> used vx_lut_quads to gather pixels, which on NEON compiles to 80 scalar byte reads per SIMD iteration filling a stack buffer one byte at a time before loading it as a vector. The SIMD unit was effectively idle. **Root Cause:** - The 3-channel horizontal pass needs 5 non-contiguous source pixels per output pixel. The existing code precomputes byte-offset index arrays and calls vx_lut_quads(src, idx) five times per loop body. On NEON, vx_lut_quads is implemented as 16 individual scalar reads → vld1q_s8, so 5 calls = 80 scalar loads producing only 12 int32 outputs. **Fix:** - Replace the gather loop with v_load_deinterleave, which maps to vld3q_u8 on AArch64 — single instruction, loads 48 bytes and hardware-deinterleaves R/G/B in one shot **Performance Benchmarks:** <img width="1021" height="536" alt="image" src="https://github.com/user-attachments/assets/6c4b5d71-d096-4dfd-9bc4-4315d4e679af" />