GNU Radio Manual and C++ API Reference  3.7.6.1
The Free & Open Software Radio Ecosystem
volk_32fc_s32f_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_32fc_s32f_deinterleave_real_16i_a_H
24 #define INCLUDED_volk_32fc_s32f_deinterleave_real_16i_a_H
25 
26 #include <volk/volk_common.h>
27 #include <inttypes.h>
28 #include <stdio.h>
29 
30 #ifdef LV_HAVE_SSE
31 #include <xmmintrin.h>
32 /*!
33  \brief Deinterleaves the complex vector, multiply the value by the scalar, convert to 16t, and in I vector data
34  \param complexVector The complex input vector
35  \param scalar The value to be multiply against each of the input values
36  \param iBuffer The I buffer output data
37  \param num_points The number of complex data values to be deinterleaved
38 */
39 static inline void volk_32fc_s32f_deinterleave_real_16i_a_sse(int16_t* iBuffer, const lv_32fc_t* complexVector, const float scalar, unsigned int num_points){
40  unsigned int number = 0;
41  const unsigned int quarterPoints = num_points / 4;
42 
43  const float* complexVectorPtr = (float*)complexVector;
44  int16_t* iBufferPtr = iBuffer;
45 
46  __m128 vScalar = _mm_set_ps1(scalar);
47 
48  __m128 cplxValue1, cplxValue2, iValue;
49 
50  __VOLK_ATTR_ALIGNED(16) float floatBuffer[4];
51 
52  for(;number < quarterPoints; number++){
53  cplxValue1 = _mm_load_ps(complexVectorPtr);
54  complexVectorPtr += 4;
55 
56  cplxValue2 = _mm_load_ps(complexVectorPtr);
57  complexVectorPtr += 4;
58 
59  // Arrange in i1i2i3i4 format
60  iValue = _mm_shuffle_ps(cplxValue1, cplxValue2, _MM_SHUFFLE(2,0,2,0));
61 
62  iValue = _mm_mul_ps(iValue, vScalar);
63 
64  _mm_store_ps(floatBuffer, iValue);
65  *iBufferPtr++ = (int16_t)(floatBuffer[0]);
66  *iBufferPtr++ = (int16_t)(floatBuffer[1]);
67  *iBufferPtr++ = (int16_t)(floatBuffer[2]);
68  *iBufferPtr++ = (int16_t)(floatBuffer[3]);
69  }
70 
71  number = quarterPoints * 4;
72  iBufferPtr = &iBuffer[number];
73  for(; number < num_points; number++){
74  *iBufferPtr++ = (int16_t)(*complexVectorPtr++ * scalar);
75  complexVectorPtr++;
76  }
77 }
78 #endif /* LV_HAVE_SSE */
79 
80 #ifdef LV_HAVE_GENERIC
81 /*!
82  \brief Deinterleaves the complex vector, multiply the value by the scalar, convert to 16t, and in I vector data
83  \param complexVector The complex input vector
84  \param scalar The value to be multiply against each of the input values
85  \param iBuffer The I buffer output data
86  \param num_points The number of complex data values to be deinterleaved
87 */
88 static inline void volk_32fc_s32f_deinterleave_real_16i_generic(int16_t* iBuffer, const lv_32fc_t* complexVector, const float scalar, unsigned int num_points){
89  const float* complexVectorPtr = (float*)complexVector;
90  int16_t* iBufferPtr = iBuffer;
91  unsigned int number = 0;
92  for(number = 0; number < num_points; number++){
93  *iBufferPtr++ = (int16_t)(*complexVectorPtr++ * scalar);
94  complexVectorPtr++;
95  }
96 
97 }
98 #endif /* LV_HAVE_GENERIC */
99 
100 
101 
102 
103 #endif /* INCLUDED_volk_32fc_s32f_deinterleave_real_16i_a_H */
signed short int16_t
Definition: stdint.h:76
#define __VOLK_ATTR_ALIGNED(x)
Definition: volk_common.h:27
float complex lv_32fc_t
Definition: volk_complex.h:56