-
Notifications
You must be signed in to change notification settings - Fork 103
/
faster_corner_utilities.h
46 lines (40 loc) · 1.18 KB
/
faster_corner_utilities.h
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
#ifndef CVD_INTERNAL_INC_FAST_CORNER_UTILITIES_H
#define CVD_INTERNAL_INC_FAST_CORNER_UTILITIES_H
#include <emmintrin.h>
namespace CVD
{
struct Less
{
template <class T1, class T2> static bool eval(const T1 a, const T2 b)
{
return a < b;
}
static int prep_t(int pixel_val, int barrier)
{
return pixel_val - barrier;
}
};
struct Greater
{
template <class T1, class T2> static bool eval(const T1 a, const T2 b)
{
return a > b;
}
static int prep_t(int pixel_val, int barrier)
{
return pixel_val + barrier;
}
};
#define CHECK_BARRIER(lo, hi, other, flags) \
{ \
__m128i diff = _mm_subs_epu8(lo, other); \
__m128i diff2 = _mm_subs_epu8(other, hi); \
__m128i z = _mm_setzero_si128(); \
diff = _mm_cmpeq_epi8(diff, z); \
diff2 = _mm_cmpeq_epi8(diff2, z); \
flags = ~(_mm_movemask_epi8(diff) | (_mm_movemask_epi8(diff2) << 16)); \
}
template <bool Aligned> inline __m128i load_si128(const void* addr) { return _mm_loadu_si128((const __m128i*)addr); }
template <> inline __m128i load_si128<true>(const void* addr) { return _mm_load_si128((const __m128i*)addr); }
}
#endif