Roman Khassraf | 059bab9 | 2015-05-20 12:49:46 +0200 | [diff] [blame] | 1 | /* -*- c++ -*- */ |
| 2 | /* |
| 3 | * @file |
Piotr Krysik | a6268a5 | 2017-08-23 16:02:19 +0200 | [diff] [blame] | 4 | * @author (C) 2015 by Roman Khassraf <rkhassraf@gmail.com> |
Roman Khassraf | 059bab9 | 2015-05-20 12:49:46 +0200 | [diff] [blame] | 5 | * @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 Krysik | a6268a5 | 2017-08-23 16:02:19 +0200 | [diff] [blame] | 26 | #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 Khassraf | 059bab9 | 2015-05-20 12:49:46 +0200 | [diff] [blame] | 32 | #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 | |
| 46 | namespace 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 Khassraf | 059bab9 | 2015-05-20 12:49:46 +0200 | [diff] [blame] | 55 | enum tch_mode d_tch_mode; |
Roman Khassraf | 23c8d8a | 2015-08-11 11:52:15 +0200 | [diff] [blame] | 56 | bool d_boundary_check; |
| 57 | bool d_boundary_decode; |
Piotr Krysik | 2b97cb1 | 2016-06-29 15:00:07 +0200 | [diff] [blame] | 58 | bool d_header_sent; |
Roman Khassraf | e159333 | 2015-06-02 13:19:01 +0200 | [diff] [blame] | 59 | |
| 60 | BitVector mU; |
| 61 | BitVector mP; |
| 62 | BitVector mD; |
| 63 | BitVector mDP; |
Roman Khassraf | e159333 | 2015-06-02 13:19:01 +0200 | [diff] [blame] | 64 | BitVector mTCHU; |
| 65 | BitVector mTCHD; |
| 66 | BitVector mClass1A_d; |
Roman Khassraf | d38206c | 2015-06-07 16:26:29 +0200 | [diff] [blame] | 67 | SoftVector mC; |
| 68 | SoftVector mClass1_c; |
| 69 | SoftVector mClass2_c; |
| 70 | SoftVector mTCHUC; |
Roman Khassraf | e159333 | 2015-06-02 13:19:01 +0200 | [diff] [blame] | 71 | |
Roman Khassraf | d38206c | 2015-06-07 16:26:29 +0200 | [diff] [blame] | 72 | Parity mBlockCoder; |
| 73 | Parity mTCHParity; |
Roman Khassraf | e159333 | 2015-06-02 13:19:01 +0200 | [diff] [blame] | 74 | |
Roman Khassraf | d38206c | 2015-06-07 16:26:29 +0200 | [diff] [blame] | 75 | ViterbiR2O4 mVR204Coder; |
| 76 | ViterbiBase *mViterbi; |
| 77 | |
Roman Khassraf | d38206c | 2015-06-07 16:26:29 +0200 | [diff] [blame] | 78 | 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 Khassraf | 059bab9 | 2015-05-20 12:49:46 +0200 | [diff] [blame] | 91 | public: |
Piotr Krysik | 0a60e7a | 2016-06-29 22:22:27 +0200 | [diff] [blame] | 92 | tch_f_decoder_impl(tch_mode mode, bool boundary_check=false); |
Roman Khassraf | 059bab9 | 2015-05-20 12:49:46 +0200 | [diff] [blame] | 93 | ~tch_f_decoder_impl(); |
| 94 | }; |
| 95 | |
| 96 | } // namespace gsm |
| 97 | } // namespace gr |
| 98 | |
| 99 | #endif /* INCLUDED_GSM_TCH_F_DECODER_IMPL_H */ |
| 100 | |