[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[Commit-gnuradio] [gnuradio] 02/15: filter: Uses last commit to make a b
From: |
git |
Subject: |
[Commit-gnuradio] [gnuradio] 02/15: filter: Uses last commit to make a better fix for issue #882. |
Date: |
Wed, 10 Feb 2016 15:44:47 +0000 (UTC) |
This is an automated email from the git hooks/post-receive script.
jcorgan pushed a commit to branch master
in repository gnuradio.
commit 33f10e2d04a61ca361f412fb66a1a93a5067fe87
Author: Tom Rondeau <address@hidden>
Date: Mon Jan 25 09:07:16 2016 -0500
filter: Uses last commit to make a better fix for issue #882.
Since we can get max_noutput_items in start(), we can preallocate the
FFT filter's buffer (d_tmp) in start() and destroy it in stop().
---
gr-filter/lib/pfb_decimator_ccf_impl.cc | 32 ++++++++++++++++++++++++--------
gr-filter/lib/pfb_decimator_ccf_impl.h | 6 +++++-
2 files changed, 29 insertions(+), 9 deletions(-)
diff --git a/gr-filter/lib/pfb_decimator_ccf_impl.cc
b/gr-filter/lib/pfb_decimator_ccf_impl.cc
index e282b48..9d1d6f6 100644
--- a/gr-filter/lib/pfb_decimator_ccf_impl.cc
+++ b/gr-filter/lib/pfb_decimator_ccf_impl.cc
@@ -73,6 +73,26 @@ namespace gr {
else {
set_history(d_taps_per_filter);
}
+
+ d_tmp = NULL;
+ }
+
+ bool pfb_decimator_ccf_impl::start()
+ {
+ if(d_use_fft_filters) {
+ d_tmp = fft::malloc_complex(max_noutput_items()*d_rate);
+ }
+
+ return block::start();
+ }
+
+ bool pfb_decimator_ccf_impl::stop()
+ {
+ if((d_use_fft_filters) && (d_tmp)) {
+ fft::free(d_tmp);
+ }
+
+ return block::stop();
}
pfb_decimator_ccf_impl::~pfb_decimator_ccf_impl()
@@ -198,14 +218,13 @@ namespace gr {
gr_complex *out = (gr_complex *)output_items[0];
int i;
- gr_complex *tmp = fft::malloc_complex(noutput_items*d_rate);
// Filter each input stream by the FFT filters; do all
// noutput_items at once to avoid repeated calls to the FFT
// setup and operation.
for(unsigned int j = 0; j < d_rate; j++) {
in = (gr_complex*)input_items[d_rate-j-1];
- d_fft_filters[j]->filter(noutput_items, in, &(tmp[j*noutput_items]));
+ d_fft_filters[j]->filter(noutput_items, in, &(d_tmp[j*noutput_items]));
}
// Rotate and add filter outputs (k=channel number; M=number of
@@ -214,11 +233,10 @@ namespace gr {
for(i = 0; i < noutput_items; i++) {
out[i] = 0;
for(unsigned int j = 0; j < d_rate; j++) {
- out[i] += tmp[j*noutput_items+i]*d_rotator[j];
+ out[i] += d_tmp[j*noutput_items+i]*d_rotator[j];
}
}
- fft::free(tmp);
return noutput_items;
}
@@ -231,18 +249,17 @@ namespace gr {
gr_complex *out = (gr_complex *)output_items[0];
int i;
- gr_complex *tmp = fft::malloc_complex(noutput_items*d_rate);
for(unsigned int j = 0; j < d_rate; j++) {
in = (gr_complex*)input_items[d_rate-j-1];
- d_fft_filters[j]->filter(noutput_items, in, &tmp[j*noutput_items]);
+ d_fft_filters[j]->filter(noutput_items, in, &d_tmp[j*noutput_items]);
}
// Performs the rotate and add operations by implementing it as
// an FFT.
for(i = 0; i < noutput_items; i++) {
for(unsigned int j = 0; j < d_rate; j++) {
- d_fft->get_inbuf()[j] = tmp[j*noutput_items + i];
+ d_fft->get_inbuf()[j] = d_tmp[j*noutput_items + i];
}
// Perform the FFT to do the complex multiply despinning for all
channels
@@ -252,7 +269,6 @@ namespace gr {
out[i] = d_fft->get_outbuf()[d_chan];
}
- fft::free(tmp);
return noutput_items;
}
diff --git a/gr-filter/lib/pfb_decimator_ccf_impl.h
b/gr-filter/lib/pfb_decimator_ccf_impl.h
index 3397701..5e0b701 100644
--- a/gr-filter/lib/pfb_decimator_ccf_impl.h
+++ b/gr-filter/lib/pfb_decimator_ccf_impl.h
@@ -40,6 +40,7 @@ namespace gr {
bool d_use_fft_rotator;
bool d_use_fft_filters;
gr_complex *d_rotator;
+ gr_complex *d_tmp; // used for fft filters
gr::thread::mutex d_mutex; // mutex to protect set/work access
inline int work_fir_exp(int noutput_items,
@@ -55,7 +56,6 @@ namespace gr {
gr_vector_const_void_star &input_items,
gr_vector_void_star &output_items);
-
public:
pfb_decimator_ccf_impl(unsigned int decim,
const std::vector<float> &taps,
@@ -70,6 +70,10 @@ namespace gr {
std::vector<std::vector<float> > taps() const;
void set_channel(const unsigned int channel);
+ // Overload to create/destroy d_tmp based on max_noutput_items.
+ bool start();
+ bool stop();
+
int work(int noutput_items,
gr_vector_const_void_star &input_items,
gr_vector_void_star &output_items);
- [Commit-gnuradio] [gnuradio] 11/15: gnuradio-runtime: append docs to set_history regarding initialization, (continued)
- [Commit-gnuradio] [gnuradio] 11/15: gnuradio-runtime: append docs to set_history regarding initialization, git, 2016/02/10
- [Commit-gnuradio] [gnuradio] 03/15: blocks: adding QA code to test max_noutput_items., git, 2016/02/10
- [Commit-gnuradio] [gnuradio] 07/15: grc: user-selectable transparent bg screen shots, git, 2016/02/10
- [Commit-gnuradio] [gnuradio] 05/15: grc: #fff as canvas bg color, git, 2016/02/10
- [Commit-gnuradio] [gnuradio] 13/15: Merge remote-tracking branch 'tom/issue713', git, 2016/02/10
- [Commit-gnuradio] [gnuradio] 09/15: Merge branch 'maint_grcwg' into docstring_gui_fixes, git, 2016/02/10
- [Commit-gnuradio] [gnuradio] 12/15: Merge remote-tracking branch 'gnuradio-wg-grc/master_grcwg', git, 2016/02/10
- [Commit-gnuradio] [gnuradio] 14/15: Merge remote-tracking branch 'tom/set_max_noutput_items', git, 2016/02/10
- [Commit-gnuradio] [gnuradio] 08/15: grc: remove [] around categories in the block library, git, 2016/02/10
- [Commit-gnuradio] [gnuradio] 06/15: grc: optional transparent bg in screen shots, git, 2016/02/10
- [Commit-gnuradio] [gnuradio] 02/15: filter: Uses last commit to make a better fix for issue #882.,
git <=
- [Commit-gnuradio] [gnuradio] 04/15: runtime: addresses issue #713., git, 2016/02/10
- [Commit-gnuradio] [gnuradio] 01/15: runtime: always set max_noutput_items., git, 2016/02/10
- [Commit-gnuradio] [gnuradio] 10/15: grc: nicer block documentation tooltip and properties dialog tab, git, 2016/02/10