GNU Radio Manual and C++ API Reference  3.8.1.0
The Free & Open Software Radio Ecosystem
unpacked_to_packed.h
Go to the documentation of this file.
1 /* -*- c++ -*- */
2 /*
3  * Copyright 2006,2013,2018 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 #ifndef UNPACKED_TO_PACKED_H
25 #define UNPACKED_TO_PACKED_H
26 
27 #include <gnuradio/block.h>
28 #include <gnuradio/blocks/api.h>
29 #include <gnuradio/endianness.h>
30 #include <cstdint>
31 
32 namespace gr {
33 namespace blocks {
34 
35 /*!
36  * \brief Convert a stream of unpacked bytes or shorts into a stream of packed bytes or
37  * shorts. \ingroup byte_operators_blk
38  *
39  * \details
40  * input: stream of T; output: stream of T
41  *
42  * This is the inverse of gr::blocks::packed_to_unpacked_XX.
43  *
44  * The low \p bits_per_chunk bits are extracted from each input
45  * byte or short. These bits are then packed densely into the
46  * output bytes or shorts, such that all 8 or 16 bits of the
47  * output bytes or shorts are filled with valid input bits. The
48  * right thing is done if bits_per_chunk is not a power of two.
49  *
50  * The combination of gr::blocks::packed_to_unpacked_XX followed by
51  * gr_chunks_to_symbols_Xf or gr_chunks_to_symbols_Xc handles the
52  * general case of mapping from a stream of bytes or shorts into
53  * arbitrary float or complex symbols.
54  *
55  * \sa gr::blocks::packed_to_unpacked_bb, gr::blocks::unpacked_to_packed_bb,
56  * \sa gr::blocks::packed_to_unpacked_ss, gr::blocks::unpacked_to_packed_ss,
57  * \sa gr::blocks::chunks_to_symbols_bf, gr::blocks::chunks_to_symbols_bc.
58  * \sa gr::blocks::chunks_to_symbols_sf, gr::blocks::chunks_to_symbols_sc.
59  */
60 template <class T>
61 class BLOCKS_API unpacked_to_packed : virtual public block
62 {
63 public:
64  // gr::blocks::unpacked_to_packed::sptr
65  typedef boost::shared_ptr<unpacked_to_packed<T>> sptr;
66 
67  static sptr make(unsigned int bits_per_chunk, endianness_t endianness);
68 };
69 
73 } /* namespace blocks */
74 } /* namespace gr */
75 
76 #endif /* UNPACKED_TO_PACKED_H */
boost::shared_ptr< unpacked_to_packed< T > > sptr
Definition: unpacked_to_packed.h:65
endianness_t
Definition: endianness.h:28
unpacked_to_packed< std::int16_t > unpacked_to_packed_ss
Definition: unpacked_to_packed.h:71
unpacked_to_packed< std::uint8_t > unpacked_to_packed_bb
Definition: unpacked_to_packed.h:70
Convert a stream of unpacked bytes or shorts into a stream of packed bytes or shorts.
Definition: unpacked_to_packed.h:61
GNU Radio logging wrapper for log4cpp library (C++ port of log4j)
Definition: basic_block.h:43
#define BLOCKS_API
Definition: gr-blocks/include/gnuradio/blocks/api.h:30
unpacked_to_packed< std::int32_t > unpacked_to_packed_ii
Definition: unpacked_to_packed.h:72
The abstract base class for all &#39;terminal&#39; processing blocks.A signal processing flow is constructed ...
Definition: block.h:71