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.
30 #define DO_PRINT_DEBUG 0
33 * encode a certain number of output bits
35 * the 'in_buf' and 'out_buf' must have enough memory to handle the
36 * number of input and output bits; no error checking is done!
38 * n_bits_to_output: the number of bits per output stream to encode
40 * returns the actual number of bits used per input stream
47 size_t n_bits_to_output)
50 std::cout << "encode{out}(): Starting:";
53 // set the class-internal number of input bits and
54 // output bits left to encode
56 size_t saved_n_input_bits;
57 saved_n_input_bits = d_n_input_bits_left =
58 compute_n_input_bits (n_bits_to_output);
59 d_n_output_bits_left = n_bits_to_output;
63 "# output bits provided = " << d_n_output_bits_left << "\n"
64 "# input bits computed = " << d_n_input_bits_left << "\n";
67 // call the private encode function
69 encode_private (in_buf, out_buf);
73 "n_input_bits_used = " <<
74 (saved_n_input_bits - d_n_input_bits_left) << "\n"
75 "n_output_bits_used = " <<
76 (n_bits_to_output - d_n_output_bits_left) << '\n';
79 // return the actual number of input bits used
81 return (saved_n_input_bits - d_n_input_bits_left);
85 * encode a certain number of input bits
87 * the 'in_buf' and 'out_buf' must have enough memory to handle the
88 * number of input and output bits; no error checking is done!
90 * n_bits_to_input: the number of bits per input stream to encode
92 * returns the actual number of bits written per output stream
98 size_t n_bits_to_input,
101 // set the class-internal number of input and
102 // output bits left to encode
104 size_t saved_n_output_bits;
105 saved_n_output_bits = d_n_output_bits_left =
106 compute_n_output_bits (n_bits_to_input);
107 d_n_input_bits_left = n_bits_to_input;
109 // call the private encode function
111 encode_private (in_buf, out_buf);
113 if (DO_PRINT_DEBUG) {
114 std::cout << "n_input_bits_used = " <<
115 (n_bits_to_input - d_n_input_bits_left) << '\n';
116 std::cout << "n_output_bits_used = " <<
117 (saved_n_output_bits - d_n_output_bits_left) << '\n';
120 // return the actual number of output bits written
122 return (saved_n_output_bits - d_n_output_bits_left);