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.
27 #include <ecc_streams_encode_convolutional.h>
28 #include <gr_io_signature.h>
32 ecc_streams_encode_convolutional_sptr
33 ecc_make_streams_encode_convolutional
37 const std::vector<int> &code_generator,
39 int start_memory_state,
42 return ecc_streams_encode_convolutional_sptr
43 (new ecc_streams_encode_convolutional (frame_size_bits,
52 ecc_streams_encode_convolutional_sptr
53 ecc_make_streams_encode_convolutional_feedback
57 const std::vector<int> &code_generator,
58 const std::vector<int> &code_feedback,
60 int start_memory_state,
63 return ecc_streams_encode_convolutional_sptr
64 (new ecc_streams_encode_convolutional (frame_size_bits,
74 ecc_streams_encode_convolutional::ecc_streams_encode_convolutional
78 const std::vector<int> &code_generators,
80 int start_memory_state,
82 : gr_block ("streams_encode_convolutional",
83 gr_make_io_signature (0, 0, 0),
84 gr_make_io_signature (0, 0, 0))
86 // error checking is done by the encoder class itself;
87 // just pass items on here.
89 d_encoder = new encoder_convolutional (frame_size_bits,
97 setup_io_signatures (n_code_inputs, n_code_outputs);
100 ecc_streams_encode_convolutional::ecc_streams_encode_convolutional
101 (int frame_size_bits,
104 const std::vector<int> &code_generators,
105 const std::vector<int> &code_feedback,
107 int start_memory_state,
108 int end_memory_state)
109 : gr_block ("streams_encode_convolutional_feedback",
110 gr_make_io_signature (0, 0, 0),
111 gr_make_io_signature (0, 0, 0))
113 // error checking is done by the encoder class itself;
114 // just pass items on here.
116 d_encoder = new encoder_convolutional (frame_size_bits,
125 setup_io_signatures (n_code_inputs, n_code_outputs);
129 ecc_streams_encode_convolutional::setup_io_signatures
133 // create the correct input signature; 1 bit per input char
135 d_in_buf = new code_input_ic1l (n_code_inputs);
136 set_input_signature (gr_make_io_signature (n_code_inputs,
140 // create the correct output signature; 1 bit per output char
142 d_out_buf = new code_output_ic1l (n_code_outputs);
143 set_output_signature (gr_make_io_signature (n_code_outputs,
148 ecc_streams_encode_convolutional::~ecc_streams_encode_convolutional
160 * Compute the number of input items needed to produce 'n_output'
161 * bits. Handled internally by the encoder.
164 void ecc_streams_encode_convolutional::forecast
166 gr_vector_int &ninput_items_required)
168 int ninput_items = d_encoder->compute_n_input_bits (noutput_items);
169 size_t ninputs = ninput_items_required.size();
170 for (size_t n = 0; n < ninputs; n++)
171 ninput_items_required[n] = ninput_items;
175 ecc_streams_encode_convolutional::general_work
177 gr_vector_int &ninput_items,
178 gr_vector_const_void_star &input_items,
179 gr_vector_void_star &output_items)
181 // compute the actual number of output items (1 bit char's) created.
183 size_t t_n_input_items = d_encoder->compute_n_input_bits (noutput_items);
185 size_t t_n_output_items = d_encoder->compute_n_output_bits (t_n_input_items);
186 assert (t_n_output_items == ((size_t)noutput_items));
188 // setup the i/o buffers
190 d_in_buf->set_buffer ((void**)(&input_items[0]), t_n_input_items);
191 d_out_buf->set_buffer ((void**)(&output_items[0]), noutput_items);
193 // "work" is handled by the encoder; which returns the actual number
194 // of input items (1-bit char's) used.
196 t_n_input_items = d_encoder->encode (d_in_buf, d_out_buf,
197 (size_t) noutput_items);
201 // consume the number of used input items on all input streams
203 consume_each (t_n_input_items);
205 // returns number of items written to each output stream
207 return (noutput_items);