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 00027 #ifndef AVCODEC_AC3DEC_H 00028 #define AVCODEC_AC3DEC_H 00029 00030 #include "libavutil/internal.h" 00031 #include "libavutil/lfg.h" 00032 #include "ac3.h" 00033 #include "bitstream.h" 00034 #include "dsputil.h" 00035 00036 /* override ac3.h to include coupling channel */ 00037 #undef AC3_MAX_CHANNELS 00038 #define AC3_MAX_CHANNELS 7 00039 #define CPL_CH 0 00040 00041 #define AC3_OUTPUT_LFEON 8 00042 00043 #define AC3_MAX_COEFS 256 00044 #define AC3_BLOCK_SIZE 256 00045 #define MAX_BLOCKS 6 00046 00047 typedef struct { 00048 AVCodecContext *avctx; 00049 GetBitContext gbc; 00050 uint8_t *input_buffer; 00051 00054 int frame_type; 00055 int substreamid; 00056 int frame_size; 00057 int bit_rate; 00058 int sample_rate; 00059 int num_blocks; 00060 int channel_mode; 00061 int lfe_on; 00062 int channel_map; 00063 int center_mix_level; 00064 int surround_mix_level; 00065 int eac3; 00066 00067 00069 int snr_offset_strategy; 00070 int block_switch_syntax; 00071 int dither_flag_syntax; 00072 int bit_allocation_syntax; 00073 int fast_gain_syntax; 00074 int dba_syntax; 00075 int skip_syntax; 00076 00077 00079 int cpl_in_use[MAX_BLOCKS]; 00080 int cpl_strategy_exists[MAX_BLOCKS]; 00081 int channel_in_cpl[AC3_MAX_CHANNELS]; 00082 int phase_flags_in_use; 00083 int phase_flags[18]; 00084 int num_cpl_subbands; 00085 int num_cpl_bands; 00086 uint8_t cpl_band_struct[18]; 00087 int firstchincpl; 00088 int first_cpl_coords[AC3_MAX_CHANNELS]; 00089 int cpl_coords[AC3_MAX_CHANNELS][18]; 00090 00091 00093 int channel_uses_aht[AC3_MAX_CHANNELS]; 00094 int pre_mantissa[AC3_MAX_CHANNELS][AC3_MAX_COEFS][MAX_BLOCKS]; 00095 00096 00098 int fbw_channels; 00099 int channels; 00100 int lfe_ch; 00101 float downmix_coeffs[AC3_MAX_CHANNELS][2]; 00102 int downmixed; 00103 int output_mode; 00104 int out_channels; 00105 00106 00108 float dynamic_range[2]; 00109 00110 00112 int start_freq[AC3_MAX_CHANNELS]; 00113 int end_freq[AC3_MAX_CHANNELS]; 00114 00115 00117 int num_rematrixing_bands; 00118 int rematrixing_flags[4]; 00119 00120 00122 int num_exp_groups[AC3_MAX_CHANNELS]; 00123 int8_t dexps[AC3_MAX_CHANNELS][AC3_MAX_COEFS]; 00124 int exp_strategy[MAX_BLOCKS][AC3_MAX_CHANNELS]; 00125 00126 00128 AC3BitAllocParameters bit_alloc_params; 00129 int first_cpl_leak; 00130 int snr_offset[AC3_MAX_CHANNELS]; 00131 int fast_gain[AC3_MAX_CHANNELS]; 00132 uint8_t bap[AC3_MAX_CHANNELS][AC3_MAX_COEFS]; 00133 int16_t psd[AC3_MAX_CHANNELS][AC3_MAX_COEFS]; 00134 int16_t band_psd[AC3_MAX_CHANNELS][50]; 00135 int16_t mask[AC3_MAX_CHANNELS][50]; 00136 int dba_mode[AC3_MAX_CHANNELS]; 00137 int dba_nsegs[AC3_MAX_CHANNELS]; 00138 uint8_t dba_offsets[AC3_MAX_CHANNELS][8]; 00139 uint8_t dba_lengths[AC3_MAX_CHANNELS][8]; 00140 uint8_t dba_values[AC3_MAX_CHANNELS][8]; 00141 00142 00144 int dither_flag[AC3_MAX_CHANNELS]; 00145 AVLFG dith_state; 00146 00147 00149 int block_switch[AC3_MAX_CHANNELS]; 00150 MDCTContext imdct_512; 00151 MDCTContext imdct_256; 00152 00153 00155 DSPContext dsp; 00156 float add_bias; 00157 float mul_bias; 00158 00159 00160 DECLARE_ALIGNED_16(int, fixed_coeffs[AC3_MAX_CHANNELS][AC3_MAX_COEFS]); 00161 00163 DECLARE_ALIGNED_16(float, transform_coeffs[AC3_MAX_CHANNELS][AC3_MAX_COEFS]); 00164 DECLARE_ALIGNED_16(float, delay[AC3_MAX_CHANNELS][AC3_BLOCK_SIZE]); 00165 DECLARE_ALIGNED_16(float, window[AC3_BLOCK_SIZE]); 00166 DECLARE_ALIGNED_16(float, tmp_output[AC3_BLOCK_SIZE]); 00167 DECLARE_ALIGNED_16(float, output[AC3_MAX_CHANNELS][AC3_BLOCK_SIZE]); 00168 00169 } AC3DecodeContext; 00170 00175 int ff_eac3_parse_header(AC3DecodeContext *s); 00176 00181 void ff_eac3_decode_transform_coeffs_aht_ch(AC3DecodeContext *s, int ch); 00182 00183 #endif /* AVCODEC_AC3DEC_H */