1 /* -*- c++ -*- */
2 /*
3  * Copyright 2012 Free Software Foundation, Inc.
4  *
5  * This file is part of GNU Radio
6  *
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 3, or (at your option)
10  * any later version.
11  *
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.
16  *
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.
21  */
22 
23 #ifndef INCLUDED_BLOCKS_REPACK_BITS_BB_IMPL_H
24 #define INCLUDED_BLOCKS_REPACK_BITS_BB_IMPL_H
25 
26 #include <gnuradio/blocks/repack_bits_bb.h>
27 
28 namespace gr {
29 namespace blocks {
30 
31 class repack_bits_bb_impl : public repack_bits_bb
32 {
33 private:
34     int d_k; //! Bits on input stream
35     int d_l; //! Bits on output stream
36     const bool d_packet_mode;
37     int d_in_index;      // Current bit of input byte
38     int d_out_index;     // Current bit of output byte
39     bool d_align_output; //! true if the output shall be aligned, false if the input shall
40                          //! be aligned
41     endianness_t d_endianness;
42 
43 protected:
44     int calculate_output_stream_length(const gr_vector_int& ninput_items);
45 
46 public:
47     repack_bits_bb_impl(int k,
48                         int l,
49                         const std::string& len_tag_key,
50                         bool align_output,
51                         endianness_t endianness = GR_LSB_FIRST);
52     ~repack_bits_bb_impl();
53     void set_k_and_l(
54         int k,
55         int l); // callback function for bits per input byte k and bits per output byte l
56     int work(int noutput_items,
57              gr_vector_int& ninput_items,
58              gr_vector_const_void_star& input_items,
59              gr_vector_void_star& output_items);
60 };
61 
62 } // namespace blocks
63 } // namespace gr
64 
65 #endif /* INCLUDED_BLOCKS_REPACK_BITS_BB_IMPL_H */
66