Files
opencv-MIRROR/modules
shivensolanki 413798a1b4 core: fix NORM_L2 overflow for CV_16S and CV_32S at the type minimum
The SIMD kernels of cv::norm(src, NORM_L2/NORM_L2SQR) for CV_16S and CV_32S
sum adjacent squares in a type that is too narrow for the most negative value:

- CV_16S: the int16 dot product accumulates pairs in int32, and
  (-32768)^2 + (-32768)^2 = 2^31 wraps to INT_MIN.
- CV_32S: the int32 dot product accumulates pairs in int64, and
  INT_MIN^2 + INT_MIN^2 = 2^63 wraps to INT64_MIN.

As a result NORM_L2SQR could return a negative value and NORM_L2 NaN, but
only for inputs long enough to reach the vector loop. Masked norm and
norm(src1, src2) were not affected.

Widen the int16 pairwise sums as unsigned (they always fit into uint32) and
square int32 values in double. Performance is unchanged.
2026-10-20 03:31:31 +00:00
..
2026-04-28 12:30:06 +02:00