GNSS-SDR 0.0.21
An Open Source GNSS Software Defined Receiver
Loading...
Searching...
No Matches
unpack_2bit_samples.h
Go to the documentation of this file.
1/*!
2 * \file unpack_2bit_samples.h
3 *
4 * \brief Unpacks 2 bit samples
5 * samples may be packed in any of the following ways:
6 * 1) Into bytes [ item == byte ]
7 * 1a) Big endian ordering within the byte
8 * 1b) Little endian ordering within the byte
9 * 2) Into shorts [ item == short ]
10 * 2a) Big endian ordering of bytes, big endian within the byte
11 * 2b) Big endian ordering of bytes, little endian within the byte
12 * 2c) Little endian ordering of bytes, big endian within the byte
13 * 2d) Little endian ordering of bytes, little endian within the byte
14 *
15 * Within a byte the two possibilities look like this:
16 * 7 6 5 4 3 2 1 0 : Bit number
17 * x_n,1 x_n,0 x_n+1,1 x_n+1,0 x_n+2,1 x_n+2,0 x_n+3,1 x_n+3,0 : Little endian
18 * x_n+3,1 x_n+3,0 x_n+2,1 x_n+2,0 x_n+1,0 x_n+1,0 x_n,1 x_n, 0 : Big Endian
19 *
20 * For a short (uint16_t) the bytes are either transmitted as follows:
21 *
22 * 1 0 : Byte number
23 * Byte_n Byte_n+1 : Little endian
24 * Byte_n+1 Byte_n : Bit endian
25 *
26 * The two bit values are assumed to have the following mapping:
27 *
28 * x_1 x_0 Value
29 * 0 0 +1
30 * 0 1 +3
31 * 1 0 -3
32 * 1 1 -1
33 *
34 * Letting x denote the two's complement interpretation of x_1 x_0, then:
35 *
36 * Value = 2*x + 1
37 *
38 * We want to output the data in the order:
39 *
40 * Value_0, Value_1, Value_2, ..., Value_n, Value_n+1, Value_n+2, ...
41 *
42 * \author Cillian O'Driscoll cillian.odriscoll (at) gmail . com
43 *
44 * -----------------------------------------------------------------------------
45 *
46 * GNSS-SDR is a Global Navigation Satellite System software-defined receiver.
47 * This file is part of GNSS-SDR.
48 *
49 * Copyright (C) 2010-2020 (see AUTHORS file for a list of contributors)
50 * SPDX-License-Identifier: GPL-3.0-or-later
51 *
52 * -----------------------------------------------------------------------------
53 */
54
55#ifndef GNSS_SDR_UNPACK_2BIT_SAMPLES_H
56#define GNSS_SDR_UNPACK_2BIT_SAMPLES_H
57
59#include <gnuradio/sync_interpolator.h>
60#include <cstdint>
61#include <vector>
62
63/** \addtogroup Signal_Source
64 * \{ */
65/** \addtogroup Signal_Source_gnuradio_blocks
66 * \{ */
67
68
70
71using unpack_2bit_samples_sptr = gnss_shared_ptr<unpack_2bit_samples>;
72
73unpack_2bit_samples_sptr make_unpack_2bit_samples(
74 bool big_endian_bytes,
75 size_t item_size,
76 bool big_endian_items,
77 bool reverse_interleaving = false);
78
79/*!
80 * \brief This class takes 2 bit samples that have been packed into bytes or
81 * shorts as input and generates a byte for each sample. It generates eight
82 * times as much data as is input (every two bits become 16 bits)
83 */
84class unpack_2bit_samples : public gr::sync_interpolator
85{
86public:
87 ~unpack_2bit_samples() = default;
88
89 unpack_2bit_samples(bool big_endian_bytes,
90 size_t item_size,
91 bool big_endian_items,
92 bool reverse_interleaving);
93
94 int work(int noutput_items,
95 gr_vector_const_void_star &input_items,
96 gr_vector_void_star &output_items);
97
98private:
99 friend unpack_2bit_samples_sptr make_unpack_2bit_samples_sptr(
100 bool big_endian_bytes,
101 size_t item_size,
102 bool big_endian_items,
103 bool reverse_interleaving);
104
105 std::vector<int8_t> work_buffer_;
106 size_t item_size_;
107 bool big_endian_bytes_;
108 bool big_endian_items_;
109 bool swap_endian_items_;
110 bool swap_endian_bytes_;
111 bool reverse_interleaving_;
112};
113
114
115/** \} */
116/** \} */
117#endif // GNSS_SDR_UNPACK_2BIT_SAMPLES_H
This class takes 2 bit samples that have been packed into bytes or shorts as input and generates a by...
This interface represents a GNSS block.