libcvd
faster_corner_utilities.h
1 #ifndef CVD_INTERNAL_INC_FAST_CORNER_UTILITIES_H
2 #define CVD_INTERNAL_INC_FAST_CORNER_UTILITIES_H
3 
4 #include <emmintrin.h>
5 
6 namespace CVD
7 {
8 
9 struct Less
10 {
11  template <class T1, class T2>
12  static bool eval(const T1 a, const T2 b)
13  {
14  return a < b;
15  }
16  static int prep_t(int pixel_val, int barrier)
17  {
18  return pixel_val - barrier;
19  }
20 };
21 struct Greater
22 {
23  template <class T1, class T2>
24  static bool eval(const T1 a, const T2 b)
25  {
26  return a > b;
27  }
28  static int prep_t(int pixel_val, int barrier)
29  {
30  return pixel_val + barrier;
31  }
32 };
33 
34 #define CHECK_BARRIER(lo, hi, other, flags) \
35  { \
36  __m128i diff = _mm_subs_epu8(lo, other); \
37  __m128i diff2 = _mm_subs_epu8(other, hi); \
38  __m128i z = _mm_setzero_si128(); \
39  diff = _mm_cmpeq_epi8(diff, z); \
40  diff2 = _mm_cmpeq_epi8(diff2, z); \
41  flags = ~(_mm_movemask_epi8(diff) | (_mm_movemask_epi8(diff2) << 16)); \
42  }
43 
44 template <bool Aligned>
45 inline __m128i load_si128(const void* addr)
46 {
47  return _mm_loadu_si128((const __m128i*)addr);
48 }
49 template <>
50 inline __m128i load_si128<true>(const void* addr) { return _mm_load_si128((const __m128i*)addr); }
51 
52 }
53 #endif
All classes and functions are within the CVD namespace.
Definition: argb.h:6
Definition: faster_corner_utilities.h:21
Definition: faster_corner_utilities.h:9