Moving towards gr_block implementation to enable non-integer output rates. Also,...
authorTom Rondeau <trondeau@vt.edu>
Mon, 12 Apr 2010 21:28:39 +0000 (17:28 -0400)
committerTom Rondeau <trondeau@vt.edu>
Mon, 12 Apr 2010 21:28:39 +0000 (17:28 -0400)
gnuradio-core/src/lib/filter/gr_pfb_channelizer_ccf.cc
gnuradio-core/src/lib/filter/gr_pfb_channelizer_ccf.h
gnuradio-core/src/lib/filter/gr_pfb_channelizer_ccf.i

index f0fd33a88de9eb8828a9f7d731217a312f332edd..ba22af99a13326e84b7df9eda19ac00b6ca65faf 100644 (file)
@@ -44,13 +44,11 @@ gr_pfb_channelizer_ccf_sptr gr_make_pfb_channelizer_ccf (unsigned int numchans,
 gr_pfb_channelizer_ccf::gr_pfb_channelizer_ccf (unsigned int numchans, 
                                                const std::vector<float> &taps,
                                                float oversample_rate)
-  : gr_sync_interpolator ("pfb_channelizer_ccf",
-                         gr_make_io_signature (numchans, numchans, sizeof(gr_complex)),
-                         gr_make_io_signature (1, 1, numchans*sizeof(gr_complex)),
-                         oversample_rate),
-    d_updated (false), d_oversample_rate(oversample_rate)
+  : gr_block ("pfb_channelizer_ccf",
+             gr_make_io_signature (numchans, numchans, sizeof(gr_complex)),
+             gr_make_io_signature (1, 1, numchans*sizeof(gr_complex))),
+    d_updated (false), d_numchans(numchans), d_oversample_rate(oversample_rate)
 {
-  d_numchans = numchans;
   d_filters = std::vector<gr_fir_ccf*>(d_numchans);
 
   // Create an FIR filter for each channel and zero out the taps
@@ -64,10 +62,23 @@ gr_pfb_channelizer_ccf::gr_pfb_channelizer_ccf (unsigned int numchans,
 
   // Create the FFT to handle the output de-spinning of the channels
   d_fft = new gri_fft_complex (d_numchans, false);
+
+  // Although the filters change, we use this look up table
+  // to set the index of the FFT input buffer, which equivalently
+  // performs the FFT shift operation on every other turn.
+  int r = d_numchans / d_oversample_rate;
+  d_idxlut = new int[d_numchans];
+  for(int i = 0; i < d_numchans; i++) {
+    d_idxlut[i] = d_numchans - ((i + r) % d_numchans) - 1;
+  }
+
+  set_output_multiple(d_oversample_rate);
 }
 
 gr_pfb_channelizer_ccf::~gr_pfb_channelizer_ccf ()
 {
+  delete [] d_idxlut; 
+  
   for(unsigned int i = 0; i < d_numchans; i++) {
     delete d_filters[i];
   }
@@ -125,9 +136,10 @@ gr_pfb_channelizer_ccf::print_taps()
 
 
 int
-gr_pfb_channelizer_ccf::work (int noutput_items,
-                             gr_vector_const_void_star &input_items,
-                             gr_vector_void_star &output_items)
+gr_pfb_channelizer_ccf::general_work (int noutput_items,
+                                     gr_vector_int &ninput_items,
+                                     gr_vector_const_void_star &input_items,
+                                     gr_vector_void_star &output_items)
 {
   gr_complex *in = (gr_complex *) input_items[0];
   gr_complex *out = (gr_complex *) output_items[0];
@@ -143,21 +155,13 @@ gr_pfb_channelizer_ccf::work (int noutput_items,
 
   int n=1, i=-1, j=0, last;
 
-  // Although the filters change, we use this look up table
-  // to set the index of the FFT input buffer, which equivalently
-  // performs the FFT shift operation on every other turn.
-  int *idxlut = new int[N];
-  for(int ii = 0; ii < N; ii++) {
-    idxlut[ii] = N - ((ii + r) % N) - 1;
-  }
-
   while(n <= noutput_items/M) {
     j = 0;
     i = (i + r) % N;
     last = i;
     while(i >= 0) {
       in = (gr_complex*)input_items[j];
-      d_fft->get_inbuf()[idxlut[j]] = d_filters[i]->filter(&in[n]);
+      d_fft->get_inbuf()[d_idxlut[j]] = d_filters[i]->filter(&in[n]);
       j++;
       i--;
     }
@@ -165,7 +169,7 @@ gr_pfb_channelizer_ccf::work (int noutput_items,
     i = N-1;
     while(i > last) {
       in = (gr_complex*)input_items[j];
-      d_fft->get_inbuf()[idxlut[j]] = d_filters[i]->filter(&in[n-1]);
+      d_fft->get_inbuf()[d_idxlut[j]] = d_filters[i]->filter(&in[n-1]);
       j++;
       i--;
     }
@@ -178,7 +182,6 @@ gr_pfb_channelizer_ccf::work (int noutput_items,
     out += d_numchans;
   }
   
-  delete [] idxlut; 
-
+  consume_each(noutput_items/M);
   return noutput_items;
 }
index 359cd043809697fc3281020928d1c4536d32fc76..1f9189e28fba2dabc9a9b2daf57df17af8c02255 100644 (file)
@@ -24,7 +24,7 @@
 #ifndef INCLUDED_GR_PFB_CHANNELIZER_CCF_H
 #define        INCLUDED_GR_PFB_CHANNELIZER_CCF_H
 
-#include <gr_sync_interpolator.h>
+#include <gr_block.h>
 
 class gr_pfb_channelizer_ccf;
 typedef boost::shared_ptr<gr_pfb_channelizer_ccf> gr_pfb_channelizer_ccf_sptr;
@@ -97,7 +97,7 @@ class gri_fft_complex;
  *
  */
 
-class gr_pfb_channelizer_ccf : public gr_sync_interpolator
+class gr_pfb_channelizer_ccf : public gr_block
 {
  private:
   /*!
@@ -109,13 +109,14 @@ class gr_pfb_channelizer_ccf : public gr_sync_interpolator
                                                                  const std::vector<float> &taps,
                                                                  float oversample_rate);
 
+  bool                    d_updated;
+  unsigned int             d_numchans;
+  float                    d_oversample_rate;
   std::vector<gr_fir_ccf*> d_filters;
   std::vector< std::vector<float> > d_taps;
-  gri_fft_complex         *d_fft;
-  unsigned int             d_numchans;
   unsigned int             d_taps_per_filter;
-  bool                    d_updated;
-  float                    d_oversample_rate;
+  gri_fft_complex         *d_fft;
+  int                     *d_idxlut;
 
   /*!
    * Build the polyphase filterbank decimator.
@@ -140,9 +141,10 @@ public:
    */
   void print_taps();
   
-  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);
 };
 
 #endif
index 1d2dcb73a5c0627e1320d54c01c5972dfe0ba700..63e3e0fe6a45544af7e17cc44b94dfea3bb295e5 100644 (file)
@@ -26,7 +26,7 @@ gr_pfb_channelizer_ccf_sptr gr_make_pfb_channelizer_ccf (unsigned int numchans,
                                                         const std::vector<float> &taps,
                                                         float oversample_rate=1);
 
-class gr_pfb_channelizer_ccf : public gr_sync_interpolator
+class gr_pfb_channelizer_ccf : public gr_block
 {
  private:
   gr_pfb_channelizer_ccf (unsigned int numchans,