From 3122bff9c288e4dd72643ddb2f9988d6f295aed4 Mon Sep 17 00:00:00 2001 From: Josh Blum Date: Tue, 12 Jun 2012 09:48:20 -0700 Subject: convert: add sc8 host to/from sc8 wire format --- host/lib/convert/convert_common.hpp | 26 ++++++++++++++++++++++++++ 1 file changed, 26 insertions(+) (limited to 'host/lib/convert/convert_common.hpp') diff --git a/host/lib/convert/convert_common.hpp b/host/lib/convert/convert_common.hpp index c1051ba46..933978a8f 100644 --- a/host/lib/convert/convert_common.hpp +++ b/host/lib/convert/convert_common.hpp @@ -173,6 +173,19 @@ template <> UHD_INLINE item32_t xx_to_item32_sc8_x1( ; } +template <> UHD_INLINE item32_t xx_to_item32_sc8_x1( + const sc8_t &in0, const sc8_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(real0) << 8) | (item32_t(imag0) << 0) | + (item32_t(real1) << 24) | (item32_t(imag1) << 16) + ; +} + template UHD_INLINE void xx_to_item32_sc8( const std::complex *input, @@ -221,6 +234,19 @@ template <> UHD_INLINE void item32_sc8_x1_to_xx( ); } +template <> UHD_INLINE void item32_sc8_x1_to_xx( + const item32_t item, sc8_t &out0, sc8_t &out1, const double +){ + out0 = sc8_t( + boost::int8_t(boost::int8_t(item >> 8)), + boost::int8_t(boost::int8_t(item >> 0)) + ); + out1 = sc8_t( + boost::int8_t(boost::int8_t(item >> 24)), + boost::int8_t(boost::int8_t(item >> 16)) + ); +} + template UHD_INLINE void item32_sc8_to_xx( const item32_t *input, -- cgit v1.2.3