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., 59 Temple Place - Suite 330,
20 * Boston, MA 02111-1307, USA.
27 #include "decoder_viterbi_full_block_i1_ic1.h"
32 const int g_max_block_size_bits = 10000000;
33 const int g_max_num_streams = 10;
34 const int g_num_bits_per_byte = 8;
36 #define DO_TIME_THOUGHPUT 0
38 #define DO_PRINT_DEBUG_INST 0
39 #define DO_PRINT_DEBUG_FSM 0
40 #define DO_PRINT_DEBUG_INIT 0
41 #define DO_PRINT_DEBUG_UP 0
42 #define DO_PRINT_DEBUG_UP_0 0
43 #define DO_PRINT_DEBUG_UP_1 0
44 #define DO_PRINT_DEBUG_MIDDLE 0
45 #define DO_PRINT_DEBUG_MIDDLE_0 0
46 #define DO_PRINT_DEBUG_MIDDLE_1 0
47 #define DO_PRINT_DEBUG_TERM 0
48 #define DO_PRINT_DEBUG_TERM_1 0
49 #define DO_PRINT_DEBUG_OUTPUT 0
50 #define DO_PRINT_DEBUG_OUTPUT_0 0
51 #define DO_PRINT_DEBUG_EXIT 0
52 #define DO_PRINT_DEBUG 1
55 #include <mld/mld_timer.h>
64 decoder_viterbi_full_block_i1_ic1::compute_n_output_bits
65 (size_t n_input_items)
72 * Compute the number of input items (metrics) needed to produce
73 * 'noutput' bits. For convolutional decoders, there is 1
74 * bit output per metric input per stream, with the addition of a some
75 * metrics for trellis termination if selected. Without termination,
76 * there is exactly 1:1 input to output (1 metric in to 1 bit out),
77 * no matter the encoding type.
79 * if (not terminating), then get the number of output bits.
81 * otherwise, find the number of blocks (not necessarily an integer),
82 * and then compute the number of input metrics (including termination)
83 * required to produce those blocks. Subtract the number of bits
84 * leftover from the previous computation, then find the number of input
85 * metrics, ceil'd to make sure there are enough.
89 decoder_viterbi_full_block_i1_ic1::compute_n_input_metrics
90 (size_t n_output_bits)
92 int t_ninput_items = 0;
93 int t_noutput_bits = ((int) n_output_bits) - ((int) d_n_saved_bits);
95 // if there are enough saved bits, just use those, no inputs required
97 if (t_noutput_bits <= 0)
100 // remove any bits already in the decoding trellis
102 if (d_time_count != 0) {
103 int t_time_bits = ((d_time_count > d_block_size_bits) ? 0 :
104 d_block_size_bits - d_time_count);
105 t_noutput_bits -= t_time_bits;
106 t_ninput_items += t_time_bits;
108 // if completing this trellis doesn't create enough outputs ...
110 if (t_noutput_bits > 0) {
112 // there is a 1:1 ratio between input symbols and output bits (per
113 // stream), except for termination bits which are already taken
114 // into account in the total # of input bits per stream class
115 // variable; need to round the # output bits to the
117 // find the number of blocks, ceil'd to the next higher integer
119 int t_nblocks = (int) ceilf (((float) t_noutput_bits) /
120 ((float) d_block_size_bits));
122 // find the number of required input bits
124 t_ninput_items += t_nblocks * d_n_total_inputs_per_stream;
127 return (t_ninput_items);
130 // FIXME, from here down dummies to get correct compiling; for testing
134 decoder_viterbi_full_block_i1_ic1::increment_input_indices
135 (bool while_decoding)
141 // increment the in_buf index, depending on mux'ing or not
142 t_in_buf_ndx += (d_do_mux_inputs == false) ? 1 : d_n_code_outputs;
147 decoder_viterbi_full_block_i1_ic1::increment_output_indices
148 (bool while_decoding)
155 decoder_viterbi_full_block_i1_ic1::output_bit
158 size_t t_output_stream)