[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[Commit-gnuradio] [gnuradio] 04/04: digital: replaces buffer copies with
From: |
git |
Subject: |
[Commit-gnuradio] [gnuradio] 04/04: digital: replaces buffer copies with fir_filter_with_buffer to handle more sanely and with fewer extra copies. |
Date: |
Fri, 7 Mar 2014 00:23:59 +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 8fbba12af7150c017f59a4fd25d607ed95a490d7
Author: Tom Rondeau <address@hidden>
Date: Thu Mar 6 13:31:12 2014 -0500
digital: replaces buffer copies with fir_filter_with_buffer to handle more
sanely and with fewer extra copies.
---
gr-digital/lib/fll_band_edge_cc_impl.cc | 43 ++++++++++++---------------------
gr-digital/lib/fll_band_edge_cc_impl.h | 20 +++++++--------
2 files changed, 25 insertions(+), 38 deletions(-)
diff --git a/gr-digital/lib/fll_band_edge_cc_impl.cc
b/gr-digital/lib/fll_band_edge_cc_impl.cc
index b136744..583e8f5 100644
--- a/gr-digital/lib/fll_band_edge_cc_impl.cc
+++ b/gr-digital/lib/fll_band_edge_cc_impl.cc
@@ -1,19 +1,19 @@
/* -*- c++ -*- */
/*
- * Copyright 2009-2012 Free Software Foundation, Inc.
- *
+ * Copyright 2009-2012,2014 Free Software Foundation, Inc.
+ *
* This file is part of GNU Radio
- *
+ *
* GNU Radio is free software; you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation; either version 3, or (at your option)
* any later version.
- *
+ *
* GNU Radio is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
- *
+ *
* You should have received a copy of the GNU General Public License
* along with GNU Radio; see the file COPYING. If not, write to
* the Free Software Foundation, Inc., 51 Franklin Street,
@@ -67,22 +67,21 @@ namespace gr {
throw std::out_of_range("fll_band_edge_cc: invalid number of sps. Must
be > 0.");
}
d_sps = samps_per_sym;
-
+
// Initialize rolloff factor
if(rolloff < 0 || rolloff > 1.0) {
throw std::out_of_range("fll_band_edge_cc: invalid rolloff factor. Must
be in [0,1].");
}
d_rolloff = rolloff;
-
+
// Initialize filter length
if(filter_size <= 0) {
throw std::out_of_range("fll_band_edge_cc: invalid filter size. Must be
> 0.");
}
d_filter_size = filter_size;
-
+
// Build the band edge filters
design_filter(d_sps, d_rolloff, d_filter_size);
- d_output_hist.resize(filter_size,0);
}
fll_band_edge_cc_impl::~fll_band_edge_cc_impl()
@@ -163,7 +162,7 @@ namespace gr {
float k = -M + i*2.0/samps_per_sym;
float tap = sinc(rolloff*k - 0.5) + sinc(rolloff*k + 0.5);
power += tap;
-
+
bb_taps.push_back(tap);
}
@@ -185,13 +184,13 @@ namespace gr {
d_taps_lower[filter_size-i-1] = t1;
d_taps_upper[filter_size-i-1] = t2;
}
-
+
d_updated = true;
// Set the history to ensure enough input items for each filter
set_history(filter_size+1);
- d_filter_upper = new gr::filter::kernel::fir_filter_ccc(1, d_taps_upper);
- d_filter_lower = new gr::filter::kernel::fir_filter_ccc(1, d_taps_lower);
+ d_filter_upper = new
gr::filter::kernel::fir_filter_with_buffer_ccc(d_taps_upper);
+ d_filter_lower = new
gr::filter::kernel::fir_filter_with_buffer_ccc(d_taps_lower);
}
void
@@ -220,8 +219,6 @@ namespace gr {
const gr_complex *in = (const gr_complex*)input_items[0];
gr_complex *out = (gr_complex*)output_items[0];
- d_fllbuffer.reserve(d_filter_size+noutput_items);
-
float *frq = NULL;
float *phs = NULL;
float *err = NULL;
@@ -241,18 +238,15 @@ namespace gr {
gr_complex nco_out;
gr_complex out_upper, out_lower;
gr_complex out_uppersse, out_lowersse;
- copy(d_output_hist.begin(), d_output_hist.end(), d_fllbuffer.begin());
for(i = 0; i < noutput_items; i++) {
nco_out = gr_expj(d_phase);
- d_fllbuffer[i+d_filter_size] = in[i] * nco_out;
+ out[i] = in[i] * nco_out;
+
// Perform the dot product of the output with the filters
- out_upper = 0;
- out_lower = 0;
+ out_upper = d_filter_lower->filter(out[i]);
+ out_lower = d_filter_upper->filter(out[i]);
- out_upper = d_filter_lower->filter(&d_fllbuffer[i]);
- out_lower = d_filter_upper->filter(&d_fllbuffer[i]);
-
error = norm(out_lower) - norm(out_upper);
advance_loop(error);
@@ -266,11 +260,6 @@ namespace gr {
}
}
- copy(d_fllbuffer.begin(), d_fllbuffer.begin()+noutput_items, out);
- copy(d_fllbuffer.begin()+noutput_items,
- d_fllbuffer.begin()+noutput_items+d_filter_size,
- d_output_hist.begin());
-
return noutput_items;
}
diff --git a/gr-digital/lib/fll_band_edge_cc_impl.h
b/gr-digital/lib/fll_band_edge_cc_impl.h
index 7bec745..0049f59 100644
--- a/gr-digital/lib/fll_band_edge_cc_impl.h
+++ b/gr-digital/lib/fll_band_edge_cc_impl.h
@@ -1,19 +1,19 @@
/* -*- c++ -*- */
/*
- * Copyright 2009,2011,2012 Free Software Foundation, Inc.
- *
+ * Copyright 2009,2011,2012,2014 Free Software Foundation, Inc.
+ *
* This file is part of GNU Radio
- *
+ *
* GNU Radio is free software; you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation; either version 3, or (at your option)
* any later version.
- *
+ *
* GNU Radio is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
- *
+ *
* You should have received a copy of the GNU General Public License
* along with GNU Radio; see the file COPYING. If not, write to
* the Free Software Foundation, Inc., 51 Franklin Street,
@@ -25,7 +25,7 @@
#include <gnuradio/digital/fll_band_edge_cc.h>
#include <gnuradio/blocks/control_loop.h>
-#include <gnuradio/filter/fir_filter.h>
+#include <gnuradio/filter/fir_filter_with_buffer.h>
namespace gr {
namespace digital {
@@ -41,10 +41,8 @@ namespace gr {
std::vector<gr_complex> d_taps_lower;
std::vector<gr_complex> d_taps_upper;
bool d_updated;
- std::vector<gr_complex> d_output_hist;
- std::vector<gr_complex> d_fllbuffer;
- gr::filter::kernel::fir_filter_ccc* d_filter_lower;
- gr::filter::kernel::fir_filter_ccc* d_filter_upper;
+ gr::filter::kernel::fir_filter_with_buffer_ccc* d_filter_lower;
+ gr::filter::kernel::fir_filter_with_buffer_ccc* d_filter_upper;
/*!
* Design the band-edge filter based on the number of samples
@@ -70,7 +68,7 @@ namespace gr {
int filter_size() const;
void print_taps();
-
+
int work(int noutput_items,
gr_vector_const_void_star &input_items,
gr_vector_void_star &output_items);