GNU Radio Manual and C++ API Reference  3.7.4.1
The Free & Open Software Radio Ecosystem
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Properties Friends Macros Groups Pages
volk_16i_convert_8i.h
Go to the documentation of this file.
1 #ifndef INCLUDED_volk_16i_convert_8i_u_H
2 #define INCLUDED_volk_16i_convert_8i_u_H
3 
4 #include <inttypes.h>
5 #include <stdio.h>
6 
7 #ifdef LV_HAVE_SSE2
8 #include <emmintrin.h>
9 /*!
10  \brief Converts the input 16 bit integer data into 8 bit integer data
11  \param inputVector The 16 bit input data buffer
12  \param outputVector The 8 bit output data buffer
13  \param num_points The number of data values to be converted
14  \note Input and output buffers do NOT need to be properly aligned
15 */
16 static inline void volk_16i_convert_8i_u_sse2(int8_t* outputVector, const int16_t* inputVector, unsigned int num_points){
17  unsigned int number = 0;
18  const unsigned int sixteenthPoints = num_points / 16;
19 
20  int8_t* outputVectorPtr = outputVector;
21  int16_t* inputPtr = (int16_t*)inputVector;
22  __m128i inputVal1;
23  __m128i inputVal2;
24  __m128i ret;
25 
26  for(;number < sixteenthPoints; number++){
27 
28  // Load the 16 values
29  inputVal1 = _mm_loadu_si128((__m128i*)inputPtr); inputPtr += 8;
30  inputVal2 = _mm_loadu_si128((__m128i*)inputPtr); inputPtr += 8;
31 
32  inputVal1 = _mm_srai_epi16(inputVal1, 8);
33  inputVal2 = _mm_srai_epi16(inputVal2, 8);
34 
35  ret = _mm_packs_epi16(inputVal1, inputVal2);
36 
37  _mm_storeu_si128((__m128i*)outputVectorPtr, ret);
38 
39  outputVectorPtr += 16;
40  }
41 
42  number = sixteenthPoints * 16;
43  for(; number < num_points; number++){
44  outputVector[number] =(int8_t)(inputVector[number] >> 8);
45  }
46 }
47 #endif /* LV_HAVE_SSE2 */
48 
49 #ifdef LV_HAVE_GENERIC
50 /*!
51  \brief Converts the input 16 bit integer data into 8 bit integer data
52  \param inputVector The 16 bit input data buffer
53  \param outputVector The 8 bit output data buffer
54  \param num_points The number of data values to be converted
55  \note Input and output buffers do NOT need to be properly aligned
56 */
57 static inline void volk_16i_convert_8i_generic(int8_t* outputVector, const int16_t* inputVector, unsigned int num_points){
58  int8_t* outputVectorPtr = outputVector;
59  const int16_t* inputVectorPtr = inputVector;
60  unsigned int number = 0;
61 
62  for(number = 0; number < num_points; number++){
63  *outputVectorPtr++ = ((int8_t)(*inputVectorPtr++ >> 8));
64  }
65 }
66 #endif /* LV_HAVE_GENERIC */
67 
68 
69 
70 
71 #endif /* INCLUDED_volk_16i_convert_8i_u_H */
72 #ifndef INCLUDED_volk_16i_convert_8i_a_H
73 #define INCLUDED_volk_16i_convert_8i_a_H
74 
75 #include <inttypes.h>
76 #include <stdio.h>
77 
78 #ifdef LV_HAVE_SSE2
79 #include <emmintrin.h>
80 /*!
81  \brief Converts the input 16 bit integer data into 8 bit integer data
82  \param inputVector The 16 bit input data buffer
83  \param outputVector The 8 bit output data buffer
84  \param num_points The number of data values to be converted
85 */
86 static inline void volk_16i_convert_8i_a_sse2(int8_t* outputVector, const int16_t* inputVector, unsigned int num_points){
87  unsigned int number = 0;
88  const unsigned int sixteenthPoints = num_points / 16;
89 
90  int8_t* outputVectorPtr = outputVector;
91  int16_t* inputPtr = (int16_t*)inputVector;
92  __m128i inputVal1;
93  __m128i inputVal2;
94  __m128i ret;
95 
96  for(;number < sixteenthPoints; number++){
97 
98  // Load the 16 values
99  inputVal1 = _mm_load_si128((__m128i*)inputPtr); inputPtr += 8;
100  inputVal2 = _mm_load_si128((__m128i*)inputPtr); inputPtr += 8;
101 
102  inputVal1 = _mm_srai_epi16(inputVal1, 8);
103  inputVal2 = _mm_srai_epi16(inputVal2, 8);
104 
105  ret = _mm_packs_epi16(inputVal1, inputVal2);
106 
107  _mm_store_si128((__m128i*)outputVectorPtr, ret);
108 
109  outputVectorPtr += 16;
110  }
111 
112  number = sixteenthPoints * 16;
113  for(; number < num_points; number++){
114  outputVector[number] =(int8_t)(inputVector[number] >> 8);
115  }
116 }
117 #endif /* LV_HAVE_SSE2 */
118 
119 #ifdef LV_HAVE_GENERIC
120 /*!
121  \brief Converts the input 16 bit integer data into 8 bit integer data
122  \param inputVector The 16 bit input data buffer
123  \param outputVector The 8 bit output data buffer
124  \param num_points The number of data values to be converted
125 */
126 static inline void volk_16i_convert_8i_a_generic(int8_t* outputVector, const int16_t* inputVector, unsigned int num_points){
127  int8_t* outputVectorPtr = outputVector;
128  const int16_t* inputVectorPtr = inputVector;
129  unsigned int number = 0;
130 
131  for(number = 0; number < num_points; number++){
132  *outputVectorPtr++ = ((int8_t)(*inputVectorPtr++ >> 8));
133  }
134 }
135 #endif /* LV_HAVE_GENERIC */
136 
137 
138 
139 
140 #endif /* INCLUDED_volk_16i_convert_8i_a_H */
signed short int16_t
Definition: stdint.h:76
signed char int8_t
Definition: stdint.h:75