From cf60045b7cc2b31d0d52072dc1bd370f85ceb724 Mon Sep 17 00:00:00 2001 From: Martin Braun Date: Wed, 17 May 2017 15:51:16 -0700 Subject: converters: Swap 16 bit samples (s16) --- host/lib/convert/gen_convert_general.py | 26 ++++++-------------------- 1 file changed, 6 insertions(+), 20 deletions(-) (limited to 'host/lib/convert') 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(inputs[0]); - item32_t *output = reinterpret_cast(outputs[0]); + const uint16_t *input = reinterpret_cast(inputs[0]); + uint16_t *output = reinterpret_cast(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(&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(inputs[0]); - item32_t *output = reinterpret_cast(outputs[0]); + const uint16_t *input = reinterpret_cast(inputs[0]); + uint16_t *output = reinterpret_cast(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(&output[n_words]) = s16_t(tmp); - }} }} """ -- cgit v1.2.3