Pratham Kumar a9dea1e4a4 Merge pull request #29811 from pratham-mcw:buildPyramid_opt
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" />
2026-09-01 10:07:11 +03:00
2020-02-26 15:12:45 +03:00
2026-07-09 12:35:42 +03:00
2018-10-11 17:57:51 +00:00
2025-08-01 09:50:10 +03:00

OpenCV: Open Source Computer Vision Library

Resources

Contributing

Please read the contribution guidelines before starting work on a pull request.

Summary of the guidelines:

  • One pull request per issue;
  • Choose the right base branch;
  • Include tests and documentation;
  • Clean up "oops" commits before submitting;
  • Follow the coding style guide.

Additional Resources

Description
Languages
C++ 87.6%
C 3.2%
Python 2.9%
CMake 2%
Java 1.5%
Other 2.6%