root / gr-filter / lib / fir_filter_XXX_impl.cc.t @ d511ba04
History | View | Annotate | Download (2.6 kB)
| 1 | /* -*- c++ -*- */ |
|---|---|
| 2 | /* |
| 3 | * Copyright 2004,2010,2012 Free Software Foundation, Inc. |
| 4 | * |
| 5 | * This file is part of GNU Radio |
| 6 | * |
| 7 | * GNU Radio is free software; you can redistribute it and/or modify |
| 8 | * it under the terms of the GNU General Public License as published by |
| 9 | * the Free Software Foundation; either version 3, or (at your option) |
| 10 | * any later version. |
| 11 | * |
| 12 | * GNU Radio is distributed in the hope that it will be useful, |
| 13 | * but WITHOUT ANY WARRANTY; without even the implied warranty of |
| 14 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
| 15 | * GNU General Public License for more details. |
| 16 | * |
| 17 | * You should have received a copy of the GNU General Public License |
| 18 | * along with GNU Radio; see the file COPYING. If not, write to |
| 19 | * the Free Software Foundation, Inc., 51 Franklin Street, |
| 20 | * Boston, MA 02110-1301, USA. |
| 21 | */ |
| 22 | |
| 23 | /* @WARNING@ */ |
| 24 | |
| 25 | #ifdef HAVE_CONFIG_H |
| 26 | #include "config.h" |
| 27 | #endif |
| 28 | |
| 29 | #include "@IMPL_NAME@.h" |
| 30 | #include <gr_io_signature.h> |
| 31 | #include <volk/volk.h> |
| 32 | |
| 33 | namespace gr {
|
| 34 | namespace filter {
|
| 35 | |
| 36 | @BASE_NAME@::sptr |
| 37 | @BASE_NAME@::make(int decimation, const std::vector<@TAP_TYPE@> &taps) |
| 38 | {
|
| 39 | return gnuradio::get_initial_sptr(new @IMPL_NAME@ |
| 40 | (decimation, taps)); |
| 41 | } |
| 42 | |
| 43 | |
| 44 | @IMPL_NAME@::@IMPL_NAME@(int decimation, const std::vector<@TAP_TYPE@> &taps) |
| 45 | : gr_sync_decimator("@BASE_NAME@",
|
| 46 | gr_make_io_signature(1, 1, sizeof(@I_TYPE@)), |
| 47 | gr_make_io_signature(1, 1, sizeof(@O_TYPE@)), |
| 48 | decimation) |
| 49 | {
|
| 50 | d_fir = new kernel::@BASE_NAME@(decimation, taps); |
| 51 | d_updated = false; |
| 52 | set_history(d_fir->ntaps()); |
| 53 | |
| 54 | const int alignment_multiple = |
| 55 | volk_get_alignment() / sizeof(float); |
| 56 | set_alignment(std::max(1, alignment_multiple)); |
| 57 | } |
| 58 | |
| 59 | @IMPL_NAME@::~@IMPL_NAME@() |
| 60 | {
|
| 61 | delete d_fir; |
| 62 | } |
| 63 | |
| 64 | void |
| 65 | @IMPL_NAME@::set_taps(const std::vector<@TAP_TYPE@> &taps) |
| 66 | {
|
| 67 | d_fir->set_taps(taps); |
| 68 | d_updated = true; |
| 69 | } |
| 70 | |
| 71 | std::vector<@TAP_TYPE@> |
| 72 | @IMPL_NAME@::taps() const |
| 73 | {
|
| 74 | return d_fir->taps(); |
| 75 | } |
| 76 | |
| 77 | int |
| 78 | @IMPL_NAME@::work(int noutput_items, |
| 79 | gr_vector_const_void_star &input_items, |
| 80 | gr_vector_void_star &output_items) |
| 81 | {
|
| 82 | const @I_TYPE@ *in = (const @I_TYPE@*)input_items[0]; |
| 83 | @O_TYPE@ *out = (@O_TYPE@*)output_items[0]; |
| 84 | |
| 85 | if (d_updated) {
|
| 86 | set_history(d_fir->ntaps()); |
| 87 | d_updated = false; |
| 88 | return 0; // history requirements may have changed. |
| 89 | } |
| 90 | |
| 91 | if (decimation() == 1) {
|
| 92 | d_fir->filterN(out, in, noutput_items); |
| 93 | } |
| 94 | else {
|
| 95 | d_fir->filterNdec(out, in, noutput_items, |
| 96 | decimation()); |
| 97 | } |
| 98 | |
| 99 | return noutput_items; |
| 100 | } |
| 101 | |
| 102 | } /* namespace filter */ |
| 103 | } /* namespace gr */ |
| 104 |