blob: cac245a55bc06eb61deb5931afc2341c560584d3 [file] [log] [blame]
Roman Khassraf059bab92015-05-20 12:49:46 +02001/* -*- c++ -*- */
2/*
3 * @file
Piotr Krysika6268a52017-08-23 16:02:19 +02004 * @author (C) 2015 by Roman Khassraf <rkhassraf@gmail.com>
Roman Khassraf059bab92015-05-20 12:49:46 +02005 * @section LICENSE
6 *
7 * Gr-gsm 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 * Gr-gsm 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 gr-gsm; 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_GSM_TCH_F_DECODER_IMPL_H
24#define INCLUDED_GSM_TCH_F_DECODER_IMPL_H
25
Piotr Krysika6268a52017-08-23 16:02:19 +020026#include "openbts/AmrCoder.h"
27#include "openbts/BitVector.h"
28#include "openbts/GSM503Tables.h"
29#include "openbts/GSM610Tables.h"
30#include "openbts/GSM660Tables.h"
31#include "openbts/ViterbiR204.h"
Roman Khassraf059bab92015-05-20 12:49:46 +020032#include <grgsm/decoding/tch_f_decoder.h>
33
34
35#define DATA_BLOCK_SIZE 184
36#define PARITY_SIZE 40
37#define FLUSH_BITS_SIZE 4
38#define PARITY_OUTPUT_SIZE (DATA_BLOCK_SIZE + PARITY_SIZE + FLUSH_BITS_SIZE)
39
40#define CONV_INPUT_SIZE PARITY_OUTPUT_SIZE
41#define CONV_SIZE (2 * CONV_INPUT_SIZE)
42
43#define BLOCKS 8
44#define iBLOCK_SIZE (CONV_SIZE / BLOCKS)
45
46namespace gr {
47 namespace gsm {
48
49 class tch_f_decoder_impl : public tch_f_decoder
50 {
51 private:
52 unsigned int d_collected_bursts_num;
53 unsigned short interleave_trans[CONV_SIZE];
54 pmt::pmt_t d_bursts[8];
Roman Khassraf059bab92015-05-20 12:49:46 +020055 enum tch_mode d_tch_mode;
Roman Khassraf23c8d8a2015-08-11 11:52:15 +020056 bool d_boundary_check;
57 bool d_boundary_decode;
Piotr Krysik2b97cb12016-06-29 15:00:07 +020058 bool d_header_sent;
Roman Khassrafe1593332015-06-02 13:19:01 +020059
60 BitVector mU;
61 BitVector mP;
62 BitVector mD;
63 BitVector mDP;
Roman Khassrafe1593332015-06-02 13:19:01 +020064 BitVector mTCHU;
65 BitVector mTCHD;
66 BitVector mClass1A_d;
Roman Khassrafd38206c2015-06-07 16:26:29 +020067 SoftVector mC;
68 SoftVector mClass1_c;
69 SoftVector mClass2_c;
70 SoftVector mTCHUC;
Roman Khassrafe1593332015-06-02 13:19:01 +020071
Roman Khassrafd38206c2015-06-07 16:26:29 +020072 Parity mBlockCoder;
73 Parity mTCHParity;
Roman Khassrafe1593332015-06-02 13:19:01 +020074
Roman Khassrafd38206c2015-06-07 16:26:29 +020075 ViterbiR2O4 mVR204Coder;
76 ViterbiBase *mViterbi;
77
Roman Khassrafd38206c2015-06-07 16:26:29 +020078 unsigned char iBLOCK[2*BLOCKS*iBLOCK_SIZE];
79 unsigned char mAMRFrameHeader;
80
81 const unsigned *mAMRBitOrder;
82 const unsigned *mPuncture;
83 unsigned mClass1ALth;
84 unsigned mClass1BLth;
85 unsigned mPunctureLth;
86 uint8_t mAMRFrameLth;
87 uint8_t mKd;
88
89 void decode(pmt::pmt_t msg);
90 void setCodingMode(tch_mode mode);
Roman Khassraf059bab92015-05-20 12:49:46 +020091 public:
Piotr Krysik0a60e7a2016-06-29 22:22:27 +020092 tch_f_decoder_impl(tch_mode mode, bool boundary_check=false);
Roman Khassraf059bab92015-05-20 12:49:46 +020093 ~tch_f_decoder_impl();
94 };
95
96 } // namespace gsm
97} // namespace gr
98
99#endif /* INCLUDED_GSM_TCH_F_DECODER_IMPL_H */
100