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
00092 int preferred_stereo_downmix;
00093 float ltrt_center_mix_level;
00094 float ltrt_surround_mix_level;
00095 float loro_center_mix_level;
00096 float loro_surround_mix_level;
00097
00099 int snr_offset_strategy;
00100 int block_switch_syntax;
00101 int dither_flag_syntax;
00102 int bit_allocation_syntax;
00103 int fast_gain_syntax;
00104 int dba_syntax;
00105 int skip_syntax;
00106
00107
00109 int cpl_in_use[AC3_MAX_BLOCKS];
00110 int cpl_strategy_exists[AC3_MAX_BLOCKS];
00111 int channel_in_cpl[AC3_MAX_CHANNELS];
00112 int phase_flags_in_use;
00113 int phase_flags[AC3_MAX_CPL_BANDS];
00114 int num_cpl_bands;
00115 uint8_t cpl_band_sizes[AC3_MAX_CPL_BANDS];
00116 int firstchincpl;
00117 int first_cpl_coords[AC3_MAX_CHANNELS];
00118 int cpl_coords[AC3_MAX_CHANNELS][AC3_MAX_CPL_BANDS];
00119
00120
00123 int spx_in_use;
00124 uint8_t channel_uses_spx[AC3_MAX_CHANNELS];
00125 int8_t spx_atten_code[AC3_MAX_CHANNELS];
00126 int spx_src_start_freq;
00127 int spx_dst_end_freq;
00128 int spx_dst_start_freq;
00129
00130 int num_spx_bands;
00131 uint8_t spx_band_sizes[SPX_MAX_BANDS];
00132 uint8_t first_spx_coords[AC3_MAX_CHANNELS];
00133 float spx_noise_blend[AC3_MAX_CHANNELS][SPX_MAX_BANDS];
00134 float spx_signal_blend[AC3_MAX_CHANNELS][SPX_MAX_BANDS];
00135
00136
00138 int channel_uses_aht[AC3_MAX_CHANNELS];
00139 int pre_mantissa[AC3_MAX_CHANNELS][AC3_MAX_COEFS][AC3_MAX_BLOCKS];
00140
00141
00143 int fbw_channels;
00144 int channels;
00145 int lfe_ch;
00146 float downmix_coeffs[AC3_MAX_CHANNELS][2];
00147 int downmixed;
00148 int output_mode;
00149 int out_channels;
00150
00151
00153 float dynamic_range[2];
00154 float drc_scale;
00155
00156
00158 int start_freq[AC3_MAX_CHANNELS];
00159 int end_freq[AC3_MAX_CHANNELS];
00160
00161
00163 int num_rematrixing_bands;
00164 int rematrixing_flags[4];
00165
00166
00168 int num_exp_groups[AC3_MAX_CHANNELS];
00169 int8_t dexps[AC3_MAX_CHANNELS][AC3_MAX_COEFS];
00170 int exp_strategy[AC3_MAX_BLOCKS][AC3_MAX_CHANNELS];
00171
00172
00174 AC3BitAllocParameters bit_alloc_params;
00175 int first_cpl_leak;
00176 int snr_offset[AC3_MAX_CHANNELS];
00177 int fast_gain[AC3_MAX_CHANNELS];
00178 uint8_t bap[AC3_MAX_CHANNELS][AC3_MAX_COEFS];
00179 int16_t psd[AC3_MAX_CHANNELS][AC3_MAX_COEFS];
00180 int16_t band_psd[AC3_MAX_CHANNELS][AC3_CRITICAL_BANDS];
00181 int16_t mask[AC3_MAX_CHANNELS][AC3_CRITICAL_BANDS];
00182 int dba_mode[AC3_MAX_CHANNELS];
00183 int dba_nsegs[AC3_MAX_CHANNELS];
00184 uint8_t dba_offsets[AC3_MAX_CHANNELS][8];
00185 uint8_t dba_lengths[AC3_MAX_CHANNELS][8];
00186 uint8_t dba_values[AC3_MAX_CHANNELS][8];
00187
00188
00190 int dither_flag[AC3_MAX_CHANNELS];
00191 AVLFG dith_state;
00192
00193
00195 int block_switch[AC3_MAX_CHANNELS];
00196 FFTContext imdct_512;
00197 FFTContext imdct_256;
00198
00199
00201 DSPContext dsp;
00202 AC3DSPContext ac3dsp;
00203 FmtConvertContext fmt_conv;
00204 float mul_bias;
00205
00206
00208 DECLARE_ALIGNED(16, int, fixed_coeffs)[AC3_MAX_CHANNELS][AC3_MAX_COEFS];
00209 DECLARE_ALIGNED(32, float, transform_coeffs)[AC3_MAX_CHANNELS][AC3_MAX_COEFS];
00210 DECLARE_ALIGNED(32, float, delay)[AC3_MAX_CHANNELS][AC3_BLOCK_SIZE];
00211 DECLARE_ALIGNED(32, float, window)[AC3_BLOCK_SIZE];
00212 DECLARE_ALIGNED(32, float, tmp_output)[AC3_BLOCK_SIZE];
00213 DECLARE_ALIGNED(32, float, output)[AC3_MAX_CHANNELS][AC3_BLOCK_SIZE];
00214 DECLARE_ALIGNED(32, uint8_t, input_buffer)[AC3_FRAME_BUFFER_SIZE + FF_INPUT_BUFFER_PADDING_SIZE];
00215
00216 } AC3DecodeContext;
00217
00222 int ff_eac3_parse_header(AC3DecodeContext *s);
00223
00228 void ff_eac3_decode_transform_coeffs_aht_ch(AC3DecodeContext *s, int ch);
00229
00230 void ff_ac3_downmix_c(float (*samples)[256], float (*matrix)[2],
00231 int out_ch, int in_ch, int len);
00232
00238 void ff_eac3_apply_spectral_extension(AC3DecodeContext *s);
00239
00240 #endif