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