Go to the documentation of this file.00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013
00014
00015
00016
00017
00018
00019
00020
00021
00050 #ifndef AVCODEC_AC3DEC_H
00051 #define AVCODEC_AC3DEC_H
00052
00053 #include "libavutil/lfg.h"
00054 #include "ac3.h"
00055 #include "ac3dsp.h"
00056 #include "get_bits.h"
00057 #include "dsputil.h"
00058 #include "fft.h"
00059 #include "fmtconvert.h"
00060
00061 #define AC3_OUTPUT_LFEON 8
00062
00063 #define SPX_MAX_BANDS 17
00064
00066 #define AC3_FRAME_BUFFER_SIZE 32768
00067
00068 typedef struct {
00069 AVClass *class;
00070 AVCodecContext *avctx;
00071 AVFrame frame;
00072 GetBitContext gbc;
00073
00076 int frame_type;
00077 int substreamid;
00078 int frame_size;
00079 int bit_rate;
00080 int sample_rate;
00081 int num_blocks;
00082 int bitstream_mode;
00083 int channel_mode;
00084 int channel_layout;
00085 int lfe_on;
00086 int channel_map;
00087 int center_mix_level;
00088 int surround_mix_level;
00089 int eac3;
00090
00091
00093 int snr_offset_strategy;
00094 int block_switch_syntax;
00095 int dither_flag_syntax;
00096 int bit_allocation_syntax;
00097 int fast_gain_syntax;
00098 int dba_syntax;
00099 int skip_syntax;
00100
00101
00103 int cpl_in_use[AC3_MAX_BLOCKS];
00104 int cpl_strategy_exists[AC3_MAX_BLOCKS];
00105 int channel_in_cpl[AC3_MAX_CHANNELS];
00106 int phase_flags_in_use;
00107 int phase_flags[AC3_MAX_CPL_BANDS];
00108 int num_cpl_bands;
00109 uint8_t cpl_band_sizes[AC3_MAX_CPL_BANDS];
00110 int firstchincpl;
00111 int first_cpl_coords[AC3_MAX_CHANNELS];
00112 int cpl_coords[AC3_MAX_CHANNELS][AC3_MAX_CPL_BANDS];
00113
00114
00117 int spx_in_use;
00118 uint8_t channel_uses_spx[AC3_MAX_CHANNELS];
00119 int8_t spx_atten_code[AC3_MAX_CHANNELS];
00120 int spx_src_start_freq;
00121 int spx_dst_end_freq;
00122 int spx_dst_start_freq;
00123
00124 int num_spx_bands;
00125 uint8_t spx_band_sizes[SPX_MAX_BANDS];
00126 uint8_t first_spx_coords[AC3_MAX_CHANNELS];
00127 float spx_noise_blend[AC3_MAX_CHANNELS][SPX_MAX_BANDS];
00128 float spx_signal_blend[AC3_MAX_CHANNELS][SPX_MAX_BANDS];
00129
00130
00132 int channel_uses_aht[AC3_MAX_CHANNELS];
00133 int pre_mantissa[AC3_MAX_CHANNELS][AC3_MAX_COEFS][AC3_MAX_BLOCKS];
00134
00135
00137 int fbw_channels;
00138 int channels;
00139 int lfe_ch;
00140 float downmix_coeffs[AC3_MAX_CHANNELS][2];
00141 int downmixed;
00142 int output_mode;
00143 int out_channels;
00144
00145
00147 float dynamic_range[2];
00148 float drc_scale;
00149
00150
00152 int start_freq[AC3_MAX_CHANNELS];
00153 int end_freq[AC3_MAX_CHANNELS];
00154
00155
00157 int num_rematrixing_bands;
00158 int rematrixing_flags[4];
00159
00160
00162 int num_exp_groups[AC3_MAX_CHANNELS];
00163 int8_t dexps[AC3_MAX_CHANNELS][AC3_MAX_COEFS];
00164 int exp_strategy[AC3_MAX_BLOCKS][AC3_MAX_CHANNELS];
00165
00166
00168 AC3BitAllocParameters bit_alloc_params;
00169 int first_cpl_leak;
00170 int snr_offset[AC3_MAX_CHANNELS];
00171 int fast_gain[AC3_MAX_CHANNELS];
00172 uint8_t bap[AC3_MAX_CHANNELS][AC3_MAX_COEFS];
00173 int16_t psd[AC3_MAX_CHANNELS][AC3_MAX_COEFS];
00174 int16_t band_psd[AC3_MAX_CHANNELS][AC3_CRITICAL_BANDS];
00175 int16_t mask[AC3_MAX_CHANNELS][AC3_CRITICAL_BANDS];
00176 int dba_mode[AC3_MAX_CHANNELS];
00177 int dba_nsegs[AC3_MAX_CHANNELS];
00178 uint8_t dba_offsets[AC3_MAX_CHANNELS][8];
00179 uint8_t dba_lengths[AC3_MAX_CHANNELS][8];
00180 uint8_t dba_values[AC3_MAX_CHANNELS][8];
00181
00182
00184 int dither_flag[AC3_MAX_CHANNELS];
00185 AVLFG dith_state;
00186
00187
00189 int block_switch[AC3_MAX_CHANNELS];
00190 FFTContext imdct_512;
00191 FFTContext imdct_256;
00192
00193
00195 DSPContext dsp;
00196 AC3DSPContext ac3dsp;
00197 FmtConvertContext fmt_conv;
00198 float mul_bias;
00199
00200
00202 DECLARE_ALIGNED(16, int, fixed_coeffs)[AC3_MAX_CHANNELS][AC3_MAX_COEFS];
00203 DECLARE_ALIGNED(32, float, transform_coeffs)[AC3_MAX_CHANNELS][AC3_MAX_COEFS];
00204 DECLARE_ALIGNED(32, float, delay)[AC3_MAX_CHANNELS][AC3_BLOCK_SIZE];
00205 DECLARE_ALIGNED(32, float, window)[AC3_BLOCK_SIZE];
00206 DECLARE_ALIGNED(32, float, tmp_output)[AC3_BLOCK_SIZE];
00207 DECLARE_ALIGNED(32, float, output)[AC3_MAX_CHANNELS][AC3_BLOCK_SIZE];
00208 DECLARE_ALIGNED(32, uint8_t, input_buffer)[AC3_FRAME_BUFFER_SIZE + FF_INPUT_BUFFER_PADDING_SIZE];
00209
00210 } AC3DecodeContext;
00211
00216 int ff_eac3_parse_header(AC3DecodeContext *s);
00217
00222 void ff_eac3_decode_transform_coeffs_aht_ch(AC3DecodeContext *s, int ch);
00223
00224 void ff_ac3_downmix_c(float (*samples)[256], float (*matrix)[2],
00225 int out_ch, int in_ch, int len);
00226
00232 void ff_eac3_apply_spectral_extension(AC3DecodeContext *s);
00233
00234 #endif