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.
23 #ifndef INCLUDED_ENCODER_H
24 #define INCLUDED_ENCODER_H
26 #include "code_types.h"
28 // the 'encoder' class is a virtual class upon which all encoder types
35 virtual ~encoder () {};
37 virtual size_t compute_n_input_bits (size_t n_output_bits) = 0;
38 virtual size_t compute_n_output_bits (size_t n_input_bits) = 0;
39 virtual size_t encode (const char** in_buf,
41 size_t n_bits_to_output);
42 virtual size_t encode (const char** in_buf,
43 size_t n_bits_to_input,
46 /* for remote access to internal info */
48 inline size_t block_size_bits () {return (d_block_size_bits);};
49 inline size_t n_code_inputs () {return (d_n_code_inputs);};
50 inline size_t n_code_outputs () {return (d_n_code_outputs);};
53 /* encode_private: encode the given in_buf and write the output bits
54 * to the out_buf, using internal class variables. This function is
55 * called from the publically available "encode()" methods, which
56 * first set the internal class variables before executing.
59 virtual void encode_private (const char** in_buf, char** out_buf) = 0;
61 /* inheriting methods need to figure out what makes the most sense
62 * for them in terms of getting new inputs and writing outputs.
65 size_t d_block_size_bits, d_n_code_inputs, d_n_code_outputs;
66 size_t d_n_enc_bits, d_total_n_enc_bits;
67 size_t d_in_buf_ndx, d_out_buf_ndx;
68 size_t d_in_bit_shift, d_out_bit_shift;
69 size_t d_n_input_bits_left, d_n_output_bits_left;
72 #endif /* INCLUDED_ENCODER_H */