GNU Radio's DVBS2RX Package
pl_signaling.h
Go to the documentation of this file.
1/* -*- c++ -*- */
2/*
3 * Copyright (c) 2021 Igor Freire.
4 *
5 * This file is part of gr-dvbs2rx.
6 *
7 * SPDX-License-Identifier: GPL-3.0-or-later
8 */
9
10#ifndef INCLUDED_DVBS2RX_PLSC_H
11#define INCLUDED_DVBS2RX_PLSC_H
12
13#include "pl_submodule.h"
14#include "reed_muller.h"
16#include <gnuradio/gr_complex.h>
17#include <volk/volk_alloc.hh>
18#include <cstring>
19
20namespace gr {
21namespace dvbs2rx {
22
23/**
24 * \brief PLSC Encoder
25 *
26 * Encodes a 7-bit physical layer signalling (PLS) code into a sequence of 64
27 * pi/2 BPSK symbols. Implements the PLSC scrambling and pi/2 BPSK mapping.
28 */
30{
31private:
32 reed_muller d_reed_muller_encoder;
33
34public:
35 /**
36 * \brief Encode the PLSC info into the corresponding pi/2 BPSK symbols.
37 * \param bpsk_out (gr_complex *) Pointer to output pi/2 BPSK symbols.
38 * \param plsc 7-bit PLSC to be mapped into pi/2 BPSK symbols.
39 */
40 void encode(gr_complex* bpsk_out, const uint8_t plsc);
41
42 /**
43 * \brief Encode the PLSC info into the corresponding pi/2 BPSK symbols.
44 * \param bpsk_out (gr_complex *) Pointer to output pi/2 BPSK symbols.
45 * \param modcod 5-bit modulation and coding scheme.
46 * \param short_fecframe False for normal FECFRAME (64800 bits), true for
47 * short FECFRAME (16200 bits).
48 * \param has_pilots Whether the FECFRAME has pilots.
49 */
50 void encode(gr_complex* bpsk_out,
51 const uint8_t modcod,
52 bool short_fecframe,
53 bool has_pilots);
54};
55
57 uint8_t plsc = 0; /**< Raw PLSC value */
58 uint8_t modcod = 0; /**< MODCOD of the decoded PLSC */
59 bool short_fecframe = false; /**< Whether the FECFRAME size is short */
60 bool has_pilots = false; /**< Whether the PLFRAME has pilot blocks */
61 bool dummy_frame = false; /**< Whether the PLFRAME is a dummy frame */
62 uint8_t n_mod = 0; /**< Bits per constellation symbol */
63 uint16_t n_slots = 0; /**< Number of slots */
64 uint16_t plframe_len = 0; /**< PLFRAME length */
65 uint16_t payload_len = 0; /**< Payload length */
66 uint16_t xfecframe_len = 0; /**< XFECFRAME length */
67 uint8_t n_pilots = 0; /**< Number of pilot blocks */
68 pls_info_t() = default;
69 pls_info_t(uint8_t dec_plsc) { parse(dec_plsc); }
70 void parse(uint8_t dec_plsc);
71 void parse(uint8_t _modcod, bool _short_fecframe, bool _has_pilots);
73 {
74 if (other.plsc != plsc) {
75 memcpy(this, &other, sizeof(pls_info_t));
76 }
77 return *this;
78 }
79};
80
81/**
82 * \brief PLSC Decoder
83 *
84 * Decodes a sequence of 64 noisy pi/2 BPSK symbols into the corresponding 7-bit
85 * PLS code. Implements the pi/2 BPSK demapping, the PLSC descrambling, and the
86 * parsing of the PLSC information.
87 */
89{
90private:
91 reed_muller d_reed_muller_decoder; /**< Reed-Muller decoder */
92 volk::vector<float> d_soft_dec_buf; /**< Soft decisions buffer */
93 pls_info_t d_pls_info; /**< PL signaling information */
94
95public:
96 uint8_t d_plsc; /**< Last decoded PLSC */
97
98 explicit plsc_decoder(int debug_level = 0);
99 explicit plsc_decoder(std::vector<uint8_t>&& expected_pls, int debug_level = 0);
101
102 /**
103 * \brief Decode the incoming pi/2 BPSK symbols of the PLSC.
104 * \param bpsk_in (const gr_complex *) Input pi/2 BPSK symbols, starting
105 * from the last SOF symbol and followed by the PLSC symbols
106 * (see note 1).
107 * \param coherent (bool) Whether to use coherent BPSK demapping (the
108 * default). When set to false, the decoding uses hard
109 * decisions produced through differential demapping of the
110 * pi/2 BPSK symbols, even if soft=true (see note 2).
111 * \param soft (bool) Whether to decode the PLSC dataword using soft pi/2
112 * BPSK decisions instead of hard decisions.
113 *
114 * \note 1 - The last SOF symbol is required when coherent=false. In
115 * contrast, when coherent=true, the implementation simply skips this
116 * symbol. However, note "bpsk_in" must start at the last SOF symbol
117 * regardless.
118 *
119 * \note 2 - The non-coherent (differential) demapping is only supported
120 * with hard decisions because there is negligible performance difference
121 * when differential demapping is used to produce soft decisions. On the
122 * contrary, based on some experiments, it seems that differential demapping
123 * with soft decisions would only be slower, and it would produce a similar
124 * (if not worse) performance than differential demapping with hard
125 * decisions. Ultimately, the supported parameter combinations are:
126 * (coherent=true, soft=false), (coherent=true, soft=true), and
127 * (coherent=false, soft=false). With (coherent=false, soft=true), the
128 * implementation will silently fall back to differential demapping with
129 * hard decisions (coherent=false, soft=false).
130 */
131 void decode(const gr_complex* bpsk_in, bool coherent = true, bool soft = true);
132
133 /**
134 * Read the last decoded PLS information
135 *
136 * \param out (pls_info_t*) Pointer to a pls_info_t structure where the
137 * last decoded information will be written.
138 */
139 void get_info(pls_info_t* out) const { *out = d_pls_info; };
140};
141
142} // namespace dvbs2rx
143} // namespace gr
144
145#endif /* INCLUDED_DVBS2RX_PLSC_H */
Definition pl_submodule.h:25
PLSC Decoder.
Definition pl_signaling.h:89
uint8_t d_plsc
Definition pl_signaling.h:96
~plsc_decoder()
Definition pl_signaling.h:100
plsc_decoder(int debug_level=0)
void decode(const gr_complex *bpsk_in, bool coherent=true, bool soft=true)
Decode the incoming pi/2 BPSK symbols of the PLSC.
plsc_decoder(std::vector< uint8_t > &&expected_pls, int debug_level=0)
void get_info(pls_info_t *out) const
Definition pl_signaling.h:139
PLSC Encoder.
Definition pl_signaling.h:30
void encode(gr_complex *bpsk_out, const uint8_t modcod, bool short_fecframe, bool has_pilots)
Encode the PLSC info into the corresponding pi/2 BPSK symbols.
void encode(gr_complex *bpsk_out, const uint8_t plsc)
Encode the PLSC info into the corresponding pi/2 BPSK symbols.
Interleaved (64, 7, 32) Reed-Muller encoder/decoder.
Definition reed_muller.h:30
#define DVBS2RX_API
Definition include/gnuradio/dvbs2rx/api.h:19
Fixed-length double-ended queue with contiguous volk-aligned elements.
Definition gr_bch.h:22
Definition pl_signaling.h:56
uint8_t plsc
Definition pl_signaling.h:57
pls_info_t & operator=(const pls_info_t &other)
Definition pl_signaling.h:72
pls_info_t(uint8_t dec_plsc)
Definition pl_signaling.h:69