Skip to content

cudaarithm: fix absdiff for CV_32S minimum value - #4237

Open
sridhar-git05 wants to merge 1 commit into
opencv:5.xfrom
sridhar-git05:fix-cuda-absdiff-int-min-4212
Open

sridhar-git05 wants to merge 1 commit into
opencv:5.xfrom
sridhar-git05:fix-cuda-absdiff-int-min-4212

Conversation

@sridhar-git05

Copy link
Copy Markdown

Fix cv::cuda::absdiff for CV_32S when the subtraction result exceeds the signed 32-bit range.

The previous implementation performed the subtraction in int before taking the absolute value, causing overflow for cases involving INT_MIN.

The fix widens the subtraction to long long, computes the absolute difference safely, and saturates the result to INT_MAX.

Regression coverage is added for INT_MIN in both operand orders.

Fixes #4212.

Pull Request Readiness Checklist

See details at https://github.com/opencv/opencv/wiki/How_to_contribute#making-a-good-pull-request

  • I agree to contribute to the project under Apache 2 License.
  • To the best of my knowledge, the proposed patch is not based on a code under GPL or another license that is incompatible with OpenCV
  • The PR is proposed to the proper branch
  • There is a reference to the original bug report and related work
  • There is accuracy test, performance test and test data in opencv_extra repository, if applicable
    Patch to opencv_extra has the same branch name.
  • The feature is well documented and sample code can be built with the project CMake

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

1 participant