gr-baz Package
baz_unpacked_to_packed_bb.h
Go to the documentation of this file.
1 /* -*- c++ -*- */
2 /*
3  * Copyright 2006,2013 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 /*
24  * gr-baz by Balint Seeber (http://spench.net/contact)
25  * Information, documentation & samples: http://wiki.spench.net/wiki/gr-baz
26  */
27 
28 #ifndef INCLUDED_BAZ_UNPACKED_TO_PACKED_BB_H
29 #define INCLUDED_BAZ_UNPACKED_TO_PACKED_BB_H
30 
31 #include <gnuradio/block.h>
32 #include <gnuradio/endianness.h>
33 
35 typedef boost::shared_ptr<baz_unpacked_to_packed_bb> baz_unpacked_to_packed_bb_sptr;
36 
37 BAZ_API baz_unpacked_to_packed_bb_sptr
38 baz_make_unpacked_to_packed_bb (unsigned int bits_per_chunk, unsigned int bits_into_output, /*gr::endianness_t*/int endianness = gr::GR_MSB_FIRST);
39 
40 /*!
41  * \brief Convert a stream of unpacked bytes or shorts into a stream of packed bytes or shorts.
42  * \ingroup converter_blk
43  *
44  * input: stream of unsigned char; output: stream of unsigned char
45  *
46  * This is the inverse of gr_packed_to_unpacked_XX.
47  *
48  * The low \p bits_per_chunk bits are extracted from each input byte or short.
49  * These bits are then packed densely into the output bytes or shorts, such that
50  * all 8 or 16 bits of the output bytes or shorts are filled with valid input bits.
51  * The right thing is done if bits_per_chunk is not a power of two.
52  *
53  * The combination of gr_packed_to_unpacked_XX followed by
54  * gr_chunks_to_symbols_Xf or gr_chunks_to_symbols_Xc handles the
55  * general case of mapping from a stream of bytes or shorts into arbitrary float
56  * or complex symbols.
57  *
58  * \sa gr_packed_to_unpacked_bb, gr_unpacked_to_packed_bb,
59  * \sa gr_packed_to_unpacked_ss, gr_unpacked_to_packed_ss,
60  * \sa gr_chunks_to_symbols_bf, gr_chunks_to_symbols_bc.
61  * \sa gr_chunks_to_symbols_sf, gr_chunks_to_symbols_sc.
62  */
63 class BAZ_API baz_unpacked_to_packed_bb : public gr::block
64 {
65  friend BAZ_API baz_unpacked_to_packed_bb_sptr
66  baz_make_unpacked_to_packed_bb (unsigned int bits_per_chunk, unsigned int bits_into_output, /*gr::endianness_t*/int endianness);
67 
68  baz_unpacked_to_packed_bb (unsigned int bits_per_chunk, unsigned int bits_into_output, /*gr::endianness_t*/int endianness);
69 
70  unsigned int d_bits_per_chunk, d_bits_into_output;
71  gr::endianness_t d_endianness;
72  unsigned int d_index;
73 
74  public:
75  void forecast(int noutput_items, gr_vector_int &ninput_items_required);
76  int general_work (int noutput_items,
77  gr_vector_int &ninput_items,
78  gr_vector_const_void_star &input_items,
79  gr_vector_void_star &output_items);
80 
81  bool check_topology(int ninputs, int noutputs) { return ninputs == noutputs; }
82 };
83 
84 #endif
Convert a stream of unpacked bytes or shorts into a stream of packed bytes or shorts.input: stream of unsigned char; output: stream of unsigned char.
Definition: baz_unpacked_to_packed_bb.h:63
bool check_topology(int ninputs, int noutputs)
Definition: baz_unpacked_to_packed_bb.h:81
BAZ_API baz_unpacked_to_packed_bb_sptr baz_make_unpacked_to_packed_bb(unsigned int bits_per_chunk, unsigned int bits_into_output, int endianness=gr::GR_MSB_FIRST)
#define BAZ_API
Definition: config.h:8
class BAZ_API baz_unpacked_to_packed_bb
Definition: baz_unpacked_to_packed_bb.h:34