1 #ifndef INCLUDED_volk_16i_max_star_horizontal_16i_a_H
2 #define INCLUDED_volk_16i_max_star_horizontal_16i_a_H
16 static inline void volk_16i_max_star_horizontal_16i_a_ssse3(
int16_t* target,
int16_t* src0,
unsigned int num_points) {
18 const unsigned int num_bytes = num_points*2;
20 const static uint8_t shufmask0[16] = {0x00, 0x01, 0x04, 0x05, 0x08, 0x09, 0x0c, 0x0d, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff};
21 const static uint8_t shufmask1[16] = {0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0x00, 0x01, 0x04, 0x05, 0x08, 0x09, 0x0c, 0x0d};
22 const static uint8_t andmask0[16] = {0x02, 0x02, 0x02, 0x02, 0x02, 0x02, 0x02,0x02, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00};
23 const static uint8_t andmask1[16] = {0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x02, 0x02, 0x02, 0x02, 0x02, 0x02, 0x02, 0x02};
27 __m128i xmm0, xmm1, xmm2, xmm3, xmm4;
28 __m128i xmm5, xmm6, xmm7, xmm8;
30 xmm4 = _mm_load_si128((__m128i*)shufmask0);
31 xmm5 = _mm_load_si128((__m128i*)shufmask1);
32 xmm6 = _mm_load_si128((__m128i*)andmask0);
33 xmm7 = _mm_load_si128((__m128i*)andmask1);
35 __m128i *p_target, *p_src0;
37 p_target = (__m128i*)target;
38 p_src0 = (__m128i*)src0;
40 int bound = num_bytes >> 5;
41 int intermediate = (num_bytes >> 4) & 1;
42 int leftovers = (num_bytes >> 1) & 7;
47 for(i = 0; i < bound; ++i) {
49 xmm0 = _mm_load_si128(p_src0);
50 xmm1 = _mm_load_si128(&p_src0[1]);
54 xmm2 = _mm_xor_si128(xmm2, xmm2);
57 xmm3 = _mm_hsub_epi16(xmm0, xmm1);
59 xmm2 = _mm_cmpgt_epi16(xmm2, xmm3);
61 xmm8 = _mm_and_si128(xmm2, xmm6);
62 xmm3 = _mm_and_si128(xmm2, xmm7);
65 xmm8 = _mm_add_epi8(xmm8, xmm4);
66 xmm3 = _mm_add_epi8(xmm3, xmm5);
68 xmm0 = _mm_shuffle_epi8(xmm0, xmm8);
69 xmm1 = _mm_shuffle_epi8(xmm1, xmm3);
72 xmm3 = _mm_add_epi16(xmm0, xmm1);
75 _mm_store_si128(p_target, xmm3);
81 for(i = 0; i < intermediate; ++i) {
83 xmm0 = _mm_load_si128(p_src0);
86 xmm2 = _mm_xor_si128(xmm2, xmm2);
89 xmm3 = _mm_hsub_epi16(xmm0, xmm1);
90 xmm2 = _mm_cmpgt_epi16(xmm2, xmm3);
92 xmm8 = _mm_and_si128(xmm2, xmm6);
94 xmm3 = _mm_add_epi8(xmm8, xmm4);
96 xmm0 = _mm_shuffle_epi8(xmm0, xmm3);
98 _mm_storel_pd((
double*)p_target,
bit128_p(&xmm0)->double_vec);
100 p_target = (__m128i*)((
int8_t*)p_target + 8);
104 for(i = (bound << 4) + (intermediate << 3); i < (bound << 4) + (intermediate << 3) + leftovers ; i += 2) {
105 target[i>>1] = ((
int16_t)(src0[i] - src0[i + 1]) > 0) ? src0[i] : src0[i + 1];
114 #include <arm_neon.h>
115 static inline void volk_16i_max_star_horizontal_16i_neon(
int16_t* target,
int16_t* src0,
unsigned int num_points) {
116 const unsigned int eighth_points = num_points / 16;
118 int16x8x2_t input_vec;
119 int16x8_t diff, max_vec, zeros;
120 uint16x8_t comp1, comp2;
121 zeros = veorq_s16(zeros, zeros);
122 for(number=0; number < eighth_points; ++number) {
123 input_vec = vld2q_s16(src0);
125 diff = vsubq_s16(input_vec.val[0], input_vec.val[1]);
126 comp1 = vcgeq_s16(diff, zeros);
127 comp2 = vcltq_s16(diff, zeros);
129 input_vec.val[0] = vandq_s16(input_vec.val[0], (int16x8_t)comp1);
130 input_vec.val[1] = vandq_s16(input_vec.val[1], (int16x8_t)comp2);
132 max_vec = vaddq_s16(input_vec.val[0], input_vec.val[1]);
133 vst1q_s16(target, max_vec);
137 for(number=0; number < num_points%16; number+=2) {
138 target[number >> 1] = ((
int16_t)(src0[number] - src0[number + 1]) > 0) ? src0[number] : src0[number+1];
145 extern void volk_16i_max_star_horizontal_16i_neonasm(
int16_t* target,
int16_t* src0,
unsigned int num_points);
148 #ifdef LV_HAVE_GENERIC
149 static inline void volk_16i_max_star_horizontal_16i_generic(
int16_t* target,
int16_t* src0,
unsigned int num_points) {
151 const unsigned int num_bytes = num_points*2;
155 int bound = num_bytes >> 1;
158 for(i = 0; i < bound; i += 2) {
159 target[i >> 1] = ((
int16_t) (src0[i] - src0[i + 1]) > 0) ? src0[i] : src0[i+1];
#define bit128_p(x)
Definition: volk_common.h:94
unsigned char uint8_t
Definition: stdint.h:78
signed short int16_t
Definition: stdint.h:76
signed char int8_t
Definition: stdint.h:75