Houston, we have a trunk.
[debian/gnuradio] / gr-error-correcting-codes / src / lib / gr_streams_encode_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., 59 Temple Place - Suite 330,
20  * Boston, MA 02111-1307, USA.
21  */
22
23 #ifndef INCLUDED_GR_STREAMS_ENCODE_TURBO_H
24 #define INCLUDED_GR_STREAMS_ENCODE_TURBO_H
25
26 #include <gr_block.h>
27 #include <gr_streams_encode_convolutional.h>
28
29 #if 0
30 #include <libecc/encoder_turbo_ic1_ic1.h>
31 #else
32 #include <libecc/encoder_turbo.h>
33 #endif
34
35 /*!
36  * \brief Encode the incoming stream(s) using a turbo encoder
37  *
38  * input: streams of char, one stream per input as defined by the
39  *     instantiated code, using only the right-most justified bit as
40  *     the single input bit per input item.
41  *
42  * output: streams of char, one stream per output as defined by the
43  *     instantiated code, using only the right-most justified bit as
44  *     the single output bit per output item.
45  *
46  * n_code_inputs:
47  * n_code_outputs: the total number of code inputs and outputs for the
48  *     overall turbo encoder (not just the constituent codes).
49  *
50  * encoders: the constituent encoders to be used; all -should- be
51  *     configured with the same "block_size" and "termination", though
52  *     from this encoder's perspective it doesn't really matter.
53  *
54  * interleavers: the interleavers to use before each encoder,
55  *     respectively, except the first encoder which will not use an
56  *     interleaver.
57  */
58
59 class gr_streams_encode_turbo;
60
61 typedef boost::shared_ptr<gr_streams_encode_turbo>
62 gr_streams_encode_turbo_sptr;
63
64 gr_streams_encode_turbo_sptr
65 gr_make_streams_encode_turbo
66 (int n_code_inputs,
67  int n_code_outputs,
68  const std::vector<gr_streams_encode_convolutional_sptr> &encoders,
69  const std::vector<size_t> &interleavers);
70
71 class gr_streams_encode_turbo : public gr_block
72 {
73   friend gr_streams_encode_turbo_sptr
74   gr_make_streams_encode_turbo
75     (int n_code_inputs,
76      int n_code_outputs,
77      const std::vector<gr_streams_encode_convolutional_sptr> &d_encoders,
78      const std::vector<size_t> &d_interleavers);
79
80   gr_streams_encode_turbo
81     (int n_code_inputs,
82      int n_code_outputs,
83      const std::vector<gr_streams_encode_convolutional_sptr> &d_encoders,
84      const std::vector<size_t> &d_interleavers);
85
86   std::vector<gr_streams_encode_turbo_sptr> d_encoders;
87   std::vector<size_t> d_interleavers;
88   size_t d_n_encoders, d_block_size_bits;
89   bool d_do_termination;
90   encoder_turbo* d_encoder;
91
92 public:
93   ~gr_streams_encode_turbo ();
94
95   virtual void forecast (int noutput_items,
96                          gr_vector_int &ninput_items_required);
97
98   virtual int general_work (int noutput_items,
99                             gr_vector_int &ninput_items,
100                             gr_vector_const_void_star &input_items,
101                             gr_vector_void_star &output_items);
102 };
103
104 #endif /* INCLUDED_GR_STREAMS_ENCODE_TURBO_H */