9b2b53269df7d5180425dea5a337f9e33dc4ac3c
[debian/gnuradio] / gr-atsc / src / lib / atsci_equalizer_nop.cc
1 /* -*- c++ -*- */
2 /*
3  * Copyright 2002 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 #include <atsci_equalizer_nop.h>
24 #include <atsci_sync_tag.h>
25 #include <assert.h>
26
27 atsci_equalizer_nop::atsci_equalizer_nop ()
28 {
29 }
30
31 atsci_equalizer_nop::~atsci_equalizer_nop ()
32 {
33 }
34
35 void
36 atsci_equalizer_nop::reset ()
37 {
38   atsci_equalizer::reset ();    // invoke superclass
39 }
40
41 int 
42 atsci_equalizer_nop::ntaps () const
43 {
44   return 1;
45 }
46
47 int
48 atsci_equalizer_nop::npretaps () const
49 {
50   return 0;
51 }
52
53 /*!
54  * Input range is known NOT TO CONTAIN data segment syncs
55  * or field syncs.  This should be the fast path.  In the
56  * non decicion directed case, this just runs the input
57  * through the filter without adapting it.
58  *
59  * \p input_samples has (nsamples + ntaps() - 1) valid entries.
60  * input_samples[0] .. input_samples[nsamples - 1 + ntaps() - 1] may be
61  * referenced to compute the output values.
62  */
63 void 
64 atsci_equalizer_nop::filter_normal (const float *input_samples,
65                                    float *output_samples,
66                                    int   nsamples)
67 {
68   for (int i = 0; i < nsamples; i++){
69     output_samples[i] = scale (input_samples[i]);
70   }
71 }
72
73
74 /*!
75  * Input range is known to consist of only a data segment sync or a
76  * portion of a data segment sync.  \p nsamples will be in [1,4].
77  * \p offset will be in [0,3].  \p offset is the offset of the input
78  * from the beginning of the data segment sync pattern.
79  *
80  * \p input_samples has (nsamples + ntaps() - 1) valid entries.
81  * input_samples[0] .. input_samples[nsamples - 1 + ntaps() - 1] may be
82  * referenced to compute the output values.
83  */
84 void 
85 atsci_equalizer_nop::filter_data_seg_sync (const float *input_samples,
86                                           float *output_samples,
87                                           int   nsamples,
88                                           int   offset)
89 {
90   for (int i = 0; i < nsamples; i++){
91     output_samples[i] = scale_and_train (input_samples[i]);
92   }
93 }
94
95   
96 /*!
97  * Input range is known to consist of only a field sync segment or a
98  * portion of a field sync segment.  \p nsamples will be in [1,832].
99  * \p offset will be in [0,831].  \p offset is the offset of the input
100  * from the beginning of the data segment sync pattern.  We consider the
101  * 4 symbols of the immediately preceding data segment sync to be the
102  * first symbols of the field sync segment.  \p which_field is in [0,1] 
103  * and specifies which field (duh).
104  *
105  * \p input_samples has (nsamples + ntaps() - 1) valid entries.
106  * input_samples[0] .. input_samples[nsamples - 1 + ntaps() - 1] may be
107  * referenced to compute the output values.
108  */
109 void 
110 atsci_equalizer_nop::filter_field_sync (const float *input_samples,
111                                        float *output_samples,
112                                        int   nsamples,
113                                        int   offset,
114                                        int   which_field)
115 {
116   int   i = 0;
117   
118   if (offset == 0 && nsamples > 0){
119     output_samples[0] = scale_and_train (input_samples[0]);
120     i++;
121   }
122
123   for (; i < nsamples; i++){
124     output_samples[i] = scale_and_train (input_samples[i]);
125   }
126 }
127
128
129 float
130 atsci_equalizer_nop::scale_and_train (float input)
131 {
132   return input;
133 }