3 * Copyright 2006 Free Software Foundation, Inc.
5 * This file is part of GNU Radio
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)
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.
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.
23 #ifndef INCLUDED_ECC_STREAMS_ENCODE_CONVOLUTIONAL_H
24 #define INCLUDED_ECC_STREAMS_ENCODE_CONVOLUTIONAL_H
27 #include <libecc/encoder_convolutional.h>
30 * \brief Encode the incoming streams using a convolutional encoder
32 * input: streams of char, one stream per input as defined by the
33 * instantiated code, using only the right-most justified bit as
34 * the single input bit per input item.
36 * output: streams of char, one stream per output as defined by the
37 * instantiated code, using only the right-most justified bit as
38 * the single output bit per output item.
40 * frame_size_bits: if == 0, then do streaming encoding ("infinite"
41 * trellis); otherwise this is the frame size in bits to encode
42 * before terminating the trellis. This value -does not- include
43 * any termination bits.
47 * code_generator: vector of integers (32 bit) representing the code
48 * to be implemented. E.g. "4" in binary is "100", which would be
49 * "D^2" for code generation. "6" == 110b == "D^2 + D"
50 * ==> The vector is listed in order for each output stream, so if there
51 * are 2 input streams (I1, I2) [specified in "n_code_inputs"]
52 * and 2 output streams (O1, O2) [specified in "n_code_outputs"],
53 * then the vector would be the code generator for:
54 * [I1->O1, I2->O1, I1->O2, I2->O2]
55 * with each element being an integer representation of the code.
57 * do_termination: valid only if frame_size_bits != 0, and defines
58 * whether or not to use trellis termination. Default is to use
59 * termination when doing block coding.
61 * start_memory_state: when starting a new block, the starting memory
62 * state to begin encoding; there will be a helper function to
63 * assist in creating this value for a given set of inputs;
64 * default is the "all zero" state.
66 * end_memory_state: when terminating a block, the ending memory
67 * state to stop encoding; there will be a helper function to
68 * assist in creating this value for a given set of inputs;
69 * default is the "all zero" state.
72 class ecc_streams_encode_convolutional;
73 typedef boost::shared_ptr<ecc_streams_encode_convolutional>
74 ecc_streams_encode_convolutional_sptr;
76 ecc_streams_encode_convolutional_sptr
77 ecc_make_streams_encode_convolutional
81 const std::vector<int> &code_generator,
82 bool do_termination = true,
83 int start_memory_state = 0,
84 int end_memory_state = 0);
86 ecc_streams_encode_convolutional_sptr
87 ecc_make_streams_encode_convolutional_feedback
91 const std::vector<int> &code_generator,
92 const std::vector<int> &code_feedback,
93 bool do_termination = true,
94 int start_memory_state = 0,
95 int end_memory_state = 0);
97 class ecc_streams_encode_convolutional : public gr_block
100 friend ecc_streams_encode_convolutional_sptr
101 ecc_make_streams_encode_convolutional
102 (int frame_size_bits,
105 const std::vector<int> &code_generator,
107 int start_memory_state,
108 int end_memory_state);
110 friend ecc_streams_encode_convolutional_sptr
111 ecc_make_streams_encode_convolutional_feedback
112 (int frame_size_bits,
115 const std::vector<int> &code_generator,
116 const std::vector<int> &code_feedback,
118 int start_memory_state,
119 int end_memory_state);
121 ecc_streams_encode_convolutional (int frame_size_bits,
124 const std::vector<int> &code_generator,
126 int start_memory_state,
127 int end_memory_state);
129 ecc_streams_encode_convolutional (int frame_size_bits,
132 const std::vector<int> &code_generator,
133 const std::vector<int> &code_feedback,
135 int start_memory_state,
136 int end_memory_state);
138 void setup_io_signatures (int n_code_inputs, int n_code_outputs);
140 encoder_convolutional* d_encoder;
141 code_input_ptr d_in_buf;
142 code_output_ptr d_out_buf;
145 ~ecc_streams_encode_convolutional ();
147 inline encoder_convolutional* encoder () {return (d_encoder);};
149 virtual void forecast (int noutput_items,
150 gr_vector_int &ninput_items_required);
152 virtual int general_work (int noutput_items,
153 gr_vector_int &ninput_items,
154 gr_vector_const_void_star &input_items,
155 gr_vector_void_star &output_items);
158 #endif /* INCLUDED_ECC_STREAMS_ENCODE_CONVOLUTIONAL_H */