GNU Radio 3.7.3 C++ API
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_ORC
142  /*!
143  \brief Converts the input 8 bit integer data into 16 bit integer data
144  \param inputVector The 8 bit input data buffer
145  \param outputVector The 16 bit output data buffer
146  \param num_points The number of data values to be converted
147  */
148 extern void volk_8i_convert_16i_a_orc_impl(int16_t* outputVector, const int8_t* inputVector, unsigned int num_points);
149 static inline void volk_8i_convert_16i_u_orc(int16_t* outputVector, const int8_t* inputVector, unsigned int num_points){
150  volk_8i_convert_16i_a_orc_impl(outputVector, inputVector, num_points);
151 }
152 #endif /* LV_HAVE_ORC */
153 
154 
155 
156 #endif /* INCLUDED_VOLK_8s_CONVERT_16s_ALIGNED8_H */
signed short int16_t
Definition: stdint.h:76
signed char int8_t
Definition: stdint.h:75