mirror of
https://github.com/opencv/opencv.git
synced 2026-10-28 16:46:46 +08:00
imgproc: don’t use ippiCopySubpixIntersect for windows crossing the image border - #30363 Fixes #30301 ### Problem `ippiCopySubpixIntersect` (used by the IPP HAL for `getRectSubPix` with 8UC1→8U, 8UC1→32F and 32FC1→32F) gets two kinds of border windows wrong: 1. **The window crosses the top edge and reaches the last column** (reported in #30301): the top rows get `src(0, cols - 2)` instead of `src(0, cols - 1)`. For 1-column images this reads the element before the start of the image. 2. **8u→8u window entirely to the left of the image** (not in the original report): the fixed-point interpolation weights overflow and the result is wrong, e.g. a 1x1 image filled with 176 gives 112. This case doesn't read outside the image. ### Fix Fall back to the generic implementation only for these two cases. The window position is computed the same way IPP does it (`(int)(x + w) - w`, which differs from `cvFloor()` for some inputs), as suggested by @andreyfe1. All other windows, including about 69% of the windows that cross the border, still go through IPP. ### Testing - Added `Imgproc_GetRectSubPix.regression_30301`: 3 cases (top-right crossing, 1-column image, window left of the image) × 3 type combinations, with the images as ROIs of a 250-filled buffer. It fails on 7 of 9 checks without the patch. - Compared IPP on vs off with IPPICV 2026.1.0: a grid sweep over 26M windows, plus on both the AVX2 and SSE4.2 paths random images up to 64x64 with windows up to 48x48 and far-away centers (16M), centers within a few ulps of every integer window position (35M), and images placed next to a PROT_NONE page so any out-of-image read crashes (31M). No differences and no crashes with the patch; without it the guard-page run crashes on case 1. - `opencv_test_imgproc`: no new failures.