Libav 0.7.1
|
00001 /* 00002 * Common code between the AC-3 and E-AC-3 decoders 00003 * Copyright (c) 2007 Bartlomiej Wolowiec <bartek.wolowiec@gmail.com> 00004 * 00005 * This file is part of Libav. 00006 * 00007 * Libav is free software; you can redistribute it and/or 00008 * modify it under the terms of the GNU Lesser General Public 00009 * License as published by the Free Software Foundation; either 00010 * version 2.1 of the License, or (at your option) any later version. 00011 * 00012 * Libav is distributed in the hope that it will be useful, 00013 * but WITHOUT ANY WARRANTY; without even the implied warranty of 00014 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU 00015 * Lesser General Public License for more details. 00016 * 00017 * You should have received a copy of the GNU Lesser General Public 00018 * License along with Libav; if not, write to the Free Software 00019 * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA 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 00065 typedef struct { 00066 AVCodecContext *avctx; 00067 GetBitContext gbc; 00068 uint8_t *input_buffer; 00069 00072 int frame_type; 00073 int substreamid; 00074 int frame_size; 00075 int bit_rate; 00076 int sample_rate; 00077 int num_blocks; 00078 int bitstream_mode; 00079 int channel_mode; 00080 int channel_layout; 00081 int lfe_on; 00082 int channel_map; 00083 int center_mix_level; 00084 int surround_mix_level; 00085 int eac3; 00086 00087 00089 int snr_offset_strategy; 00090 int block_switch_syntax; 00091 int dither_flag_syntax; 00092 int bit_allocation_syntax; 00093 int fast_gain_syntax; 00094 int dba_syntax; 00095 int skip_syntax; 00096 00097 00099 int cpl_in_use[AC3_MAX_BLOCKS]; 00100 int cpl_strategy_exists[AC3_MAX_BLOCKS]; 00101 int channel_in_cpl[AC3_MAX_CHANNELS]; 00102 int phase_flags_in_use; 00103 int phase_flags[AC3_MAX_CPL_BANDS]; 00104 int num_cpl_bands; 00105 uint8_t cpl_band_sizes[AC3_MAX_CPL_BANDS]; 00106 int firstchincpl; 00107 int first_cpl_coords[AC3_MAX_CHANNELS]; 00108 int cpl_coords[AC3_MAX_CHANNELS][AC3_MAX_CPL_BANDS]; 00109 00110 00113 int spx_in_use; 00114 uint8_t channel_uses_spx[AC3_MAX_CHANNELS]; 00115 int8_t spx_atten_code[AC3_MAX_CHANNELS]; 00116 int spx_src_start_freq; 00117 int spx_dst_end_freq; 00118 int spx_dst_start_freq; 00119 00120 int num_spx_bands; 00121 uint8_t spx_band_sizes[SPX_MAX_BANDS]; 00122 uint8_t first_spx_coords[AC3_MAX_CHANNELS]; 00123 float spx_noise_blend[AC3_MAX_CHANNELS][SPX_MAX_BANDS]; 00124 float spx_signal_blend[AC3_MAX_CHANNELS][SPX_MAX_BANDS]; 00125 00126 00128 int channel_uses_aht[AC3_MAX_CHANNELS]; 00129 int pre_mantissa[AC3_MAX_CHANNELS][AC3_MAX_COEFS][AC3_MAX_BLOCKS]; 00130 00131 00133 int fbw_channels; 00134 int channels; 00135 int lfe_ch; 00136 float downmix_coeffs[AC3_MAX_CHANNELS][2]; 00137 int downmixed; 00138 int output_mode; 00139 int out_channels; 00140 00141 00143 float dynamic_range[2]; 00144 00145 00147 int start_freq[AC3_MAX_CHANNELS]; 00148 int end_freq[AC3_MAX_CHANNELS]; 00149 00150 00152 int num_rematrixing_bands; 00153 int rematrixing_flags[4]; 00154 00155 00157 int num_exp_groups[AC3_MAX_CHANNELS]; 00158 int8_t dexps[AC3_MAX_CHANNELS][AC3_MAX_COEFS]; 00159 int exp_strategy[AC3_MAX_BLOCKS][AC3_MAX_CHANNELS]; 00160 00161 00163 AC3BitAllocParameters bit_alloc_params; 00164 int first_cpl_leak; 00165 int snr_offset[AC3_MAX_CHANNELS]; 00166 int fast_gain[AC3_MAX_CHANNELS]; 00167 uint8_t bap[AC3_MAX_CHANNELS][AC3_MAX_COEFS]; 00168 int16_t psd[AC3_MAX_CHANNELS][AC3_MAX_COEFS]; 00169 int16_t band_psd[AC3_MAX_CHANNELS][AC3_CRITICAL_BANDS]; 00170 int16_t mask[AC3_MAX_CHANNELS][AC3_CRITICAL_BANDS]; 00171 int dba_mode[AC3_MAX_CHANNELS]; 00172 int dba_nsegs[AC3_MAX_CHANNELS]; 00173 uint8_t dba_offsets[AC3_MAX_CHANNELS][8]; 00174 uint8_t dba_lengths[AC3_MAX_CHANNELS][8]; 00175 uint8_t dba_values[AC3_MAX_CHANNELS][8]; 00176 00177 00179 int dither_flag[AC3_MAX_CHANNELS]; 00180 AVLFG dith_state; 00181 00182 00184 int block_switch[AC3_MAX_CHANNELS]; 00185 FFTContext imdct_512; 00186 FFTContext imdct_256; 00187 00188 00190 DSPContext dsp; 00191 AC3DSPContext ac3dsp; 00192 FmtConvertContext fmt_conv; 00193 float mul_bias; 00194 00195 00197 DECLARE_ALIGNED(16, int, fixed_coeffs)[AC3_MAX_CHANNELS][AC3_MAX_COEFS]; 00198 DECLARE_ALIGNED(32, float, transform_coeffs)[AC3_MAX_CHANNELS][AC3_MAX_COEFS]; 00199 DECLARE_ALIGNED(32, float, delay)[AC3_MAX_CHANNELS][AC3_BLOCK_SIZE]; 00200 DECLARE_ALIGNED(32, float, window)[AC3_BLOCK_SIZE]; 00201 DECLARE_ALIGNED(32, float, tmp_output)[AC3_BLOCK_SIZE]; 00202 DECLARE_ALIGNED(32, float, output)[AC3_MAX_CHANNELS][AC3_BLOCK_SIZE]; 00203 00204 } AC3DecodeContext; 00205 00210 int ff_eac3_parse_header(AC3DecodeContext *s); 00211 00216 void ff_eac3_decode_transform_coeffs_aht_ch(AC3DecodeContext *s, int ch); 00217 00218 void ff_ac3_downmix_c(float (*samples)[256], float (*matrix)[2], 00219 int out_ch, int in_ch, int len); 00220 00226 void ff_eac3_apply_spectral_extension(AC3DecodeContext *s); 00227 00228 #endif /* AVCODEC_AC3DEC_H */