GNU Radio's DVBS2RX Package
bbdeheader_bb_impl.h
Go to the documentation of this file.
1/* -*- c++ -*- */
2/*
3 * Copyright 2018 Ron Economos.
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_BBDEHEADER_BB_IMPL_H
11#define INCLUDED_DVBS2RX_BBDEHEADER_BB_IMPL_H
12
13#include "dvb_defines.h"
14#include "gf_util.h"
16
17namespace gr {
18namespace dvbs2rx {
19
20#define TS_PACKET_LENGTH 188
21
22typedef struct {
23 int ts_gs;
26 int issyi;
27 int npd;
28 int ro;
29 int isi;
30 unsigned int upl;
31 unsigned int dfl;
32 int sync;
33 unsigned int syncd;
34} BBHeader;
35
37{
38private:
39 const int d_debug_level; /**< Debug level*/
40 unsigned int d_kbch_bytes; /**< BBFRAME length in bytes */
41 unsigned int d_max_dfl; /**< Maximum DATAFIELD length in bits */
42 bool d_synched; /**< Synchronized to the start of TS packets */
43 unsigned int d_partial_ts_bytes; /**< Byte count of the partial TS packet
44 extracted at the end of the previous BBFRAME */
45 unsigned char d_partial_pkt[TS_PACKET_LENGTH]; /**< Partial TS packet storage */
46 BBHeader d_bbheader; /**< Parsed BBHEADER */
47 uint64_t d_packet_cnt; /**< All-time count of received packets */
48 uint64_t d_error_cnt; /**< All-time count of packets with bit errors */
49 uint64_t d_bbframe_cnt; /**< All-time count of processed BBFRAMEs */
50 uint64_t d_bbframe_drop_cnt; /**< All-time count of dropped BBFRAMEs */
51 gf2_poly<uint16_t> d_crc_poly; /**< CRC-8 generator polynomial */
52 std::array<uint16_t, 256> d_crc8_table; /**< CRC-8 remainder look-up table */
53
54 /**
55 * @brief Parse and validate an incoming BBHEADER
56 *
57 * @param in Input bytes carrying the BBHEADER.
58 * @param h Output parsed BBHEADER.
59 * @return true When the BBHEADER is valid.
60 * @return false When the BBHEADER is invalid.
61 */
62 bool parse_bbheader(u8_cptr_t in, BBHeader* h);
63
64 /**
65 * @brief Check the CRC-8 of a sequence of bytes
66 *
67 * @param in Input bytes to check.
68 * @param size Number of bytes to check.
69 * @return true When the CRC-8 is valid.
70 * @return false When the CRC-8 is invalid.
71 */
72 bool check_crc8(u8_cptr_t in, int size);
73
74public:
76 dvb_framesize_t framesize,
77 dvb_code_rate_t rate,
78 int debug_level);
80
81 void forecast(int noutput_items, gr_vector_int& ninput_items_required);
82
83 int general_work(int noutput_items,
84 gr_vector_int& ninput_items,
85 gr_vector_const_void_star& input_items,
86 gr_vector_void_star& output_items);
87
88 uint64_t get_packet_count() { return d_packet_cnt; }
89 uint64_t get_error_count() { return d_error_cnt; }
90 uint64_t get_bbframe_count() { return d_bbframe_cnt; }
91 uint64_t get_bbframe_drop_count() { return d_bbframe_drop_cnt; }
92};
93
94} // namespace dvbs2rx
95} // namespace gr
96
97#endif /* INCLUDED_DVBS2RX_BBDEHEADER_BB_IMPL_H */
#define TS_PACKET_LENGTH
Definition bbdeheader_bb_impl.h:20
Definition bbdeheader_bb_impl.h:37
uint64_t get_packet_count()
Get count of MPEG TS packets extracted from BBFRAMEs.
Definition bbdeheader_bb_impl.h:88
void forecast(int noutput_items, gr_vector_int &ninput_items_required)
int general_work(int noutput_items, gr_vector_int &ninput_items, gr_vector_const_void_star &input_items, gr_vector_void_star &output_items)
uint64_t get_bbframe_drop_count()
Get count of BBFRAMEs dropped due to invalid BBHEADER.
Definition bbdeheader_bb_impl.h:91
uint64_t get_error_count()
Get count of corrupt MPEG TS packets extracted from BBFRAMEs.
Definition bbdeheader_bb_impl.h:89
bbdeheader_bb_impl(dvb_standard_t standard, dvb_framesize_t framesize, dvb_code_rate_t rate, int debug_level)
uint64_t get_bbframe_count()
Get count of processed BBFRAMEs.
Definition bbdeheader_bb_impl.h:90
<+description of block+>
Definition bbdeheader_bb.h:28
Polynomial over GF(2).
Definition gf.h:203
const unsigned char * u8_cptr_t
Definition gf_util.h:24
dvb_framesize_t
Definition dvb_config.h:74
dvb_code_rate_t
Definition dvb_config.h:20
dvb_standard_t
Definition dvb_config.h:15
Fixed-length double-ended queue with contiguous volk-aligned elements.
Definition gr_bch.h:22
Definition bbdeheader_bb_impl.h:22
int isi
Definition bbdeheader_bb_impl.h:29
unsigned int dfl
Definition bbdeheader_bb_impl.h:31
int sync
Definition bbdeheader_bb_impl.h:32
int sis_mis
Definition bbdeheader_bb_impl.h:24
int npd
Definition bbdeheader_bb_impl.h:27
int ro
Definition bbdeheader_bb_impl.h:28
unsigned int upl
Definition bbdeheader_bb_impl.h:30
int ccm_acm
Definition bbdeheader_bb_impl.h:25
int ts_gs
Definition bbdeheader_bb_impl.h:23
unsigned int syncd
Definition bbdeheader_bb_impl.h:33
int issyi
Definition bbdeheader_bb_impl.h:26