diff options
Diffstat (limited to 'gr-filter/lib')
-rw-r--r-- | gr-filter/lib/CMakeLists.txt | 1 | ||||
-rw-r--r-- | gr-filter/lib/adaptive_fir.cc | 185 | ||||
-rw-r--r-- | gr-filter/lib/adaptive_fir_ccc_impl.cc | 18 | ||||
-rw-r--r-- | gr-filter/lib/adaptive_fir_ccc_impl.h | 5 | ||||
-rw-r--r-- | gr-filter/lib/adaptive_fir_ccf_impl.cc | 18 | ||||
-rw-r--r-- | gr-filter/lib/adaptive_fir_ccf_impl.h | 5 |
6 files changed, 38 insertions, 194 deletions
diff --git a/gr-filter/lib/CMakeLists.txt b/gr-filter/lib/CMakeLists.txt index f5dbd1bb3..7a6394b57 100644 --- a/gr-filter/lib/CMakeLists.txt +++ b/gr-filter/lib/CMakeLists.txt @@ -105,7 +105,6 @@ link_directories(${FFTW3F_LIBRARY_DIRS}) # Setup library ######################################################################## list(APPEND filter_sources - adaptive_fir.cc fir_filter.cc fir_filter_with_buffer.cc fft_filter.cc diff --git a/gr-filter/lib/adaptive_fir.cc b/gr-filter/lib/adaptive_fir.cc deleted file mode 100644 index 9098e86ca..000000000 --- a/gr-filter/lib/adaptive_fir.cc +++ /dev/null @@ -1,185 +0,0 @@ -/* -*- c++ -*- */ -/* - * Copyright 2012 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, - * Boston, MA 02110-1301, USA. - */ - -#ifdef HAVE_CONFIG_H -#include "config.h" -#endif - -#include <filter/adaptive_fir.h> -#include <fft/fft.h> -#include <volk/volk.h> - -namespace gr { - namespace filter { - namespace kernel { - - adaptive_fir_ccc::adaptive_fir_ccc(int decimation, - const std::vector<gr_complex> &taps) - { - d_taps = NULL; - d_decim = decimation; - set_taps(taps); - } - - void - adaptive_fir_ccc::set_taps(const std::vector<gr_complex> &taps) - { - // Free the taps if already allocated - if(d_taps != NULL) { - fft::free(d_taps); - d_taps = NULL; - } - - d_ntaps = (int)taps.size(); - d_taps = fft::malloc_complex(d_ntaps); - for(unsigned int i = 0; i < d_ntaps; i++) { - d_taps[d_ntaps-i-1] = taps[i]; - } - } - - std::vector<gr_complex> - adaptive_fir_ccc::taps() const - { - std::vector<gr_complex> t; - for(unsigned int i = 0; i < d_ntaps; i++) - t.push_back(d_taps[d_ntaps-i-1]); - return t; - } - - int - adaptive_fir_ccc::decimation() const - { - return d_decim; - } - - unsigned int - adaptive_fir_ccc::ntaps() const - { - return d_ntaps; - } - - gr_complex - adaptive_fir_ccc::filter(gr_complex *input) - { - gr_complex output; - volk_32fc_x2_dot_prod_32fc_u(&output, input, d_taps, d_ntaps); - return output; - } - - void - adaptive_fir_ccc::filterN(gr_complex *out, gr_complex *in, - int nitems) - { - int j = 0; - unsigned int k; - for(int i = 0; i < nitems; i++) { - out[i] = filter(&in[j]); - - // Adjust taps - d_error = error(out[i]); - for(k = 0; k < d_ntaps; k++) { - update_tap(d_taps[d_ntaps-k-1], in[j+k]); - } - - j += decimation(); - } - } - - - /**************************************************************/ - - - adaptive_fir_ccf::adaptive_fir_ccf(int decimation, - const std::vector<float> &taps) - { - d_taps = NULL; - d_decim = decimation; - set_taps(taps); - } - - void - adaptive_fir_ccf::set_taps(const std::vector<float> &taps) - { - // Free the taps if already allocated - if(d_taps != NULL) { - fft::free(d_taps); - d_taps = NULL; - } - - d_ntaps = (int)taps.size(); - d_taps = fft::malloc_complex(d_ntaps); - for(unsigned int i = 0; i < d_ntaps; i++) { - d_taps[d_ntaps-i-1] = taps[i]; - } - } - - std::vector<float> - adaptive_fir_ccf::taps() const - { - std::vector<float> t; - for(unsigned int i = 0; i < d_ntaps; i++) - t.push_back(d_taps[d_ntaps-i-1].real()); - return t; - } - - int - adaptive_fir_ccf::decimation() const - { - return d_decim; - } - - unsigned int - adaptive_fir_ccf::ntaps() const - { - return d_ntaps; - } - - gr_complex - adaptive_fir_ccf::filter(gr_complex *input) - { - gr_complex output; - volk_32fc_x2_dot_prod_32fc_u(&output, input, d_taps, d_ntaps); - return output; - } - - void - adaptive_fir_ccf::filterN(gr_complex *out, gr_complex *in, - int nitems) - { - int j = 0; - unsigned int k; - for(int i = 0; i < nitems; i++) { - out[i] = filter(&in[j]); - - // Adjust taps - d_error = error(out[i]); - for(k = 0; k < d_ntaps; k++) { - update_tap(d_taps[d_ntaps-k-1], in[j+k]); - } - - j += decimation(); - } - } - - } /* namespace kernel */ - } /* namespace filter */ -} /* namespace gr */ diff --git a/gr-filter/lib/adaptive_fir_ccc_impl.cc b/gr-filter/lib/adaptive_fir_ccc_impl.cc index 06736ae6f..515ef90cd 100644 --- a/gr-filter/lib/adaptive_fir_ccc_impl.cc +++ b/gr-filter/lib/adaptive_fir_ccc_impl.cc @@ -43,7 +43,7 @@ namespace gr { gr_make_io_signature(1, 1, sizeof(gr_complex)), gr_make_io_signature(1, 1, sizeof(gr_complex)), decimation), - kernel::adaptive_fir_ccc(decimation, taps), + kernel::fir_filter_ccc(decimation, taps), d_updated(false) { set_history(d_ntaps); @@ -56,6 +56,12 @@ namespace gr { d_updated = true; } + std::vector<gr_complex> + adaptive_fir_ccc_impl::taps() const + { + return kernel::fir_filter_ccc::taps(); + } + gr_complex adaptive_fir_ccc_impl::error(const gr_complex &out) { @@ -77,7 +83,7 @@ namespace gr { gr_complex *out = (gr_complex *)output_items[0]; if (d_updated) { - kernel::adaptive_fir_ccc::set_taps(d_new_taps); + kernel::fir_filter_ccc::set_taps(d_new_taps); set_history(d_ntaps); d_updated = false; return 0; // history requirements may have changed. @@ -85,7 +91,13 @@ namespace gr { // Call base class filtering function that uses // overloaded error and update_tap functions. - filterN(out, in, noutput_items); + if (decimation() == 1) { + filterN(out, in, noutput_items); + } + else { + filterNdec(out, in, noutput_items, + decimation()); + } return noutput_items; } diff --git a/gr-filter/lib/adaptive_fir_ccc_impl.h b/gr-filter/lib/adaptive_fir_ccc_impl.h index f145ceeaa..fd6274a1d 100644 --- a/gr-filter/lib/adaptive_fir_ccc_impl.h +++ b/gr-filter/lib/adaptive_fir_ccc_impl.h @@ -24,17 +24,19 @@ #define INCLUDED_FILTER_ADAPTIVE_FIR_CCC_IMPL_H #include <filter/adaptive_fir_ccc.h> +#include <filter/fir_filter.h> #include <gr_types.h> namespace gr { namespace filter { - class FILTER_API adaptive_fir_ccc_impl : public adaptive_fir_ccc, public kernel::adaptive_fir_ccc + class FILTER_API adaptive_fir_ccc_impl : public adaptive_fir_ccc, public kernel::fir_filter_ccc { private: std::vector<gr_complex> d_new_taps; bool d_updated; + protected: // Override to calculate error signal per output gr_complex error(const gr_complex &out); @@ -43,6 +45,7 @@ namespace gr { public: void set_taps(const std::vector<gr_complex> &taps); + std::vector<gr_complex> taps() const; adaptive_fir_ccc_impl(const char *name, int decimation, const std::vector<gr_complex> &taps); diff --git a/gr-filter/lib/adaptive_fir_ccf_impl.cc b/gr-filter/lib/adaptive_fir_ccf_impl.cc index 053facdc2..62d7e5337 100644 --- a/gr-filter/lib/adaptive_fir_ccf_impl.cc +++ b/gr-filter/lib/adaptive_fir_ccf_impl.cc @@ -43,7 +43,7 @@ namespace gr { gr_make_io_signature(1, 1, sizeof(gr_complex)), gr_make_io_signature(1, 1, sizeof(gr_complex)), decimation), - kernel::adaptive_fir_ccf(decimation, taps), + kernel::fir_filter_ccf(decimation, taps), d_updated(false) { set_history(d_ntaps); @@ -56,6 +56,12 @@ namespace gr { d_updated = true; } + std::vector<float> + adaptive_fir_ccf_impl::taps() + { + return kernel::fir_filter_ccf::taps(); + } + float adaptive_fir_ccf_impl::error(const gr_complex &out) { @@ -77,7 +83,7 @@ namespace gr { gr_complex *out = (gr_complex *)output_items[0]; if (d_updated) { - kernel::adaptive_fir_ccf::set_taps(d_new_taps); + kernel::fir_filter_ccf::set_taps(d_new_taps); set_history(d_ntaps); d_updated = false; return 0; // history requirements may have changed. @@ -85,7 +91,13 @@ namespace gr { // Call base class filtering function that uses // overloaded error and update_tap functions. - filterN(out, in, noutput_items); + if (decimation() == 1) { + filterN(out, in, noutput_items); + } + else { + filterNdec(out, in, noutput_items, + decimation()); + } return noutput_items; } diff --git a/gr-filter/lib/adaptive_fir_ccf_impl.h b/gr-filter/lib/adaptive_fir_ccf_impl.h index fa9a42189..2a1c7e5e9 100644 --- a/gr-filter/lib/adaptive_fir_ccf_impl.h +++ b/gr-filter/lib/adaptive_fir_ccf_impl.h @@ -24,17 +24,19 @@ #define INCLUDED_FILTER_ADAPTIVE_FIR_CCF_IMPL_H #include <filter/adaptive_fir_ccf.h> +#include <filter/fir_filter.h> #include <gr_types.h> namespace gr { namespace filter { - class FILTER_API adaptive_fir_ccf_impl : public adaptive_fir_ccf, public kernel::adaptive_fir_ccf + class FILTER_API adaptive_fir_ccf_impl : public adaptive_fir_ccf, public kernel::fir_filter_ccf { private: std::vector<float> d_new_taps; bool d_updated; + protected: // Override to calculate error signal per output float error(const gr_complex &out); @@ -43,6 +45,7 @@ namespace gr { public: void set_taps(const std::vector<float> &taps); + std::vector<float> taps(); adaptive_fir_ccf_impl(const char *name, int decimation, const std::vector<float> &taps); |