1 /* -*- c++ -*- */
2 /*
3  * Copyright 2015,2016,2019 Free Software Foundation, Inc.
4  *
5  * This is free software; you can redistribute it and/or modify
6  * it under the terms of the GNU General Public License as published by
7  * the Free Software Foundation; either version 3, or (at your option)
8  * any later version.
9  *
10  * This software is distributed in the hope that it will be useful,
11  * but WITHOUT ANY WARRANTY; without even the implied warranty of
12  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
13  * GNU General Public License for more details.
14  *
15  * You should have received a copy of the GNU General Public License
16  * along with this software; see the file COPYING.  If not, write to
17  * the Free Software Foundation, Inc., 51 Franklin Street,
18  * Boston, MA 02110-1301, USA.
19  */
20 
21 #ifndef INCLUDED_DTV_DVB_BCH_BB_IMPL_H
22 #define INCLUDED_DTV_DVB_BCH_BB_IMPL_H
23 
24 #include "dvb_defines.h"
25 #include <gnuradio/dtv/dvb_bch_bb.h>
26 #include <bitset>
27 
28 #define MAX_BCH_PARITY_BITS 192
29 
30 namespace gr {
31 namespace dtv {
32 
33 class dvb_bch_bb_impl : public dvb_bch_bb
34 {
35 private:
36     unsigned int kbch;
37     unsigned int nbch;
38     unsigned int bch_code;
39     unsigned int frame_size;
40 
41     std::bitset<MAX_BCH_PARITY_BITS> crc_table[256];
42     std::bitset<MAX_BCH_PARITY_BITS> crc_medium_table[16];
43     unsigned int num_parity_bits;
44     std::bitset<MAX_BCH_PARITY_BITS> polynome;
45 
46     void calculate_crc_table();
47     void calculate_medium_crc_table();
48     int poly_mult(const int*, int, const int*, int, int*);
49     void bch_poly_build_tables(void);
50 
51 public:
52     dvb_bch_bb_impl(dvb_standard_t standard,
53                     dvb_framesize_t framesize,
54                     dvb_code_rate_t rate);
55     ~dvb_bch_bb_impl();
56 
57     void forecast(int noutput_items, gr_vector_int& ninput_items_required);
58 
59     int general_work(int noutput_items,
60                      gr_vector_int& ninput_items,
61                      gr_vector_const_void_star& input_items,
62                      gr_vector_void_star& output_items);
63 };
64 
65 } // namespace dtv
66 } // namespace gr
67 
68 #endif /* INCLUDED_DTV_DVB_BCH_BB_IMPL_H */
69