diff options
author | Thomas Habets <thomas@habets.se> | 2019-12-21 19:21:30 +0000 |
---|---|---|
committer | Martin Braun <martin.braun@ettus.com> | 2020-01-06 15:38:02 -0800 |
commit | 2c2c65656197596b8455ae0813c3c80cea023406 (patch) | |
tree | dc7ecaf696acce1ff82a1acb4f2a730365551e51 | |
parent | b1afefa6b2f95cd1da9cf7736df8416f3654f79e (diff) |
gr-blocks/packed&unpacked: Add const
-rw-r--r-- | gr-blocks/lib/packed_to_unpacked_impl.cc | 10 | ||||
-rw-r--r-- | gr-blocks/lib/packed_to_unpacked_impl.h | 4 | ||||
-rw-r--r-- | gr-blocks/lib/unpacked_to_packed_impl.cc | 12 | ||||
-rw-r--r-- | gr-blocks/lib/unpacked_to_packed_impl.h | 4 |
4 files changed, 15 insertions, 15 deletions
diff --git a/gr-blocks/lib/packed_to_unpacked_impl.cc b/gr-blocks/lib/packed_to_unpacked_impl.cc index f63e040b2a..bcd9008809 100644 --- a/gr-blocks/lib/packed_to_unpacked_impl.cc +++ b/gr-blocks/lib/packed_to_unpacked_impl.cc @@ -65,9 +65,9 @@ template <class T> void packed_to_unpacked_impl<T>::forecast(int noutput_items, gr_vector_int& ninput_items_required) { - int input_required = (int)ceil((d_index + noutput_items * d_bits_per_chunk) / + const int input_required = (int)ceil((d_index + noutput_items * d_bits_per_chunk) / (1.0 * this->d_bits_per_type)); - unsigned ninputs = ninput_items_required.size(); + const unsigned ninputs = ninput_items_required.size(); for (unsigned int i = 0; i < ninputs; i++) { ninput_items_required[i] = input_required; // printf("Forecast wants %d needs %d\n",noutput_items,ninput_items_required[i]); @@ -78,7 +78,7 @@ template <class T> unsigned int packed_to_unpacked_impl<T>::get_bit_le(const T* in_vector, unsigned int bit_addr) { - T x = in_vector[bit_addr >> this->d_log2_l_type]; + const T x = in_vector[bit_addr >> this->d_log2_l_type]; return (x >> (bit_addr & (this->d_bits_per_type - 1))) & 1; } @@ -86,7 +86,7 @@ template <class T> unsigned int packed_to_unpacked_impl<T>::get_bit_be(const T* in_vector, unsigned int bit_addr) { - T x = in_vector[bit_addr >> this->d_log2_l_type]; + const T x = in_vector[bit_addr >> this->d_log2_l_type]; return (x >> ((this->d_bits_per_type - 1) - (bit_addr & (this->d_bits_per_type - 1)))) & 1; @@ -101,7 +101,7 @@ int packed_to_unpacked_impl<T>::general_work(int noutput_items, unsigned int index_tmp = d_index; assert(input_items.size() == output_items.size()); - int nstreams = input_items.size(); + const int nstreams = input_items.size(); for (int m = 0; m < nstreams; m++) { const T* in = (T*)input_items[m]; diff --git a/gr-blocks/lib/packed_to_unpacked_impl.h b/gr-blocks/lib/packed_to_unpacked_impl.h index 8d56be3f17..e49f02fa0e 100644 --- a/gr-blocks/lib/packed_to_unpacked_impl.h +++ b/gr-blocks/lib/packed_to_unpacked_impl.h @@ -34,8 +34,8 @@ template <class T> class packed_to_unpacked_impl : public packed_to_unpacked<T> { private: - unsigned int d_bits_per_chunk; - endianness_t d_endianness; + const unsigned int d_bits_per_chunk; + const endianness_t d_endianness; unsigned int d_index; const unsigned int d_bits_per_type = sizeof(T) * 8; const unsigned int d_log2_l_type = log2_const<sizeof(T) * 8>(); diff --git a/gr-blocks/lib/unpacked_to_packed_impl.cc b/gr-blocks/lib/unpacked_to_packed_impl.cc index cdca25dd7e..d65f6327b9 100644 --- a/gr-blocks/lib/unpacked_to_packed_impl.cc +++ b/gr-blocks/lib/unpacked_to_packed_impl.cc @@ -66,9 +66,9 @@ template <class T> void unpacked_to_packed_impl<T>::forecast(int noutput_items, gr_vector_int& ninput_items_required) { - int input_required = + const int input_required = (int)ceil((d_index + noutput_items * 1.0 * d_bits_per_type) / d_bits_per_chunk); - unsigned ninputs = ninput_items_required.size(); + const unsigned ninputs = ninput_items_required.size(); for (unsigned int i = 0; i < ninputs; i++) { ninput_items_required[i] = input_required; } @@ -79,9 +79,9 @@ unsigned int unpacked_to_packed_impl<T>::get_bit_be1(const T* in_vector, unsigned int bit_addr, unsigned int bits_per_chunk) { - unsigned int byte_addr = (int)bit_addr / bits_per_chunk; - T x = in_vector[byte_addr]; - unsigned int residue = bit_addr - byte_addr * bits_per_chunk; + const unsigned int byte_addr = (int)bit_addr / bits_per_chunk; + const T x = in_vector[byte_addr]; + const unsigned int residue = bit_addr - byte_addr * bits_per_chunk; // printf("Bit addr %d byte addr %d residue %d val // %d\n",bit_addr,byte_addr,residue,(x>>(bits_per_chunk-1-residue))&1); return (x >> (bits_per_chunk - 1 - residue)) & 1; @@ -96,7 +96,7 @@ int unpacked_to_packed_impl<T>::general_work(int noutput_items, unsigned int index_tmp = d_index; assert(input_items.size() == output_items.size()); - int nstreams = input_items.size(); + const int nstreams = input_items.size(); for (int m = 0; m < nstreams; m++) { const T* in = (T*)input_items[m]; diff --git a/gr-blocks/lib/unpacked_to_packed_impl.h b/gr-blocks/lib/unpacked_to_packed_impl.h index daa2ba6949..50398aee8c 100644 --- a/gr-blocks/lib/unpacked_to_packed_impl.h +++ b/gr-blocks/lib/unpacked_to_packed_impl.h @@ -33,8 +33,8 @@ template <class T> class unpacked_to_packed_impl : public unpacked_to_packed<T> { private: - unsigned int d_bits_per_chunk; - endianness_t d_endianness; + const unsigned int d_bits_per_chunk; + const endianness_t d_endianness; unsigned int d_index; const unsigned int d_bits_per_type = sizeof(T) * 8; unsigned int |