From c0a9d1c71cb0d82085221ffca4974a573de98552 Mon Sep 17 00:00:00 2001 From: Josh Blum Date: Thu, 10 May 2012 00:15:07 -0700 Subject: convert: applied sc8 signed convert fix --- host/lib/convert/convert_common.hpp | 20 ++++++++++++-------- 1 file changed, 12 insertions(+), 8 deletions(-) (limited to 'host/lib') diff --git a/host/lib/convert/convert_common.hpp b/host/lib/convert/convert_common.hpp index 602e60230..c1051ba46 100644 --- a/host/lib/convert/convert_common.hpp +++ b/host/lib/convert/convert_common.hpp @@ -150,22 +150,26 @@ UHD_INLINE void item32_sc16_to_xx( template UHD_INLINE item32_t xx_to_item32_sc8_x1( const std::complex &in0, const std::complex &in1, const double scale_factor ){ + boost::uint8_t real0 = boost::int8_t(in0.real()*float(scale_factor)); + boost::uint8_t imag0 = boost::int8_t(in0.imag()*float(scale_factor)); + boost::uint8_t real1 = boost::int8_t(in1.real()*float(scale_factor)); + boost::uint8_t imag1 = boost::int8_t(in1.imag()*float(scale_factor)); return - (item32_t(boost::uint8_t(in0.real()*float(scale_factor))) << 8) | - (item32_t(boost::uint8_t(in0.imag()*float(scale_factor))) << 0) | - (item32_t(boost::uint8_t(in1.real()*float(scale_factor))) << 24) | - (item32_t(boost::uint8_t(in1.imag()*float(scale_factor))) << 16) + (item32_t(real0) << 8) | (item32_t(imag0) << 0) | + (item32_t(real1) << 24) | (item32_t(imag1) << 16) ; } template <> UHD_INLINE item32_t xx_to_item32_sc8_x1( const sc16_t &in0, const sc16_t &in1, const double ){ + boost::uint8_t real0 = boost::int8_t(in0.real()); + boost::uint8_t imag0 = boost::int8_t(in0.imag()); + boost::uint8_t real1 = boost::int8_t(in1.real()); + boost::uint8_t imag1 = boost::int8_t(in1.imag()); return - (item32_t(boost::uint8_t(in0.real())) << 8) | - (item32_t(boost::uint8_t(in0.imag())) << 0) | - (item32_t(boost::uint8_t(in1.real())) << 24) | - (item32_t(boost::uint8_t(in1.imag())) << 16) + (item32_t(real0) << 8) | (item32_t(imag0) << 0) | + (item32_t(real1) << 24) | (item32_t(imag1) << 16) ; } -- cgit v1.2.3