GNU Radio 3.6.4.2 C++ API
|
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_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 */ 00072 #ifndef INCLUDED_volk_16i_convert_8i_a_H 00073 #define INCLUDED_volk_16i_convert_8i_a_H 00074 00075 #include <inttypes.h> 00076 #include <stdio.h> 00077 00078 #ifdef LV_HAVE_SSE2 00079 #include <emmintrin.h> 00080 /*! 00081 \brief Converts the input 16 bit integer data into 8 bit integer data 00082 \param inputVector The 16 bit input data buffer 00083 \param outputVector The 8 bit output data buffer 00084 \param num_points The number of data values to be converted 00085 */ 00086 static inline void volk_16i_convert_8i_a_sse2(int8_t* outputVector, const int16_t* inputVector, unsigned int num_points){ 00087 unsigned int number = 0; 00088 const unsigned int sixteenthPoints = num_points / 16; 00089 00090 int8_t* outputVectorPtr = outputVector; 00091 int16_t* inputPtr = (int16_t*)inputVector; 00092 __m128i inputVal1; 00093 __m128i inputVal2; 00094 __m128i ret; 00095 00096 for(;number < sixteenthPoints; number++){ 00097 00098 // Load the 16 values 00099 inputVal1 = _mm_load_si128((__m128i*)inputPtr); inputPtr += 8; 00100 inputVal2 = _mm_load_si128((__m128i*)inputPtr); inputPtr += 8; 00101 00102 inputVal1 = _mm_srai_epi16(inputVal1, 8); 00103 inputVal2 = _mm_srai_epi16(inputVal2, 8); 00104 00105 ret = _mm_packs_epi16(inputVal1, inputVal2); 00106 00107 _mm_store_si128((__m128i*)outputVectorPtr, ret); 00108 00109 outputVectorPtr += 16; 00110 } 00111 00112 number = sixteenthPoints * 16; 00113 for(; number < num_points; number++){ 00114 outputVector[number] =(int8_t)(inputVector[number] >> 8); 00115 } 00116 } 00117 #endif /* LV_HAVE_SSE2 */ 00118 00119 #ifdef LV_HAVE_GENERIC 00120 /*! 00121 \brief Converts the input 16 bit integer data into 8 bit integer data 00122 \param inputVector The 16 bit input data buffer 00123 \param outputVector The 8 bit output data buffer 00124 \param num_points The number of data values to be converted 00125 */ 00126 static inline void volk_16i_convert_8i_a_generic(int8_t* outputVector, const int16_t* inputVector, unsigned int num_points){ 00127 int8_t* outputVectorPtr = outputVector; 00128 const int16_t* inputVectorPtr = inputVector; 00129 unsigned int number = 0; 00130 00131 for(number = 0; number < num_points; number++){ 00132 *outputVectorPtr++ = ((int8_t)(*inputVectorPtr++ >> 8)); 00133 } 00134 } 00135 #endif /* LV_HAVE_GENERIC */ 00136 00137 00138 00139 00140 #endif /* INCLUDED_volk_16i_convert_8i_a_H */