1
0
mirror of https://github.com/opencv/opencv_contrib.git synced 2025-10-18 17:24:28 +08:00

Merge pull request #2488 from shimat:fix_uwp_arm

This commit is contained in:
Alexander Alekhin
2020-04-12 17:14:32 +00:00
3 changed files with 27 additions and 14 deletions

View File

@@ -63,14 +63,14 @@ namespace
const float LSBPtau = 0.05f;
#ifdef _MSC_VER
#if defined(_MSC_VER) && !(defined(_M_ARM) || defined(_M_ARM64))
#include <intrin.h>
#pragma intrinsic(__popcnt)
#endif
inline int LSBPDist32(unsigned n) {
#if defined(__GNUC__) || defined(__clang__)
return __builtin_popcount(n);
#elif defined(_MSC_VER)
#elif defined(_MSC_VER) && !(defined(_M_ARM) || defined(_M_ARM64))
return __popcnt(n);
#else
// Taken from http://graphics.stanford.edu/~seander/bithacks.html#CountBitsSetParallel

View File

@@ -46,12 +46,20 @@
#include "precomp.hpp"
#ifdef _MSC_VER
#if defined(_M_ARM) || defined(_M_ARM64)
static inline UINT32 popcnt(UINT32 v)
{
v = v - ((v >> 1) & 0x55555555);
v = (v & 0x33333333) + ((v >> 2) & 0x33333333);
return ((v + (v >> 4) & 0xF0F0F0F) * 0x1010101) >> 24;
}
#else
# include <intrin.h>
# define popcnt __popcnt
# pragma warning( disable : 4267 )
#endif
#else
# define popcnt __builtin_popcount
#endif
/* LUT */

View File

@@ -152,17 +152,6 @@ inline cv::Rect Vec4i2Rect( cv::Vec4i &v )
}
#if defined(_MSC_VER)
# include <intrin.h>
# define POPCNT(x) __popcnt(x)
# define POPCNT64(x) (__popcnt((unsigned)(x)) + __popcnt((unsigned)((uint64_t)(x) >> 32)))
#endif
#if defined(__GNUC__)
# define POPCNT(x) __builtin_popcount(x)
# define POPCNT64(x) __builtin_popcountll(x)
#endif
inline int popcnt64( uint64_t u )
{
u = ( u & 0x5555555555555555 ) + ( ( u >> 1 ) & 0x5555555555555555 );
@@ -252,6 +241,22 @@ inline int popcnt_byte( uint32_t u )
return (int)c;
}
#if defined(_MSC_VER)
#if defined(_M_ARM) || defined(_M_ARM64)
# define POPCNT(x) popcnt((x))
# define POPCNT64(x) popcnt64((x))
#else
# include <intrin.h>
# define POPCNT(x) __popcnt(x)
# define POPCNT64(x) (__popcnt((unsigned)(x)) + __popcnt((unsigned)((uint64_t)(x) >> 32)))
#endif
#endif
#if defined(__GNUC__)
# define POPCNT(x) __builtin_popcount(x)
# define POPCNT64(x) __builtin_popcountll(x)
#endif
}
}