Files
opencv-MIRROR/modules/imgproc
Madan mohan Manokar be44bb6112 Port 4.x faster bit-exact BGR(A)2GRAY on x86 AVX-512 to 5.x (#30962)
* imgproc: bit-exact BGR(A)2GRAY on AVX-512 (5.x)

Port of https://github.com/opencv/opencv/pull/29848.
5.x already dispatches color_rgb through AVX512_ICL, but the uchar RGB2Gray kernel was still the universal SIMD path. Use vpmaddwd for BGRA and vpermb+vpmaddwd for BGR, and keep that kernel as the fallback.

* imgproc: fix AVX-512 RGB2Gray tail for overlapping buffers (5.x)

Additional fixes.

- Take the AVX-512 kernels only when the source and destination byte ranges are disjoint. The clamped final block re-reads source pixels, and an overlapping store can overwrite them (src == dst, or a 1-channel dst that starts 1-3 bytes into the source). Those cases use the existing fallback.
- Use 'i <= n - 16' as the loop bound so the check cannot overflow for very large rows.
- Add exact integer-reference tests for CV_8UC4 BGRA2GRAY and RGBA2GRAY at widths 1-263 with random alpha, and aliased-storage tests at widths 15-33.

* imgproc: scalar tail for overlapping BGR(A)2GRAY buffers (5.x)

Rewinding the final vector block re-reads source pixels already overwritten when dst overlaps src. Use the scalar tail for overlapping buffers, and test widths 63-129 on both the dispatched and baseline paths.

* imgproc: tidy BGRA/RGBA2GRAY 4ch tests (5.x)

- Use the shared theRNG() instead of fixed seeds
- Reduce exact-check widths to 1, 16, 17, 263

* imgproc: drop BGRA/RGBA2GRAY 4ch tests (5.x)

- Existing BGRA2GRAY/RGBA2GRAY bit-exact tests already cover color conversion
- Remove the 4ch exact and aliased checks added in this branch

* imgproc: check buffer overlap once in RGB2Gray float/ushort (5.x)
2026-11-26 10:21:24 +05:30
..
2024-10-13 03:25:24 +03:00