summaryrefslogtreecommitdiff
path: root/gnuradio-core/src/lib
diff options
context:
space:
mode:
authorTim O'Shea2012-06-10 13:54:09 -0400
committerTim O'Shea2012-06-10 14:48:25 -0400
commitc8c5158133fb7a20413e42f59632930758561ad9 (patch)
treedc8460f9227ff0660e0c7fb55b0b30afd0446715 /gnuradio-core/src/lib
parentf2ab263b6fc9c24adc88fb55f2c210dd88e9345a (diff)
downloadgnuradio-c8c5158133fb7a20413e42f59632930758561ad9.tar.gz
gnuradio-c8c5158133fb7a20413e42f59632930758561ad9.tar.bz2
gnuradio-c8c5158133fb7a20413e42f59632930758561ad9.zip
gr_unpack_k_bits:
added python QA code reversed bit ordering to match gr_pack_k_bits gr_keep_m_in_n: added python QA code switched block to operate on individual items as itemsize instead of vectors updated GRC to match
Diffstat (limited to 'gnuradio-core/src/lib')
-rw-r--r--gnuradio-core/src/lib/general/gr_keep_m_in_n.cc36
-rw-r--r--gnuradio-core/src/lib/general/gr_keep_m_in_n.h11
-rw-r--r--gnuradio-core/src/lib/general/gr_pack_k_bits_bb.cc2
3 files changed, 32 insertions, 17 deletions
diff --git a/gnuradio-core/src/lib/general/gr_keep_m_in_n.cc b/gnuradio-core/src/lib/general/gr_keep_m_in_n.cc
index f17c3e00d..a9f4c12ba 100644
--- a/gnuradio-core/src/lib/general/gr_keep_m_in_n.cc
+++ b/gnuradio-core/src/lib/general/gr_keep_m_in_n.cc
@@ -44,42 +44,52 @@ gr_make_keep_m_in_n (size_t item_size, int m, int n, int offset)
* we take m items out of each n
*/
gr_keep_m_in_n::gr_keep_m_in_n (size_t item_size, int m, int n, int offset)
- : gr_sync_block ("keep_m_in_n",
- gr_make_io_signature (1, 1, n*item_size),
- gr_make_io_signature (1, 1, m*item_size)),
+ : gr_block ("keep_m_in_n",
+ gr_make_io_signature (1, 1, item_size),
+ gr_make_io_signature (1, 1, item_size)),
d_n(n),
d_m(m),
- d_offset( offset )
+ d_offset( offset ),
+ d_itemsize( item_size )
{
// sanity checking
assert(d_m > 0);
assert(d_n > 0);
assert(d_m <= d_n);
assert(d_offset <= (d_n-d_m));
+
+ set_output_multiple(m);
}
+void gr_keep_m_in_n::forecast (int noutput_items, gr_vector_int &ninput_items_required){
+ ninput_items_required[0] = d_n*(noutput_items/d_m);
+}
+
void gr_keep_m_in_n::set_offset(int offset){
d_offset = offset;
}
int
-gr_keep_m_in_n::work (int noutput_items,
+gr_keep_m_in_n::general_work (int noutput_items,
+ gr_vector_int &ninput_items,
gr_vector_const_void_star &input_items,
gr_vector_void_star &output_items)
{
uint8_t* out = (uint8_t*) output_items[0];
const uint8_t* in = (const uint8_t*) input_items[0];
- int in_item( input_signature()->sizeof_stream_item(0) );
- int out_item( output_signature()->sizeof_stream_item(0) );
- int single_size = in_item/d_n;
-
// iterate over data blocks of size {n, input : m, output}
- for(int i=0; i<noutput_items; i++){
- memcpy( &out[out_item*i], &in[in_item*i + single_size*d_offset], out_item);
+ int blks = std::min( noutput_items/d_m, ninput_items[0]/d_n );
+ for(int i=0; i<blks; i++){
+ // set up copy pointers
+ const uint8_t* iptr = &in[(i*d_n + d_offset)*d_itemsize];
+ uint8_t* optr = &out[i*d_m*d_itemsize];
+ // perform copy
+ memcpy( optr, iptr, d_m*d_itemsize );
}
-
- return noutput_items;
+
+ consume_each(d_n);
+ return d_m;
}
diff --git a/gnuradio-core/src/lib/general/gr_keep_m_in_n.h b/gnuradio-core/src/lib/general/gr_keep_m_in_n.h
index f9d5a268b..22fbd2f4c 100644
--- a/gnuradio-core/src/lib/general/gr_keep_m_in_n.h
+++ b/gnuradio-core/src/lib/general/gr_keep_m_in_n.h
@@ -24,7 +24,7 @@
#define INCLUDED_GR_KEEP_M_IN_N_H
#include <gr_core_api.h>
-#include <gr_sync_block.h>
+#include <gr_block.h>
class gr_keep_m_in_n;
typedef boost::shared_ptr<gr_keep_m_in_n> gr_keep_m_in_n_sptr;
@@ -37,7 +37,7 @@ gr_make_keep_m_in_n (size_t item_size, int m, int n, int offset);
* \brief decimate a stream, keeping one item out of every n.
* \ingroup slicedice_blk
*/
-class GR_CORE_API gr_keep_m_in_n : public gr_sync_block
+class GR_CORE_API gr_keep_m_in_n : public gr_block
{
friend GR_CORE_API gr_keep_m_in_n_sptr
gr_make_keep_m_in_n (size_t item_size, int m, int n, int offset);
@@ -46,16 +46,21 @@ class GR_CORE_API gr_keep_m_in_n : public gr_sync_block
int d_m;
int d_count;
int d_offset;
+ int d_itemsize;
protected:
gr_keep_m_in_n (size_t item_size, int m, int n, int offset);
+ void forecast (int noutput_items, gr_vector_int &ninput_items_required);
public:
- int work (int noutput_items,
+ int general_work (int noutput_items,
+ gr_vector_int &ninput_items,
gr_vector_const_void_star &input_items,
gr_vector_void_star &output_items);
void set_offset(int offset);
+ void set_n(int n){ d_n = n; }
+ void set_m(int m){ d_m = m; }
};
diff --git a/gnuradio-core/src/lib/general/gr_pack_k_bits_bb.cc b/gnuradio-core/src/lib/general/gr_pack_k_bits_bb.cc
index 0237a4d69..fc7e689fe 100644
--- a/gnuradio-core/src/lib/general/gr_pack_k_bits_bb.cc
+++ b/gnuradio-core/src/lib/general/gr_pack_k_bits_bb.cc
@@ -61,7 +61,7 @@ gr_pack_k_bits_bb::work (int noutput_items,
for (int i = 0; i < noutput_items; i++){
out[i] = 0x00;
for (unsigned int j = 0; j < d_k; j++){
- out[i] |= (0x01 & in[i*d_k+j])<<j;
+ out[i] |= (0x01 & in[i*d_k+j])<<(d_k-j-1);
}
}