GNU Radio Manual and C++ API Reference  3.7.6.1
The Free & Open Software Radio Ecosystem
volk_16ic_deinterleave_real_8i.h
Go to the documentation of this file.
1 /* -*- c++ -*- */
2 /*
3  * Copyright 2014 Free Software Foundation, Inc.
4  *
5  * This file is part of GNU Radio
6  *
7  * GNU Radio is free software; you can redistribute it and/or modify
8  * it under the terms of the GNU General Public License as published by
9  * the Free Software Foundation; either version 3, or (at your option)
10  * any later version.
11  *
12  * GNU Radio is distributed in the hope that it will be useful,
13  * but WITHOUT ANY WARRANTY; without even the implied warranty of
14  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
15  * GNU General Public License for more details.
16  *
17  * You should have received a copy of the GNU General Public License
18  * along with GNU Radio; see the file COPYING. If not, write to
19  * the Free Software Foundation, Inc., 51 Franklin Street,
20  * Boston, MA 02110-1301, USA.
21  */
22 
23 #ifndef INCLUDED_volk_16ic_deinterleave_real_8i_a_H
24 #define INCLUDED_volk_16ic_deinterleave_real_8i_a_H
25 
26 #include <inttypes.h>
27 #include <stdio.h>
28 
29 #ifdef LV_HAVE_SSSE3
30 #include <tmmintrin.h>
31 /*!
32  \brief Deinterleaves the complex 16 bit vector into 8 bit I vector data
33  \param complexVector The complex input vector
34  \param iBuffer The I buffer output data
35  \param num_points The number of complex data values to be deinterleaved
36 */
37 static inline void volk_16ic_deinterleave_real_8i_a_ssse3(int8_t* iBuffer, const lv_16sc_t* complexVector, unsigned int num_points){
38  unsigned int number = 0;
39  const int8_t* complexVectorPtr = (int8_t*)complexVector;
40  int8_t* iBufferPtr = iBuffer;
41  __m128i iMoveMask1 = _mm_set_epi8(0x80, 0x80, 0x80, 0x80, 0x80, 0x80, 0x80, 0x80, 13, 12, 9, 8, 5, 4, 1, 0);
42  __m128i iMoveMask2 = _mm_set_epi8(13, 12, 9, 8, 5, 4, 1, 0, 0x80, 0x80, 0x80, 0x80, 0x80, 0x80, 0x80, 0x80);
43  __m128i complexVal1, complexVal2, complexVal3, complexVal4, iOutputVal;
44 
45  unsigned int sixteenthPoints = num_points / 16;
46 
47  for(number = 0; number < sixteenthPoints; number++){
48  complexVal1 = _mm_load_si128((__m128i*)complexVectorPtr); complexVectorPtr += 16;
49  complexVal2 = _mm_load_si128((__m128i*)complexVectorPtr); complexVectorPtr += 16;
50 
51  complexVal3 = _mm_load_si128((__m128i*)complexVectorPtr); complexVectorPtr += 16;
52  complexVal4 = _mm_load_si128((__m128i*)complexVectorPtr); complexVectorPtr += 16;
53 
54  complexVal1 = _mm_shuffle_epi8(complexVal1, iMoveMask1);
55  complexVal2 = _mm_shuffle_epi8(complexVal2, iMoveMask2);
56 
57  complexVal1 = _mm_or_si128(complexVal1, complexVal2);
58 
59  complexVal3 = _mm_shuffle_epi8(complexVal3, iMoveMask1);
60  complexVal4 = _mm_shuffle_epi8(complexVal4, iMoveMask2);
61 
62  complexVal3 = _mm_or_si128(complexVal3, complexVal4);
63 
64 
65  complexVal1 = _mm_srai_epi16(complexVal1, 8);
66  complexVal3 = _mm_srai_epi16(complexVal3, 8);
67 
68  iOutputVal = _mm_packs_epi16(complexVal1, complexVal3);
69 
70  _mm_store_si128((__m128i*)iBufferPtr, iOutputVal);
71 
72  iBufferPtr += 16;
73  }
74 
75  number = sixteenthPoints * 16;
76  int16_t* int16ComplexVectorPtr = (int16_t*)complexVectorPtr;
77  for(; number < num_points; number++){
78  *iBufferPtr++ = ((int8_t)(*int16ComplexVectorPtr++ >> 8));
79  int16ComplexVectorPtr++;
80  }
81 }
82 #endif /* LV_HAVE_SSSE3 */
83 
84 #ifdef LV_HAVE_GENERIC
85 /*!
86  \brief Deinterleaves the complex 16 bit vector into 8 bit I vector data
87  \param complexVector The complex input vector
88  \param iBuffer The I buffer output data
89  \param num_points The number of complex data values to be deinterleaved
90 */
91 static inline void volk_16ic_deinterleave_real_8i_generic(int8_t* iBuffer, const lv_16sc_t* complexVector, unsigned int num_points){
92  unsigned int number = 0;
93  int16_t* complexVectorPtr = (int16_t*)complexVector;
94  int8_t* iBufferPtr = iBuffer;
95  for(number = 0; number < num_points; number++){
96  *iBufferPtr++ = ((int8_t)(*complexVectorPtr++ >> 8));
97  complexVectorPtr++;
98  }
99 }
100 #endif /* LV_HAVE_GENERIC */
101 
102 #ifdef LV_HAVE_ORC
103 /*!
104  \brief Deinterleaves the complex 16 bit vector into 8 bit I vector data
105  \param complexVector The complex input vector
106  \param iBuffer The I buffer output data
107  \param num_points The number of complex data values to be deinterleaved
108 */
109 extern void volk_16ic_deinterleave_real_8i_a_orc_impl(int8_t* iBuffer, const lv_16sc_t* complexVector, unsigned int num_points);
110 static inline void volk_16ic_deinterleave_real_8i_u_orc(int8_t* iBuffer, const lv_16sc_t* complexVector, unsigned int num_points){
111  volk_16ic_deinterleave_real_8i_a_orc_impl(iBuffer, complexVector, num_points);
112 }
113 #endif /* LV_HAVE_ORC */
114 
115 
116 #endif /* INCLUDED_volk_16ic_deinterleave_real_8i_a_H */
short complex lv_16sc_t
Definition: volk_complex.h:53
signed short int16_t
Definition: stdint.h:76
signed char int8_t
Definition: stdint.h:75