blob: d60384555aa2780aaf9eac243be50f4851d67f44 [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 Khassraf059bab92015-05-20 12:49:46 +020028#include "VocoderFrame.h"
Roman Khassrafd38206c2015-06-07 16:26:29 +020029#include "GSM503Tables.h"
Roman Khassraf059bab92015-05-20 12:49:46 +020030#include "GSM610Tables.h"
31#include "GSM660Tables.h"
32#include "GSM690Tables.h"
Roman Khassrafd71e6582015-06-02 08:49:12 +020033#include "ViterbiR204.h"
Roman Khassraf059bab92015-05-20 12:49:46 +020034#include <grgsm/decoding/tch_f_decoder.h>
35
36
37#define DATA_BLOCK_SIZE 184
38#define PARITY_SIZE 40
39#define FLUSH_BITS_SIZE 4
40#define PARITY_OUTPUT_SIZE (DATA_BLOCK_SIZE + PARITY_SIZE + FLUSH_BITS_SIZE)
41
42#define CONV_INPUT_SIZE PARITY_OUTPUT_SIZE
43#define CONV_SIZE (2 * CONV_INPUT_SIZE)
44
45#define BLOCKS 8
46#define iBLOCK_SIZE (CONV_SIZE / BLOCKS)
47
48namespace gr {
49 namespace gsm {
50
51 class tch_f_decoder_impl : public tch_f_decoder
52 {
53 private:
54 unsigned int d_collected_bursts_num;
55 unsigned short interleave_trans[CONV_SIZE];
56 pmt::pmt_t d_bursts[8];
57 FILE * d_speech_file;
58 enum tch_mode d_tch_mode;
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
78 const unsigned char amr_nb_magic[6] = { 0x23, 0x21, 0x41, 0x4d, 0x52, 0x0a };
79 unsigned char iBLOCK[2*BLOCKS*iBLOCK_SIZE];
80 unsigned char mAMRFrameHeader;
81
82 const unsigned *mAMRBitOrder;
83 const unsigned *mPuncture;
84 unsigned mClass1ALth;
85 unsigned mClass1BLth;
86 unsigned mPunctureLth;
87 uint8_t mAMRFrameLth;
88 uint8_t mKd;
89
90 void decode(pmt::pmt_t msg);
91 void setCodingMode(tch_mode mode);
Roman Khassraf059bab92015-05-20 12:49:46 +020092 public:
93 tch_f_decoder_impl(tch_mode mode, const std::string &file);
94 ~tch_f_decoder_impl();
95 };
96
97 } // namespace gsm
98} // namespace gr
99
100#endif /* INCLUDED_GSM_TCH_F_DECODER_IMPL_H */
101