aboutsummaryrefslogtreecommitdiffstats
path: root/host/lib/convert/gen_convert_general.py
diff options
context:
space:
mode:
authorJosh Blum <josh@joshknows.com>2011-10-07 17:30:42 -0700
committerJosh Blum <josh@joshknows.com>2011-11-03 20:37:11 -0700
commit861e66848f05001fcaca4fe91dbf67cd186649dc (patch)
tree33f685249fe9580c14eacc3ff2e25d08798ebfac /host/lib/convert/gen_convert_general.py
parent65fb4d225204b4ee2b7c73fc0ec393cfff9d6149 (diff)
downloaduhd-861e66848f05001fcaca4fe91dbf67cd186649dc.tar.gz
uhd-861e66848f05001fcaca4fe91dbf67cd186649dc.tar.bz2
uhd-861e66848f05001fcaca4fe91dbf67cd186649dc.zip
usrp2: work on alternative OTW formats
Diffstat (limited to 'host/lib/convert/gen_convert_general.py')
-rw-r--r--host/lib/convert/gen_convert_general.py32
1 files changed, 30 insertions, 2 deletions
diff --git a/host/lib/convert/gen_convert_general.py b/host/lib/convert/gen_convert_general.py
index 0cd4155fa..43e1f9967 100644
--- a/host/lib/convert/gen_convert_general.py
+++ b/host/lib/convert/gen_convert_general.py
@@ -34,7 +34,7 @@ DECLARE_CONVERTER($(cpu_type), 1, sc16_item32_$(end), 1, PRIORITY_GENERAL){
item32_t *output = reinterpret_cast<item32_t *>(outputs[0]);
for (size_t i = 0; i < nsamps; i++){
- output[i] = $(to_wire)($(cpu_type)_to_item32(input[i], scale_factor));
+ output[i] = $(to_wire)($(cpu_type)_to_item32_sc16(input[i], scale_factor));
}
}
@@ -43,7 +43,35 @@ DECLARE_CONVERTER(sc16_item32_$(end), 1, $(cpu_type), 1, PRIORITY_GENERAL){
$(cpu_type)_t *output = reinterpret_cast<$(cpu_type)_t *>(outputs[0]);
for (size_t i = 0; i < nsamps; i++){
- output[i] = item32_to_$(cpu_type)($(to_host)(input[i]), scale_factor);
+ output[i] = item32_sc16_to_$(cpu_type)($(to_host)(input[i]), scale_factor);
+ }
+}
+
+DECLARE_CONVERTER(sc8_item32_$(end), 1, $(cpu_type), 1, PRIORITY_GENERAL){
+ const item32_t *input = reinterpret_cast<const item32_t *>(size_t(inputs[0]) & ~0x3);
+ $(cpu_type)_t *output = reinterpret_cast<$(cpu_type)_t *>(outputs[0]);
+ $(cpu_type)_t dummy;
+
+ const bool head_case = ((size_t(inputs[0]) & 0x3) != 0);
+ const bool tail_case = ((nsamps & 0x1) == 0)? head_case : not head_case;
+ const size_t num_pairs = (head_case? nsamps-1 : nsamps)/2;
+ size_t i = 0, j = 0;
+
+ //special head case, probably from a partial recv
+ if (head_case){
+ const item32_t item0 = $(to_host)(input[i++]);
+ item32_sc8_to_$(cpu_type)(item0, dummy, output[j++], scale_factor);
+ }
+
+ for (; i < num_pairs; i++, j+=2){
+ const item32_t item_i = $(to_host)(input[i]);
+ item32_sc8_to_$(cpu_type)(item_i, output[j], output[j+1], scale_factor);
+ }
+
+ //special tail case, finished on an odd number
+ if (tail_case){
+ const item32_t item_i = $(to_host)(input[i]);
+ item32_sc8_to_$(cpu_type)(item_i, output[j], dummy, scale_factor);
}
}
"""