summaryrefslogtreecommitdiff
path: root/gr-blocks/lib/packed_to_unpacked_impl.cc
diff options
context:
space:
mode:
Diffstat (limited to 'gr-blocks/lib/packed_to_unpacked_impl.cc')
-rw-r--r--gr-blocks/lib/packed_to_unpacked_impl.cc20
1 files changed, 17 insertions, 3 deletions
diff --git a/gr-blocks/lib/packed_to_unpacked_impl.cc b/gr-blocks/lib/packed_to_unpacked_impl.cc
index 03a80aa44c..f516f1a8a3 100644
--- a/gr-blocks/lib/packed_to_unpacked_impl.cc
+++ b/gr-blocks/lib/packed_to_unpacked_impl.cc
@@ -63,10 +63,24 @@ void packed_to_unpacked_impl<T>::forecast(int noutput_items,
}
template <class T>
+unsigned int packed_to_unpacked_impl<T>::log2_l_type()
+{
+ unsigned int val = sizeof(T);
+ if (!val || (val & (val - 1))) {
+ return 0;
+ }
+ unsigned int ld = 0;
+ while (val >>= 1) {
+ ld++;
+ }
+ return ld + 3;
+};
+
+template <class T>
unsigned int packed_to_unpacked_impl<T>::get_bit_le(const T* in_vector,
unsigned int bit_addr)
{
- const T x = in_vector[bit_addr >> this->d_log2_l_type];
+ const T x = in_vector[bit_addr >> this->log2_l_type()];
return (x >> (bit_addr & (this->d_bits_per_type - 1))) & 1;
}
@@ -74,7 +88,7 @@ template <class T>
unsigned int packed_to_unpacked_impl<T>::get_bit_be(const T* in_vector,
unsigned int bit_addr)
{
- const T x = in_vector[bit_addr >> this->d_log2_l_type];
+ const T x = in_vector[bit_addr >> this->log2_l_type()];
return (x >>
((this->d_bits_per_type - 1) - (bit_addr & (this->d_bits_per_type - 1)))) &
1;
@@ -129,7 +143,7 @@ int packed_to_unpacked_impl<T>::general_work(int noutput_items,
}
d_index = index_tmp;
- this->consume_each(d_index >> this->d_log2_l_type);
+ this->consume_each(d_index >> this->log2_l_type());
d_index = d_index & (this->d_bits_per_type - 1);
// printf("got to end\n");
return noutput_items;