GNU Radio Manual and C++ API Reference  3.10.9.1
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  * SPDX-License-Identifier: GPL-3.0-or-later
8  *
9  */
10 
11 
12 #ifndef UNPACKED_TO_PACKED_H
13 #define UNPACKED_TO_PACKED_H
14 
15 #include <gnuradio/block.h>
16 #include <gnuradio/blocks/api.h>
17 #include <gnuradio/endianness.h>
18 #include <cstdint>
19 
20 namespace gr {
21 namespace blocks {
22 
23 /*!
24  * \brief Convert a stream of unpacked bytes or shorts into a stream of packed bytes or
25  * shorts. \ingroup byte_operators_blk
26  *
27  * \details
28  * input: stream of T; output: stream of T
29  *
30  * This is the inverse of gr::blocks::packed_to_unpacked_XX.
31  *
32  * The low \p bits_per_chunk bits are extracted from each input
33  * byte or short. These bits are then packed densely into the
34  * output bytes or shorts, such that all 8 or 16 bits of the
35  * output bytes or shorts are filled with valid input bits. The
36  * right thing is done if bits_per_chunk is not a power of two.
37  *
38  * The combination of gr::blocks::packed_to_unpacked_XX followed by
39  * gr_chunks_to_symbols_Xf or gr_chunks_to_symbols_Xc handles the
40  * general case of mapping from a stream of bytes or shorts into
41  * arbitrary float or complex symbols.
42  *
43  * \sa gr::blocks::packed_to_unpacked_bb, gr::blocks::unpacked_to_packed_bb,
44  * \sa gr::blocks::packed_to_unpacked_ss, gr::blocks::unpacked_to_packed_ss,
45  * \sa gr::blocks::chunks_to_symbols_bf, gr::blocks::chunks_to_symbols_bc.
46  * \sa gr::blocks::chunks_to_symbols_sf, gr::blocks::chunks_to_symbols_sc.
47  */
48 template <class T>
49 class BLOCKS_API unpacked_to_packed : virtual public block
50 {
51 public:
52  // gr::blocks::unpacked_to_packed::sptr
53  typedef std::shared_ptr<unpacked_to_packed<T>> sptr;
54 
55  static sptr make(unsigned int bits_per_chunk, endianness_t endianness);
56 };
57 
61 } /* namespace blocks */
62 } /* namespace gr */
63 
64 #endif /* UNPACKED_TO_PACKED_H */
The abstract base class for all 'terminal' processing blocks.
Definition: gnuradio-runtime/include/gnuradio/block.h:63
Convert a stream of unpacked bytes or shorts into a stream of packed bytes or shorts.
Definition: unpacked_to_packed.h:50
std::shared_ptr< unpacked_to_packed< T > > sptr
Definition: unpacked_to_packed.h:53
static sptr make(unsigned int bits_per_chunk, endianness_t endianness)
#define BLOCKS_API
Definition: gr-blocks/include/gnuradio/blocks/api.h:18
unpacked_to_packed< std::uint8_t > unpacked_to_packed_bb
Definition: unpacked_to_packed.h:58
unpacked_to_packed< std::int32_t > unpacked_to_packed_ii
Definition: unpacked_to_packed.h:60
unpacked_to_packed< std::int16_t > unpacked_to_packed_ss
Definition: unpacked_to_packed.h:59
GNU Radio logging wrapper.
Definition: basic_block.h:29
endianness_t
Definition: endianness.h:16