aboutsummaryrefslogtreecommitdiffstats
path: root/host/lib
diff options
context:
space:
mode:
Diffstat (limited to 'host/lib')
-rw-r--r--host/lib/convert/convert_with_tables.cpp30
1 files changed, 30 insertions, 0 deletions
diff --git a/host/lib/convert/convert_with_tables.cpp b/host/lib/convert/convert_with_tables.cpp
index c45415d5d..c033a2959 100644
--- a/host/lib/convert/convert_with_tables.cpp
+++ b/host/lib/convert/convert_with_tables.cpp
@@ -17,6 +17,7 @@
#include "convert_common.hpp"
#include <uhd/utils/byteswap.hpp>
+#include <boost/math/special_functions/round.hpp>
#include <vector>
using namespace uhd::convert;
@@ -68,6 +69,19 @@ 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
+ 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;
+ }
+
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);
@@ -149,6 +163,14 @@ 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, SHIFT_PAIR0>());
}
+static converter::sptr make_convert_sc8_item32_be_1_to_sc16_1(void){
+ return converter::sptr(new convert_sc8_item32_1_to_fcxx_1<s16_t, uhd::ntohx, SHIFT_PAIR1>());
+}
+
+static converter::sptr make_convert_sc8_item32_le_1_to_sc16_1(void){
+ return converter::sptr(new convert_sc8_item32_1_to_fcxx_1<s16_t, uhd::wtohx, SHIFT_PAIR0>());
+}
+
UHD_STATIC_BLOCK(register_convert_sc16_item32_1_to_fcxx_1){
uhd::convert::id_type id;
id.num_inputs = 1;
@@ -185,4 +207,12 @@ UHD_STATIC_BLOCK(register_convert_sc16_item32_1_to_fcxx_1){
id.output_format = "fc64";
id.input_format = "sc8_item32_le";
uhd::convert::register_converter(id, &make_convert_sc8_item32_le_1_to_fc64_1, PRIORITY_TABLE);
+
+ id.output_format = "sc16";
+ id.input_format = "sc8_item32_be";
+ uhd::convert::register_converter(id, &make_convert_sc8_item32_be_1_to_sc16_1, PRIORITY_TABLE);
+
+ id.output_format = "sc16";
+ id.input_format = "sc8_item32_le";
+ uhd::convert::register_converter(id, &make_convert_sc8_item32_le_1_to_sc16_1, PRIORITY_TABLE);
}