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 AVCodecContext *avctx;
00070 GetBitContext gbc;
00071
00074 int frame_type;
00075 int substreamid;
00076 int frame_size;
00077 int bit_rate;
00078 int sample_rate;
00079 int num_blocks;
00080 int bitstream_mode;
00081 int channel_mode;
00082 int channel_layout;
00083 int lfe_on;
00084 int channel_map;
00085 int center_mix_level;
00086 int surround_mix_level;
00087 int eac3;
00088
00089
00091 int snr_offset_strategy;
00092 int block_switch_syntax;
00093 int dither_flag_syntax;
00094 int bit_allocation_syntax;
00095 int fast_gain_syntax;
00096 int dba_syntax;
00097 int skip_syntax;
00098
00099
00101 int cpl_in_use[AC3_MAX_BLOCKS];
00102 int cpl_strategy_exists[AC3_MAX_BLOCKS];
00103 int channel_in_cpl[AC3_MAX_CHANNELS];
00104 int phase_flags_in_use;
00105 int phase_flags[AC3_MAX_CPL_BANDS];
00106 int num_cpl_bands;
00107 uint8_t cpl_band_sizes[AC3_MAX_CPL_BANDS];
00108 int firstchincpl;
00109 int first_cpl_coords[AC3_MAX_CHANNELS];
00110 int cpl_coords[AC3_MAX_CHANNELS][AC3_MAX_CPL_BANDS];
00111
00112
00115 int spx_in_use;
00116 uint8_t channel_uses_spx[AC3_MAX_CHANNELS];
00117 int8_t spx_atten_code[AC3_MAX_CHANNELS];
00118 int spx_src_start_freq;
00119 int spx_dst_end_freq;
00120 int spx_dst_start_freq;
00121
00122 int num_spx_bands;
00123 uint8_t spx_band_sizes[SPX_MAX_BANDS];
00124 uint8_t first_spx_coords[AC3_MAX_CHANNELS];
00125 float spx_noise_blend[AC3_MAX_CHANNELS][SPX_MAX_BANDS];
00126 float spx_signal_blend[AC3_MAX_CHANNELS][SPX_MAX_BANDS];
00127
00128
00130 int channel_uses_aht[AC3_MAX_CHANNELS];
00131 int pre_mantissa[AC3_MAX_CHANNELS][AC3_MAX_COEFS][AC3_MAX_BLOCKS];
00132
00133
00135 int fbw_channels;
00136 int channels;
00137 int lfe_ch;
00138 float downmix_coeffs[AC3_MAX_CHANNELS][2];
00139 int downmixed;
00140 int output_mode;
00141 int out_channels;
00142
00143
00145 float dynamic_range[2];
00146
00147
00149 int start_freq[AC3_MAX_CHANNELS];
00150 int end_freq[AC3_MAX_CHANNELS];
00151
00152
00154 int num_rematrixing_bands;
00155 int rematrixing_flags[4];
00156
00157
00159 int num_exp_groups[AC3_MAX_CHANNELS];
00160 int8_t dexps[AC3_MAX_CHANNELS][AC3_MAX_COEFS];
00161 int exp_strategy[AC3_MAX_BLOCKS][AC3_MAX_CHANNELS];
00162
00163
00165 AC3BitAllocParameters bit_alloc_params;
00166 int first_cpl_leak;
00167 int snr_offset[AC3_MAX_CHANNELS];
00168 int fast_gain[AC3_MAX_CHANNELS];
00169 uint8_t bap[AC3_MAX_CHANNELS][AC3_MAX_COEFS];
00170 int16_t psd[AC3_MAX_CHANNELS][AC3_MAX_COEFS];
00171 int16_t band_psd[AC3_MAX_CHANNELS][AC3_CRITICAL_BANDS];
00172 int16_t mask[AC3_MAX_CHANNELS][AC3_CRITICAL_BANDS];
00173 int dba_mode[AC3_MAX_CHANNELS];
00174 int dba_nsegs[AC3_MAX_CHANNELS];
00175 uint8_t dba_offsets[AC3_MAX_CHANNELS][8];
00176 uint8_t dba_lengths[AC3_MAX_CHANNELS][8];
00177 uint8_t dba_values[AC3_MAX_CHANNELS][8];
00178
00179
00181 int dither_flag[AC3_MAX_CHANNELS];
00182 AVLFG dith_state;
00183
00184
00186 int block_switch[AC3_MAX_CHANNELS];
00187 FFTContext imdct_512;
00188 FFTContext imdct_256;
00189
00190
00192 DSPContext dsp;
00193 AC3DSPContext ac3dsp;
00194 FmtConvertContext fmt_conv;
00195 float mul_bias;
00196
00197
00199 DECLARE_ALIGNED(16, int, fixed_coeffs)[AC3_MAX_CHANNELS][AC3_MAX_COEFS];
00200 DECLARE_ALIGNED(32, float, transform_coeffs)[AC3_MAX_CHANNELS][AC3_MAX_COEFS];
00201 DECLARE_ALIGNED(32, float, delay)[AC3_MAX_CHANNELS][AC3_BLOCK_SIZE];
00202 DECLARE_ALIGNED(32, float, window)[AC3_BLOCK_SIZE];
00203 DECLARE_ALIGNED(32, float, tmp_output)[AC3_BLOCK_SIZE];
00204 DECLARE_ALIGNED(32, float, output)[AC3_MAX_CHANNELS][AC3_BLOCK_SIZE];
00205 DECLARE_ALIGNED(32, uint8_t, input_buffer)[AC3_FRAME_BUFFER_SIZE + FF_INPUT_BUFFER_PADDING_SIZE];
00206
00207 } AC3DecodeContext;
00208
00213 int ff_eac3_parse_header(AC3DecodeContext *s);
00214
00219 void ff_eac3_decode_transform_coeffs_aht_ch(AC3DecodeContext *s, int ch);
00220
00221 void ff_ac3_downmix_c(float (*samples)[256], float (*matrix)[2],
00222 int out_ch, int in_ch, int len);
00223
00229 void ff_eac3_apply_spectral_extension(AC3DecodeContext *s);
00230
00231 #endif