Updated license from GPL version 2 or later to GPL version 3 or later.
[debian/gnuradio] / gr-atsc / src / lib / atsci_basic_trellis_encoder.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 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 #ifndef _ATSC_BASIC_TRELLIS_ENCODER_H_
23 #define _ATSC_BASIC_TRELLIS_ENCODER_H_
24
25 #include <assert.h>
26
27 /*!
28  * \brief ATSC trellis encoder building block.
29  *
30  * Note this is NOT the 12x interleaved interface.
31  *
32  * This implements a single instance of the ATSC trellis encoder.
33  * This is a rate 2/3 encoder (really a constraint length 3, rate 1/2
34  * encoder with the top bit passed through unencoded.  This does not
35  * implement the "precoding" of the top bit, because the NTSC rejection
36  * filter is not supported.
37  */
38
39 class atsci_basic_trellis_encoder {
40
41 private:
42   int               state;              // two bit state;
43
44 public:
45   atsci_basic_trellis_encoder () : state (0) {}
46
47   /*!
48    * Encode two bit INPUT into 3 bit return value.  Domain is [0,3],
49    * Range is [0,7].  The mapping to bipolar levels is not done.
50    */
51   int encode (unsigned int input);
52
53   //! reset encoder state
54   void reset () { state = 0; }
55
56   static const unsigned char next_state[32];
57   static const unsigned char out_symbol[32];
58 };
59
60 #endif /* _ATSC_BASIC_TRELLIS_ENCODER_H_ */