GNU Radio's DVBS2RX Package
pl_descrambler.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_PL_DESCRAMBLER_H
11#define INCLUDED_DVBS2RX_PL_DESCRAMBLER_H
12
13#include "pl_defs.h"
15#include <gnuradio/gr_complex.h>
16#include <volk/volk_alloc.hh>
17
18namespace gr {
19namespace dvbs2rx {
20
21/**
22 * \brief PL Descrambler
23 *
24 * Multiplies the scrambled payload of a PLFRAME by the conjugate of the complex
25 * randomization sequence used on the Tx side for PL scrambling. This multiplication
26 * effectively undoes the scrambling, and the resulting descrambled payload is stored
27 * internally for later access through the `get_payload()` method. This processes depends
28 * only on the Gold code defining the complex scrambling sequence, which must be provided
29 * to the constructor.
30 */
32{
33private:
34 const int d_gold_code; /**< Gold code (scrambling code) */
35 volk::vector<gr_complex> d_descrambling_seq; /**< Complex descrambling sequence */
36 volk::vector<gr_complex> d_payload_buf; /**< Descrambled payload buffer */
37 int parity_chk(long a, long b) const;
38
39 /**
40 * \brief Pre-compute the complex descrambling sequence
41 */
42 void compute_descrambling_sequence();
43
44public:
45 pl_descrambler(int gold_code);
47
48 /**
49 * \brief Descramble a PLFRAME payload.
50 *
51 * Descrambles a given PLFRAME payload and stores the descrambled result on
52 * the internal descrambled payload buffer, which can be accessed through
53 * method `get_payload()`.
54 *
55 * \param in (const gr_complex*) Pointer to the target scrambled PLFRAME payload
56 * buffer.
57 * \param payload_len (uint16_t) Payload length.
58 * \note The payload length must be equal to the PLFRAME length minus 90
59 * (the PLHEADER length). This means that pilots are part of the payload,
60 * since the pilot symbols must be descrambled.
61 */
62 void descramble(const gr_complex* in, uint16_t payload_len);
63
64 /**
65 * \brief Get the descrambled payload.
66 * \return Pointer to the descrambled payload buffer.
67 */
68 const gr_complex* get_payload() { return d_payload_buf.data(); }
69};
70
71} // namespace dvbs2rx
72} // namespace gr
73
74#endif /* INCLUDED_DVBS2RX_PL_DESCRAMBLER_H */
PL Descrambler.
Definition pl_descrambler.h:32
const gr_complex * get_payload()
Get the descrambled payload.
Definition pl_descrambler.h:68
~pl_descrambler()
Definition pl_descrambler.h:46
pl_descrambler(int gold_code)
void descramble(const gr_complex *in, uint16_t payload_len)
Descramble a PLFRAME payload.
#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