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 #ifdef LV_HAVE_GENERIC
115 static inline void volk_16i_max_star_horizontal_16i_generic(
int16_t* target,
int16_t* src0,
unsigned int num_points) {
117 const unsigned int num_bytes = num_points*2;
121 int bound = num_bytes >> 1;
124 for(i = 0; i < bound; i += 2) {
125 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