GNU Radio Manual and C++ API Reference  3.7.6.1
The Free & Open Software Radio Ecosystem
volk_16ic_deinterleave_real_16i.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_16i_a_H
24 #define INCLUDED_volk_16ic_deinterleave_real_16i_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 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_16i_a_ssse3(int16_t* iBuffer, const lv_16sc_t* complexVector, unsigned int num_points){
38  unsigned int number = 0;
39  const int16_t* complexVectorPtr = (int16_t*)complexVector;
40  int16_t* iBufferPtr = iBuffer;
41 
42  __m128i iMoveMask1 = _mm_set_epi8(0x80, 0x80, 0x80, 0x80, 0x80, 0x80, 0x80, 0x80, 13, 12, 9, 8, 5, 4, 1, 0);
43  __m128i iMoveMask2 = _mm_set_epi8(13, 12, 9, 8, 5, 4, 1, 0, 0x80, 0x80, 0x80, 0x80, 0x80, 0x80, 0x80, 0x80);
44 
45  __m128i complexVal1, complexVal2, iOutputVal;
46 
47  unsigned int eighthPoints = num_points / 8;
48 
49  for(number = 0; number < eighthPoints; number++){
50  complexVal1 = _mm_load_si128((__m128i*)complexVectorPtr); complexVectorPtr += 8;
51  complexVal2 = _mm_load_si128((__m128i*)complexVectorPtr); complexVectorPtr += 8;
52 
53  complexVal1 = _mm_shuffle_epi8(complexVal1, iMoveMask1);
54  complexVal2 = _mm_shuffle_epi8(complexVal2, iMoveMask2);
55 
56  iOutputVal = _mm_or_si128(complexVal1, complexVal2);
57 
58  _mm_store_si128((__m128i*)iBufferPtr, iOutputVal);
59 
60  iBufferPtr += 8;
61  }
62 
63  number = eighthPoints * 8;
64  for(; number < num_points; number++){
65  *iBufferPtr++ = *complexVectorPtr++;
66  complexVectorPtr++;
67  }
68 }
69 #endif /* LV_HAVE_SSSE3 */
70 
71 
72 #ifdef LV_HAVE_SSE2
73 #include <emmintrin.h>
74 /*!
75  \brief Deinterleaves the complex 16 bit vector into I vector data
76  \param complexVector The complex input vector
77  \param iBuffer The I buffer output data
78  \param num_points The number of complex data values to be deinterleaved
79 */
80 static inline void volk_16ic_deinterleave_real_16i_a_sse2(int16_t* iBuffer, const lv_16sc_t* complexVector, unsigned int num_points){
81  unsigned int number = 0;
82  const int16_t* complexVectorPtr = (int16_t*)complexVector;
83  int16_t* iBufferPtr = iBuffer;
84  __m128i complexVal1, complexVal2, iOutputVal;
85  __m128i lowMask = _mm_set_epi32(0x0, 0x0, 0xFFFFFFFF, 0xFFFFFFFF);
86  __m128i highMask = _mm_set_epi32(0xFFFFFFFF, 0xFFFFFFFF, 0x0, 0x0);
87 
88  unsigned int eighthPoints = num_points / 8;
89 
90  for(number = 0; number < eighthPoints; number++){
91  complexVal1 = _mm_load_si128((__m128i*)complexVectorPtr); complexVectorPtr += 8;
92  complexVal2 = _mm_load_si128((__m128i*)complexVectorPtr); complexVectorPtr += 8;
93 
94  complexVal1 = _mm_shufflelo_epi16(complexVal1, _MM_SHUFFLE(3,1,2,0));
95 
96  complexVal1 = _mm_shufflehi_epi16(complexVal1, _MM_SHUFFLE(3,1,2,0));
97 
98  complexVal1 = _mm_shuffle_epi32(complexVal1, _MM_SHUFFLE(3,1,2,0));
99 
100  complexVal2 = _mm_shufflelo_epi16(complexVal2, _MM_SHUFFLE(3,1,2,0));
101 
102  complexVal2 = _mm_shufflehi_epi16(complexVal2, _MM_SHUFFLE(3,1,2,0));
103 
104  complexVal2 = _mm_shuffle_epi32(complexVal2, _MM_SHUFFLE(2,0,3,1));
105 
106  iOutputVal = _mm_or_si128(_mm_and_si128(complexVal1, lowMask), _mm_and_si128(complexVal2, highMask));
107 
108  _mm_store_si128((__m128i*)iBufferPtr, iOutputVal);
109 
110  iBufferPtr += 8;
111  }
112 
113  number = eighthPoints * 8;
114  for(; number < num_points; number++){
115  *iBufferPtr++ = *complexVectorPtr++;
116  complexVectorPtr++;
117  }
118 }
119 #endif /* LV_HAVE_SSE2 */
120 
121 #ifdef LV_HAVE_GENERIC
122 /*!
123  \brief Deinterleaves the complex 16 bit vector into I vector data
124  \param complexVector The complex input vector
125  \param iBuffer The I buffer output data
126  \param num_points The number of complex data values to be deinterleaved
127 */
128 static inline void volk_16ic_deinterleave_real_16i_generic(int16_t* iBuffer, const lv_16sc_t* complexVector, unsigned int num_points){
129  unsigned int number = 0;
130  const int16_t* complexVectorPtr = (int16_t*)complexVector;
131  int16_t* iBufferPtr = iBuffer;
132  for(number = 0; number < num_points; number++){
133  *iBufferPtr++ = *complexVectorPtr++;
134  complexVectorPtr++;
135  }
136 }
137 #endif /* LV_HAVE_GENERIC */
138 
139 
140 
141 
142 #endif /* INCLUDED_volk_16ic_deinterleave_real_16i_a_H */
short complex lv_16sc_t
Definition: volk_complex.h:53
signed short int16_t
Definition: stdint.h:76