diff options
author | Martin Braun <martin.braun@ettus.com> | 2019-07-18 16:23:12 -0700 |
---|---|---|
committer | Martin Braun <martin.braun@ettus.com> | 2019-11-26 11:49:11 -0800 |
commit | 75ad0c55164e8e2f08b4bfc9d5361f2445a80f52 (patch) | |
tree | b81f683d926d059ffbb69bb1d727b89be19ab087 /host/lib/convert/convert_common.hpp | |
parent | 9df26a9d89ef8fb50a667428066f3ef1732245c9 (diff) | |
download | uhd-75ad0c55164e8e2f08b4bfc9d5361f2445a80f52.tar.gz uhd-75ad0c55164e8e2f08b4bfc9d5361f2445a80f52.tar.bz2 uhd-75ad0c55164e8e2f08b4bfc9d5361f2445a80f52.zip |
convert: Add chdr converters for sc16 -> fc32 and vice versa
These differ from the item32 converters in that they don't IQ swap, and
also don't have a BE/LE version.
Diffstat (limited to 'host/lib/convert/convert_common.hpp')
-rw-r--r-- | host/lib/convert/convert_common.hpp | 39 |
1 files changed, 39 insertions, 0 deletions
diff --git a/host/lib/convert/convert_common.hpp b/host/lib/convert/convert_common.hpp index 7b627061e..0de344b75 100644 --- a/host/lib/convert/convert_common.hpp +++ b/host/lib/convert/convert_common.hpp @@ -114,6 +114,26 @@ UHD_INLINE void xx_to_item32_sc16( } } +template <typename T> +UHD_FORCE_INLINE sc16_t xx_to_sc16_x1( + const std::complex<T>& num, const double scale_factor) +{ + uint16_t real = int16_t(num.real() * T(scale_factor)); + uint16_t imag = int16_t(num.imag() * T(scale_factor)); + return sc16_t(real, imag); +} + +template <typename T> +UHD_FORCE_INLINE void xx_to_chdr_sc16(const std::complex<T>* input, + sc16_t* output, + const size_t nsamps, + const double scale_factor) +{ + for (size_t i = 0; i < nsamps; i++) { + output[i] = xx_to_sc16_x1(input[i], scale_factor); + } +} + /*********************************************************************** * Convert items32 sc16 buffer to xx **********************************************************************/ @@ -147,6 +167,25 @@ UHD_INLINE void item32_sc16_to_xx( } } +template <typename T> +UHD_FORCE_INLINE std::complex<T> chdr_sc16_x1_to_xx( + const sc16_t item, const double scale_factor) +{ + return std::complex<T>( + T(item.real()) * T(scale_factor), T(item.imag()) * T(scale_factor)); +} + +template <typename T> +UHD_FORCE_INLINE void chdr_sc16_to_xx(const sc16_t* input, + std::complex<T>* output, + const size_t nsamps, + const double scale_factor) +{ + for (size_t i = 0; i < nsamps; i++) { + output[i] = chdr_sc16_x1_to_xx<T>(input[i], scale_factor); + } +} + /*********************************************************************** * Convert xx to items32 sc8 buffer **********************************************************************/ |