Merge commit 'v3.3.1' into try-3.3.1
[debian/gnuradio] / gnuradio-core / src / lib / filter / gr_pfb_arb_resampler_ccf.cc
index 5a6e753ab4c2b45d61ee4e432fae921d0b9668d4..84b0c578f59bc12310a261e6391f2a20d7034c7f 100644 (file)
@@ -34,8 +34,8 @@ gr_pfb_arb_resampler_ccf_sptr gr_make_pfb_arb_resampler_ccf (float rate,
                                                             const std::vector<float> &taps,
                                                             unsigned int filter_size)
 {
-  return gr_pfb_arb_resampler_ccf_sptr (new gr_pfb_arb_resampler_ccf (rate, taps,
-                                                                     filter_size));
+  return gnuradio::get_initial_sptr(new gr_pfb_arb_resampler_ccf (rate, taps,
+                                                                 filter_size));
 }
 
 
@@ -71,7 +71,7 @@ gr_pfb_arb_resampler_ccf::gr_pfb_arb_resampler_ccf (float rate,
 
   // Create an FIR filter for each channel and zero out the taps
   std::vector<float> vtaps(0, d_int_rate);
-  for(int i = 0; i < d_int_rate; i++) {
+  for(unsigned int i = 0; i < d_int_rate; i++) {
     d_filters[i] = gr_fir_util::create_gr_fir_ccf(vtaps);
     d_diff_filters[i] = gr_fir_util::create_gr_fir_ccf(vtaps);
   }
@@ -81,6 +81,8 @@ gr_pfb_arb_resampler_ccf::gr_pfb_arb_resampler_ccf (float rate,
   create_diff_taps(taps, dtaps);
   create_taps(taps, d_taps, d_filters);
   create_taps(dtaps, d_dtaps, d_diff_filters);
+
+  set_relative_rate(rate);
 }
 
 gr_pfb_arb_resampler_ccf::~gr_pfb_arb_resampler_ccf ()
@@ -95,8 +97,6 @@ gr_pfb_arb_resampler_ccf::create_taps (const std::vector<float> &newtaps,
                                       std::vector< std::vector<float> > &ourtaps,
                                       std::vector<gr_fir_ccf*> &ourfilter)
 {
-  int i,j;
-
   unsigned int ntaps = newtaps.size();
   d_taps_per_filter = (unsigned int)ceil((double)ntaps/(double)d_int_rate);
 
@@ -112,10 +112,10 @@ gr_pfb_arb_resampler_ccf::create_taps (const std::vector<float> &newtaps,
   }
   
   // Partition the filter
-  for(i = 0; i < d_int_rate; i++) {
+  for(unsigned int i = 0; i < d_int_rate; i++) {
     // Each channel uses all d_taps_per_filter with 0's if not enough taps to fill out
     ourtaps[d_int_rate-1-i] = std::vector<float>(d_taps_per_filter, 0);
-    for(j = 0; j < d_taps_per_filter; j++) {
+    for(unsigned int j = 0; j < d_taps_per_filter; j++) {
       ourtaps[d_int_rate - 1 - i][j] = tmp_taps[i + j*d_int_rate];
     }
     
@@ -171,14 +171,16 @@ gr_pfb_arb_resampler_ccf::general_work (int noutput_items,
     return 0;               // history requirements may have changed.
   }
 
-  int i = 0, j, count = d_start_index;
+  int i = 0, count = d_start_index;
+  unsigned int j;
   gr_complex o0, o1;
 
   // Restore the last filter position
   j = d_last_filter;
 
   // produce output as long as we can and there are enough input samples
-  while((i < noutput_items) && (count < ninput_items[0]-1)) {
+  int max_input = ninput_items[0]-(int)d_taps_per_filter;
+  while((i < noutput_items) && (count < max_input)) {
 
     // start j by wrapping around mod the number of channels
     while((j < d_int_rate) && (i < noutput_items)) {