GNU Radio's DVBS2RX Package
xfecframe_demapper_cb_impl.h
Go to the documentation of this file.
1/* -*- c++ -*- */
2/*
3 * Copyright 2023 Igor Freire.
4 *
5 * SPDX-License-Identifier: GPL-3.0-or-later
6 */
7
8#ifndef INCLUDED_DVBS2RX_XFECFRAME_DEMAPPER_CB_IMPL_H
9#define INCLUDED_DVBS2RX_XFECFRAME_DEMAPPER_CB_IMPL_H
10
11#include "cpu_features_macros.h"
12#include "psk.hh"
13#include "qpsk.h"
15#include <volk/volk_alloc.hh>
16#include <array>
17
18namespace gr {
19namespace dvbs2rx {
20
21// Store enough XFECFRAMEs in a pool to measure the post-decoder SNR. Assume the LDPC
22// decoder will typically process a single SIMD batch at a time, and that it is unlikely
23// we need to store more than two SIMD batches here. On an x86 machine, which could be
24// running AVX2 with a SIMD batch of 32 frames, store 64 XFECFRAMEs. On an ARM processor,
25// which could have ARM Neon with a batch of 16, store 32 XFECFRAMEs. Note this can use
26// quite a bit of memory. For instance, with n_mod=2 and normal FECFRAMEs, the XFECFRAME
27// has 32400 complex symbols, so a 64-frame pool would use 32400*64*8 ~= 15.8 MB.
28#ifdef CPU_FEATURES_ARCH_ANY_ARM
29#define XFECFRAME_POOL_SIZE 32
30#else
31#define XFECFRAME_POOL_SIZE 64
32#endif
33
35{
36private:
37 dvb_constellation_t d_constellation;
38 bool d_waiting_first_llr;
39 unsigned int d_fecframe_len;
40 unsigned int d_xfecframe_len;
41 unsigned int d_rowaddr0;
42 unsigned int d_rowaddr1;
43 unsigned int d_rowaddr2;
44 float d_snr; /**< Estimated SNR in dB */
45 float d_N0; /**< Estimated noise energy per complex dimension */
46 float d_precision;
47 uint64_t d_frame_cnt; /**< Total count of processed frames */
48 volk::vector<int8_t> d_aux_8i_buffer;
49 volk::vector<int8_t> d_aux_8i_buffer_2;
50 Modulation<gr_complex, int8_t>* d_mod;
51 std::unique_ptr<QpskConstellation> d_qpsk;
52 gr::thread::mutex d_mutex;
53
54 // Used for measuring the post-decoder SNR using the LLRs reported by the LDPC decoder
55 std::array<volk::vector<gr_complex>, XFECFRAME_POOL_SIZE> d_xfecframe_buffer_pool;
56 std::array<uint64_t, XFECFRAME_POOL_SIZE> d_xfecframe_saved;
57 size_t d_idx_xfecframe_buffer; /**< Index to the next XFECFRAME bufer */
58 const pmt::pmt_t d_pdu_port_id = pmt::mp("llr_pdu");
59 void handle_llr_pdu(pmt::pmt_t pdu);
60
61public:
63 dvb_code_rate_t rate,
64 dvb_constellation_t constellation);
66
67 void forecast(int noutput_items, gr_vector_int& ninput_items_required);
68
69 int general_work(int noutput_items,
70 gr_vector_int& ninput_items,
71 gr_vector_const_void_star& input_items,
72 gr_vector_void_star& output_items);
73
74 float get_snr() { return d_snr; }
75};
76
77} // namespace dvbs2rx
78} // namespace gr
79
80#endif /* INCLUDED_DVBS2RX_XFECFRAME_DEMAPPER_CB_IMPL_H */
Definition xfecframe_demapper_cb_impl.h:35
float get_snr()
Get the measured SNR.
Definition xfecframe_demapper_cb_impl.h:74
void forecast(int noutput_items, gr_vector_int &ninput_items_required)
xfecframe_demapper_cb_impl(dvb_framesize_t framesize, dvb_code_rate_t rate, dvb_constellation_t constellation)
int general_work(int noutput_items, gr_vector_int &ninput_items, gr_vector_const_void_star &input_items, gr_vector_void_star &output_items)
XFECFRAME Constellation Demapper.
Definition xfecframe_demapper_cb.h:24
dvb_framesize_t
Definition dvb_config.h:74
dvb_constellation_t
Definition dvb_config.h:80
dvb_code_rate_t
Definition dvb_config.h:20
Fixed-length double-ended queue with contiguous volk-aligned elements.
Definition gr_bch.h:22
#define XFECFRAME_POOL_SIZE
Definition xfecframe_demapper_cb_impl.h:31