aboutsummaryrefslogtreecommitdiffstats
path: root/host
diff options
context:
space:
mode:
authorJosh Blum <josh@joshknows.com>2013-08-28 17:07:07 -0700
committerJosh Blum <josh@joshknows.com>2013-08-28 17:07:07 -0700
commit9f993843e52b1da877fd579de499e492f602ce81 (patch)
tree7a8e28f0f7f84ae22da44712ea3b76507cc0a1b6 /host
parent96e50aebb7a4b3f98aac3c11aa1a3f06c14c0849 (diff)
downloaduhd-9f993843e52b1da877fd579de499e492f602ce81.tar.gz
uhd-9f993843e52b1da877fd579de499e492f602ce81.tar.bz2
uhd-9f993843e52b1da877fd579de499e492f602ce81.zip
convert: sc8 swap for vita compliance
Diffstat (limited to 'host')
-rw-r--r--host/lib/convert/convert_common.hpp38
-rw-r--r--host/lib/convert/convert_orc.orc1
-rw-r--r--host/lib/convert/convert_with_orc.cpp4
-rw-r--r--host/lib/convert/convert_with_tables.cpp30
-rw-r--r--host/lib/convert/sse2_fc32_to_sc8.cpp6
-rw-r--r--host/lib/convert/sse2_fc64_to_sc8.cpp18
-rw-r--r--host/lib/convert/sse2_sc8_to_fc32.cpp6
-rw-r--r--host/lib/convert/sse2_sc8_to_fc64.cpp6
8 files changed, 54 insertions, 55 deletions
diff --git a/host/lib/convert/convert_common.hpp b/host/lib/convert/convert_common.hpp
index 933978a8f..ceaa1151c 100644
--- a/host/lib/convert/convert_common.hpp
+++ b/host/lib/convert/convert_common.hpp
@@ -1,5 +1,5 @@
//
-// Copyright 2011-2012 Ettus Research LLC
+// Copyright 2011-2013 Ettus Research LLC
//
// This program is free software: you can redistribute it and/or modify
// it under the terms of the GNU General Public License as published by
@@ -150,10 +150,10 @@ UHD_INLINE void item32_sc16_to_xx(
template <typename T> UHD_INLINE item32_t xx_to_item32_sc8_x1(
const std::complex<T> &in0, const std::complex<T> &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));
+ boost::uint8_t real1 = boost::int8_t(in0.real()*float(scale_factor));
+ boost::uint8_t imag1 = boost::int8_t(in0.imag()*float(scale_factor));
+ boost::uint8_t real0 = boost::int8_t(in1.real()*float(scale_factor));
+ boost::uint8_t imag0 = boost::int8_t(in1.imag()*float(scale_factor));
return
(item32_t(real0) << 8) | (item32_t(imag0) << 0) |
(item32_t(real1) << 24) | (item32_t(imag1) << 16)
@@ -163,10 +163,10 @@ template <typename T> UHD_INLINE item32_t xx_to_item32_sc8_x1(
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());
+ boost::uint8_t real1 = boost::int8_t(in0.real());
+ boost::uint8_t imag1 = boost::int8_t(in0.imag());
+ boost::uint8_t real0 = boost::int8_t(in1.real());
+ boost::uint8_t imag0 = boost::int8_t(in1.imag());
return
(item32_t(real0) << 8) | (item32_t(imag0) << 0) |
(item32_t(real1) << 24) | (item32_t(imag1) << 16)
@@ -176,10 +176,10 @@ 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());
+ boost::uint8_t real1 = boost::int8_t(in0.real());
+ boost::uint8_t imag1 = boost::int8_t(in0.imag());
+ boost::uint8_t real0 = boost::int8_t(in1.real());
+ boost::uint8_t imag0 = boost::int8_t(in1.imag());
return
(item32_t(real0) << 8) | (item32_t(imag0) << 0) |
(item32_t(real1) << 24) | (item32_t(imag1) << 16)
@@ -211,11 +211,11 @@ UHD_INLINE void xx_to_item32_sc8(
template <typename T> UHD_INLINE void item32_sc8_x1_to_xx(
const item32_t item, std::complex<T> &out0, std::complex<T> &out1, const double scale_factor
){
- out0 = std::complex<T>(
+ out1 = std::complex<T>(
T(boost::int8_t(item >> 8)*float(scale_factor)),
T(boost::int8_t(item >> 0)*float(scale_factor))
);
- out1 = std::complex<T>(
+ out0 = std::complex<T>(
T(boost::int8_t(item >> 24)*float(scale_factor)),
T(boost::int8_t(item >> 16)*float(scale_factor))
);
@@ -224,11 +224,11 @@ template <typename T> UHD_INLINE void item32_sc8_x1_to_xx(
template <> UHD_INLINE void item32_sc8_x1_to_xx(
const item32_t item, sc16_t &out0, sc16_t &out1, const double
){
- out0 = sc16_t(
+ out1 = sc16_t(
boost::int16_t(boost::int8_t(item >> 8)),
boost::int16_t(boost::int8_t(item >> 0))
);
- out1 = sc16_t(
+ out0 = sc16_t(
boost::int16_t(boost::int8_t(item >> 24)),
boost::int16_t(boost::int8_t(item >> 16))
);
@@ -237,11 +237,11 @@ 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(
+ out1 = sc8_t(
boost::int8_t(boost::int8_t(item >> 8)),
boost::int8_t(boost::int8_t(item >> 0))
);
- out1 = sc8_t(
+ out0 = sc8_t(
boost::int8_t(boost::int8_t(item >> 24)),
boost::int8_t(boost::int8_t(item >> 16))
);
diff --git a/host/lib/convert/convert_orc.orc b/host/lib/convert/convert_orc.orc
index f7075606e..ffb298f26 100644
--- a/host/lib/convert/convert_orc.orc
+++ b/host/lib/convert/convert_orc.orc
@@ -75,6 +75,5 @@ swapl dst, src
.floatparam 4 scalar
x2 mulf tmp, src, scalar
x2 convfl tmp, tmp
-swaplq tmp, tmp
x2 convlw tmp2, tmp
x2 convwb dst, tmp2
diff --git a/host/lib/convert/convert_with_orc.cpp b/host/lib/convert/convert_with_orc.cpp
index e44c8ca73..19755fa44 100644
--- a/host/lib/convert/convert_with_orc.cpp
+++ b/host/lib/convert/convert_with_orc.cpp
@@ -1,5 +1,5 @@
//
-// Copyright 2011 Ettus Research LLC
+// Copyright 2011-2013 Ettus Research LLC
//
// This program is free software: you can redistribute it and/or modify
// it under the terms of the GNU General Public License as published by
@@ -57,9 +57,9 @@ DECLARE_CONVERTER(sc16_item32_le, 1, sc16, 1, PRIORITY_LIBORC){
DECLARE_CONVERTER(fc32, 1, sc8_item32_be, 1, PRIORITY_LIBORC){
_convert_fc32_1_to_sc8_1_nswap_orc(outputs[0], inputs[0], scale_factor, nsamps);
- _convert_swap_byte_pairs_orc(outputs[0], outputs[0], (nsamps + 1)/2);
}
DECLARE_CONVERTER(fc32, 1, sc8_item32_le, 1, PRIORITY_LIBORC){
_convert_fc32_1_to_sc8_1_nswap_orc(outputs[0], inputs[0], scale_factor, nsamps);
+ _convert_swap_byte_pairs_orc(outputs[0], outputs[0], (nsamps + 1)/2);
}
diff --git a/host/lib/convert/convert_with_tables.cpp b/host/lib/convert/convert_with_tables.cpp
index cd7773d4b..4d295fa01 100644
--- a/host/lib/convert/convert_with_tables.cpp
+++ b/host/lib/convert/convert_with_tables.cpp
@@ -1,5 +1,5 @@
//
-// Copyright 2011-2012 Ettus Research LLC
+// Copyright 2011-2013 Ettus Research LLC
//
// This program is free software: you can redistribute it and/or modify
// it under the terms of the GNU General Public License as published by
@@ -59,16 +59,16 @@ public:
item32_t lookup(const sc16_t &in0, const sc16_t &in1){
if (swap){ //hope this compiles out, its a template constant
return
- (item32_t(_table[boost::uint16_t(in0.real())]) << 16) |
- (item32_t(_table[boost::uint16_t(in0.imag())]) << 24) |
- (item32_t(_table[boost::uint16_t(in1.real())]) << 0) |
- (item32_t(_table[boost::uint16_t(in1.imag())]) << 8) ;
+ (item32_t(_table[boost::uint16_t(in1.real())]) << 16) |
+ (item32_t(_table[boost::uint16_t(in1.imag())]) << 24) |
+ (item32_t(_table[boost::uint16_t(in0.real())]) << 0) |
+ (item32_t(_table[boost::uint16_t(in0.imag())]) << 8) ;
}
return
- (item32_t(_table[boost::uint16_t(in0.real())]) << 8) |
- (item32_t(_table[boost::uint16_t(in0.imag())]) << 0) |
- (item32_t(_table[boost::uint16_t(in1.real())]) << 24) |
- (item32_t(_table[boost::uint16_t(in1.imag())]) << 16) ;
+ (item32_t(_table[boost::uint16_t(in1.real())]) << 8) |
+ (item32_t(_table[boost::uint16_t(in1.imag())]) << 0) |
+ (item32_t(_table[boost::uint16_t(in0.real())]) << 24) |
+ (item32_t(_table[boost::uint16_t(in0.imag())]) << 16) ;
}
private:
@@ -196,27 +196,27 @@ static converter::sptr make_convert_sc16_item32_le_1_to_fc64_1(void){
}
static converter::sptr make_convert_sc8_item32_be_1_to_fc32_1(void){
- return converter::sptr(new convert_sc8_item32_1_to_fcxx_1<float, uhd::ntohx, SHIFT_PAIR1>());
+ return converter::sptr(new convert_sc8_item32_1_to_fcxx_1<float, uhd::ntohx, SHIFT_PAIR0>());
}
static converter::sptr make_convert_sc8_item32_be_1_to_fc64_1(void){
- return converter::sptr(new convert_sc8_item32_1_to_fcxx_1<double, uhd::ntohx, SHIFT_PAIR1>());
+ return converter::sptr(new convert_sc8_item32_1_to_fcxx_1<double, uhd::ntohx, SHIFT_PAIR0>());
}
static converter::sptr make_convert_sc8_item32_le_1_to_fc32_1(void){
- return converter::sptr(new convert_sc8_item32_1_to_fcxx_1<float, uhd::wtohx, SHIFT_PAIR0>());
+ return converter::sptr(new convert_sc8_item32_1_to_fcxx_1<float, uhd::wtohx, SHIFT_PAIR1>());
}
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>());
+ return converter::sptr(new convert_sc8_item32_1_to_fcxx_1<double, uhd::wtohx, SHIFT_PAIR1>());
}
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>());
+ return converter::sptr(new convert_sc8_item32_1_to_fcxx_1<s16_t, uhd::ntohx, SHIFT_PAIR0>());
}
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>());
+ return converter::sptr(new convert_sc8_item32_1_to_fcxx_1<s16_t, uhd::wtohx, SHIFT_PAIR1>());
}
static converter::sptr make_convert_sc16_1_to_sc8_item32_be_1(void){
diff --git a/host/lib/convert/sse2_fc32_to_sc8.cpp b/host/lib/convert/sse2_fc32_to_sc8.cpp
index dd884640d..36aa68b0e 100644
--- a/host/lib/convert/sse2_fc32_to_sc8.cpp
+++ b/host/lib/convert/sse2_fc32_to_sc8.cpp
@@ -1,5 +1,5 @@
//
-// Copyright 2012 Ettus Research LLC
+// Copyright 2012-2013 Ettus Research LLC
//
// This program is free software: you can redistribute it and/or modify
// it under the terms of the GNU General Public License as published by
@@ -47,7 +47,7 @@ DECLARE_CONVERTER(fc32, 1, sc8_item32_be, 1, PRIORITY_SIMD){
item32_t *output = reinterpret_cast<item32_t *>(outputs[0]);
const __m128 scalar = _mm_set_ps1(float(scale_factor));
- const int shuf = _MM_SHUFFLE(1, 0, 3, 2);
+ const int shuf = _MM_SHUFFLE(3, 2, 1, 0);
#define convert_fc32_1_to_sc8_item32_1_bswap_guts(_al_) \
for (size_t j = 0; i+7 < nsamps; i+=8, j+=4){ \
@@ -83,7 +83,7 @@ DECLARE_CONVERTER(fc32, 1, sc8_item32_le, 1, PRIORITY_SIMD){
item32_t *output = reinterpret_cast<item32_t *>(outputs[0]);
const __m128 scalar = _mm_set_ps1(float(scale_factor));
- const int shuf = _MM_SHUFFLE(2, 3, 0, 1);
+ const int shuf = _MM_SHUFFLE(0, 1, 2, 3);
#define convert_fc32_1_to_sc8_item32_1_nswap_guts(_al_) \
for (size_t j = 0; i+7 < nsamps; i+=8, j+=4){ \
diff --git a/host/lib/convert/sse2_fc64_to_sc8.cpp b/host/lib/convert/sse2_fc64_to_sc8.cpp
index bf3719e13..82a8e0bb0 100644
--- a/host/lib/convert/sse2_fc64_to_sc8.cpp
+++ b/host/lib/convert/sse2_fc64_to_sc8.cpp
@@ -1,5 +1,5 @@
//
-// Copyright 2012 Ettus Research LLC
+// Copyright 2012-2013 Ettus Research LLC
//
// This program is free software: you can redistribute it and/or modify
// it under the terms of the GNU General Public License as published by
@@ -59,10 +59,10 @@ DECLARE_CONVERTER(fc64, 1, sc8_item32_be, 1, PRIORITY_SIMD){
\
/* interleave */ \
const __m128i tmpi = pack_sc8_item32_4x( \
- pack_sc32_4x(tmp0, tmp1, scalar), \
- pack_sc32_4x(tmp2, tmp3, scalar), \
- pack_sc32_4x(tmp4, tmp5, scalar), \
- pack_sc32_4x(tmp6, tmp7, scalar) \
+ pack_sc32_4x(tmp1, tmp0, scalar), \
+ pack_sc32_4x(tmp3, tmp2, scalar), \
+ pack_sc32_4x(tmp5, tmp4, scalar), \
+ pack_sc32_4x(tmp7, tmp6, scalar) \
); \
\
/* store to output */ \
@@ -103,10 +103,10 @@ DECLARE_CONVERTER(fc64, 1, sc8_item32_le, 1, PRIORITY_SIMD){
\
/* interleave */ \
__m128i tmpi = pack_sc8_item32_4x( \
- pack_sc32_4x(tmp1, tmp0, scalar), \
- pack_sc32_4x(tmp3, tmp2, scalar), \
- pack_sc32_4x(tmp5, tmp4, scalar), \
- pack_sc32_4x(tmp7, tmp6, scalar) \
+ pack_sc32_4x(tmp0, tmp1, scalar), \
+ pack_sc32_4x(tmp2, tmp3, scalar), \
+ pack_sc32_4x(tmp4, tmp5, scalar), \
+ pack_sc32_4x(tmp6, tmp7, scalar) \
); \
tmpi = _mm_or_si128(_mm_srli_epi16(tmpi, 8), _mm_slli_epi16(tmpi, 8)); /*byteswap*/\
\
diff --git a/host/lib/convert/sse2_sc8_to_fc32.cpp b/host/lib/convert/sse2_sc8_to_fc32.cpp
index c0e561814..724af0225 100644
--- a/host/lib/convert/sse2_sc8_to_fc32.cpp
+++ b/host/lib/convert/sse2_sc8_to_fc32.cpp
@@ -1,5 +1,5 @@
//
-// Copyright 2012 Ettus Research LLC
+// Copyright 2012-2013 Ettus Research LLC
//
// This program is free software: you can redistribute it and/or modify
// it under the terms of the GNU General Public License as published by
@@ -48,7 +48,7 @@ DECLARE_CONVERTER(sc8_item32_be, 1, fc32, 1, PRIORITY_SIMD){
fc32_t *output = reinterpret_cast<fc32_t *>(outputs[0]);
const __m128 scalar = _mm_set_ps1(float(scale_factor)/(1 << 24));
- const int shuf = _MM_SHUFFLE(1, 0, 3, 2);
+ const int shuf = _MM_SHUFFLE(3, 2, 1, 0);
size_t i = 0, j = 0;
fc32_t dummy;
@@ -92,7 +92,7 @@ DECLARE_CONVERTER(sc8_item32_le, 1, fc32, 1, PRIORITY_SIMD){
fc32_t *output = reinterpret_cast<fc32_t *>(outputs[0]);
const __m128 scalar = _mm_set_ps1(float(scale_factor)/(1 << 24));
- const int shuf = _MM_SHUFFLE(2, 3, 0, 1);
+ const int shuf = _MM_SHUFFLE(0, 1, 2, 3);
size_t i = 0, j = 0;
fc32_t dummy;
diff --git a/host/lib/convert/sse2_sc8_to_fc64.cpp b/host/lib/convert/sse2_sc8_to_fc64.cpp
index ef9c0fdb4..94d8911f6 100644
--- a/host/lib/convert/sse2_sc8_to_fc64.cpp
+++ b/host/lib/convert/sse2_sc8_to_fc64.cpp
@@ -1,5 +1,5 @@
//
-// Copyright 2012 Ettus Research LLC
+// Copyright 2012-2013 Ettus Research LLC
//
// This program is free software: you can redistribute it and/or modify
// it under the terms of the GNU General Public License as published by
@@ -77,7 +77,7 @@ DECLARE_CONVERTER(sc8_item32_be, 1, fc64, 1, PRIORITY_SIMD){
\
/* unpack */ \
__m128d tmp0, tmp1, tmp2, tmp3, tmp4, tmp5, tmp6, tmp7; \
- unpack_sc32_8x(tmpi, tmp1, tmp0, tmp3, tmp2, tmp5, tmp4, tmp7, tmp6, scalar); \
+ unpack_sc32_8x(tmpi, tmp0, tmp1, tmp2, tmp3, tmp4, tmp5, tmp6, tmp7, scalar); \
\
/* store to output */ \
_mm_store ## _al_ ## pd(reinterpret_cast<double *>(output+j+0), tmp0); \
@@ -125,7 +125,7 @@ DECLARE_CONVERTER(sc8_item32_le, 1, fc64, 1, PRIORITY_SIMD){
/* unpack */ \
__m128d tmp0, tmp1, tmp2, tmp3, tmp4, tmp5, tmp6, tmp7; \
tmpi = _mm_or_si128(_mm_srli_epi16(tmpi, 8), _mm_slli_epi16(tmpi, 8)); /*byteswap*/\
- unpack_sc32_8x(tmpi, tmp0, tmp1, tmp2, tmp3, tmp4, tmp5, tmp6, tmp7, scalar); \
+ unpack_sc32_8x(tmpi, tmp1, tmp0, tmp3, tmp2, tmp5, tmp4, tmp7, tmp6, scalar); \
\
/* store to output */ \
_mm_store ## _al_ ## pd(reinterpret_cast<double *>(output+j+0), tmp0); \