GNU Radio C++ API Reference  gcd20ee2
The Free & Open Software Radio Ecosystem
unpack_k_bits.h
Go to the documentation of this file.
1 /* -*- c++ -*- */
2 /*
3  * Copyright 2014 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 #ifndef INCLUDED_GR_BLOCKS_UNPACK_K_BITS_H
12 #define INCLUDED_GR_BLOCKS_UNPACK_K_BITS_H
13 
14 #include <gnuradio/blocks/api.h>
15 
16 namespace gr {
17 namespace blocks {
18 namespace kernel {
19 
20 /*!
21  * \brief Converts a byte with k relevant bits to k output bytes with 1 bit in the LSB.
22  *
23  * This is the algorithm kernel for the gr::blocks::unpack_k_bits_bb block.
24  *
25  * Example:
26  * k = 4
27  * in = [0xf5, 0x08]
28  * out = [0,1,0,1, 1,0,0,0]
29  *
30  * k = 8
31  * in = [0xf5, 0x08]
32  * out = [1,1,1,1, 0,1,0,1, 0,0,0,0, 1,0,0,0]
33  * \ingroup byte_operators_blk
34  */
36 {
37 public:
38  /*!
39  * \brief Make an unpack_k_bits object.
40  * \param k number of bits to unpack.
41  */
42  unpack_k_bits(unsigned k);
44 
45  /*!
46  * \brief Perform the unpacking.
47  *
48  * This function performs no bounds checking. It assumes that the
49  * input, \p in, has of length \p nbytes and that the output
50  * vector, \p out, has k*nbytes available for writing.
51  *
52  * \param bits output vector (1-bit per byte) of the unpacked data
53  * \param bytes The input vector of bytes to unpack
54  * \param nbytes The number of input bytes
55  */
56  void unpack(unsigned char* bits, const unsigned char* bytes, int nbytes) const;
57 
58  /*!
59  * Unpacks in reverse order from unpack().
60  */
61  void unpack_rev(unsigned char* bits, const unsigned char* bytes, int nbytes) const;
62 
63  int k() const;
64 
65 private:
66  unsigned d_k;
67 };
68 
69 } /* namespace kernel */
70 } /* namespace blocks */
71 } /* namespace gr */
72 
73 #endif /* INCLUDED_GR_BLOCKS_UNPACK_K_BITS_BB_H */
Converts a byte with k relevant bits to k output bytes with 1 bit in the LSB.
Definition: unpack_k_bits.h:36
void unpack_rev(unsigned char *bits, const unsigned char *bytes, int nbytes) const
unpack_k_bits(unsigned k)
Make an unpack_k_bits object.
void unpack(unsigned char *bits, const unsigned char *bytes, int nbytes) const
Perform the unpacking.
#define BLOCKS_API
Definition: gr-blocks/include/gnuradio/blocks/api.h:18
GNU Radio logging wrapper.
Definition: basic_block.h:29