GNSS-SDR 0.0.21
An Open Source GNSS Software Defined Receiver
Loading...
Searching...
No Matches
unpack_ntlab_2bit_samples.h
Go to the documentation of this file.
1/*!
2 * \file unpack_ntlab_2bit_samples.h
3 *
4 * \brief Unpacks multichannel 2-bit samples into 4 real-valued floats
5 * per input byte.
6 * \author Pedro Pereira pereirapedrocp (at) gmail.com
7 *
8 * -----------------------------------------------------------------------------
9 *
10 * GNSS-SDR is a Global Navigation Satellite System software-defined receiver.
11 * This file is part of GNSS-SDR.
12 *
13 * Copyright (C) 2010-2020 (see AUTHORS file for a list of contributors)
14 * SPDX-License-Identifier: GPL-3.0-or-later
15 *
16 * -----------------------------------------------------------------------------
17 */
18
19#ifndef GNSS_SDR_UNPACK_NTLAB_2BIT_SAMPLES_H
20#define GNSS_SDR_UNPACK_NTLAB_2BIT_SAMPLES_H
21
23#include <gnuradio/sync_interpolator.h>
24#include <cstdint>
25#include <vector>
26
27/** \addtogroup Signal_Source
28 * \{ */
29/** \addtogroup Signal_Source_gnuradio_blocks
30 * \{ */
31
32
34
35using unpack_ntlab_2bit_samples_sptr = gnss_shared_ptr<unpack_ntlab_2bit_samples>;
36
37unpack_ntlab_2bit_samples_sptr make_unpack_ntlab_2bit_samples(
38 size_t item_size,
39 int nchannels = 4);
40
41/*!
42 * \brief This class implements conversion between byte packet multichannel samples
43 * to 2bit samples 1 byte = 4 2bit samples
44 *
45 * Unpack each of the four 2-bit samples in the byte 'b' into four real-valued outputs.
46 *
47 * The NTLAB format encodes samples as sign+magnitude pairs in each byte:
48 * bits 7-6 = [M0 S0] -> sample 0
49 * bits 5-4 = [M1 S1] -> sample 1
50 * bits 3-2 = [M2 S2] -> sample 2
51 * bits 1-0 = [M3 S3] -> sample 3
52 *
53 * M = magnitude bit (1->|sample|=3, 0->|sample|=1)
54 * S = sign bit (1->positive, 0->negative)
55 */
56class unpack_ntlab_2bit_samples : public gr::sync_interpolator
57{
58public:
59 ~unpack_ntlab_2bit_samples() = default;
60
61 unpack_ntlab_2bit_samples(size_t item_size,
62 int nchannels);
63
64 int work(int noutput_items,
65 gr_vector_const_void_star &input_items,
66 gr_vector_void_star &output_items);
67
68private:
69 static constexpr int SAMPLES_PER_BYTE = 4;
70
71 friend unpack_ntlab_2bit_samples_sptr make_unpack_ntlab_2bit_samples_sptr(
72 size_t item_size,
73 int nchannels);
74
75 int nchannels_;
76};
77
78
79/** \} */
80/** \} */
81#endif // GNSS_SDR_UNPACK_NTLAB_2BIT_SAMPLES_H
This class implements conversion between byte packet multichannel samples to 2bit samples 1 byte = 4 ...
This interface represents a GNSS block.