GNU Radio 3.6.5 C++ API

volk_16i_convert_8i_u.h

Go to the documentation of this file.
00001 #ifndef INCLUDED_volk_16i_convert_8i_u_H
00002 #define INCLUDED_volk_16i_convert_8i_u_H
00003 
00004 #include <inttypes.h>
00005 #include <stdio.h>
00006 
00007 #ifdef LV_HAVE_SSE2
00008 #include <emmintrin.h>
00009 /*!
00010   \brief Converts the input 16 bit integer data into 8 bit integer data
00011   \param inputVector The 16 bit input data buffer
00012   \param outputVector The 8 bit output data buffer
00013   \param num_points The number of data values to be converted
00014   \note Input and output buffers do NOT need to be properly aligned
00015 */
00016 static inline void volk_16i_convert_8i_u_sse2(int8_t* outputVector, const int16_t* inputVector, unsigned int num_points){
00017     unsigned int number = 0;
00018     const unsigned int sixteenthPoints = num_points / 16;
00019 
00020      int8_t* outputVectorPtr = outputVector;
00021     int16_t* inputPtr = (int16_t*)inputVector;
00022     __m128i inputVal1;
00023     __m128i inputVal2;
00024     __m128i ret;
00025 
00026     for(;number < sixteenthPoints; number++){
00027 
00028       // Load the 16 values
00029       inputVal1 = _mm_loadu_si128((__m128i*)inputPtr); inputPtr += 8;
00030       inputVal2 = _mm_loadu_si128((__m128i*)inputPtr); inputPtr += 8;
00031 
00032       inputVal1 = _mm_srai_epi16(inputVal1, 8);
00033       inputVal2 = _mm_srai_epi16(inputVal2, 8);
00034 
00035       ret = _mm_packs_epi16(inputVal1, inputVal2);
00036 
00037       _mm_storeu_si128((__m128i*)outputVectorPtr, ret);
00038 
00039       outputVectorPtr += 16;
00040     }
00041 
00042     number = sixteenthPoints * 16;
00043     for(; number < num_points; number++){
00044       outputVector[number] =(int8_t)(inputVector[number] >> 8);
00045     }
00046 }
00047 #endif /* LV_HAVE_SSE2 */
00048 
00049 #ifdef LV_HAVE_GENERIC
00050 /*!
00051   \brief Converts the input 16 bit integer data into 8 bit integer data
00052   \param inputVector The 16 bit input data buffer
00053   \param outputVector The 8 bit output data buffer
00054   \param num_points The number of data values to be converted
00055   \note Input and output buffers do NOT need to be properly aligned
00056 */
00057 static inline void volk_16i_convert_8i_u_generic(int8_t* outputVector, const int16_t* inputVector, unsigned int num_points){
00058   int8_t* outputVectorPtr = outputVector;
00059   const int16_t* inputVectorPtr = inputVector;
00060   unsigned int number = 0;
00061 
00062   for(number = 0; number < num_points; number++){
00063     *outputVectorPtr++ = ((int8_t)(*inputVectorPtr++  >> 8));
00064   }
00065 }
00066 #endif /* LV_HAVE_GENERIC */
00067 
00068 
00069 
00070 
00071 #endif /* INCLUDED_volk_16i_convert_8i_u_H */