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