vil_math_sse.h
Go to the documentation of this file.
1 // This is core/vil/vil_math_sse.h
2 #ifndef vil_math_sse_h_
3 #define vil_math_sse_h_
4 
5 #ifndef vil_math_h_
6 #error "This header cannot be included directly, only through vil_math.h"
7 #endif
8 
9 //:
10 // \file
11 // \brief Various mathematical manipulations of 2D images implemented with SSE
12 // intrinsic functions
13 // \author Chuck Atkins
14 
15 // To add a new optimized implementation for a different set of types:
16 //
17 // 1. Add a call to VIL_MATH_IMAGE_ABS_DIFF_1D_SSE_SPECIALIZE_DECL for the
18 // new combination of types the implementation is defined for. This will
19 // declare the prototype for the specialization.
20 // 2. Add a call to VIL_MATH_IMAGE_ABS_DIFF_1D_SSE_SPECIALIZE_IMPL for the
21 // new combination of types the implementation is defined for. This will
22 // implement the outer function which calls the SSE optimized function for
23 // the right set of types.
24 // 3. Add the implementation for vil_math_image_abs_difference_1d_sse
25 // specialized for the new type combination in vil_math_sse.hxx
26 //
27 // Note:
28 // The types need not all three be the same so long as the specialization
29 // of vil_math_image_abs_difference_1d_sse in vil_math_sse.hxx is implemented
30 // for the defined combination of types
31 
32 
33 //: Compute absolute difference of two 1D images (imD = |imA-imB|)
34 template<class aT, class bT, class dT>
36  const aT* pxA, std::ptrdiff_t isA,
37  const bT* pxB, std::ptrdiff_t isB,
38  dT* pxD, std::ptrdiff_t isD,
39  unsigned len);
40 
41 template<class aT, class bT, class dT>
43  const aT* pxA, const bT* pxB, dT* pxD,
44  unsigned len);
45 
46 template<class aT, class bT, class dT>
48  const aT* pxA, std::ptrdiff_t isA,
49  const bT* pxB, std::ptrdiff_t isB,
50  dT* pxD, std::ptrdiff_t isD,
51  unsigned len);
52 
53 #define VIL_MATH_IMAGE_ABS_DIFF_1D_SSE_SPECIALIZE_DECL(aT,bT,dT) \
54 template<> \
55 void vil_math_image_abs_difference_1d_sse<aT,bT,dT>( \
56  const aT* pxA, const bT* pxB, dT* pxD, \
57  unsigned len); \
58 template<> \
59 void vil_math_image_abs_difference_1d<aT,bT,dT>( \
60  const aT* pxA, std::ptrdiff_t isA, \
61  const bT* pxB, std::ptrdiff_t isB, \
62  dT* pxD, std::ptrdiff_t isD, \
63  unsigned len);
64 
65 VIL_MATH_IMAGE_ABS_DIFF_1D_SSE_SPECIALIZE_DECL(vxl_byte,vxl_byte,vxl_byte)
67 
68 #undef VIL_MATH_IMAGE_ABS_DIFF_1D_SSE_SPECIALIZE_DECL
69 
70 #define VIL_MATH_IMAGE_ABS_DIFF_1D_SSE_SPECIALIZE_IMPL(aT,bT,dT) \
71 template<> \
72 inline void vil_math_image_abs_difference_1d<aT,bT,dT>( \
73  const aT* pxA, std::ptrdiff_t isA, \
74  const bT* pxB, std::ptrdiff_t isB, \
75  dT* pxD, std::ptrdiff_t isD, \
76  unsigned len) \
77 { \
78  if (isA == 1 && isB == 1 && isD == 1) \
79  { \
80  vil_math_image_abs_difference_1d_sse<aT,bT,dT>(pxA, pxB, pxD, len); \
81  } \
82  else \
83  { \
84  vil_math_image_abs_difference_1d_generic<aT,bT,dT>( \
85  pxA, isA, pxB, isB, pxD, isD, len); \
86  } \
87 }
88 
89 VIL_MATH_IMAGE_ABS_DIFF_1D_SSE_SPECIALIZE_IMPL(vxl_byte,vxl_byte,vxl_byte)
91 
92 #undef VIL_MATH_IMAGE_ABS_DIFF_1D_SSE_SPECIALIZE_IMPL
93 
94 #endif
#define VIL_MATH_IMAGE_ABS_DIFF_1D_SSE_SPECIALIZE_IMPL(aT, bT, dT)
Definition: vil_math_sse.h:70
#define VIL_MATH_IMAGE_ABS_DIFF_1D_SSE_SPECIALIZE_DECL(aT, bT, dT)
Definition: vil_math_sse.h:53
void vil_math_image_abs_difference_1d(const aT *pxA, std::ptrdiff_t isA, const bT *pxB, std::ptrdiff_t isB, dT *pxD, std::ptrdiff_t isD, unsigned len)
Compute absolute difference of two 1D images (im_sum = |imA-imB|).
Definition: vil_math.h:941
void vil_math_image_abs_difference_1d_generic(const aT *pxA, std::ptrdiff_t isA, const bT *pxB, std::ptrdiff_t isB, dT *pxD, std::ptrdiff_t isD, unsigned len)
Compute absolute difference of two 1D images (im_sum = |imA-imB|).
Definition: vil_math.h:924
void vil_math_image_abs_difference_1d_sse(const aT *pxA, const bT *pxB, dT *pxD, unsigned len)