Files
opencv-MIRROR/modules
pranayr710 afa5b1b5f3 core: saturate cv::absdiff on CV_64S instead of letting it return a negative
getAbsdiffFunc_() documents that a signed depth has two outputs: R == T, the saturating |a-b| kept
in the signed range, which is the depth cv::absdiff returns; and R == the unsigned type of the same
width. CV_8S, CV_16S and CV_32S each have both. CV_64S only had the unsigned one, so the signed
form fell through to a path that wraps:

    absdiff(INT64_MIN, 0)         -> -9223372036854775808
    absdiff(INT64_MIN, INT64_MAX) -> -1

at every length, scalar included, in a CV_64S destination. The narrower depths all saturate at
their maximum: absdiff(INT_MIN, INT_MAX) on CV_32S is INT_MAX.

The missing row now uses EwAbsdiffS, whose scalar step gains a 64-bit overload. The generic one
widens into the work type, which the narrower depths have (short, int, int64_t) and 64-bit does not,
and |INT64_MIN - b| does not fit in int64_t anyway. The difference is therefore taken in uint64,
which is exact for every pair, and clamped to INT64_MAX. The narrower depths reach that overload
only through their int64 work type, where |a - b| is at most 2^32 and the clamp is a no-op.

Core_AbsdiffSigned checks both properties - never negative, and saturating at the depth's maximum -
across CV_8S, CV_16S, CV_32S and CV_64S.
2026-10-21 09:49:45 +03:00
..
2026-07-09 12:17:24 +03:00
2026-07-09 12:17:24 +03:00
2026-08-19 17:38:39 +02:00