commit-gnuradio
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

[Commit-gnuradio] [gnuradio] 32/57: blocks: add optional argument to dei


From: git
Subject: [Commit-gnuradio] [gnuradio] 32/57: blocks: add optional argument to deinterleave and interleave ctors to not set relative rate.
Date: Wed, 21 May 2014 03:10:27 +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 81b7275ea6e915c7da2e593bb29a3b01df14805b
Author: Tom Rondeau <address@hidden>
Date:   Mon May 12 12:41:39 2014 -0400

    blocks: add optional argument to deinterleave and interleave ctors to not 
set relative rate.
    
    Whe using blocks of data, this doesn't always make sense (see the threading 
of the extended encoder and decoder in gr-fec).
---
 gr-blocks/include/gnuradio/blocks/deinterleave.h |  6 ++++-
 gr-blocks/include/gnuradio/blocks/interleave.h   |  6 ++++-
 gr-blocks/lib/deinterleave_impl.cc               | 27 +++++++++++--------
 gr-blocks/lib/deinterleave_impl.h                |  9 ++++---
 gr-blocks/lib/interleave_impl.cc                 | 33 ++++++++++++++----------
 gr-blocks/lib/interleave_impl.h                  |  8 +++---
 6 files changed, 55 insertions(+), 34 deletions(-)

diff --git a/gr-blocks/include/gnuradio/blocks/deinterleave.h 
b/gr-blocks/include/gnuradio/blocks/deinterleave.h
index a3b5480..8e29873 100644
--- a/gr-blocks/include/gnuradio/blocks/deinterleave.h
+++ b/gr-blocks/include/gnuradio/blocks/deinterleave.h
@@ -67,8 +67,12 @@ namespace gr {
        *
        * \param itemsize stream itemsize
        * \param blocksize size of block to deinterleave
+       * \param set_rel_rate should the block set the relative_rate
+       *        - changes tags locations and may not be appropriate
+       *        for all circumstances.
        */
-      static sptr make(size_t itemsize, unsigned int blocksize = 1);
+      static sptr make(size_t itemsize, unsigned int blocksize = 1,
+                       bool set_rel_rate=true);
     };
 
   } /* namespace blocks */
diff --git a/gr-blocks/include/gnuradio/blocks/interleave.h 
b/gr-blocks/include/gnuradio/blocks/interleave.h
index 7f7587d..8e68ce9 100644
--- a/gr-blocks/include/gnuradio/blocks/interleave.h
+++ b/gr-blocks/include/gnuradio/blocks/interleave.h
@@ -68,8 +68,12 @@ namespace gr {
        *
        * \param itemsize stream itemsize
        * \param blocksize size of block of samples to interleave
+       * \param set_rel_rate should the block set the relative_rate
+       *        - changes tags locations and may not be appropriate
+       *        for all circumstances.
        */
-      static sptr make(size_t itemsize, unsigned int blocksize = 1);
+      static sptr make(size_t itemsize, unsigned int blocksize = 1,
+                       bool set_rel_rate=true);
     };
 
   } /* namespace blocks */
diff --git a/gr-blocks/lib/deinterleave_impl.cc 
b/gr-blocks/lib/deinterleave_impl.cc
index 5e1cc52..025e2b6 100644
--- a/gr-blocks/lib/deinterleave_impl.cc
+++ b/gr-blocks/lib/deinterleave_impl.cc
@@ -1,6 +1,6 @@
 /* -*- c++ -*- */
 /*
- * Copyright 2012 Free Software Foundation, Inc.
+ * Copyright 2012,2014 Free Software Foundation, Inc.
  *
  * This file is part of GNU Radio
  *
@@ -30,16 +30,20 @@
 namespace gr {
   namespace blocks {
 
-    deinterleave::sptr deinterleave::make(size_t itemsize, unsigned int 
blocksize)
+    deinterleave::sptr deinterleave::make(size_t itemsize, unsigned int 
blocksize,
+                                          bool set_rel_rate)
     {
-      return gnuradio::get_initial_sptr(new deinterleave_impl(itemsize, 
blocksize));
+      return gnuradio::get_initial_sptr
+        (new deinterleave_impl(itemsize, blocksize, set_rel_rate));
     }
-    
-    deinterleave_impl::deinterleave_impl(size_t itemsize, unsigned int 
blocksize)
+
+    deinterleave_impl::deinterleave_impl(size_t itemsize, unsigned int 
blocksize,
+                                         bool set_rel_rate)
       : 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)
+        d_itemsize(itemsize), d_blocksize(blocksize), d_current_output(0),
+        d_set_rel_rate(set_rel_rate)
     {
       set_output_multiple(blocksize);
     }
@@ -47,11 +51,12 @@ namespace gr {
     bool
     deinterleave_impl::check_topology(int ninputs, int noutputs)
     {
-      set_relative_rate((double)noutputs);
+      if(d_set_rel_rate)
+        set_relative_rate(1.0/static_cast<double>(noutputs));
       d_noutputs = noutputs;
       return true;
     }
-    
+
     int
     deinterleave_impl::general_work(int noutput_items,
                                     gr_vector_int& ninput_items,
@@ -60,14 +65,14 @@ namespace gr {
     {
       const char *in = (const char*)input_items[0];
       char **out = (char**)&output_items[0];
-      
+
       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 a7a9e0a..8ca61e5 100644
--- a/gr-blocks/lib/deinterleave_impl.h
+++ b/gr-blocks/lib/deinterleave_impl.h
@@ -30,15 +30,16 @@ 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;
-
+      bool d_set_rel_rate;
 
     public:
-      deinterleave_impl(size_t itemsize, unsigned int blocksize);
+      deinterleave_impl(size_t itemsize, unsigned int blocksize,
+                        bool set_rel_rate=true);
 
       bool check_topology(int ninputs, int noutputs);
 
@@ -51,6 +52,6 @@ namespace gr {
 
   } /* namespace blocks */
 } /* namespace gr */
-   
+
 
 #endif /* INCLUDED_DEINTERLEAVE_IMPL_H */
diff --git a/gr-blocks/lib/interleave_impl.cc b/gr-blocks/lib/interleave_impl.cc
index 22d6488..5584eec 100644
--- a/gr-blocks/lib/interleave_impl.cc
+++ b/gr-blocks/lib/interleave_impl.cc
@@ -1,6 +1,6 @@
 /* -*- c++ -*- */
 /*
- * Copyright 2012 Free Software Foundation, Inc.
+ * Copyright 2012,2014 Free Software Foundation, Inc.
  *
  * This file is part of GNU Radio
  *
@@ -29,17 +29,21 @@
 
 namespace gr {
   namespace blocks {
-    
-    interleave::sptr interleave::make(size_t itemsize, unsigned int blocksize)
+
+    interleave::sptr interleave::make(size_t itemsize, unsigned int blocksize,
+                                      bool set_rel_rate)
     {
-      return gnuradio::get_initial_sptr(new interleave_impl(itemsize, 
blocksize));
+      return gnuradio::get_initial_sptr
+        (new interleave_impl(itemsize, blocksize, set_rel_rate));
     }
-    
-    interleave_impl::interleave_impl(size_t itemsize, unsigned int blocksize)
+
+    interleave_impl::interleave_impl(size_t itemsize, unsigned int blocksize,
+                                     bool set_rel_rate)
       : block("interleave",
               io_signature::make (1, io_signature::IO_INFINITE, itemsize),
               io_signature::make (1, 1, itemsize)),
-        d_itemsize(itemsize), d_blocksize(blocksize)
+        d_itemsize(itemsize), d_blocksize(blocksize),
+        d_set_rel_rate(set_rel_rate)
     {
       set_fixed_rate(true);
       set_output_multiple(d_blocksize);
@@ -48,13 +52,14 @@ namespace gr {
     bool
     interleave_impl::check_topology(int ninputs, int noutputs)
     {
-      set_relative_rate((double)ninputs);
+      if(d_set_rel_rate)
+        set_relative_rate(static_cast<double>(ninputs));
       d_ninputs = ninputs;
       set_output_multiple(d_blocksize * d_ninputs);
       return true;
     }
-    
-    
+
+
     int
     interleave_impl::fixed_rate_ninput_to_noutput(int ninput)
     {
@@ -66,7 +71,7 @@ namespace gr {
     {
       return (int) ((noutput / d_ninputs) + .5);
     }
-    
+
     void
     interleave_impl::forecast(int noutput_items,
                               gr_vector_int& ninput_items_required)
@@ -85,7 +90,7 @@ namespace gr {
       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);
@@ -98,7 +103,7 @@ namespace gr {
     }
 
 
-      
-    
+
+
   } /* namespace blocks */
 } /* namespace gr */
diff --git a/gr-blocks/lib/interleave_impl.h b/gr-blocks/lib/interleave_impl.h
index c74127f..a54dfe7 100644
--- a/gr-blocks/lib/interleave_impl.h
+++ b/gr-blocks/lib/interleave_impl.h
@@ -1,6 +1,6 @@
 /* -*- c++ -*- */
 /*
- * Copyright 2012 Free Software Foundation, Inc.
+ * Copyright 2012,2014 Free Software Foundation, Inc.
  *
  * This file is part of GNU Radio
  *
@@ -33,9 +33,11 @@ namespace gr {
       size_t d_itemsize;
       unsigned int d_blocksize;
       unsigned int d_ninputs;
+      bool d_set_rel_rate;
 
     public:
-      interleave_impl(size_t itemsize, unsigned int blocksize);
+      interleave_impl(size_t itemsize, unsigned int blocksize,
+                      bool set_rel_rate=true);
 
       bool check_topology(int ninputs, int noutputs);
 
@@ -58,6 +60,6 @@ namespace gr {
 
   } /* namespace blocks */
 } /* namespace gr */
-   
+
 
 #endif /* INCLUDED_INTERLEAVE_IMPL_H */



reply via email to

[Prev in Thread] Current Thread [Next in Thread]