GNU Radio 3.6.3.1 C++ API
volk_16i_convert_8i_a.h
Go to the documentation of this file.
1 #ifndef INCLUDED_volk_16i_convert_8i_a_H
2 #define INCLUDED_volk_16i_convert_8i_a_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 */
15 static inline void volk_16i_convert_8i_a_sse2(int8_t* outputVector, const int16_t* inputVector, unsigned int num_points){
16  unsigned int number = 0;
17  const unsigned int sixteenthPoints = num_points / 16;
18 
19  int8_t* outputVectorPtr = outputVector;
20  int16_t* inputPtr = (int16_t*)inputVector;
21  __m128i inputVal1;
22  __m128i inputVal2;
23  __m128i ret;
24 
25  for(;number < sixteenthPoints; number++){
26 
27  // Load the 16 values
28  inputVal1 = _mm_load_si128((__m128i*)inputPtr); inputPtr += 8;
29  inputVal2 = _mm_load_si128((__m128i*)inputPtr); inputPtr += 8;
30 
31  inputVal1 = _mm_srai_epi16(inputVal1, 8);
32  inputVal2 = _mm_srai_epi16(inputVal2, 8);
33 
34  ret = _mm_packs_epi16(inputVal1, inputVal2);
35 
36  _mm_store_si128((__m128i*)outputVectorPtr, ret);
37 
38  outputVectorPtr += 16;
39  }
40 
41  number = sixteenthPoints * 16;
42  for(; number < num_points; number++){
43  outputVector[number] =(int8_t)(inputVector[number] >> 8);
44  }
45 }
46 #endif /* LV_HAVE_SSE2 */
47 
48 #ifdef LV_HAVE_GENERIC
49 /*!
50  \brief Converts the input 16 bit integer data into 8 bit integer data
51  \param inputVector The 16 bit input data buffer
52  \param outputVector The 8 bit output data buffer
53  \param num_points The number of data values to be converted
54 */
55 static inline void volk_16i_convert_8i_a_generic(int8_t* outputVector, const int16_t* inputVector, unsigned int num_points){
56  int8_t* outputVectorPtr = outputVector;
57  const int16_t* inputVectorPtr = inputVector;
58  unsigned int number = 0;
59 
60  for(number = 0; number < num_points; number++){
61  *outputVectorPtr++ = ((int8_t)(*inputVectorPtr++ >> 8));
62  }
63 }
64 #endif /* LV_HAVE_GENERIC */
65 
66 
67 
68 
69 #endif /* INCLUDED_volk_16i_convert_8i_a_H */