1 /* -*- c++ -*- */ 2 /* 3 * Copyright 2013-2014 Free Software Foundation, Inc. 4 * 5 * This file is part of GNU Radio 6 * 7 * GNU Radio is free software; you can redistribute it and/or modify 8 * it under the terms of the GNU General Public License as published by 9 * the Free Software Foundation; either version 3, or (at your option) 10 * any later version. 11 * 12 * GNU Radio is distributed in the hope that it will be useful, 13 * but WITHOUT ANY WARRANTY; without even the implied warranty of 14 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 15 * GNU General Public License for more details. 16 * 17 * You should have received a copy of the GNU General Public License 18 * along with GNU Radio; see the file COPYING. If not, write to 19 * the Free Software Foundation, Inc., 51 Franklin Street, 20 * Boston, MA 02110-1301, USA. 21 */ 22 23 #ifndef INCLUDED_FEC_CC_DECODER_IMPL_H 24 #define INCLUDED_FEC_CC_DECODER_IMPL_H 25 26 #include <gnuradio/fec/cc_decoder.h> 27 #include <map> 28 #include <string> 29 30 namespace gr { 31 namespace fec { 32 namespace code { 33 34 class FEC_API cc_decoder_impl : public cc_decoder 35 { 36 private: 37 // plug into the generic fec api 38 int get_output_size(); 39 int get_input_size(); 40 int get_history(); 41 float get_shift(); 42 int get_input_item_size(); 43 const char* get_input_conversion(); 44 // const char* get_output_conversion(); 45 46 // everything else... 47 void create_viterbi(); 48 int init_viterbi(struct v* vp, int starting_state); 49 int init_viterbi_unbiased(struct v* vp); 50 int update_viterbi_blk(unsigned char* syms, int nbits); 51 int chainback_viterbi(unsigned char* data, 52 unsigned int nbits, 53 unsigned int endstate, 54 unsigned int tailsize); 55 int find_endstate(); 56 57 unsigned char* Branchtab; 58 unsigned char Partab[256]; 59 60 61 int d_ADDSHIFT; 62 int d_SUBSHIFT; 63 conv_kernel d_kernel; 64 unsigned int d_max_frame_size; 65 unsigned int d_frame_size; 66 unsigned int d_k; 67 unsigned int d_rate; 68 std::vector<int> d_polys; 69 cc_mode_t d_mode; 70 int d_padding; 71 72 struct v* d_vp; 73 unsigned char* d_managed_in; 74 unsigned int d_managed_in_size; 75 int d_numstates; 76 int d_decision_t_size; 77 int* d_start_state; 78 int d_start_state_chaining; 79 int d_start_state_nonchaining; 80 int* d_end_state; 81 int d_end_state_chaining; 82 int d_end_state_nonchaining; 83 unsigned int d_veclen; 84 85 int parity(int x); 86 int parityb(unsigned char x); 87 void partab_init(void); 88 89 public: 90 cc_decoder_impl(int frame_size, 91 int k, 92 int rate, 93 std::vector<int> polys, 94 int start_state = 0, 95 int end_state = -1, 96 cc_mode_t mode = CC_STREAMING, 97 bool padded = false); 98 ~cc_decoder_impl(); 99 100 void generic_work(void* inbuffer, void* outbuffer); 101 bool set_frame_size(unsigned int frame_size); 102 double rate(); 103 }; 104 105 } /* namespace code */ 106 } /* namespace fec */ 107 } /* namespace gr */ 108 109 #endif /* INCLUDED_FEC_CC_DECODER_IMPL_H */ 110