3 * Copyright 2006 Free Software Foundation, Inc.
5 * This file is part of GNU Radio
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)
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.
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.
27 #include <atsc_equalizer.h>
28 #include <create_atsci_equalizer.h>
29 #include <gr_io_signature.h>
30 #include <atsc_consts.h>
31 #include <atsci_syminfo.h>
37 return atsc_equalizer_sptr(new atsc_equalizer());
40 // had atsc_equalizer(atsci_equalizer *equalizer)
41 atsc_equalizer::atsc_equalizer()
42 : gr_sync_block("atsc_equalizer",
43 gr_make_io_signature(2, 2, sizeof(float)),
44 gr_make_io_signature(2, 2, sizeof(float)))
46 d_equalizer = create_atsci_equalizer_lms();
49 atsc_equalizer::~atsc_equalizer ()
51 // Anything that isn't automatically cleaned up...
58 atsc_equalizer::forecast (int noutput_items, gr_vector_int &ninput_items_required)
61 int ntaps = d_equalizer->ntaps ();
63 unsigned ninputs = ninput_items_required.size();
64 for (unsigned i = 0; i < ninputs; i++)
65 ninput_items_required[i] = fixed_rate_noutput_to_ninput (noutput_items + ntaps);
73 atsc_equalizer::work (int noutput_items,
74 gr_vector_const_void_star &input_items,
75 gr_vector_void_star &output_items)
77 const float *in = (const float *) input_items[0];
78 const atsc::syminfo *in_tags = (const atsc::syminfo *) input_items[1];
79 float *out = (float *) output_items[0];
80 atsc::syminfo *out_tags = (atsc::syminfo *) output_items[1];
82 assert(sizeof(float) == sizeof(atsc::syminfo));
84 int ntaps = d_equalizer->ntaps ();
85 int npretaps = d_equalizer->npretaps ();
88 assert (npretaps >= 0 && npretaps < ntaps);
90 int offset = ntaps - npretaps - 1;
91 assert (offset >= 0 && offset < ntaps);
94 // peform the actual equalization
96 d_equalizer->filter (in, in_tags + offset,
99 // write the output tags
101 for (int i = 0; i < noutput_items; i++)
102 out_tags[i] = in_tags[i + offset];
104 return noutput_items;