Mercurial > libavcodec.hg
comparison ac3dec.c @ 7020:40a2db8dbaa2 libavcodec
move the decode context and some macro constants to a new file, ac3dec.h
author | jbr |
---|---|
date | Sat, 07 Jun 2008 22:30:16 +0000 |
parents | 81d5c68233e5 |
children | 4bd2ccb0619e |
comparison
equal
deleted
inserted
replaced
7019:81d5c68233e5 | 7020:40a2db8dbaa2 |
---|---|
36 #include "libavutil/random.h" | 36 #include "libavutil/random.h" |
37 #include "avcodec.h" | 37 #include "avcodec.h" |
38 #include "ac3_parser.h" | 38 #include "ac3_parser.h" |
39 #include "bitstream.h" | 39 #include "bitstream.h" |
40 #include "dsputil.h" | 40 #include "dsputil.h" |
41 #include "ac3dec.h" | |
41 | 42 |
42 /** Maximum possible frame size when the specification limit is ignored */ | 43 /** Maximum possible frame size when the specification limit is ignored */ |
43 #define AC3_MAX_FRAME_SIZE 21695 | 44 #define AC3_MAX_FRAME_SIZE 21695 |
44 | 45 |
45 /** | 46 /** |
118 { { 2, 7 }, { 7, 2 }, { 6, 6 }, }, | 119 { { 2, 7 }, { 7, 2 }, { 6, 6 }, }, |
119 { { 2, 7 }, { 5, 5 }, { 7, 2 }, { 8, 8 }, }, | 120 { { 2, 7 }, { 5, 5 }, { 7, 2 }, { 8, 8 }, }, |
120 { { 2, 7 }, { 7, 2 }, { 6, 7 }, { 7, 6 }, }, | 121 { { 2, 7 }, { 7, 2 }, { 6, 7 }, { 7, 6 }, }, |
121 { { 2, 7 }, { 5, 5 }, { 7, 2 }, { 6, 7 }, { 7, 6 }, }, | 122 { { 2, 7 }, { 5, 5 }, { 7, 2 }, { 6, 7 }, { 7, 6 }, }, |
122 }; | 123 }; |
123 | |
124 /* override ac3.h to include coupling channel */ | |
125 #undef AC3_MAX_CHANNELS | |
126 #define AC3_MAX_CHANNELS 7 | |
127 #define CPL_CH 0 | |
128 | |
129 #define AC3_OUTPUT_LFEON 8 | |
130 | |
131 typedef struct { | |
132 int num_blocks; ///< number of audio blocks | |
133 int channel_mode; ///< channel mode (acmod) | |
134 int block_switch[AC3_MAX_CHANNELS]; ///< block switch flags | |
135 int dither_flag[AC3_MAX_CHANNELS]; ///< dither flags | |
136 int dither_all; ///< true if all channels are dithered | |
137 int cpl_in_use; ///< coupling in use | |
138 int channel_in_cpl[AC3_MAX_CHANNELS]; ///< channel in coupling | |
139 int phase_flags_in_use; ///< phase flags in use | |
140 int phase_flags[18]; ///< phase flags | |
141 int cpl_band_struct[18]; ///< coupling band structure | |
142 int num_rematrixing_bands; ///< number of rematrixing bands | |
143 int rematrixing_flags[4]; ///< rematrixing flags | |
144 int exp_strategy[AC3_MAX_CHANNELS]; ///< exponent strategies | |
145 int snr_offset[AC3_MAX_CHANNELS]; ///< signal-to-noise ratio offsets | |
146 int fast_gain[AC3_MAX_CHANNELS]; ///< fast gain values (signal-to-mask ratio) | |
147 int dba_mode[AC3_MAX_CHANNELS]; ///< delta bit allocation mode | |
148 int dba_nsegs[AC3_MAX_CHANNELS]; ///< number of delta segments | |
149 uint8_t dba_offsets[AC3_MAX_CHANNELS][8]; ///< delta segment offsets | |
150 uint8_t dba_lengths[AC3_MAX_CHANNELS][8]; ///< delta segment lengths | |
151 uint8_t dba_values[AC3_MAX_CHANNELS][8]; ///< delta values for each segment | |
152 | |
153 int sample_rate; ///< sample frequency, in Hz | |
154 int bit_rate; ///< stream bit rate, in bits-per-second | |
155 int frame_type; ///< frame type (strmtyp) | |
156 int substreamid; ///< substream identification | |
157 int frame_size; ///< current frame size, in bytes | |
158 | |
159 int channels; ///< number of total channels | |
160 int fbw_channels; ///< number of full-bandwidth channels | |
161 int lfe_on; ///< lfe channel in use | |
162 int lfe_ch; ///< index of LFE channel | |
163 int output_mode; ///< output channel configuration | |
164 int out_channels; ///< number of output channels | |
165 | |
166 int center_mix_level; ///< Center mix level index | |
167 int surround_mix_level; ///< Surround mix level index | |
168 float downmix_coeffs[AC3_MAX_CHANNELS][2]; ///< stereo downmix coefficients | |
169 float downmix_coeff_adjust[2]; ///< adjustment needed for each output channel when downmixing | |
170 float dynamic_range[2]; ///< dynamic range | |
171 int cpl_coords[AC3_MAX_CHANNELS][18]; ///< coupling coordinates | |
172 int num_cpl_bands; ///< number of coupling bands | |
173 int num_cpl_subbands; ///< number of coupling sub bands | |
174 int start_freq[AC3_MAX_CHANNELS]; ///< start frequency bin | |
175 int end_freq[AC3_MAX_CHANNELS]; ///< end frequency bin | |
176 AC3BitAllocParameters bit_alloc_params; ///< bit allocation parameters | |
177 | |
178 int num_exp_groups[AC3_MAX_CHANNELS]; ///< Number of exponent groups | |
179 int8_t dexps[AC3_MAX_CHANNELS][256]; ///< decoded exponents | |
180 uint8_t bap[AC3_MAX_CHANNELS][256]; ///< bit allocation pointers | |
181 int16_t psd[AC3_MAX_CHANNELS][256]; ///< scaled exponents | |
182 int16_t band_psd[AC3_MAX_CHANNELS][50]; ///< interpolated exponents | |
183 int16_t mask[AC3_MAX_CHANNELS][50]; ///< masking curve values | |
184 | |
185 int fixed_coeffs[AC3_MAX_CHANNELS][256]; ///> fixed-point transform coefficients | |
186 DECLARE_ALIGNED_16(float, transform_coeffs[AC3_MAX_CHANNELS][256]); ///< transform coefficients | |
187 int downmixed; ///< indicates if coeffs are currently downmixed | |
188 | |
189 /* For IMDCT. */ | |
190 MDCTContext imdct_512; ///< for 512 sample IMDCT | |
191 MDCTContext imdct_256; ///< for 256 sample IMDCT | |
192 DSPContext dsp; ///< for optimization | |
193 float add_bias; ///< offset for float_to_int16 conversion | |
194 float mul_bias; ///< scaling for float_to_int16 conversion | |
195 | |
196 DECLARE_ALIGNED_16(float, output[AC3_MAX_CHANNELS][256]); ///< output after imdct transform and windowing | |
197 DECLARE_ALIGNED_16(short, int_output[AC3_MAX_CHANNELS-1][256]); ///< final 16-bit integer output | |
198 DECLARE_ALIGNED_16(float, delay[AC3_MAX_CHANNELS][256]); ///< delay - added to the next block | |
199 DECLARE_ALIGNED_16(float, tmp_imdct[256]); ///< temporary storage for imdct transform | |
200 DECLARE_ALIGNED_16(float, tmp_output[512]); ///< temporary storage for output before windowing | |
201 DECLARE_ALIGNED_16(float, window[256]); ///< window coefficients | |
202 | |
203 /* Miscellaneous. */ | |
204 GetBitContext gbc; ///< bitstream reader | |
205 AVRandomState dith_state; ///< for dither generation | |
206 AVCodecContext *avctx; ///< parent context | |
207 uint8_t *input_buffer; ///< temp buffer to prevent overread | |
208 } AC3DecodeContext; | |
209 | 124 |
210 /** | 125 /** |
211 * Symmetrical Dequantization | 126 * Symmetrical Dequantization |
212 * reference: Section 7.3.3 Expansion of Mantissas for Symmetrical Quantization | 127 * reference: Section 7.3.3 Expansion of Mantissas for Symmetrical Quantization |
213 * Tables 7.19 to 7.23 | 128 * Tables 7.19 to 7.23 |