Mercurial > libavcodec.hg
annotate ac3dec.h @ 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 | |
children | 49afffc0dc60 |
rev | line source |
---|---|
7020
40a2db8dbaa2
move the decode context and some macro constants to a new file, ac3dec.h
jbr
parents:
diff
changeset
|
1 /* |
40a2db8dbaa2
move the decode context and some macro constants to a new file, ac3dec.h
jbr
parents:
diff
changeset
|
2 * Common code between AC3 and E-AC3 decoder |
40a2db8dbaa2
move the decode context and some macro constants to a new file, ac3dec.h
jbr
parents:
diff
changeset
|
3 * Copyright (c) 2007 Bartlomiej Wolowiec <bartek.wolowiec@gmail.com> |
40a2db8dbaa2
move the decode context and some macro constants to a new file, ac3dec.h
jbr
parents:
diff
changeset
|
4 * |
40a2db8dbaa2
move the decode context and some macro constants to a new file, ac3dec.h
jbr
parents:
diff
changeset
|
5 * This file is part of FFmpeg. |
40a2db8dbaa2
move the decode context and some macro constants to a new file, ac3dec.h
jbr
parents:
diff
changeset
|
6 * |
40a2db8dbaa2
move the decode context and some macro constants to a new file, ac3dec.h
jbr
parents:
diff
changeset
|
7 * FFmpeg is free software; you can redistribute it and/or |
40a2db8dbaa2
move the decode context and some macro constants to a new file, ac3dec.h
jbr
parents:
diff
changeset
|
8 * modify it under the terms of the GNU Lesser General Public |
40a2db8dbaa2
move the decode context and some macro constants to a new file, ac3dec.h
jbr
parents:
diff
changeset
|
9 * License as published by the Free Software Foundation; either |
40a2db8dbaa2
move the decode context and some macro constants to a new file, ac3dec.h
jbr
parents:
diff
changeset
|
10 * version 2.1 of the License, or (at your option) any later version. |
40a2db8dbaa2
move the decode context and some macro constants to a new file, ac3dec.h
jbr
parents:
diff
changeset
|
11 * |
40a2db8dbaa2
move the decode context and some macro constants to a new file, ac3dec.h
jbr
parents:
diff
changeset
|
12 * FFmpeg is distributed in the hope that it will be useful, |
40a2db8dbaa2
move the decode context and some macro constants to a new file, ac3dec.h
jbr
parents:
diff
changeset
|
13 * but WITHOUT ANY WARRANTY; without even the implied warranty of |
40a2db8dbaa2
move the decode context and some macro constants to a new file, ac3dec.h
jbr
parents:
diff
changeset
|
14 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU |
40a2db8dbaa2
move the decode context and some macro constants to a new file, ac3dec.h
jbr
parents:
diff
changeset
|
15 * Lesser General Public License for more details. |
40a2db8dbaa2
move the decode context and some macro constants to a new file, ac3dec.h
jbr
parents:
diff
changeset
|
16 * |
40a2db8dbaa2
move the decode context and some macro constants to a new file, ac3dec.h
jbr
parents:
diff
changeset
|
17 * You should have received a copy of the GNU Lesser General Public |
40a2db8dbaa2
move the decode context and some macro constants to a new file, ac3dec.h
jbr
parents:
diff
changeset
|
18 * License along with FFmpeg; if not, write to the Free Software |
40a2db8dbaa2
move the decode context and some macro constants to a new file, ac3dec.h
jbr
parents:
diff
changeset
|
19 * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA |
40a2db8dbaa2
move the decode context and some macro constants to a new file, ac3dec.h
jbr
parents:
diff
changeset
|
20 */ |
40a2db8dbaa2
move the decode context and some macro constants to a new file, ac3dec.h
jbr
parents:
diff
changeset
|
21 |
40a2db8dbaa2
move the decode context and some macro constants to a new file, ac3dec.h
jbr
parents:
diff
changeset
|
22 /** |
40a2db8dbaa2
move the decode context and some macro constants to a new file, ac3dec.h
jbr
parents:
diff
changeset
|
23 * @file ac3.h |
40a2db8dbaa2
move the decode context and some macro constants to a new file, ac3dec.h
jbr
parents:
diff
changeset
|
24 * Common code between AC3 and E-AC3 decoder. |
40a2db8dbaa2
move the decode context and some macro constants to a new file, ac3dec.h
jbr
parents:
diff
changeset
|
25 */ |
40a2db8dbaa2
move the decode context and some macro constants to a new file, ac3dec.h
jbr
parents:
diff
changeset
|
26 |
40a2db8dbaa2
move the decode context and some macro constants to a new file, ac3dec.h
jbr
parents:
diff
changeset
|
27 #ifndef FFMPEG_AC3DEC_H |
40a2db8dbaa2
move the decode context and some macro constants to a new file, ac3dec.h
jbr
parents:
diff
changeset
|
28 #define FFMPEG_AC3DEC_H |
40a2db8dbaa2
move the decode context and some macro constants to a new file, ac3dec.h
jbr
parents:
diff
changeset
|
29 |
40a2db8dbaa2
move the decode context and some macro constants to a new file, ac3dec.h
jbr
parents:
diff
changeset
|
30 #include "libavutil/random.h" |
40a2db8dbaa2
move the decode context and some macro constants to a new file, ac3dec.h
jbr
parents:
diff
changeset
|
31 #include "ac3tab.h" |
40a2db8dbaa2
move the decode context and some macro constants to a new file, ac3dec.h
jbr
parents:
diff
changeset
|
32 #include "ac3.h" |
40a2db8dbaa2
move the decode context and some macro constants to a new file, ac3dec.h
jbr
parents:
diff
changeset
|
33 #include "bitstream.h" |
40a2db8dbaa2
move the decode context and some macro constants to a new file, ac3dec.h
jbr
parents:
diff
changeset
|
34 #include "dsputil.h" |
40a2db8dbaa2
move the decode context and some macro constants to a new file, ac3dec.h
jbr
parents:
diff
changeset
|
35 |
40a2db8dbaa2
move the decode context and some macro constants to a new file, ac3dec.h
jbr
parents:
diff
changeset
|
36 /* override ac3.h to include coupling channel */ |
40a2db8dbaa2
move the decode context and some macro constants to a new file, ac3dec.h
jbr
parents:
diff
changeset
|
37 #undef AC3_MAX_CHANNELS |
40a2db8dbaa2
move the decode context and some macro constants to a new file, ac3dec.h
jbr
parents:
diff
changeset
|
38 #define AC3_MAX_CHANNELS 7 |
40a2db8dbaa2
move the decode context and some macro constants to a new file, ac3dec.h
jbr
parents:
diff
changeset
|
39 #define CPL_CH 0 |
40a2db8dbaa2
move the decode context and some macro constants to a new file, ac3dec.h
jbr
parents:
diff
changeset
|
40 |
40a2db8dbaa2
move the decode context and some macro constants to a new file, ac3dec.h
jbr
parents:
diff
changeset
|
41 #define AC3_OUTPUT_LFEON 8 |
40a2db8dbaa2
move the decode context and some macro constants to a new file, ac3dec.h
jbr
parents:
diff
changeset
|
42 |
40a2db8dbaa2
move the decode context and some macro constants to a new file, ac3dec.h
jbr
parents:
diff
changeset
|
43 typedef struct { |
40a2db8dbaa2
move the decode context and some macro constants to a new file, ac3dec.h
jbr
parents:
diff
changeset
|
44 int num_blocks; ///< number of audio blocks |
40a2db8dbaa2
move the decode context and some macro constants to a new file, ac3dec.h
jbr
parents:
diff
changeset
|
45 int channel_mode; ///< channel mode (acmod) |
40a2db8dbaa2
move the decode context and some macro constants to a new file, ac3dec.h
jbr
parents:
diff
changeset
|
46 int block_switch[AC3_MAX_CHANNELS]; ///< block switch flags |
40a2db8dbaa2
move the decode context and some macro constants to a new file, ac3dec.h
jbr
parents:
diff
changeset
|
47 int dither_flag[AC3_MAX_CHANNELS]; ///< dither flags |
40a2db8dbaa2
move the decode context and some macro constants to a new file, ac3dec.h
jbr
parents:
diff
changeset
|
48 int dither_all; ///< true if all channels are dithered |
40a2db8dbaa2
move the decode context and some macro constants to a new file, ac3dec.h
jbr
parents:
diff
changeset
|
49 int cpl_in_use; ///< coupling in use |
40a2db8dbaa2
move the decode context and some macro constants to a new file, ac3dec.h
jbr
parents:
diff
changeset
|
50 int channel_in_cpl[AC3_MAX_CHANNELS]; ///< channel in coupling |
40a2db8dbaa2
move the decode context and some macro constants to a new file, ac3dec.h
jbr
parents:
diff
changeset
|
51 int phase_flags_in_use; ///< phase flags in use |
40a2db8dbaa2
move the decode context and some macro constants to a new file, ac3dec.h
jbr
parents:
diff
changeset
|
52 int phase_flags[18]; ///< phase flags |
40a2db8dbaa2
move the decode context and some macro constants to a new file, ac3dec.h
jbr
parents:
diff
changeset
|
53 int cpl_band_struct[18]; ///< coupling band structure |
40a2db8dbaa2
move the decode context and some macro constants to a new file, ac3dec.h
jbr
parents:
diff
changeset
|
54 int num_rematrixing_bands; ///< number of rematrixing bands |
40a2db8dbaa2
move the decode context and some macro constants to a new file, ac3dec.h
jbr
parents:
diff
changeset
|
55 int rematrixing_flags[4]; ///< rematrixing flags |
40a2db8dbaa2
move the decode context and some macro constants to a new file, ac3dec.h
jbr
parents:
diff
changeset
|
56 int exp_strategy[AC3_MAX_CHANNELS]; ///< exponent strategies |
40a2db8dbaa2
move the decode context and some macro constants to a new file, ac3dec.h
jbr
parents:
diff
changeset
|
57 int snr_offset[AC3_MAX_CHANNELS]; ///< signal-to-noise ratio offsets |
40a2db8dbaa2
move the decode context and some macro constants to a new file, ac3dec.h
jbr
parents:
diff
changeset
|
58 int fast_gain[AC3_MAX_CHANNELS]; ///< fast gain values (signal-to-mask ratio) |
40a2db8dbaa2
move the decode context and some macro constants to a new file, ac3dec.h
jbr
parents:
diff
changeset
|
59 int dba_mode[AC3_MAX_CHANNELS]; ///< delta bit allocation mode |
40a2db8dbaa2
move the decode context and some macro constants to a new file, ac3dec.h
jbr
parents:
diff
changeset
|
60 int dba_nsegs[AC3_MAX_CHANNELS]; ///< number of delta segments |
40a2db8dbaa2
move the decode context and some macro constants to a new file, ac3dec.h
jbr
parents:
diff
changeset
|
61 uint8_t dba_offsets[AC3_MAX_CHANNELS][8]; ///< delta segment offsets |
40a2db8dbaa2
move the decode context and some macro constants to a new file, ac3dec.h
jbr
parents:
diff
changeset
|
62 uint8_t dba_lengths[AC3_MAX_CHANNELS][8]; ///< delta segment lengths |
40a2db8dbaa2
move the decode context and some macro constants to a new file, ac3dec.h
jbr
parents:
diff
changeset
|
63 uint8_t dba_values[AC3_MAX_CHANNELS][8]; ///< delta values for each segment |
40a2db8dbaa2
move the decode context and some macro constants to a new file, ac3dec.h
jbr
parents:
diff
changeset
|
64 |
40a2db8dbaa2
move the decode context and some macro constants to a new file, ac3dec.h
jbr
parents:
diff
changeset
|
65 int sample_rate; ///< sample frequency, in Hz |
40a2db8dbaa2
move the decode context and some macro constants to a new file, ac3dec.h
jbr
parents:
diff
changeset
|
66 int bit_rate; ///< stream bit rate, in bits-per-second |
40a2db8dbaa2
move the decode context and some macro constants to a new file, ac3dec.h
jbr
parents:
diff
changeset
|
67 int frame_type; ///< frame type (strmtyp) |
40a2db8dbaa2
move the decode context and some macro constants to a new file, ac3dec.h
jbr
parents:
diff
changeset
|
68 int substreamid; ///< substream identification |
40a2db8dbaa2
move the decode context and some macro constants to a new file, ac3dec.h
jbr
parents:
diff
changeset
|
69 int frame_size; ///< current frame size, in bytes |
40a2db8dbaa2
move the decode context and some macro constants to a new file, ac3dec.h
jbr
parents:
diff
changeset
|
70 |
40a2db8dbaa2
move the decode context and some macro constants to a new file, ac3dec.h
jbr
parents:
diff
changeset
|
71 int channels; ///< number of total channels |
40a2db8dbaa2
move the decode context and some macro constants to a new file, ac3dec.h
jbr
parents:
diff
changeset
|
72 int fbw_channels; ///< number of full-bandwidth channels |
40a2db8dbaa2
move the decode context and some macro constants to a new file, ac3dec.h
jbr
parents:
diff
changeset
|
73 int lfe_on; ///< lfe channel in use |
40a2db8dbaa2
move the decode context and some macro constants to a new file, ac3dec.h
jbr
parents:
diff
changeset
|
74 int lfe_ch; ///< index of LFE channel |
40a2db8dbaa2
move the decode context and some macro constants to a new file, ac3dec.h
jbr
parents:
diff
changeset
|
75 int output_mode; ///< output channel configuration |
40a2db8dbaa2
move the decode context and some macro constants to a new file, ac3dec.h
jbr
parents:
diff
changeset
|
76 int out_channels; ///< number of output channels |
40a2db8dbaa2
move the decode context and some macro constants to a new file, ac3dec.h
jbr
parents:
diff
changeset
|
77 |
40a2db8dbaa2
move the decode context and some macro constants to a new file, ac3dec.h
jbr
parents:
diff
changeset
|
78 int center_mix_level; ///< Center mix level index |
40a2db8dbaa2
move the decode context and some macro constants to a new file, ac3dec.h
jbr
parents:
diff
changeset
|
79 int surround_mix_level; ///< Surround mix level index |
40a2db8dbaa2
move the decode context and some macro constants to a new file, ac3dec.h
jbr
parents:
diff
changeset
|
80 float downmix_coeffs[AC3_MAX_CHANNELS][2]; ///< stereo downmix coefficients |
40a2db8dbaa2
move the decode context and some macro constants to a new file, ac3dec.h
jbr
parents:
diff
changeset
|
81 float downmix_coeff_adjust[2]; ///< adjustment needed for each output channel when downmixing |
40a2db8dbaa2
move the decode context and some macro constants to a new file, ac3dec.h
jbr
parents:
diff
changeset
|
82 float dynamic_range[2]; ///< dynamic range |
40a2db8dbaa2
move the decode context and some macro constants to a new file, ac3dec.h
jbr
parents:
diff
changeset
|
83 int cpl_coords[AC3_MAX_CHANNELS][18]; ///< coupling coordinates |
40a2db8dbaa2
move the decode context and some macro constants to a new file, ac3dec.h
jbr
parents:
diff
changeset
|
84 int num_cpl_bands; ///< number of coupling bands |
40a2db8dbaa2
move the decode context and some macro constants to a new file, ac3dec.h
jbr
parents:
diff
changeset
|
85 int num_cpl_subbands; ///< number of coupling sub bands |
40a2db8dbaa2
move the decode context and some macro constants to a new file, ac3dec.h
jbr
parents:
diff
changeset
|
86 int start_freq[AC3_MAX_CHANNELS]; ///< start frequency bin |
40a2db8dbaa2
move the decode context and some macro constants to a new file, ac3dec.h
jbr
parents:
diff
changeset
|
87 int end_freq[AC3_MAX_CHANNELS]; ///< end frequency bin |
40a2db8dbaa2
move the decode context and some macro constants to a new file, ac3dec.h
jbr
parents:
diff
changeset
|
88 AC3BitAllocParameters bit_alloc_params; ///< bit allocation parameters |
40a2db8dbaa2
move the decode context and some macro constants to a new file, ac3dec.h
jbr
parents:
diff
changeset
|
89 |
40a2db8dbaa2
move the decode context and some macro constants to a new file, ac3dec.h
jbr
parents:
diff
changeset
|
90 int num_exp_groups[AC3_MAX_CHANNELS]; ///< Number of exponent groups |
40a2db8dbaa2
move the decode context and some macro constants to a new file, ac3dec.h
jbr
parents:
diff
changeset
|
91 int8_t dexps[AC3_MAX_CHANNELS][256]; ///< decoded exponents |
40a2db8dbaa2
move the decode context and some macro constants to a new file, ac3dec.h
jbr
parents:
diff
changeset
|
92 uint8_t bap[AC3_MAX_CHANNELS][256]; ///< bit allocation pointers |
40a2db8dbaa2
move the decode context and some macro constants to a new file, ac3dec.h
jbr
parents:
diff
changeset
|
93 int16_t psd[AC3_MAX_CHANNELS][256]; ///< scaled exponents |
40a2db8dbaa2
move the decode context and some macro constants to a new file, ac3dec.h
jbr
parents:
diff
changeset
|
94 int16_t band_psd[AC3_MAX_CHANNELS][50]; ///< interpolated exponents |
40a2db8dbaa2
move the decode context and some macro constants to a new file, ac3dec.h
jbr
parents:
diff
changeset
|
95 int16_t mask[AC3_MAX_CHANNELS][50]; ///< masking curve values |
40a2db8dbaa2
move the decode context and some macro constants to a new file, ac3dec.h
jbr
parents:
diff
changeset
|
96 |
40a2db8dbaa2
move the decode context and some macro constants to a new file, ac3dec.h
jbr
parents:
diff
changeset
|
97 int fixed_coeffs[AC3_MAX_CHANNELS][256]; ///> fixed-point transform coefficients |
40a2db8dbaa2
move the decode context and some macro constants to a new file, ac3dec.h
jbr
parents:
diff
changeset
|
98 DECLARE_ALIGNED_16(float, transform_coeffs[AC3_MAX_CHANNELS][256]); ///< transform coefficients |
40a2db8dbaa2
move the decode context and some macro constants to a new file, ac3dec.h
jbr
parents:
diff
changeset
|
99 int downmixed; ///< indicates if coeffs are currently downmixed |
40a2db8dbaa2
move the decode context and some macro constants to a new file, ac3dec.h
jbr
parents:
diff
changeset
|
100 |
40a2db8dbaa2
move the decode context and some macro constants to a new file, ac3dec.h
jbr
parents:
diff
changeset
|
101 /* For IMDCT. */ |
40a2db8dbaa2
move the decode context and some macro constants to a new file, ac3dec.h
jbr
parents:
diff
changeset
|
102 MDCTContext imdct_512; ///< for 512 sample IMDCT |
40a2db8dbaa2
move the decode context and some macro constants to a new file, ac3dec.h
jbr
parents:
diff
changeset
|
103 MDCTContext imdct_256; ///< for 256 sample IMDCT |
40a2db8dbaa2
move the decode context and some macro constants to a new file, ac3dec.h
jbr
parents:
diff
changeset
|
104 DSPContext dsp; ///< for optimization |
40a2db8dbaa2
move the decode context and some macro constants to a new file, ac3dec.h
jbr
parents:
diff
changeset
|
105 float add_bias; ///< offset for float_to_int16 conversion |
40a2db8dbaa2
move the decode context and some macro constants to a new file, ac3dec.h
jbr
parents:
diff
changeset
|
106 float mul_bias; ///< scaling for float_to_int16 conversion |
40a2db8dbaa2
move the decode context and some macro constants to a new file, ac3dec.h
jbr
parents:
diff
changeset
|
107 |
40a2db8dbaa2
move the decode context and some macro constants to a new file, ac3dec.h
jbr
parents:
diff
changeset
|
108 DECLARE_ALIGNED_16(float, output[AC3_MAX_CHANNELS][256]); ///< output after imdct transform and windowing |
40a2db8dbaa2
move the decode context and some macro constants to a new file, ac3dec.h
jbr
parents:
diff
changeset
|
109 DECLARE_ALIGNED_16(short, int_output[AC3_MAX_CHANNELS-1][256]); ///< final 16-bit integer output |
40a2db8dbaa2
move the decode context and some macro constants to a new file, ac3dec.h
jbr
parents:
diff
changeset
|
110 DECLARE_ALIGNED_16(float, delay[AC3_MAX_CHANNELS][256]); ///< delay - added to the next block |
40a2db8dbaa2
move the decode context and some macro constants to a new file, ac3dec.h
jbr
parents:
diff
changeset
|
111 DECLARE_ALIGNED_16(float, tmp_imdct[256]); ///< temporary storage for imdct transform |
40a2db8dbaa2
move the decode context and some macro constants to a new file, ac3dec.h
jbr
parents:
diff
changeset
|
112 DECLARE_ALIGNED_16(float, tmp_output[512]); ///< temporary storage for output before windowing |
40a2db8dbaa2
move the decode context and some macro constants to a new file, ac3dec.h
jbr
parents:
diff
changeset
|
113 DECLARE_ALIGNED_16(float, window[256]); ///< window coefficients |
40a2db8dbaa2
move the decode context and some macro constants to a new file, ac3dec.h
jbr
parents:
diff
changeset
|
114 |
40a2db8dbaa2
move the decode context and some macro constants to a new file, ac3dec.h
jbr
parents:
diff
changeset
|
115 /* Miscellaneous. */ |
40a2db8dbaa2
move the decode context and some macro constants to a new file, ac3dec.h
jbr
parents:
diff
changeset
|
116 GetBitContext gbc; ///< bitstream reader |
40a2db8dbaa2
move the decode context and some macro constants to a new file, ac3dec.h
jbr
parents:
diff
changeset
|
117 AVRandomState dith_state; ///< for dither generation |
40a2db8dbaa2
move the decode context and some macro constants to a new file, ac3dec.h
jbr
parents:
diff
changeset
|
118 AVCodecContext *avctx; ///< parent context |
40a2db8dbaa2
move the decode context and some macro constants to a new file, ac3dec.h
jbr
parents:
diff
changeset
|
119 uint8_t *input_buffer; ///< temp buffer to prevent overread |
40a2db8dbaa2
move the decode context and some macro constants to a new file, ac3dec.h
jbr
parents:
diff
changeset
|
120 } AC3DecodeContext; |
40a2db8dbaa2
move the decode context and some macro constants to a new file, ac3dec.h
jbr
parents:
diff
changeset
|
121 |
40a2db8dbaa2
move the decode context and some macro constants to a new file, ac3dec.h
jbr
parents:
diff
changeset
|
122 #endif /* FFMPEG_AC3DEC_H */ |