Updated FSF address in all files. Fixes ticket:51
[debian/gnuradio] / gr-atsc / src / lib / atsci_fs_correlator_naive.h
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 2, 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 #ifndef _ATSC_FS_CORRELATOR_NAIVE_H_
24 #define _ATSC_FS_CORRELATOR_NAIVE_H_
25
26 #include <atsci_fs_correlator.h>
27
28 /*!
29  * \brief Naive concrete implementation of field sync correlator
30  */
31 class atsci_fs_correlator_naive : public atsci_fs_correlator {
32
33  private:
34   static const int      SRSIZE = 1024;          // must be power of two
35   int                   d_index;                // points at oldest sample
36   float                 d_sample_sr[SRSIZE];    // sample shift register
37   unsigned char         d_bit_sr[SRSIZE];       // binary decision shift register
38
39   static const int      OFFSET_511 = 0;         // offset to PN 511 pattern
40   static const int      LENGTH_511 = 511 + 4;   // length of PN 511 pattern (+ 4 seg sync)
41   static const int      OFFSET_2ND_63 = 578;    // offset to second PN 63 pattern
42   static const int      LENGTH_2ND_63 = 63;     // length of PN 63 pattern
43
44   static unsigned char  s_511[LENGTH_511];      // PN 511 pattern
45   static unsigned char  s_63[LENGTH_2ND_63];    // PN 63 pattern
46
47   inline static int wrap (int index){ return index & (SRSIZE - 1); }
48   inline static int incr (int index){ return wrap (index + 1); }
49   inline static int decr (int index){ return wrap (index - 1); }
50
51  public:
52
53   // CREATORS
54   atsci_fs_correlator_naive ();
55   ~atsci_fs_correlator_naive ();
56
57   // MANIPULATORS
58   virtual void reset ();
59   void filter (float input_sample, float *output_sample, float *output_tag);
60
61   // ACCESSORS
62
63   //! return delay in samples from input to output
64   int delay () const;
65   
66 };
67
68
69 #endif /* _ATSC_FS_CORRELATOR_NAIVE_H_ */