[Top][All Lists]
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[Commit-gnuradio] r11285 - gnuradio/branches/developers/trondeau/pfb/gnu
From: |
trondeau |
Subject: |
[Commit-gnuradio] r11285 - gnuradio/branches/developers/trondeau/pfb/gnuradio-core/src/lib/filter |
Date: |
Thu, 25 Jun 2009 18:47:19 -0600 (MDT) |
Author: trondeau
Date: 2009-06-25 18:47:18 -0600 (Thu, 25 Jun 2009)
New Revision: 11285
Modified:
gnuradio/branches/developers/trondeau/pfb/gnuradio-core/src/lib/filter/gr_pfb_filter_ccf.cc
gnuradio/branches/developers/trondeau/pfb/gnuradio-core/src/lib/filter/gr_pfb_filter_ccf.h
Log:
Significantly optimized handing of filterbank; requires a set of streams as
input.
Modified:
gnuradio/branches/developers/trondeau/pfb/gnuradio-core/src/lib/filter/gr_pfb_filter_ccf.cc
===================================================================
---
gnuradio/branches/developers/trondeau/pfb/gnuradio-core/src/lib/filter/gr_pfb_filter_ccf.cc
2009-06-25 22:48:04 UTC (rev 11284)
+++
gnuradio/branches/developers/trondeau/pfb/gnuradio-core/src/lib/filter/gr_pfb_filter_ccf.cc
2009-06-26 00:47:18 UTC (rev 11285)
@@ -40,39 +40,24 @@
gr_pfb_filter_ccf::gr_pfb_filter_ccf (unsigned int numchans,
const std::vector<float> &taps)
: gr_block ("pfb_filter_ccf",
- gr_make_io_signature (1, 1, sizeof(gr_complex)),
+ gr_make_io_signature (numchans, numchans, sizeof(gr_complex)),
gr_make_io_signature (1, 1, numchans*sizeof(gr_complex))),
d_updated (false)
{
- unsigned int i,j;
-
- unsigned int ntaps = taps.size();
d_numchans = numchans;
- d_taps_per_filter = (unsigned int)ceil((double)ntaps/(double)d_numchans);
d_filters = std::vector<gr_fir_ccf*>(d_numchans);
- d_delay_line = std::vector<gr_complex*>(d_numchans);
- // Create d_numchan vectors to store each channel's taps
- std::vector< std::vector<float> > vtaps(d_numchans);
-
- // Partition the filter
- for(i = 0; i < d_numchans; i++) {
- // Each channel uses all d_taps_per_filter with 0's if not enough taps to
fill out
- vtaps[i] = std::vector<float>(d_taps_per_filter, 0);
- for(j = 0; j < d_taps_per_filter; j++) {
- vtaps[i][j] = taps[i + j*d_numchans]; // add taps to channels in
reverse order
- }
-
- // Build a filter for each channel and add it's taps to it
- d_filters[i] = gr_fir_util::create_gr_fir_ccf(vtaps[i]);
- d_delay_line[i] = new gr_complex[d_taps_per_filter];
- memset(d_delay_line[i], 0, d_taps_per_filter*sizeof(gr_complex));
+ // Create an FIR filter for each channel and zero out the taps
+ std::vector<float> vtaps(0, d_numchans);
+ for(unsigned int i = 0; i < d_numchans; i++) {
+ d_filters[i] = gr_fir_util::create_gr_fir_ccf(vtaps);
}
-
+
+ // Now, actually set the filters' taps
+ set_taps(taps);
+
// Create the FFT to handle the output de-spinning of the channels
d_fft = new gri_fft_complex (d_numchans, false);
-
- set_history (d_taps_per_filter);
}
gr_pfb_filter_ccf::~gr_pfb_filter_ccf ()
@@ -85,8 +70,29 @@
void
gr_pfb_filter_ccf::set_taps (const std::vector<float> &taps)
{
- // FIXME: implement this
+ unsigned int i,j;
+ unsigned int ntaps = taps.size();
+ d_taps_per_filter = (unsigned int)ceil((double)ntaps/(double)d_numchans);
+
+ // Create d_numchan vectors to store each channel's taps
+ std::vector< std::vector<float> > vtaps(d_numchans);
+
+ // Partition the filter
+ for(i = 0; i < d_numchans; i++) {
+ // Each channel uses all d_taps_per_filter with 0's if not enough taps to
fill out
+ vtaps[i] = std::vector<float>(d_taps_per_filter, 0);
+ for(j = 0; j < d_taps_per_filter; j++) {
+ vtaps[i][j] = taps[i + j*d_numchans]; // add taps to channels in
reverse order
+ }
+
+ // Build a filter for each channel and add it's taps to it
+ d_filters[i]->set_taps(vtaps[i]);
+ }
+
+ // Set the history to ensure enough input items for each filter
+ set_history (d_taps_per_filter);
+
d_updated = true;
}
@@ -100,49 +106,36 @@
gr_complex *out = (gr_complex *) output_items[0];
if (d_updated) {
- //d_fir->set_taps (d_new_taps);
- //set_history (d_fir->ntaps ());
d_updated = false;
return 0; // history requirements may have changed.
}
- printf("noutput_items: %d\n", noutput_items);
- printf("ninput_items: %d\n", ninput_items[0]);
+ //printf("noutput_items: %d\n", noutput_items);
+ //printf("ninput_items: %d\n", ninput_items[0]);
// FIXME: simple initial implementation
// yes, this will be optimized
- unsigned int i = 0, count = 0;
- gr_complex *flt_out = new gr_complex[d_numchans];
+ int i = 0, count = 0;
+
// for(int i = 0; i < noutput_items; i++) {
while((i < noutput_items) && (count < ninput_items[0])) {
// Move through filters from bottom to top
-
- memset(flt_out, 0, d_numchans*sizeof(gr_complex));
-
for(int j = d_numchans-1; j >= 0; j--) {
- // Move all values in delay line forward to make room for new value
- for(unsigned int k = 0; k < d_taps_per_filter-1; k++) {
- d_delay_line[j][k] = d_delay_line[j][k+1];
- }
- d_delay_line[j][d_taps_per_filter-1] = in[0]; // add new value to delay
line
- in++;
- count++;
-
- // Filter current delay line with its respective filter
- flt_out[j] = d_filters[j]->filter(d_delay_line[j]);
+ // Take in the items from the first input stream to d_numchans
+ in = (gr_complex*)input_items[d_numchans - 1 - j];
+
+ // Filter current input stream from bottom filter to top
+ d_fft->get_inbuf()[j] = d_filters[j]->filter(&in[i]);
}
// despin through FFT
- memcpy(d_fft->get_inbuf(), &flt_out[0], d_numchans*sizeof(gr_complex));
d_fft->execute();
memcpy(&out[d_numchans*i], d_fft->get_outbuf(),
d_numchans*sizeof(gr_complex));
- //memcpy(&out[i], flt_out, d_numchans*sizeof(gr_complex));
i++;
+ count++;
}
- delete flt_out;
-
- printf("count: %d\n", count);
+ //printf("count: %d\n", count);
consume_each(count);
return i;
}
Modified:
gnuradio/branches/developers/trondeau/pfb/gnuradio-core/src/lib/filter/gr_pfb_filter_ccf.h
===================================================================
---
gnuradio/branches/developers/trondeau/pfb/gnuradio-core/src/lib/filter/gr_pfb_filter_ccf.h
2009-06-25 22:48:04 UTC (rev 11284)
+++
gnuradio/branches/developers/trondeau/pfb/gnuradio-core/src/lib/filter/gr_pfb_filter_ccf.h
2009-06-26 00:47:18 UTC (rev 11285)
@@ -45,7 +45,6 @@
const
std::vector<float> &taps);
std::vector<gr_fir_ccf*> d_filters;
- std::vector<gr_complex*> d_delay_line;
gri_fft_complex *d_fft;
unsigned int d_numchans;
unsigned int d_taps_per_filter;
[Prev in Thread] |
Current Thread |
[Next in Thread] |
- [Commit-gnuradio] r11285 - gnuradio/branches/developers/trondeau/pfb/gnuradio-core/src/lib/filter,
trondeau <=