blob: f6d054b02d99f9323cd08330dac7b9b4da0549ce [file] [log] [blame]
Roman Khassraf059bab92015-05-20 12:49:46 +02001/* -*- c++ -*- */
2/*
3 * @file
Roman Khassraf05bfb822015-05-22 11:46:00 +02004 * @author 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
Roman Khassrafd38206c2015-06-07 16:26:29 +020026#include "AmrCoder.h"
27#include "BitVector.h"
Roman Khassrafd38206c2015-06-07 16:26:29 +020028#include "GSM503Tables.h"
Roman Khassraf059bab92015-05-20 12:49:46 +020029#include "GSM610Tables.h"
30#include "GSM660Tables.h"
Roman Khassrafd71e6582015-06-02 08:49:12 +020031#include "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];
55 FILE * d_speech_file;
56 enum tch_mode d_tch_mode;
Roman Khassrafe1593332015-06-02 13:19:01 +020057
58 BitVector mU;
59 BitVector mP;
60 BitVector mD;
61 BitVector mDP;
Roman Khassrafe1593332015-06-02 13:19:01 +020062 BitVector mTCHU;
63 BitVector mTCHD;
64 BitVector mClass1A_d;
Roman Khassrafd38206c2015-06-07 16:26:29 +020065 SoftVector mC;
66 SoftVector mClass1_c;
67 SoftVector mClass2_c;
68 SoftVector mTCHUC;
Roman Khassrafe1593332015-06-02 13:19:01 +020069
Roman Khassrafd38206c2015-06-07 16:26:29 +020070 Parity mBlockCoder;
71 Parity mTCHParity;
Roman Khassrafe1593332015-06-02 13:19:01 +020072
Roman Khassrafd38206c2015-06-07 16:26:29 +020073 ViterbiR2O4 mVR204Coder;
74 ViterbiBase *mViterbi;
75
Roman Khassrafd38206c2015-06-07 16:26:29 +020076 unsigned char iBLOCK[2*BLOCKS*iBLOCK_SIZE];
77 unsigned char mAMRFrameHeader;
78
79 const unsigned *mAMRBitOrder;
80 const unsigned *mPuncture;
81 unsigned mClass1ALth;
82 unsigned mClass1BLth;
83 unsigned mPunctureLth;
84 uint8_t mAMRFrameLth;
85 uint8_t mKd;
86
87 void decode(pmt::pmt_t msg);
88 void setCodingMode(tch_mode mode);
Roman Khassraf059bab92015-05-20 12:49:46 +020089 public:
90 tch_f_decoder_impl(tch_mode mode, const std::string &file);
91 ~tch_f_decoder_impl();
92 };
93
94 } // namespace gsm
95} // namespace gr
96
97#endif /* INCLUDED_GSM_TCH_F_DECODER_IMPL_H */
98