3 * Copyright 2002 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.
22 #ifndef _ATSC_SLIDING_CORRELATOR_H_
23 #define _ATSC_SLIDING_CORRELATOR_H_
27 extern const unsigned char atsc_pn511[511];
28 extern const unsigned char atsc_pn63[63];
31 * \brief look for the PN 511 field sync pattern
33 class atsci_sliding_correlator {
36 atsci_sliding_correlator ();
37 ~atsci_sliding_correlator (){};
39 //! input hard decision bit, return correlation (0,511)
40 // Result is the number of wrong bits.
41 // E.g., 0 -> perfect match; 511 -> all bits are wrong
43 int input_bit (int bit);
45 //! input sample, return correlation (0,511)
46 // Result is the number of wrong bits.
47 // E.g., 0 -> perfect match; 511 -> all bits are wrong
49 int input_int (int sample){
50 return input_bit (sample < 0 ? 0 : 1);
53 //! input sample, return correlation (0,511)
54 // Result is the number of wrong bits.
55 // E.g., 0 -> perfect match; 511 -> all bits are wrong
57 int input_float (float sample){
58 return input_bit (sample < 0 ? 0 : 1);
61 void reset () { input.reset (); }
65 typedef unsigned long srblock;
66 static const int bits_per_char = 8;
67 static const int srblock_bitsize = sizeof (srblock) * bits_per_char;
68 static const int NSRBLOCKS = (511 + srblock_bitsize - 1) / srblock_bitsize;
72 shift_reg () { reset (); }
73 void reset () { memset (d, 0, sizeof (d)); }
74 void shift_in (int bit);
78 shift_reg mask; // pattern we're looking for
79 shift_reg input; // current input window
80 shift_reg and_mask; // bits to consider
83 #endif /* _ATSC_SLIDING_CORRELATOR_H_ */