From 183c75358b856052453af7d3a9d4e8eecc6e9ef0 Mon Sep 17 00:00:00 2001 From: Alexander Alekhin Date: Tue, 8 Nov 2016 15:44:52 +0300 Subject: [PATCH] imgproc: fix trailingZeros for MSVS 2010 --- modules/imgproc/src/contours.cpp | 10 ++++++++-- 1 file changed, 8 insertions(+), 2 deletions(-) diff --git a/modules/imgproc/src/contours.cpp b/modules/imgproc/src/contours.cpp index 4c78621408..0adc01b1a7 100644 --- a/modules/imgproc/src/contours.cpp +++ b/modules/imgproc/src/contours.cpp @@ -50,10 +50,15 @@ static const CvPoint icvCodeDeltas[8] = { CvPoint(1, 0), CvPoint(1, -1), CvPoint(0, -1), CvPoint(-1, -1), CvPoint(-1, 0), CvPoint(-1, 1), CvPoint(0, 1), CvPoint(1, 1) }; +#if CV_SSE2 +static inline unsigned int trailingZeros(unsigned int value) { + CV_DbgAssert(value != 0); // undefined for zero input (https://en.wikipedia.org/wiki/Find_first_set) #if defined(_MSC_VER) -#if (_MSC_VER < 1500) - return _BitScanForward(value); +#if (_MSC_VER < 1700) + unsigned long index = 0; + _BitScanForward(&index, value); + return (unsigned int)index; #else return _tzcnt_u32(value); #endif @@ -70,6 +75,7 @@ inline unsigned int trailingZeros(unsigned int value) { return MultiplyDeBruijnBitPosition[((uint32_t)((value & -value) * 0x077CB531U)) >> 27]; #endif } +#endif CV_IMPL void cvStartReadChainPoints( CvChain * chain, CvChainPtReader * reader ) -- GitLab