GNU Radio's DAB Package
mp4_decode_bs_impl.h
Go to the documentation of this file.
1 /* -*- c++ -*- */
2 /*
3  *
4  * Copyright 2017 Moritz Luca Schmid, Communications Engineering Lab (CEL) / Karlsruhe Institute of Technology (KIT).
5  *
6  * GNU Radio block written for gr-dab including the following third party elements:
7  * -QT-DAB: classes mp4Processor and faad-decoder except the reed-solomon class
8  * Copyright (C) 2013
9  * Jan van Katwijk (J.vanKatwijk@gmail.com)
10  * Lazy Chair Computing
11  * -KA9Q: the char-sized Reed-Solomon encoder and decoder of the libfec library
12  * (details on the license see /fec/LICENCE)
13  *
14  * This is free software; you can redistribute it and/or modify
15  * it under the terms of the GNU General Public License as published by
16  * the Free Software Foundation; either version 3, or (at your option)
17  * any later version.
18  *
19  * This software is distributed in the hope that it will be useful,
20  * but WITHOUT ANY WARRANTY; without even the implied warranty of
21  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
22  * GNU General Public License for more details.
23  *
24  * You should have received a copy of the GNU General Public License
25  * along with this software; see the file COPYING. If not, write to
26  * the Free Software Foundation, Inc., 51 Franklin Street,
27  * Boston, MA 02110-1301, USA.
28  */
29 
30 #ifndef INCLUDED_DAB_MP4_DECODE_BS_IMPL_H
31 #define INCLUDED_DAB_MP4_DECODE_BS_IMPL_H
32 
33 #include <grdab/mp4_decode_bs.h>
34 #include "neaacdec.h"
35 
36 namespace gr {
37  namespace dab {
38 /*! \brief DAB+ Audio frame decoder
39  * according to ETSI TS 102 563
40  */
42  private:
43  int d_nsamples_produced;
44  int d_bit_rate_n;
45  int d_sample_rate;
46  int d_superframe_size;
47  bool d_aacInitialized;
48  int32_t baudRate;
49  uint8_t d_dac_rate, d_sbr_flag, d_aac_channel_mode, d_ps_flag, d_mpeg_surround, d_num_aus;
50  int16_t d_au_start[10];
51 
52  NeAACDecHandle aacHandle;
53 
54  bool crc16(const uint8_t *msg, int16_t len);
55 
56  uint16_t BinToDec(const uint8_t *data, size_t offset, size_t length);
57 
58  int get_aac_channel_configuration(int16_t m_mpeg_surround_config, uint8_t aacChannelMode);
59 
60  bool initialize(uint8_t dacRate,
61  uint8_t sbrFlag,
62  int16_t mpegSurround,
63  uint8_t aacChannelMode);
64 
65  void handle_aac_frame(const uint8_t *v,
66  int16_t frame_length,
67  uint8_t dacRate,
68  uint8_t sbrFlag,
69  uint8_t mpegSurround,
70  uint8_t aacChannelMode,
71  int16_t *out_sample1,
72  int16_t *out_sample2);
73 
74  int16_t MP42PCM(uint8_t dacRate,
75  uint8_t sbrFlag,
76  int16_t mpegSurround,
77  uint8_t aacChannelMode,
78  uint8_t buffer[],
79  int16_t bufferLength,
80  int16_t *out_sample1,
81  int16_t *out_sample2);
82 
83  public:
84  mp4_decode_bs_impl(int bit_rate_n);
85 
87 
88  virtual int get_sample_rate()
89  { return d_sample_rate; }
90 
91  // Where all the action really happens
92  void forecast(int noutput_items, gr_vector_int &ninput_items_required);
93 
94  int general_work(int noutput_items,
95  gr_vector_int &ninput_items,
96  gr_vector_const_void_star &input_items,
97  gr_vector_void_star &output_items);
98  };
99 
100  } // namespace dab
101 } // namespace gr
102 
103 #endif /* INCLUDED_DAB_MP4_DECODE_BS_IMPL_H */
void forecast(int noutput_items, gr_vector_int &ninput_items_required)
void * NeAACDecHandle
Definition: neaacdec.h:139
Definition: complex_to_interleaved_float_vcf.h:28
DAB+ Audio frame decoder according to ETSI TS 102 563.
Definition: mp4_decode_bs_impl.h:41
virtual int get_sample_rate()
Definition: mp4_decode_bs_impl.h:88
int general_work(int noutput_items, gr_vector_int &ninput_items, gr_vector_const_void_star &input_items, gr_vector_void_star &output_items)
DAB+ Audio frame decoder.
Definition: mp4_decode_bs.h:37
mp4_decode_bs_impl(int bit_rate_n)