mirror of
https://github.com/opencv/opencv.git
synced 2026-11-30 21:32:07 -06:00
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.