Updated FSF address in all files. Fixes ticket:51
[debian/gnuradio] / gr-error-correcting-codes / src / lib / ecc_metrics_decode_viterbi_full_block.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_ECC_METRICS_DECODE_VITERBI_FULL_BLOCK_H
24 #define INCLUDED_ECC_METRICS_DECODE_VITERBI_FULL_BLOCK_H
25
26 #include <gr_block.h>
27 #include <libecc/decoder_viterbi_full_block.h>
28 #include <libecc/encoder_convolutional.h>
29
30 class ecc_metrics_decode_viterbi_full_block;
31
32 typedef boost::shared_ptr<ecc_metrics_decode_viterbi_full_block>
33 ecc_metrics_decode_viterbi_full_block_sptr,
34 ecc_metrics_decode_viterbi_full_block_feedback_sptr;
35
36 ecc_metrics_decode_viterbi_full_block_sptr
37 ecc_make_metrics_decode_viterbi_full_block
38 (int sample_precision,
39  int frame_size_bits,
40  int n_code_inputs,
41  int n_code_outputs,
42  const std::vector<int>& code_generator,
43  bool do_termination = true,
44  int start_memory_state = 0,
45  int end_memory_state = 0);
46
47 ecc_metrics_decode_viterbi_full_block_feedback_sptr
48 ecc_make_metrics_decode_viterbi_full_block_feedback
49 (int sample_precision,
50  int frame_size_bits,
51  int n_code_inputs,
52  int n_code_outputs,
53  const std::vector<int>& code_generator,
54  const std::vector<int>& code_feedback,
55  bool do_termination = true,
56  int start_memory_state = 0,
57  int end_memory_state = 0);
58
59 /*!
60  * \brief Decode the incoming streams using a Viterbi-style decoder,
61  *     full trellis block decoding.
62  *
63  * input: symbol metrics data.
64  *
65  * output: stream(s) of char, single bit stored in the LSB.
66  */
67
68 class ecc_metrics_decode_viterbi_full_block : public gr_block
69 {
70 protected:
71   friend ecc_metrics_decode_viterbi_full_block_sptr
72   ecc_make_metrics_decode_viterbi_full_block
73   (int sample_precision,
74    int frame_size_bits,
75    int n_code_inputs,
76    int n_code_outputs,
77    const std::vector<int>& code_generator,
78    bool do_termination,
79    int start_memory_state,
80    int end_memory_state);
81
82   friend ecc_metrics_decode_viterbi_full_block_feedback_sptr
83   ecc_make_metrics_decode_viterbi_full_block_feedback
84   (int sample_precision,
85    int frame_size_bits,
86    int n_code_inputs,
87    int n_code_outputs,
88    const std::vector<int>& code_generator,
89    const std::vector<int>& code_feedback,
90    bool do_termination,
91    int start_memory_state,
92    int end_memory_state);
93 /*
94  * frame_size_bits: if == 0, then do streaming decoding (infinite
95  *     trellis); otherwise this is the block size to decode before
96  *     terminating the trellis.
97  *
98  * code_generator: vector of integers (32 bit) representing the code
99  *     to be implemented in octal form.  E.g. "04" in binary is "100",
100  *     which would be "D^2" for code generation.  "06" == 110b == "D^2 + D"
101  *  ==> The vector is listed in order for each input stream, so if there
102  *     are 2 input streams (I1, I2) [specified in "n_code_inputs"]
103  *     and 2 output streams (O1, O2) [specified in "n_code_outputs"],
104  *     then the vector would be the code generator for:
105  *       [I1->O1, I1->O2, I2->O1, I2->O2]
106  *     with each element being the octal representation of the code.
107  *
108  * do_termination is valid only if frame_size_bits != 0, and defines
109  *     whether or not to to trellis termination.
110  *
111  * do_mux_input: is true, then the one input stream will be
112  *     interpreted as the multiplexing all of the input bits.  For
113  *     example for a 3 input decoder, the input stream would be
114  *     [I1[k], I2[k], I3[k], I1[k+1], I2[k+1], ...], where "k" is the
115  *     input sample time, and "I1" through "I3" are the 3 input
116  *     streams.
117  *
118  * n_code_inputs: the number of decoder-input (encoder-output)
119  *     streams, no matter if separate or mux'ed
120  *
121  * n_code_outputs: the number of decoder-output (encoder-input) streams
122  */
123
124   ecc_metrics_decode_viterbi_full_block
125   (int sample_precision,
126    int frame_size_bits,
127    int n_code_inputs,
128    int n_code_outputs,
129    const std::vector<int>& code_generator,
130    bool do_termination,
131    int start_memory_state,
132    int end_memory_state);
133
134   ecc_metrics_decode_viterbi_full_block
135   (int sample_precision,
136    int frame_size_bits,
137    int n_code_inputs,
138    int n_code_outputs,
139    const std::vector<int>& code_generator,
140    const std::vector<int>& code_feedback,
141    bool do_termination,
142    int start_memory_state,
143    int end_memory_state);
144
145   void setup_io_signatures (int sample_precision,
146                             int n_code_inputs,
147                             int n_code_outputs);
148
149   int d_n_code_inputs, d_n_code_outputs;
150   decoder_viterbi_full_block* d_decoder;
151   encoder_convolutional* d_encoder;
152   code_input_ptr d_in_buf;
153   code_output_ptr d_out_buf;
154
155 public:
156   ~ecc_metrics_decode_viterbi_full_block ();
157
158   virtual void forecast (int noutput_items,
159                          gr_vector_int& ninput_items_required);
160
161   virtual int general_work (int noutput_items,
162                             gr_vector_int& ninput_items,
163                             gr_vector_const_void_star& input_items,
164                             gr_vector_void_star& output_items);
165 };
166
167 #endif /* INCLUDED_ECC_METRICS_DECODE_VITERBI_FULL_BLOCK_H */