Merge commit 'v3.3.0' into upstream
[debian/gnuradio] / gr-atsc / src / lib / atsci_viterbi_decoder.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
23 #ifndef _ATSC_VITERBI_DECODER_H_
24 #define _ATSC_VITERBI_DECODER_H_
25
26 #define USE_SIMPLE_SLICER  0
27
28 #include <atsc_types.h>
29 #include <interleaver_fifo.h>
30
31 #if (USE_SIMPLE_SLICER)
32 #include <atsci_fake_single_viterbi.h>
33 typedef atsci_fake_single_viterbi       single_viterbi_t;
34 #else
35 #include <atsci_single_viterbi.h>
36 typedef atsci_single_viterbi            single_viterbi_t;
37 #endif
38
39 /*!
40  * \brief fancy, schmancy 12-way interleaved viterbi decoder for ATSC
41  */
42
43 class atsci_viterbi_decoder {
44 public:
45   static const int      NCODERS = 12;
46
47   atsci_viterbi_decoder ();
48   ~atsci_viterbi_decoder ();
49
50   //! reset all decoder states
51   void reset ();
52
53   /*!
54    * Take 12 data segments of soft decisions (floats) and
55    * produce 12 RS encoded data segments.  We work in groups of 12
56    * because that's the smallest number of segments that composes a
57    * single full cycle of the decoder mux.
58    */
59   void decode (atsc_mpeg_packet_rs_encoded out[NCODERS],
60                const atsc_soft_data_segment in[NCODERS]);
61
62
63   
64  protected:
65   typedef interleaver_fifo<unsigned char>       fifo_t;
66
67   static const int SEGMENT_SIZE = ATSC_MPEG_RS_ENCODED_LENGTH;  // 207
68   static const int OUTPUT_SIZE = (SEGMENT_SIZE * 12);
69   static const int INPUT_SIZE = (ATSC_DATA_SEGMENT_LENGTH * 12);
70   
71   void decode_helper (unsigned char out[OUTPUT_SIZE],
72                       const float in[INPUT_SIZE]);
73
74   
75   single_viterbi_t      viterbi[NCODERS];
76   fifo_t                *fifo[NCODERS]; 
77   bool                  debug;
78
79 };
80
81
82
83 #endif /* _ATSC_VITERBI_DECODER_H_ */