From 2a54f8e291ded149268542a1fa23e870106d7e4b Mon Sep 17 00:00:00 2001 From: Tom Tsou Date: Thu, 8 Jan 2015 11:53:23 -0800 Subject: convert: Fix sc12 unpack shifting Resolve issue #666 "B200: Rx signal distortion when using SC12". During 12-bit unpacking, OTW samples are shifted into the high order bits of the 16-bit intermediate values. The remaining 4-bits are not zeroed and contain bits from adjacent samples. Consequently, signal distortion becomes noticable with spurs and other random signal garbage when operating at low signal levels. Signed-off-by: Tom Tsou --- host/lib/convert/convert_unpack_sc12.cpp | 16 ++++++++-------- 1 file changed, 8 insertions(+), 8 deletions(-) (limited to 'host') diff --git a/host/lib/convert/convert_unpack_sc12.cpp b/host/lib/convert/convert_unpack_sc12.cpp index a2aec2ae5..94b415355 100644 --- a/host/lib/convert/convert_unpack_sc12.cpp +++ b/host/lib/convert/convert_unpack_sc12.cpp @@ -62,17 +62,17 @@ void convert_sc12_item32_3_to_star_4 const boost::uint64_t line12 = (boost::uint64_t(line1) << 32) | line2; //step 1: shift out and mask off the individual numbers - const type i0 = type(boost::int16_t(line0 >> 16)*scalar); - const type q0 = type(boost::int16_t(line0 >> 4)*scalar); + const type i0 = type(boost::int16_t((line0 >> 16) & 0xfff0)*scalar); + const type q0 = type(boost::int16_t((line0 >> 4) & 0xfff0)*scalar); - const type i1 = type(boost::int16_t(line01 >> 24)*scalar); - const type q1 = type(boost::int16_t(line1 >> 12)*scalar); + const type i1 = type(boost::int16_t((line01 >> 24) & 0xfff0)*scalar); + const type q1 = type(boost::int16_t((line1 >> 12) & 0xfff0)*scalar); - const type i2 = type(boost::int16_t(line1 >> 0)*scalar); - const type q2 = type(boost::int16_t(line12 >> 20)*scalar); + const type i2 = type(boost::int16_t((line1 >> 0) & 0xfff0)*scalar); + const type q2 = type(boost::int16_t((line12 >> 20) & 0xfff0)*scalar); - const type i3 = type(boost::int16_t(line2 >> 8)*scalar); - const type q3 = type(boost::int16_t(line2 << 4)*scalar); + const type i3 = type(boost::int16_t((line2 >> 8) & 0xfff0)*scalar); + const type q3 = type(boost::int16_t((line2 << 4) & 0xfff0)*scalar); //step 2: load the outputs out0 = std::complex(i0, q0); -- cgit v1.2.3