Libav
|
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 FFmpeg. 00006 * 00007 * FFmpeg 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 * FFmpeg 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 FFmpeg; 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 "get_bits.h" 00056 #include "dsputil.h" 00057 #include "fft.h" 00058 00059 /* override ac3.h to include coupling channel */ 00060 #undef AC3_MAX_CHANNELS 00061 #define AC3_MAX_CHANNELS 7 00062 #define CPL_CH 0 00063 00064 #define AC3_OUTPUT_LFEON 8 00065 00066 #define AC3_MAX_COEFS 256 00067 #define AC3_BLOCK_SIZE 256 00068 #define MAX_BLOCKS 6 00069 #define SPX_MAX_BANDS 17 00070 00071 typedef struct { 00072 AVCodecContext *avctx; 00073 GetBitContext gbc; 00074 uint8_t *input_buffer; 00075 00078 int frame_type; 00079 int substreamid; 00080 int frame_size; 00081 int bit_rate; 00082 int sample_rate; 00083 int num_blocks; 00084 int channel_mode; 00085 int channel_layout; 00086 int lfe_on; 00087 int channel_map; 00088 int center_mix_level; 00089 int surround_mix_level; 00090 int eac3; 00091 00092 00094 int snr_offset_strategy; 00095 int block_switch_syntax; 00096 int dither_flag_syntax; 00097 int bit_allocation_syntax; 00098 int fast_gain_syntax; 00099 int dba_syntax; 00100 int skip_syntax; 00101 00102 00104 int cpl_in_use[MAX_BLOCKS]; 00105 int cpl_strategy_exists[MAX_BLOCKS]; 00106 int channel_in_cpl[AC3_MAX_CHANNELS]; 00107 int phase_flags_in_use; 00108 int phase_flags[18]; 00109 int num_cpl_bands; 00110 uint8_t cpl_band_sizes[18]; 00111 int firstchincpl; 00112 int first_cpl_coords[AC3_MAX_CHANNELS]; 00113 int cpl_coords[AC3_MAX_CHANNELS][18]; 00114 00115 00118 int spx_in_use; 00119 uint8_t channel_uses_spx[AC3_MAX_CHANNELS]; 00120 int8_t spx_atten_code[AC3_MAX_CHANNELS]; 00121 int spx_src_start_freq; 00122 int spx_dst_end_freq; 00123 int spx_dst_start_freq; 00124 00125 int num_spx_bands; 00126 uint8_t spx_band_sizes[SPX_MAX_BANDS]; 00127 uint8_t first_spx_coords[AC3_MAX_CHANNELS]; 00128 float spx_noise_blend[AC3_MAX_CHANNELS][SPX_MAX_BANDS]; 00129 float spx_signal_blend[AC3_MAX_CHANNELS][SPX_MAX_BANDS]; 00130 00131 00133 int channel_uses_aht[AC3_MAX_CHANNELS]; 00134 int pre_mantissa[AC3_MAX_CHANNELS][AC3_MAX_COEFS][MAX_BLOCKS]; 00135 00136 00138 int fbw_channels; 00139 int channels; 00140 int lfe_ch; 00141 float downmix_coeffs[AC3_MAX_CHANNELS][2]; 00142 int downmixed; 00143 int output_mode; 00144 int out_channels; 00145 00146 00148 float dynamic_range[2]; 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[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][50]; 00175 int16_t mask[AC3_MAX_CHANNELS][50]; 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 float add_bias; 00197 float mul_bias; 00198 00199 00201 DECLARE_ALIGNED(16, int, fixed_coeffs)[AC3_MAX_CHANNELS][AC3_MAX_COEFS]; 00202 DECLARE_ALIGNED(16, float, transform_coeffs)[AC3_MAX_CHANNELS][AC3_MAX_COEFS]; 00203 DECLARE_ALIGNED(16, float, delay)[AC3_MAX_CHANNELS][AC3_BLOCK_SIZE]; 00204 DECLARE_ALIGNED(16, float, window)[AC3_BLOCK_SIZE]; 00205 DECLARE_ALIGNED(16, float, tmp_output)[AC3_BLOCK_SIZE]; 00206 DECLARE_ALIGNED(16, float, output)[AC3_MAX_CHANNELS][AC3_BLOCK_SIZE]; 00207 00208 } AC3DecodeContext; 00209 00214 int ff_eac3_parse_header(AC3DecodeContext *s); 00215 00220 void ff_eac3_decode_transform_coeffs_aht_ch(AC3DecodeContext *s, int ch); 00221 00222 void ff_ac3_downmix_c(float (*samples)[256], float (*matrix)[2], 00223 int out_ch, int in_ch, int len); 00224 00230 void ff_eac3_apply_spectral_extension(AC3DecodeContext *s); 00231 00232 #endif /* AVCODEC_AC3DEC_H */