diff options
author | Martin Braun <martin.braun@ettus.com> | 2017-05-17 15:51:16 -0700 |
---|---|---|
committer | Martin Braun <martin.braun@ettus.com> | 2017-12-22 15:03:53 -0800 |
commit | cf60045b7cc2b31d0d52072dc1bd370f85ceb724 (patch) | |
tree | 9ed6e50a32e06c4a4a8103436a0d58d0b1eecc4b /host/lib/convert/gen_convert_general.py | |
parent | 11977ad25c47ba5a2f0870a5bff5ba62b661ef9c (diff) | |
download | uhd-cf60045b7cc2b31d0d52072dc1bd370f85ceb724.tar.gz uhd-cf60045b7cc2b31d0d52072dc1bd370f85ceb724.tar.bz2 uhd-cf60045b7cc2b31d0d52072dc1bd370f85ceb724.zip |
converters: Swap 16 bit samples (s16)
Diffstat (limited to 'host/lib/convert/gen_convert_general.py')
-rw-r--r-- | host/lib/convert/gen_convert_general.py | 26 |
1 files changed, 6 insertions, 20 deletions
diff --git a/host/lib/convert/gen_convert_general.py b/host/lib/convert/gen_convert_general.py index 588617a92..e47eafd1e 100644 --- a/host/lib/convert/gen_convert_general.py +++ b/host/lib/convert/gen_convert_general.py @@ -101,35 +101,21 @@ DECLARE_CONVERTER({us8}_item32_{end}, 1, {us8}, 1, PRIORITY_GENERAL) {{ TMPL_CONV_S16 = """ DECLARE_CONVERTER(s16, 1, s16_item32_{end}, 1, PRIORITY_GENERAL) {{ - const item32_t *input = reinterpret_cast<const item32_t *>(inputs[0]); - item32_t *output = reinterpret_cast<item32_t *>(outputs[0]); + const uint16_t *input = reinterpret_cast<const uint16_t *>(inputs[0]); + uint16_t *output = reinterpret_cast<uint16_t *>(outputs[0]); - // 1) Copy all the 4-byte tuples - size_t n_words = nsamps / 2; - for (size_t i = 0; i < n_words; i++) {{ + for (size_t i = 0; i < nsamps; i++) {{ output[i] = {to_wire}(input[i]); }} - // 2) If nsamps was not a multiple of 2, copy the last one by hand - if (nsamps % 2) {{ - item32_t tmp = item32_t(*reinterpret_cast<const s16_t *>(&input[n_words])); - output[n_words] = {to_wire}(tmp); - }} }} DECLARE_CONVERTER(s16_item32_{end}, 1, s16, 1, PRIORITY_GENERAL) {{ - const item32_t *input = reinterpret_cast<const item32_t *>(inputs[0]); - item32_t *output = reinterpret_cast<item32_t *>(outputs[0]); + const uint16_t *input = reinterpret_cast<const uint16_t *>(inputs[0]); + uint16_t *output = reinterpret_cast<uint16_t *>(outputs[0]); - // 1) Copy all the 4-byte tuples - size_t n_words = nsamps / 2; - for (size_t i = 0; i < n_words; i++) {{ + for (size_t i = 0; i < nsamps; i++) {{ output[i] = {to_host}(input[i]); }} - // 2) If nsamps was not a multiple of 2, copy the last one by hand - if (nsamps % 2) {{ - item32_t tmp = {to_host}(input[n_words]); - *reinterpret_cast<s16_t *>(&output[n_words]) = s16_t(tmp); - }} }} """ |