[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[Commit-gnuradio] [gnuradio] 14/57: block interleave/deinterleave with s
From: |
git |
Subject: |
[Commit-gnuradio] [gnuradio] 14/57: block interleave/deinterleave with statefull deinterleave |
Date: |
Wed, 21 May 2014 03:10:25 +0000 (UTC) |
This is an automated email from the git hooks/post-receive script.
trondeau pushed a commit to branch master
in repository gnuradio.
commit 9cd145e6c3cd2ca4c2a67e104d227424d09db49c
Author: Nicholas McCarthy <address@hidden>
Date: Mon Mar 24 18:29:44 2014 -0400
block interleave/deinterleave with statefull deinterleave
---
gr-blocks/grc/blocks_deinterleave.xml | 9 ++-
gr-blocks/grc/blocks_interleave.xml | 9 ++-
gr-blocks/include/gnuradio/blocks/deinterleave.h | 6 +-
gr-blocks/include/gnuradio/blocks/interleave.h | 6 +-
gr-blocks/lib/deinterleave_impl.cc | 53 ++++++++--------
gr-blocks/lib/deinterleave_impl.h | 15 +++--
gr-blocks/lib/interleave_impl.cc | 78 ++++++++++++++++--------
gr-blocks/lib/interleave_impl.h | 16 ++++-
8 files changed, 126 insertions(+), 66 deletions(-)
diff --git a/gr-blocks/grc/blocks_deinterleave.xml
b/gr-blocks/grc/blocks_deinterleave.xml
index e3970bd..6af6d3c 100644
--- a/gr-blocks/grc/blocks_deinterleave.xml
+++ b/gr-blocks/grc/blocks_deinterleave.xml
@@ -8,7 +8,7 @@
<name>Deinterleave</name>
<key>blocks_deinterleave</key>
<import>from gnuradio import blocks</import>
- <make>blocks.deinterleave($type.size*$vlen)</make>
+ <make>blocks.deinterleave($type.size*$vlen, $blocksize)</make>
<param>
<name>IO Type</name>
<key>type</key>
@@ -45,6 +45,13 @@
<value>2</value>
<type>int</type>
</param>
+ <param>
+ <name>Block Size</name>
+ <key>blocksize</key>
+ <value>1</value>
+ <type>int</type>
+ <hide>part</hide>
+ </param>
<param>
<name>Vec Length</name>
<key>vlen</key>
diff --git a/gr-blocks/grc/blocks_interleave.xml
b/gr-blocks/grc/blocks_interleave.xml
index f01a3be..675693b 100644
--- a/gr-blocks/grc/blocks_interleave.xml
+++ b/gr-blocks/grc/blocks_interleave.xml
@@ -8,7 +8,7 @@
<name>Interleave</name>
<key>blocks_interleave</key>
<import>from gnuradio import blocks</import>
- <make>blocks.interleave($type.size*$vlen)</make>
+ <make>blocks.interleave($type.size*$vlen, $blocksize)</make>
<param>
<name>IO Type</name>
<key>type</key>
@@ -45,6 +45,13 @@
<value>2</value>
<type>int</type>
</param>
+ <param>
+ <name>Block Size</name>
+ <key>blocksize</key>
+ <value>1</value>
+ <type>int</type>
+ <hide>part</hide>
+ </param>
<param>
<name>Vec Length</name>
<key>vlen</key>
diff --git a/gr-blocks/include/gnuradio/blocks/deinterleave.h
b/gr-blocks/include/gnuradio/blocks/deinterleave.h
index 4545208..a79649f 100644
--- a/gr-blocks/include/gnuradio/blocks/deinterleave.h
+++ b/gr-blocks/include/gnuradio/blocks/deinterleave.h
@@ -24,7 +24,7 @@
#define INCLUDED_BLOCKS_DEINTERLEAVE_H
#include <gnuradio/blocks/api.h>
-#include <gnuradio/sync_decimator.h>
+#include <gnuradio/block.h>
namespace gr {
namespace blocks {
@@ -33,7 +33,7 @@ namespace gr {
* \brief deinterleave a single input into N outputs
* \ingroup stream_operators_blk
*/
- class BLOCKS_API deinterleave : virtual public sync_decimator
+ class BLOCKS_API deinterleave : virtual public block
{
public:
// gr::blocks::deinterleave::sptr
@@ -44,7 +44,7 @@ namespace gr {
*
* \param itemsize stream itemsize
*/
- static sptr make(size_t itemsize);
+ static sptr make(size_t itemsize, unsigned int blocksize = 1);
};
} /* namespace blocks */
diff --git a/gr-blocks/include/gnuradio/blocks/interleave.h
b/gr-blocks/include/gnuradio/blocks/interleave.h
index 7c28d54..811c3e3 100644
--- a/gr-blocks/include/gnuradio/blocks/interleave.h
+++ b/gr-blocks/include/gnuradio/blocks/interleave.h
@@ -24,7 +24,7 @@
#define INCLUDED_BLOCKS_INTERLEAVE_H
#include <gnuradio/blocks/api.h>
-#include <gnuradio/sync_interpolator.h>
+#include <gnuradio/block.h>
namespace gr {
namespace blocks {
@@ -33,7 +33,7 @@ namespace gr {
* \brief interleave N inputs into a single output
* \ingroup stream_operators_blk
*/
- class BLOCKS_API interleave : virtual public sync_interpolator
+ class BLOCKS_API interleave : virtual public block
{
public:
// gr::blocks::interleave::sptr
@@ -44,7 +44,7 @@ namespace gr {
*
* \param itemsize stream itemsize
*/
- static sptr make(size_t itemsize);
+ static sptr make(size_t itemsize, unsigned int blocksize = 1);
};
} /* namespace blocks */
diff --git a/gr-blocks/lib/deinterleave_impl.cc
b/gr-blocks/lib/deinterleave_impl.cc
index 6866cc7..5e1cc52 100644
--- a/gr-blocks/lib/deinterleave_impl.cc
+++ b/gr-blocks/lib/deinterleave_impl.cc
@@ -30,47 +30,44 @@
namespace gr {
namespace blocks {
- deinterleave::sptr deinterleave::make(size_t itemsize)
+ deinterleave::sptr deinterleave::make(size_t itemsize, unsigned int
blocksize)
{
- return gnuradio::get_initial_sptr(new deinterleave_impl(itemsize));
+ return gnuradio::get_initial_sptr(new deinterleave_impl(itemsize,
blocksize));
}
-
- deinterleave_impl::deinterleave_impl(size_t itemsize)
- : sync_decimator("deinterleave",
- io_signature::make (1, 1, itemsize),
- io_signature::make (1, io_signature::IO_INFINITE,
itemsize),
- 1),
- d_itemsize(itemsize)
+
+ deinterleave_impl::deinterleave_impl(size_t itemsize, unsigned int
blocksize)
+ : block("deinterleave",
+ io_signature::make (1, 1, itemsize),
+ io_signature::make (1, io_signature::IO_INFINITE, itemsize)),
+ d_itemsize(itemsize), d_blocksize(blocksize), d_current_output(0)
{
+ set_output_multiple(blocksize);
}
bool
deinterleave_impl::check_topology(int ninputs, int noutputs)
{
- set_decimation(noutputs);
+ set_relative_rate((double)noutputs);
+ d_noutputs = noutputs;
return true;
}
-
+
int
- deinterleave_impl::work(int noutput_items,
- gr_vector_const_void_star &input_items,
- gr_vector_void_star &output_items)
+ deinterleave_impl::general_work(int noutput_items,
+ gr_vector_int& ninput_items,
+ gr_vector_const_void_star &input_items,
+ gr_vector_void_star &output_items)
{
- size_t nchan = output_items.size();
- size_t itemsize = d_itemsize;
- const char *in = (const char *)input_items[0];
- char **out = (char **)&output_items[0];
+ const char *in = (const char*)input_items[0];
+ char **out = (char**)&output_items[0];
- for (int i = 0; i < noutput_items; i++){
- for (unsigned int n = 0; n < nchan; n++){
- memcpy(out[n], in, itemsize);
- out[n] += itemsize;
- in += itemsize;
- }
- }
-
- return noutput_items;
+ memcpy(out[d_current_output], in, d_itemsize * d_blocksize);
+ consume_each(d_blocksize);
+ produce(d_current_output, d_blocksize);
+ d_current_output = (d_current_output + 1) % d_noutputs;
+ return WORK_CALLED_PRODUCE;
}
-
+
+
} /* namespace blocks */
} /* namespace gr */
diff --git a/gr-blocks/lib/deinterleave_impl.h
b/gr-blocks/lib/deinterleave_impl.h
index d4d9392..a7a9e0a 100644
--- a/gr-blocks/lib/deinterleave_impl.h
+++ b/gr-blocks/lib/deinterleave_impl.h
@@ -30,16 +30,23 @@ namespace gr {
class BLOCKS_API deinterleave_impl : public deinterleave
{
+
size_t d_itemsize;
+ unsigned int d_blocksize;
+ unsigned int d_current_output;
+ unsigned int d_noutputs;
+
public:
- deinterleave_impl(size_t itemsize);
+ deinterleave_impl(size_t itemsize, unsigned int blocksize);
bool check_topology(int ninputs, int noutputs);
- int work(int noutput_items,
- gr_vector_const_void_star &input_items,
- gr_vector_void_star &output_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);
+
};
} /* namespace blocks */
diff --git a/gr-blocks/lib/interleave_impl.cc b/gr-blocks/lib/interleave_impl.cc
index 1f68cfc..22d6488 100644
--- a/gr-blocks/lib/interleave_impl.cc
+++ b/gr-blocks/lib/interleave_impl.cc
@@ -29,48 +29,76 @@
namespace gr {
namespace blocks {
-
- interleave::sptr interleave::make(size_t itemsize)
+
+ interleave::sptr interleave::make(size_t itemsize, unsigned int blocksize)
{
- return gnuradio::get_initial_sptr(new interleave_impl(itemsize));
+ return gnuradio::get_initial_sptr(new interleave_impl(itemsize,
blocksize));
}
-
- interleave_impl::interleave_impl(size_t itemsize)
- : sync_interpolator("interleave",
- io_signature::make (1, io_signature::IO_INFINITE,
itemsize),
- io_signature::make (1, 1, itemsize),
- 1),
- d_itemsize(itemsize)
+
+ interleave_impl::interleave_impl(size_t itemsize, unsigned int blocksize)
+ : block("interleave",
+ io_signature::make (1, io_signature::IO_INFINITE, itemsize),
+ io_signature::make (1, 1, itemsize)),
+ d_itemsize(itemsize), d_blocksize(blocksize)
{
+ set_fixed_rate(true);
+ set_output_multiple(d_blocksize);
}
bool
interleave_impl::check_topology(int ninputs, int noutputs)
{
- set_interpolation(ninputs);
+ set_relative_rate((double)ninputs);
+ d_ninputs = ninputs;
+ set_output_multiple(d_blocksize * d_ninputs);
return true;
}
+
+
+ int
+ interleave_impl::fixed_rate_ninput_to_noutput(int ninput)
+ {
+ return ninput * d_ninputs;
+ }
int
- interleave_impl::work(int noutput_items,
- gr_vector_const_void_star &input_items,
- gr_vector_void_star &output_items)
+ interleave_impl::fixed_rate_noutput_to_ninput(int noutput)
{
- size_t nchan = input_items.size();
- size_t itemsize = d_itemsize;
- const char **in = (const char **)&input_items[0];
- char *out = (char *)output_items[0];
-
- for (int i = 0; i < noutput_items; i += nchan) {
- for (unsigned int n = 0; n < nchan; n++) {
- memcpy (out, in[n], itemsize);
- out += itemsize;
- in[n] += itemsize;
- }
+ return (int) ((noutput / d_ninputs) + .5);
+ }
+
+ void
+ interleave_impl::forecast(int noutput_items,
+ gr_vector_int& ninput_items_required)
+ {
+ for(unsigned int i = 0; i < ninput_items_required.size(); ++i) {
+ ninput_items_required[i] = (int) ((noutput_items /
ninput_items_required.size()) + .5);
}
+ }
+ int
+ interleave_impl::general_work(int noutput_items,
+ gr_vector_int& ninput_items,
+ gr_vector_const_void_star &input_items,
+ gr_vector_void_star &output_items)
+ {
+ size_t noutput_blocks = (size_t) ((noutput_items/d_blocksize) + .5);
+ const char **in = (const char**)&input_items[0];
+ char *out = (char*)output_items[0];
+
+ for (unsigned int i = 0; i < noutput_blocks; i += d_ninputs) {
+ for (unsigned int n = 0; n < d_ninputs; n++){
+ memcpy(out, in[n], d_itemsize * d_blocksize);
+ out += d_itemsize * d_blocksize;
+ in[n] += d_itemsize * d_blocksize;
+ }
+ }
+ consume_each((int)((noutput_items/d_ninputs) + .5));
return noutput_items;
}
+
+
+
} /* namespace blocks */
} /* namespace gr */
diff --git a/gr-blocks/lib/interleave_impl.h b/gr-blocks/lib/interleave_impl.h
index 962747c..c74127f 100644
--- a/gr-blocks/lib/interleave_impl.h
+++ b/gr-blocks/lib/interleave_impl.h
@@ -31,12 +31,26 @@ namespace gr {
class BLOCKS_API interleave_impl : public interleave
{
size_t d_itemsize;
+ unsigned int d_blocksize;
+ unsigned int d_ninputs;
public:
- interleave_impl(size_t itemsize);
+ interleave_impl(size_t itemsize, unsigned int blocksize);
bool check_topology(int ninputs, int noutputs);
+ int fixed_rate_ninput_to_noutput(int ninput);
+
+ int fixed_rate_noutput_to_ninput(int noutput);
+
+ void forecast(int noutput_items,
+ gr_vector_int& ninput_items_required);
+
+ int general_work(int noutput_items,
+ gr_vector_int& ninput_items,
+ gr_vector_const_void_star &input_items,
+ gr_vector_void_star &output_items);
+
int work(int noutput_items,
gr_vector_const_void_star &input_items,
gr_vector_void_star &output_items);
- [Commit-gnuradio] [gnuradio] branch master updated (cb0bc7f -> 4750647), git, 2014/05/20
- [Commit-gnuradio] [gnuradio] 01/57: cmake and build: fixes for cross-compiling to enable ControlPort with ICE., git, 2014/05/20
- [Commit-gnuradio] [gnuradio] 06/57: Bring codec2 up to the latest version, and add support for all six bit rates., git, 2014/05/20
- [Commit-gnuradio] [gnuradio] 12/57: qtgui: removing unused NumberDisplayPlot; the number sink doesn't have a canvas like the other plotters do and so doesn't require this., git, 2014/05/20
- [Commit-gnuradio] [gnuradio] 04/57: controlport: allows reset_perf_counters to be called over controlport; gr-perf-monitorx has button to call this., git, 2014/05/20
- [Commit-gnuradio] [gnuradio] 07/57: vocoder: add default mode parameter and updated documentation, git, 2014/05/20
- [Commit-gnuradio] [gnuradio] 10/57: controlport: in gr-perf-monitorx, if all work times returned are 0, avoid a divide-by-zero fault., git, 2014/05/20
- [Commit-gnuradio] [gnuradio] 11/57: docs: doxygen mangles sections named with the same reference name. ControlPort and Vocoder both used 'using' - renamed for each., git, 2014/05/20
- [Commit-gnuradio] [gnuradio] 13/57: volk: adding a rate 1/2, K=7 convolutional decoder volk kernel., git, 2014/05/20
- [Commit-gnuradio] [gnuradio] 14/57: block interleave/deinterleave with statefull deinterleave,
git <=
- [Commit-gnuradio] [gnuradio] 03/57: controlport: adding a 'toggle' interface for ControlPort., git, 2014/05/20
- [Commit-gnuradio] [gnuradio] 20/57: digital: correlate_access_code_tag d_mask was set improperly when access code len = 64., git, 2014/05/20
- [Commit-gnuradio] [gnuradio] 09/57: documentation - fix example in case anyone gets confused, git, 2014/05/20
- [Commit-gnuradio] [gnuradio] 08/57: Corrected codec2 encoder documentation., git, 2014/05/20
- [Commit-gnuradio] [gnuradio] 15/57: tests for block mode, git, 2014/05/20
- [Commit-gnuradio] [gnuradio] 19/57: volk: missing updates for volk qa and profile from last checkin., git, 2014/05/20
- [Commit-gnuradio] [gnuradio] 25/57: fec: encoder now outputs bytes to make it more easily integratable with modulators., git, 2014/05/20
- [Commit-gnuradio] [gnuradio] 21/57: fec: improved fecapi stuff., git, 2014/05/20
- [Commit-gnuradio] [gnuradio] 23/57: fec: wip: allowing ber block to be used as a streaming block., git, 2014/05/20
- [Commit-gnuradio] [gnuradio] 17/57: adding ber sink to qt gui, git, 2014/05/20