Updated FSF address in all files. Fixes ticket:51
[debian/gnuradio] / gr-error-correcting-codes / src / lib / libecc / encoder_turbo.h
1 /* -*- c++ -*- */
2 /*
3  * Copyright 2006 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 INCLUDED_ENCODER_TURBO_H
24 #define INCLUDED_ENCODER_TURBO_H
25
26 #include "encoder_convolutional.h"
27
28 typedef std::vector<size_t> interleaver_t;
29
30 class encoder_turbo : public encoder
31 {
32 public:
33 /*!
34  * class encoder_turbo : public encoder
35  *
36  * Encode the incoming streams using a turbo encoder; This is a
37  *     virtual class which defines the basics of a turbo encoder, but
38  *     not how input and output bits are handled.  These features are
39  *     all defined by overriding methods appropriately.
40  *
41  * n_code_inputs:
42  * n_code_outputs: the total number of code inputs and outputs for the
43  *     overall turbo encoder (not just the constituent codes).
44  *
45  * encoders: the constituent encoders to be used; all -should- be
46  *     configured with the same "block_size" and "termination", though
47  *     from this encoder's perspective it doesn't really matter.
48  *
49  * interleavers: the interleavers to use before each encoder,
50  *     respectively, except the first encoder which will not use an
51  *     interleaver.
52  */
53
54   encoder_turbo
55   (int n_code_inputs,
56    int n_code_outputs,
57    const std::vector<encoder_convolutional*>& encoders,
58    const std::vector<interleaver_t>& interleavers);
59
60   virtual ~encoder_turbo () {};
61
62 /* for remote access to internal info */
63
64   inline const bool do_termination () {return (d_do_termination);};
65
66 #if 1
67   // dummy functions for now
68   virtual size_t compute_n_input_bits (size_t n_output_bits){return(0);};
69   virtual size_t compute_n_output_bits (size_t n_input_bits){return(0);};
70 #endif
71
72 protected:
73 /*
74  * fsm_enc_turbo_t: finite state machine for the turbo encoder;
75  *     output happens all the time, so that's built-in to each state.
76  *
77  * fsm_enc_turbo_init: initialize for a new frame / block; this is already
78  *     done at instantiation, so do it only at the end of a block.
79  *
80  * fsm_enc_turbo_doing_input: doing encoding inside the trellis
81  *
82  * fsm_enc_turbo_doing_term: termination trellis, if requested
83  */
84
85   enum fsm_enc_turbo_t {
86     fsm_enc_turbo_init, fsm_enc_turbo_doing_input, fsm_enc_turbo_doing_term
87   };
88
89   // methods defined in this class
90 #if 1
91   // temporary just to get full compilation
92
93   virtual void encode_private () {};
94
95 #else
96   virtual void encode_private () = 0;
97   virtual void encode_loop (size_t* which_counter, size_t how_many) = 0;
98   virtual char get_next_bit (const char** in_buf, size_t code_input_n) = 0;
99   virtual char get_next_bit__term (size_t code_input_n) = 0;
100
101   // methods which are required by classes which inherit from this
102   // one; primarily just the parts which deal with getting input bits
103   // and writing output bits, changing the indices for those buffers.
104
105   virtual char get_next_bit__input (const char** in_buf,
106                                     size_t code_input_n) = 0;
107 #endif
108
109   // variables
110
111   fsm_enc_turbo_t d_fsm_state;
112   bool d_do_termination;
113   size_t d_max_memory, d_n_memories;
114
115   std::vector<encoder_convolutional*> d_encoders;
116   std::vector<size_t> d_interleavers;
117 };
118
119 #endif /* INCLUDED_ENCODER_TURBO_H */