cvd_src/faster_corner_utilities.h

00001 #ifndef CVD_INTERNAL_INC_FAST_CORNER_UTILITIES_H
00002 #define CVD_INTERNAL_INC_FAST_CORNER_UTILITIES_H
00003 
00004 #include <emmintrin.h>
00005 
00006 namespace CVD
00007 {
00008 
00009   struct Less 
00010   { 
00011     template <class T1, class T2> static bool eval(const T1 a, const T2 b) 
00012     {
00013     return a < b; 
00014     }
00015     static int prep_t(int pixel_val, int barrier)
00016     {
00017       return pixel_val - barrier;
00018     }
00019   };
00020   struct Greater 
00021   {
00022     template <class T1, class T2> static bool eval(const T1 a, const T2 b) 
00023     {
00024       return a > b; 
00025     }
00026     static int prep_t(int pixel_val, int barrier)
00027     {
00028       return pixel_val + barrier;
00029     }
00030   };
00031   
00032 #define CHECK_BARRIER(lo, hi, other, flags)             \
00033     {                                   \
00034     __m128i diff = _mm_subs_epu8(lo, other);            \
00035     __m128i diff2 = _mm_subs_epu8(other, hi);           \
00036     __m128i z = _mm_setzero_si128();                \
00037     diff = _mm_cmpeq_epi8(diff, z);                 \
00038     diff2 = _mm_cmpeq_epi8(diff2, z);               \
00039     flags = ~(_mm_movemask_epi8(diff) | (_mm_movemask_epi8(diff2) << 16)); \
00040     }
00041      
00042     template <bool Aligned> inline __m128i load_si128(const void* addr) { return _mm_loadu_si128((const __m128i*)addr); }
00043     template <> inline __m128i load_si128<true>(const void* addr) { return _mm_load_si128((const __m128i*)addr); }
00044 
00045 }
00046 #endif

Generated on Wed Feb 18 10:23:02 2009 for CVD by  doxygen 1.5.3