diff options
author | Josh Blum <josh@joshknows.com> | 2011-11-13 17:11:15 -0800 |
---|---|---|
committer | Josh Blum <josh@joshknows.com> | 2011-11-13 17:11:15 -0800 |
commit | 7a1bd6135ad7201f4a23ee71d929ae15de26a103 (patch) | |
tree | de392478c0f9cc4e1dc14c4db4f58c81d4b27fd5 /host | |
parent | ff49029e395e5c78c7ad76e9ff2d7370e5503e7f (diff) | |
download | uhd-7a1bd6135ad7201f4a23ee71d929ae15de26a103.tar.gz uhd-7a1bd6135ad7201f4a23ee71d929ae15de26a103.tar.bz2 uhd-7a1bd6135ad7201f4a23ee71d929ae15de26a103.zip |
uhd: fixed sc8 table conversion, and simplified shifts
Diffstat (limited to 'host')
-rw-r--r-- | host/lib/convert/convert_with_tables.cpp | 34 |
1 files changed, 15 insertions, 19 deletions
diff --git a/host/lib/convert/convert_with_tables.cpp b/host/lib/convert/convert_with_tables.cpp index ac12b4440..bcb7ec2c7 100644 --- a/host/lib/convert/convert_with_tables.cpp +++ b/host/lib/convert/convert_with_tables.cpp @@ -29,7 +29,7 @@ typedef boost::uint16_t (*tohost16_type)(boost::uint16_t); * Implementation for sc16 lookup table * - Lookup the real and imaginary parts individually **********************************************************************/ -template <typename type, tohost16_type tohost, size_t lo_shift, size_t hi_shift> +template <typename type, tohost16_type tohost, size_t re_shift, size_t im_shift> class convert_sc16_item32_1_to_fcxx_1 : public converter{ public: convert_sc16_item32_1_to_fcxx_1(void): _table(sc16_table_len){} @@ -48,8 +48,8 @@ public: for (size_t i = 0; i < nsamps; i++){ const item32_t item = input[i]; output[i] = std::complex<type>( - _table[boost::uint16_t(item >> lo_shift)], - _table[boost::uint16_t(item >> hi_shift)] + _table[boost::uint16_t(item >> re_shift)], + _table[boost::uint16_t(item >> im_shift)] ); } } @@ -108,47 +108,43 @@ private: **********************************************************************/ #ifdef BOOST_BIG_ENDIAN -# define BE_LO_SHIFT 16 -# define BE_HI_SHIFT 0 -# define LE_LO_SHIFT 0 -# define LE_HI_SHIFT 16 +# define SHIFT_PAIR0 16, 0 +# define SHIFT_PAIR1 0, 16 #else -# define BE_LO_SHIFT 0 -# define BE_HI_SHIFT 16 -# define LE_LO_SHIFT 16 -# define LE_HI_SHIFT 0 +# define SHIFT_PAIR0 0, 16 +# define SHIFT_PAIR1 16, 0 #endif static converter::sptr make_convert_sc16_item32_be_1_to_fc32_1(void){ - return converter::sptr(new convert_sc16_item32_1_to_fcxx_1<float, uhd::ntohx, BE_LO_SHIFT, BE_HI_SHIFT>()); + return converter::sptr(new convert_sc16_item32_1_to_fcxx_1<float, uhd::ntohx, SHIFT_PAIR0>()); } static converter::sptr make_convert_sc16_item32_be_1_to_fc64_1(void){ - return converter::sptr(new convert_sc16_item32_1_to_fcxx_1<double, uhd::ntohx, BE_LO_SHIFT, BE_HI_SHIFT>()); + return converter::sptr(new convert_sc16_item32_1_to_fcxx_1<double, uhd::ntohx, SHIFT_PAIR0>()); } static converter::sptr make_convert_sc16_item32_le_1_to_fc32_1(void){ - return converter::sptr(new convert_sc16_item32_1_to_fcxx_1<float, uhd::wtohx, LE_LO_SHIFT, LE_HI_SHIFT>()); + return converter::sptr(new convert_sc16_item32_1_to_fcxx_1<float, uhd::wtohx, SHIFT_PAIR1>()); } static converter::sptr make_convert_sc16_item32_le_1_to_fc64_1(void){ - return converter::sptr(new convert_sc16_item32_1_to_fcxx_1<double, uhd::wtohx, LE_LO_SHIFT, LE_HI_SHIFT>()); + return converter::sptr(new convert_sc16_item32_1_to_fcxx_1<double, uhd::wtohx, SHIFT_PAIR1>()); } static converter::sptr make_convert_sc8_item32_be_1_to_fc32_1(void){ - return converter::sptr(new convert_sc8_item32_1_to_fcxx_1<float, uhd::ntohx, BE_LO_SHIFT, BE_HI_SHIFT>()); + return converter::sptr(new convert_sc8_item32_1_to_fcxx_1<float, uhd::ntohx, SHIFT_PAIR1>()); } static converter::sptr make_convert_sc8_item32_be_1_to_fc64_1(void){ - return converter::sptr(new convert_sc8_item32_1_to_fcxx_1<double, uhd::ntohx, BE_LO_SHIFT, BE_HI_SHIFT>()); + return converter::sptr(new convert_sc8_item32_1_to_fcxx_1<double, uhd::ntohx, SHIFT_PAIR1>()); } static converter::sptr make_convert_sc8_item32_le_1_to_fc32_1(void){ - return converter::sptr(new convert_sc8_item32_1_to_fcxx_1<float, uhd::wtohx, LE_LO_SHIFT, LE_HI_SHIFT>()); + return converter::sptr(new convert_sc8_item32_1_to_fcxx_1<float, uhd::wtohx, SHIFT_PAIR0>()); } static converter::sptr make_convert_sc8_item32_le_1_to_fc64_1(void){ - return converter::sptr(new convert_sc8_item32_1_to_fcxx_1<double, uhd::wtohx, LE_LO_SHIFT, LE_HI_SHIFT>()); + return converter::sptr(new convert_sc8_item32_1_to_fcxx_1<double, uhd::wtohx, SHIFT_PAIR0>()); } UHD_STATIC_BLOCK(register_convert_sc16_item32_1_to_fcxx_1){ |