diff options
author | Josh Blum | 2012-09-13 22:25:30 -0700 |
---|---|---|
committer | Josh Blum | 2012-09-13 22:25:30 -0700 |
commit | cae524fdf1da052cd70f3a872a8db4e80f202504 (patch) | |
tree | 6fbb198c92789d556029c976857ef652a527480c | |
parent | 85b29ab7235d85ff17062cf8521f522b5a84fe3d (diff) | |
download | sandhi-cae524fdf1da052cd70f3a872a8db4e80f202504.tar.gz sandhi-cae524fdf1da052cd70f3a872a8db4e80f202504.tar.bz2 sandhi-cae524fdf1da052cd70f3a872a8db4e80f202504.zip |
make input history calls and history compat for off by 1 issue
-rw-r--r-- | include/gnuradio/block.hpp | 11 | ||||
-rw-r--r-- | include/gnuradio/gr_block.h | 7 | ||||
-rw-r--r-- | lib/block.cpp | 6 | ||||
-rw-r--r-- | lib/gras_impl/input_buffer_queues.hpp | 1 |
4 files changed, 17 insertions, 8 deletions
diff --git a/include/gnuradio/block.hpp b/include/gnuradio/block.hpp index cfaa00b..459e25b 100644 --- a/include/gnuradio/block.hpp +++ b/include/gnuradio/block.hpp @@ -74,9 +74,16 @@ struct GRAS_API Block : Element * Basic routines from basic block ******************************************************************/ - size_t history(const size_t which_input = 0) const; + //! Get the number of history items (default 0) + size_t input_history(const size_t which_input = 0) const; - void set_history(const size_t history, const size_t which_input = 0); + /*! + * Set the number of items that will be saved from the previous run. + * Input buffers will begin with an overlap of the previous's buffer's + * num history items. This is used to implement sample memory for + * things like sliding dot products/FIR filters. + */ + void set_input_history(const size_t history, const size_t which_input = 0); void set_output_multiple(const size_t multiple, const size_t which_output = 0); diff --git a/include/gnuradio/gr_block.h b/include/gnuradio/gr_block.h index 5b3e9f2..3bd0cc0 100644 --- a/include/gnuradio/gr_block.h +++ b/include/gnuradio/gr_block.h @@ -66,12 +66,15 @@ struct GRAS_API gr_block : gnuradio::Block unsigned history(void) const { - return gnuradio::Block::history(); + //implement off-by-one history compat + return this->input_history()+1; } void set_history(unsigned history) { - gnuradio::Block::set_history(history); + //implement off-by-one history compat + if (history == 0) history++; + this->set_input_history(history-1); } void set_alignment(const size_t alignment); diff --git a/lib/block.cpp b/lib/block.cpp index bb55a3f..406e16b 100644 --- a/lib/block.cpp +++ b/lib/block.cpp @@ -28,7 +28,7 @@ Block::Block(void) Block::Block(const std::string &name): Element(name) { - this->set_history(0); + this->set_input_history(0); this->set_output_multiple(1); this->set_fixed_rate(true); this->set_relative_rate(1.0); @@ -67,12 +67,12 @@ typename V::value_type vector_get(const V &v, const size_t index) return v[index]; } -size_t Block::history(const size_t which_input) const +size_t Block::input_history(const size_t which_input) const { return vector_get((*this)->input_history_items, which_input); } -void Block::set_history(const size_t history, const size_t which_input) +void Block::set_input_history(const size_t history, const size_t which_input) { vector_set((*this)->input_history_items, history, which_input); } diff --git a/lib/gras_impl/input_buffer_queues.hpp b/lib/gras_impl/input_buffer_queues.hpp index 8d00d85..9e7bf63 100644 --- a/lib/gras_impl/input_buffer_queues.hpp +++ b/lib/gras_impl/input_buffer_queues.hpp @@ -159,7 +159,6 @@ inline void InputBufferQueues::init( //determine byte sizes for buffers and dealing with history _history_bytes[i] = input_item_sizes[i]*input_history_items[i]; - if (_history_bytes[i]) _history_bytes[i] -= input_item_sizes[i]; //crazy history-1 API //calculate the input multiple aka reserve size _reserve_bytes[i] = input_item_sizes[i]*input_multiple_items[i]; |