EstervQrCode 2.0.0
Library for qr code manipulation
Loading...
Searching...
No Matches
simd_utils.impl.hpp
1// This file is part of OpenCV project.
2// It is subject to the license terms in the LICENSE file found in the top-level directory
3// of this distribution and at http://opencv.org/license.html
4
5// This header is not standalone. Don't include directly, use "intrin.hpp" instead.
6#ifdef OPENCV_HAL_INTRIN_HPP // defined in intrin.hpp
7
8
9#if CV_SIMD128 || CV_SIMD128_CPP
10
11template<typename _T> struct Type2Vec128_Traits;
12#define CV_INTRIN_DEF_TYPE2VEC128_TRAITS(type_, vec_type_) \
13 template<> struct Type2Vec128_Traits<type_> \
14 { \
15 typedef vec_type_ vec_type; \
16 }
17
18CV_INTRIN_DEF_TYPE2VEC128_TRAITS(uchar, v_uint8x16);
19CV_INTRIN_DEF_TYPE2VEC128_TRAITS(schar, v_int8x16);
20CV_INTRIN_DEF_TYPE2VEC128_TRAITS(ushort, v_uint16x8);
21CV_INTRIN_DEF_TYPE2VEC128_TRAITS(short, v_int16x8);
22CV_INTRIN_DEF_TYPE2VEC128_TRAITS(unsigned, v_uint32x4);
23CV_INTRIN_DEF_TYPE2VEC128_TRAITS(int, v_int32x4);
24CV_INTRIN_DEF_TYPE2VEC128_TRAITS(float, v_float32x4);
25CV_INTRIN_DEF_TYPE2VEC128_TRAITS(uint64, v_uint64x2);
26CV_INTRIN_DEF_TYPE2VEC128_TRAITS(int64, v_int64x2);
27#if CV_SIMD128_64F
28CV_INTRIN_DEF_TYPE2VEC128_TRAITS(double, v_float64x2);
29#endif
30
31template<typename _T> static inline
32typename Type2Vec128_Traits<_T>::vec_type v_setall(const _T& a);
33
34template<> inline Type2Vec128_Traits< uchar>::vec_type v_setall< uchar>(const uchar& a) { return v_setall_u8(a); }
35template<> inline Type2Vec128_Traits< schar>::vec_type v_setall< schar>(const schar& a) { return v_setall_s8(a); }
36template<> inline Type2Vec128_Traits<ushort>::vec_type v_setall<ushort>(const ushort& a) { return v_setall_u16(a); }
37template<> inline Type2Vec128_Traits< short>::vec_type v_setall< short>(const short& a) { return v_setall_s16(a); }
38template<> inline Type2Vec128_Traits< uint>::vec_type v_setall< uint>(const uint& a) { return v_setall_u32(a); }
39template<> inline Type2Vec128_Traits< int>::vec_type v_setall< int>(const int& a) { return v_setall_s32(a); }
40template<> inline Type2Vec128_Traits<uint64>::vec_type v_setall<uint64>(const uint64& a) { return v_setall_u64(a); }
41template<> inline Type2Vec128_Traits< int64>::vec_type v_setall< int64>(const int64& a) { return v_setall_s64(a); }
42template<> inline Type2Vec128_Traits< float>::vec_type v_setall< float>(const float& a) { return v_setall_f32(a); }
43#if CV_SIMD128_64F
44template<> inline Type2Vec128_Traits<double>::vec_type v_setall<double>(const double& a) { return v_setall_f64(a); }
45#endif
46
47#endif // SIMD128
48
49
50#if CV_SIMD256
51
52template<typename _T> struct Type2Vec256_Traits;
53#define CV_INTRIN_DEF_TYPE2VEC256_TRAITS(type_, vec_type_) \
54 template<> struct Type2Vec256_Traits<type_> \
55 { \
56 typedef vec_type_ vec_type; \
57 }
58
59CV_INTRIN_DEF_TYPE2VEC256_TRAITS(uchar, v_uint8x32);
60CV_INTRIN_DEF_TYPE2VEC256_TRAITS(schar, v_int8x32);
61CV_INTRIN_DEF_TYPE2VEC256_TRAITS(ushort, v_uint16x16);
62CV_INTRIN_DEF_TYPE2VEC256_TRAITS(short, v_int16x16);
63CV_INTRIN_DEF_TYPE2VEC256_TRAITS(unsigned, v_uint32x8);
64CV_INTRIN_DEF_TYPE2VEC256_TRAITS(int, v_int32x8);
65CV_INTRIN_DEF_TYPE2VEC256_TRAITS(float, v_float32x8);
66CV_INTRIN_DEF_TYPE2VEC256_TRAITS(uint64, v_uint64x4);
67CV_INTRIN_DEF_TYPE2VEC256_TRAITS(int64, v_int64x4);
68#if CV_SIMD256_64F
69CV_INTRIN_DEF_TYPE2VEC256_TRAITS(double, v_float64x4);
70#endif
71
72template<typename _T> static inline
73typename Type2Vec256_Traits<_T>::vec_type v256_setall(const _T& a);
74
75template<> inline Type2Vec256_Traits< uchar>::vec_type v256_setall< uchar>(const uchar& a) { return v256_setall_u8(a); }
76template<> inline Type2Vec256_Traits< schar>::vec_type v256_setall< schar>(const schar& a) { return v256_setall_s8(a); }
77template<> inline Type2Vec256_Traits<ushort>::vec_type v256_setall<ushort>(const ushort& a) { return v256_setall_u16(a); }
78template<> inline Type2Vec256_Traits< short>::vec_type v256_setall< short>(const short& a) { return v256_setall_s16(a); }
79template<> inline Type2Vec256_Traits< uint>::vec_type v256_setall< uint>(const uint& a) { return v256_setall_u32(a); }
80template<> inline Type2Vec256_Traits< int>::vec_type v256_setall< int>(const int& a) { return v256_setall_s32(a); }
81template<> inline Type2Vec256_Traits<uint64>::vec_type v256_setall<uint64>(const uint64& a) { return v256_setall_u64(a); }
82template<> inline Type2Vec256_Traits< int64>::vec_type v256_setall< int64>(const int64& a) { return v256_setall_s64(a); }
83template<> inline Type2Vec256_Traits< float>::vec_type v256_setall< float>(const float& a) { return v256_setall_f32(a); }
84#if CV_SIMD256_64F
85template<> inline Type2Vec256_Traits<double>::vec_type v256_setall<double>(const double& a) { return v256_setall_f64(a); }
86#endif
87
88#endif // SIMD256
89
90
91#if CV_SIMD512
92
93template<typename _T> struct Type2Vec512_Traits;
94#define CV_INTRIN_DEF_TYPE2VEC512_TRAITS(type_, vec_type_) \
95 template<> struct Type2Vec512_Traits<type_> \
96 { \
97 typedef vec_type_ vec_type; \
98 }
99
100CV_INTRIN_DEF_TYPE2VEC512_TRAITS(uchar, v_uint8x64);
101CV_INTRIN_DEF_TYPE2VEC512_TRAITS(schar, v_int8x64);
102CV_INTRIN_DEF_TYPE2VEC512_TRAITS(ushort, v_uint16x32);
103CV_INTRIN_DEF_TYPE2VEC512_TRAITS(short, v_int16x32);
104CV_INTRIN_DEF_TYPE2VEC512_TRAITS(unsigned, v_uint32x16);
105CV_INTRIN_DEF_TYPE2VEC512_TRAITS(int, v_int32x16);
106CV_INTRIN_DEF_TYPE2VEC512_TRAITS(float, v_float32x16);
107CV_INTRIN_DEF_TYPE2VEC512_TRAITS(uint64, v_uint64x8);
108CV_INTRIN_DEF_TYPE2VEC512_TRAITS(int64, v_int64x8);
109#if CV_SIMD512_64F
110CV_INTRIN_DEF_TYPE2VEC512_TRAITS(double, v_float64x8);
111#endif
112
113template<typename _T> static inline
114typename Type2Vec512_Traits<_T>::vec_type v512_setall(const _T& a);
115
116template<> inline Type2Vec512_Traits< uchar>::vec_type v512_setall< uchar>(const uchar& a) { return v512_setall_u8(a); }
117template<> inline Type2Vec512_Traits< schar>::vec_type v512_setall< schar>(const schar& a) { return v512_setall_s8(a); }
118template<> inline Type2Vec512_Traits<ushort>::vec_type v512_setall<ushort>(const ushort& a) { return v512_setall_u16(a); }
119template<> inline Type2Vec512_Traits< short>::vec_type v512_setall< short>(const short& a) { return v512_setall_s16(a); }
120template<> inline Type2Vec512_Traits< uint>::vec_type v512_setall< uint>(const uint& a) { return v512_setall_u32(a); }
121template<> inline Type2Vec512_Traits< int>::vec_type v512_setall< int>(const int& a) { return v512_setall_s32(a); }
122template<> inline Type2Vec512_Traits<uint64>::vec_type v512_setall<uint64>(const uint64& a) { return v512_setall_u64(a); }
123template<> inline Type2Vec512_Traits< int64>::vec_type v512_setall< int64>(const int64& a) { return v512_setall_s64(a); }
124template<> inline Type2Vec512_Traits< float>::vec_type v512_setall< float>(const float& a) { return v512_setall_f32(a); }
125#if CV_SIMD512_64F
126template<> inline Type2Vec512_Traits<double>::vec_type v512_setall<double>(const double& a) { return v512_setall_f64(a); }
127#endif
128
129#endif // SIMD512
130
131#if CV_SIMD_SCALABLE
132template<typename _T> struct Type2Vec_Traits;
133#define CV_INTRIN_DEF_TYPE2VEC_TRAITS(type_, vec_type_) \
134 template<> struct Type2Vec_Traits<type_> \
135 { \
136 typedef vec_type_ vec_type; \
137 }
138
139CV_INTRIN_DEF_TYPE2VEC_TRAITS(uchar, v_uint8);
140CV_INTRIN_DEF_TYPE2VEC_TRAITS(schar, v_int8);
141CV_INTRIN_DEF_TYPE2VEC_TRAITS(ushort, v_uint16);
142CV_INTRIN_DEF_TYPE2VEC_TRAITS(short, v_int16);
143CV_INTRIN_DEF_TYPE2VEC_TRAITS(unsigned, v_uint32);
144CV_INTRIN_DEF_TYPE2VEC_TRAITS(int, v_int32);
145CV_INTRIN_DEF_TYPE2VEC_TRAITS(float, v_float32);
146CV_INTRIN_DEF_TYPE2VEC_TRAITS(uint64, v_uint64);
147CV_INTRIN_DEF_TYPE2VEC_TRAITS(int64, v_int64);
148#if CV_SIMD_SCALABLE_64F
149CV_INTRIN_DEF_TYPE2VEC_TRAITS(double, v_float64);
150#endif
151template<typename _T> static inline
152typename Type2Vec_Traits<_T>::vec_type v_setall(const _T& a);
153
154template<> inline Type2Vec_Traits< uchar>::vec_type v_setall< uchar>(const uchar& a) { return v_setall_u8(a); }
155template<> inline Type2Vec_Traits< schar>::vec_type v_setall< schar>(const schar& a) { return v_setall_s8(a); }
156template<> inline Type2Vec_Traits<ushort>::vec_type v_setall<ushort>(const ushort& a) { return v_setall_u16(a); }
157template<> inline Type2Vec_Traits< short>::vec_type v_setall< short>(const short& a) { return v_setall_s16(a); }
158template<> inline Type2Vec_Traits< uint>::vec_type v_setall< uint>(const uint& a) { return v_setall_u32(a); }
159template<> inline Type2Vec_Traits< int>::vec_type v_setall< int>(const int& a) { return v_setall_s32(a); }
160template<> inline Type2Vec_Traits<uint64>::vec_type v_setall<uint64>(const uint64& a) { return v_setall_u64(a); }
161template<> inline Type2Vec_Traits< int64>::vec_type v_setall< int64>(const int64& a) { return v_setall_s64(a); }
162template<> inline Type2Vec_Traits< float>::vec_type v_setall< float>(const float& a) { return v_setall_f32(a); }
163#if CV_SIMD_SCALABLE_64F
164template<> inline Type2Vec_Traits<double>::vec_type v_setall<double>(const double& a) { return v_setall_f64(a); }
165#endif
166#endif
167
168
169#if CV_SIMD_SCALABLE
170template<typename _T> static inline
171typename Type2Vec_Traits<_T>::vec_type vx_setall(const _T& a) { return v_setall(a); }
172#elif CV_SIMD_WIDTH == 16
173template<typename _T> static inline
174typename Type2Vec128_Traits<_T>::vec_type vx_setall(const _T& a) { return v_setall(a); }
175#elif CV_SIMD_WIDTH == 32
176template<typename _T> static inline
177typename Type2Vec256_Traits<_T>::vec_type vx_setall(const _T& a) { return v256_setall(a); }
178#elif CV_SIMD_WIDTH == 64
179template<typename _T> static inline
180typename Type2Vec512_Traits<_T>::vec_type vx_setall(const _T& a) { return v512_setall(a); }
181#else
182#error "Build configuration error, unsupported CV_SIMD_WIDTH"
183#endif
184
185
186#endif // OPENCV_HAL_INTRIN_HPP
signed char schar
Definition interface.h:48
uint32_t uint
Definition interface.h:42
unsigned char uchar
Definition interface.h:51
int64_t int64
Definition interface.h:61
unsigned short ushort
Definition interface.h:52
uint64_t uint64
Definition interface.h:62