GNU Radio 3.6.2 C++ API
volk_16i_convert_8i_u.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_u_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 */