GNU Radio 3.6.5 C++ API
|
00001 #ifndef INCLUDED_volk_16i_convert_8i_a_H 00002 #define INCLUDED_volk_16i_convert_8i_a_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 */ 00015 static inline void volk_16i_convert_8i_a_sse2(int8_t* outputVector, const int16_t* inputVector, unsigned int num_points){ 00016 unsigned int number = 0; 00017 const unsigned int sixteenthPoints = num_points / 16; 00018 00019 int8_t* outputVectorPtr = outputVector; 00020 int16_t* inputPtr = (int16_t*)inputVector; 00021 __m128i inputVal1; 00022 __m128i inputVal2; 00023 __m128i ret; 00024 00025 for(;number < sixteenthPoints; number++){ 00026 00027 // Load the 16 values 00028 inputVal1 = _mm_load_si128((__m128i*)inputPtr); inputPtr += 8; 00029 inputVal2 = _mm_load_si128((__m128i*)inputPtr); inputPtr += 8; 00030 00031 inputVal1 = _mm_srai_epi16(inputVal1, 8); 00032 inputVal2 = _mm_srai_epi16(inputVal2, 8); 00033 00034 ret = _mm_packs_epi16(inputVal1, inputVal2); 00035 00036 _mm_store_si128((__m128i*)outputVectorPtr, ret); 00037 00038 outputVectorPtr += 16; 00039 } 00040 00041 number = sixteenthPoints * 16; 00042 for(; number < num_points; number++){ 00043 outputVector[number] =(int8_t)(inputVector[number] >> 8); 00044 } 00045 } 00046 #endif /* LV_HAVE_SSE2 */ 00047 00048 #ifdef LV_HAVE_GENERIC 00049 /*! 00050 \brief Converts the input 16 bit integer data into 8 bit integer data 00051 \param inputVector The 16 bit input data buffer 00052 \param outputVector The 8 bit output data buffer 00053 \param num_points The number of data values to be converted 00054 */ 00055 static inline void volk_16i_convert_8i_a_generic(int8_t* outputVector, const int16_t* inputVector, unsigned int num_points){ 00056 int8_t* outputVectorPtr = outputVector; 00057 const int16_t* inputVectorPtr = inputVector; 00058 unsigned int number = 0; 00059 00060 for(number = 0; number < num_points; number++){ 00061 *outputVectorPtr++ = ((int8_t)(*inputVectorPtr++ >> 8)); 00062 } 00063 } 00064 #endif /* LV_HAVE_GENERIC */ 00065 00066 00067 00068 00069 #endif /* INCLUDED_volk_16i_convert_8i_a_H */