GNU Radio 3.6.5 C++ API
|
00001 #ifndef INCLUDED_volk_16u_byteswap_a_H 00002 #define INCLUDED_volk_16u_byteswap_a_H 00003 00004 #include <inttypes.h> 00005 #include <stdio.h> 00006 00007 #ifdef LV_HAVE_SSE2 00008 #include <emmintrin.h> 00009 00010 /*! 00011 \brief Byteswaps (in-place) an aligned vector of int16_t's. 00012 \param intsToSwap The vector of data to byte swap 00013 \param numDataPoints The number of data points 00014 */ 00015 static inline void volk_16u_byteswap_a_sse2(uint16_t* intsToSwap, unsigned int num_points){ 00016 unsigned int number = 0; 00017 uint16_t* inputPtr = intsToSwap; 00018 __m128i input, left, right, output; 00019 00020 const unsigned int eighthPoints = num_points / 8; 00021 for(;number < eighthPoints; number++){ 00022 // Load the 16t values, increment inputPtr later since we're doing it in-place. 00023 input = _mm_load_si128((__m128i*)inputPtr); 00024 // Do the two shifts 00025 left = _mm_slli_epi16(input, 8); 00026 right = _mm_srli_epi16(input, 8); 00027 // Or the left and right halves together 00028 output = _mm_or_si128(left, right); 00029 // Store the results 00030 _mm_store_si128((__m128i*)inputPtr, output); 00031 inputPtr += 8; 00032 } 00033 00034 00035 // Byteswap any remaining points: 00036 number = eighthPoints*8; 00037 for(; number < num_points; number++){ 00038 uint16_t outputVal = *inputPtr; 00039 outputVal = (((outputVal >> 8) & 0xff) | ((outputVal << 8) & 0xff00)); 00040 *inputPtr = outputVal; 00041 inputPtr++; 00042 } 00043 } 00044 #endif /* LV_HAVE_SSE2 */ 00045 00046 #ifdef LV_HAVE_GENERIC 00047 /*! 00048 \brief Byteswaps (in-place) an aligned vector of int16_t's. 00049 \param intsToSwap The vector of data to byte swap 00050 \param numDataPoints The number of data points 00051 */ 00052 static inline void volk_16u_byteswap_a_generic(uint16_t* intsToSwap, unsigned int num_points){ 00053 unsigned int point; 00054 uint16_t* inputPtr = intsToSwap; 00055 for(point = 0; point < num_points; point++){ 00056 uint16_t output = *inputPtr; 00057 output = (((output >> 8) & 0xff) | ((output << 8) & 0xff00)); 00058 *inputPtr = output; 00059 inputPtr++; 00060 } 00061 } 00062 #endif /* LV_HAVE_GENERIC */ 00063 00064 #ifdef LV_HAVE_ORC 00065 /*! 00066 \brief Byteswaps (in-place) an aligned vector of int16_t's. 00067 \param intsToSwap The vector of data to byte swap 00068 \param numDataPoints The number of data points 00069 */ 00070 extern void volk_16u_byteswap_a_orc_impl(uint16_t* intsToSwap, unsigned int num_points); 00071 static inline void volk_16u_byteswap_a_orc(uint16_t* intsToSwap, unsigned int num_points){ 00072 volk_16u_byteswap_a_orc_impl(intsToSwap, num_points); 00073 } 00074 #endif /* LV_HAVE_ORC */ 00075 00076 00077 #endif /* INCLUDED_volk_16u_byteswap_a_H */