diff options
author | Josh Blum <josh@joshknows.com> | 2012-01-30 22:23:38 -0800 |
---|---|---|
committer | Josh Blum <josh@joshknows.com> | 2012-01-31 14:56:31 -0800 |
commit | d46c176af34b728fd43b3dd46485b38623a7335e (patch) | |
tree | 4c93a5dc27c6c5213c858f6c4312d1195a44e32d /host/lib/convert/convert_with_tables.cpp | |
parent | 781cafa8717f00b883a4543b4a9150060691eee3 (diff) | |
download | uhd-d46c176af34b728fd43b3dd46485b38623a7335e.tar.gz uhd-d46c176af34b728fd43b3dd46485b38623a7335e.tar.bz2 uhd-d46c176af34b728fd43b3dd46485b38623a7335e.zip |
dsp rework: tx trailer, scaling work (peak)
Diffstat (limited to 'host/lib/convert/convert_with_tables.cpp')
-rw-r--r-- | host/lib/convert/convert_with_tables.cpp | 21 |
1 files changed, 8 insertions, 13 deletions
diff --git a/host/lib/convert/convert_with_tables.cpp b/host/lib/convert/convert_with_tables.cpp index c033a2959..2379739a7 100644 --- a/host/lib/convert/convert_with_tables.cpp +++ b/host/lib/convert/convert_with_tables.cpp @@ -68,24 +68,19 @@ class convert_sc8_item32_1_to_fcxx_1 : public converter{ public: convert_sc8_item32_1_to_fcxx_1(void): _table(sc16_table_len){} - void set_scalar(const double scalar){ - - //special case, this is converts sc8 to sc16, - //use the scale-factor but no normalization + //special case for sc16 type, 32767 undoes float normalization + static type conv(const boost::int8_t &num, const double scalar){ if (sizeof(type) == sizeof(s16_t)){ - for (size_t i = 0; i < sc16_table_len; i++){ - const boost::uint16_t val = tohost(boost::uint16_t(i & 0xffff)); - const type real = type(boost::math::iround(boost::int8_t(val >> 8)*scalar*32767)); - const type imag = type(boost::math::iround(boost::int8_t(val >> 0)*scalar*32767)); - _table[i] = std::complex<type>(real, imag); - } - return; + return type(boost::math::iround(num*scalar*32767)); } + return type(num*scalar); + } + void set_scalar(const double scalar){ for (size_t i = 0; i < sc16_table_len; i++){ const boost::uint16_t val = tohost(boost::uint16_t(i & 0xffff)); - const type real = type(boost::int8_t(val >> 8)*scalar); - const type imag = type(boost::int8_t(val >> 0)*scalar); + const type real = conv(boost::int8_t(val >> 8), scalar); + const type imag = conv(boost::int8_t(val >> 0), scalar); _table[i] = std::complex<type>(real, imag); } } |