GNU Radio Manual and C++ API Reference  3.7.5.1
The Free & Open Software Radio Ecosystem
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Properties Friends Macros Groups Pages
volk_8i_convert_16i.h
Go to the documentation of this file.
1 #ifndef INCLUDED_volk_8i_convert_16i_u_H
2 #define INCLUDED_volk_8i_convert_16i_u_H
3 
4 #include <inttypes.h>
5 #include <stdio.h>
6 
7 #ifdef LV_HAVE_SSE4_1
8 #include <smmintrin.h>
9 
10  /*!
11  \brief Converts the input 8 bit integer data into 16 bit integer data
12  \param inputVector The 8 bit input data buffer
13  \param outputVector The 16 bit output data buffer
14  \param num_points The number of data values to be converted
15  \note Input and output buffers do NOT need to be properly aligned
16  */
17 static inline void volk_8i_convert_16i_u_sse4_1(int16_t* outputVector, const int8_t* inputVector, unsigned int num_points){
18  unsigned int number = 0;
19  const unsigned int sixteenthPoints = num_points / 16;
20 
21  const __m128i* inputVectorPtr = (const __m128i*)inputVector;
22  __m128i* outputVectorPtr = (__m128i*)outputVector;
23  __m128i inputVal;
24  __m128i ret;
25 
26  for(;number < sixteenthPoints; number++){
27  inputVal = _mm_loadu_si128(inputVectorPtr);
28  ret = _mm_cvtepi8_epi16(inputVal);
29  ret = _mm_slli_epi16(ret, 8); // Multiply by 256
30  _mm_storeu_si128(outputVectorPtr, ret);
31 
32  outputVectorPtr++;
33 
34  inputVal = _mm_srli_si128(inputVal, 8);
35  ret = _mm_cvtepi8_epi16(inputVal);
36  ret = _mm_slli_epi16(ret, 8); // Multiply by 256
37  _mm_storeu_si128(outputVectorPtr, ret);
38 
39  outputVectorPtr++;
40 
41  inputVectorPtr++;
42  }
43 
44  number = sixteenthPoints * 16;
45  for(; number < num_points; number++){
46  outputVector[number] = (int16_t)(inputVector[number])*256;
47  }
48 }
49 #endif /* LV_HAVE_SSE4_1 */
50 
51 #ifdef LV_HAVE_GENERIC
52  /*!
53  \brief Converts the input 8 bit integer data into 16 bit integer data
54  \param inputVector The 8 bit input data buffer
55  \param outputVector The 16 bit output data buffer
56  \param num_points The number of data values to be converted
57  \note Input and output buffers do NOT need to be properly aligned
58  */
59 static inline void volk_8i_convert_16i_generic(int16_t* outputVector, const int8_t* inputVector, unsigned int num_points){
60  int16_t* outputVectorPtr = outputVector;
61  const int8_t* inputVectorPtr = inputVector;
62  unsigned int number = 0;
63 
64  for(number = 0; number < num_points; number++){
65  *outputVectorPtr++ = ((int16_t)(*inputVectorPtr++)) * 256;
66  }
67 }
68 #endif /* LV_HAVE_GENERIC */
69 
70 
71 
72 
73 #endif /* INCLUDED_VOLK_8s_CONVERT_16s_UNALIGNED8_H */
74 #ifndef INCLUDED_volk_8i_convert_16i_a_H
75 #define INCLUDED_volk_8i_convert_16i_a_H
76 
77 #include <inttypes.h>
78 #include <stdio.h>
79 
80 #ifdef LV_HAVE_SSE4_1
81 #include <smmintrin.h>
82 
83  /*!
84  \brief Converts the input 8 bit integer data into 16 bit integer data
85  \param inputVector The 8 bit input data buffer
86  \param outputVector The 16 bit output data buffer
87  \param num_points The number of data values to be converted
88  */
89 static inline void volk_8i_convert_16i_a_sse4_1(int16_t* outputVector, const int8_t* inputVector, unsigned int num_points){
90  unsigned int number = 0;
91  const unsigned int sixteenthPoints = num_points / 16;
92 
93  const __m128i* inputVectorPtr = (const __m128i*)inputVector;
94  __m128i* outputVectorPtr = (__m128i*)outputVector;
95  __m128i inputVal;
96  __m128i ret;
97 
98  for(;number < sixteenthPoints; number++){
99  inputVal = _mm_load_si128(inputVectorPtr);
100  ret = _mm_cvtepi8_epi16(inputVal);
101  ret = _mm_slli_epi16(ret, 8); // Multiply by 256
102  _mm_store_si128(outputVectorPtr, ret);
103 
104  outputVectorPtr++;
105 
106  inputVal = _mm_srli_si128(inputVal, 8);
107  ret = _mm_cvtepi8_epi16(inputVal);
108  ret = _mm_slli_epi16(ret, 8); // Multiply by 256
109  _mm_store_si128(outputVectorPtr, ret);
110 
111  outputVectorPtr++;
112 
113  inputVectorPtr++;
114  }
115 
116  number = sixteenthPoints * 16;
117  for(; number < num_points; number++){
118  outputVector[number] = (int16_t)(inputVector[number])*256;
119  }
120 }
121 #endif /* LV_HAVE_SSE4_1 */
122 
123 #ifdef LV_HAVE_GENERIC
124  /*!
125  \brief Converts the input 8 bit integer data into 16 bit integer data
126  \param inputVector The 8 bit input data buffer
127  \param outputVector The 16 bit output data buffer
128  \param num_points The number of data values to be converted
129  */
130 static inline void volk_8i_convert_16i_a_generic(int16_t* outputVector, const int8_t* inputVector, unsigned int num_points){
131  int16_t* outputVectorPtr = outputVector;
132  const int8_t* inputVectorPtr = inputVector;
133  unsigned int number = 0;
134 
135  for(number = 0; number < num_points; number++){
136  *outputVectorPtr++ = ((int16_t)(*inputVectorPtr++)) * 256;
137  }
138 }
139 #endif /* LV_HAVE_GENERIC */
140 
141 #ifdef LV_HAVE_NEON
142 #include <arm_neon.h>
143 
144  /*!
145  \brief Converts the input 8 bit integer data into 16 bit integer data
146  \param inputVector The 8 bit input data buffer
147  \param outputVector The 16 bit output data buffer
148  \param num_points The number of data values to be converted
149  \note Input and output buffers do NOT need to be properly aligned
150  */
151 static inline void volk_8i_convert_16i_neon(int16_t* outputVector, const int8_t* inputVector, unsigned int num_points){
152  int16_t* outputVectorPtr = outputVector;
153  const int8_t* inputVectorPtr = inputVector;
154  unsigned int number;
155  const unsigned int eighth_points = num_points / 8;
156 
157  int8x8_t input_vec ;
158  int16x8_t converted_vec;
159 
160  // NEON doesn't have a concept of 8 bit registers, so we are really
161  // dealing with the low half of 16-bit registers. Since this requires
162  // a move instruction we likely do better with ASM here.
163  for(number = 0; number < eighth_points; ++number) {
164  input_vec = vld1_s8(inputVectorPtr);
165  converted_vec = vmovl_s8(input_vec);
166  //converted_vec = vmulq_s16(converted_vec, scale_factor);
167  converted_vec = vshlq_n_s16(converted_vec, 8);
168  vst1q_s16( outputVectorPtr, converted_vec);
169 
170  inputVectorPtr += 8;
171  outputVectorPtr += 8;
172  }
173 
174  for(number = eighth_points * 8; number < num_points; number++){
175  *outputVectorPtr++ = ((int16_t)(*inputVectorPtr++)) * 256;
176  }
177 }
178 #endif /* LV_HAVE_NEON */
179 
180 #ifdef LV_HAVE_ORC
181  /*!
182  \brief Converts the input 8 bit integer data into 16 bit integer data
183  \param inputVector The 8 bit input data buffer
184  \param outputVector The 16 bit output data buffer
185  \param num_points The number of data values to be converted
186  */
187 extern void volk_8i_convert_16i_a_orc_impl(int16_t* outputVector, const int8_t* inputVector, unsigned int num_points);
188 static inline void volk_8i_convert_16i_u_orc(int16_t* outputVector, const int8_t* inputVector, unsigned int num_points){
189  volk_8i_convert_16i_a_orc_impl(outputVector, inputVector, num_points);
190 }
191 #endif /* LV_HAVE_ORC */
192 
193 
194 
195 #endif /* INCLUDED_VOLK_8s_CONVERT_16s_ALIGNED8_H */
signed short int16_t
Definition: stdint.h:76
signed char int8_t
Definition: stdint.h:75