commit-gnuradio
[Top][All Lists]
Advanced

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

[Commit-gnuradio] [gnuradio] 02/03: blocks: fixed up keem_m_in_n to hand


From: git
Subject: [Commit-gnuradio] [gnuradio] 02/03: blocks: fixed up keem_m_in_n to handle relative rate and correct number of items in calls to work.
Date: Thu, 25 Sep 2014 16:19:51 +0000 (UTC)

This is an automated email from the git hooks/post-receive script.

trondeau pushed a commit to branch maint
in repository gnuradio.

commit 0efc17902814aa9d80ea6acc6cb71ef1e545969c
Author: Tom Rondeau <address@hidden>
Date:   Thu Sep 25 11:47:54 2014 -0400

    blocks: fixed up keem_m_in_n to handle relative rate and correct number of 
items in calls to work.
    
    Original patch from Zhe Feng on mailing list.
---
 gr-blocks/lib/keep_m_in_n_impl.cc | 28 +++++++++++++++++++++++++---
 gr-blocks/lib/keep_m_in_n_impl.h  |  6 +++---
 2 files changed, 28 insertions(+), 6 deletions(-)

diff --git a/gr-blocks/lib/keep_m_in_n_impl.cc 
b/gr-blocks/lib/keep_m_in_n_impl.cc
index 878531d..b33eb7c 100644
--- a/gr-blocks/lib/keep_m_in_n_impl.cc
+++ b/gr-blocks/lib/keep_m_in_n_impl.cc
@@ -59,13 +59,14 @@ namespace gr {
         std::string s = boost::str(boost::format("keep_m_in_n: m (%1%) <= n 
%2%") % d_m % d_n);
         throw std::runtime_error(s);
       }
-      if(d_offset < (d_n - d_m)) {
+      if(d_offset > (d_n - d_m)) {
         std::string s = boost::str(boost::format("keep_m_in_n: offset (%1%) <= 
n (%2%) - m (%3%)") \
                                    % d_offset % d_n % d_m);
         throw std::runtime_error(s);
       }
 
       set_output_multiple(m);
+      set_relative_rate(static_cast<double>(d_n)/static_cast<double>(d_m));
     }
 
     void
@@ -74,6 +75,27 @@ namespace gr {
       ninput_items_required[0] = d_n*(noutput_items/d_m);
     }
 
+    void
+    keep_m_in_n_impl::set_m(int m)
+    {
+      d_m = m;
+      set_output_multiple(m);
+      set_relative_rate(static_cast<double>(d_n)/static_cast<double>(d_m));
+    }
+
+    void
+    keep_m_in_n_impl::set_n(int n)
+    {
+      d_n = n;
+      set_relative_rate(static_cast<double>(d_n)/static_cast<double>(d_m));
+    }
+
+    void
+    keep_m_in_n_impl::set_offset(int offset)
+    {
+      d_offset = offset;
+    }
+
     int
     keep_m_in_n_impl::general_work(int noutput_items,
                                   gr_vector_int &ninput_items,
@@ -94,8 +116,8 @@ namespace gr {
        memcpy( optr, iptr, d_m*d_itemsize );
       }
 
-      consume_each(d_n);
-      return d_m;
+      consume_each(blks*d_n);
+      return blks*d_m;
     }
 
   } /* namespace blocks */
diff --git a/gr-blocks/lib/keep_m_in_n_impl.h b/gr-blocks/lib/keep_m_in_n_impl.h
index 39c78d3..4a54b4c 100644
--- a/gr-blocks/lib/keep_m_in_n_impl.h
+++ b/gr-blocks/lib/keep_m_in_n_impl.h
@@ -45,9 +45,9 @@ namespace gr {
                       gr_vector_const_void_star &input_items,
                       gr_vector_void_star &output_items);
 
-      void set_m(int m) { d_m = m; }
-      void set_n(int n) { d_n = n; }
-      void set_offset(int offset) { d_offset = offset; }
+      void set_m(int m);
+      void set_n(int n);
+      void set_offset(int offset);
     };
 
   } /* namespace blocks */



reply via email to

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