2
2
* Common code between the AC-3 encoder and decoder
3
3
* Copyright (c) 2000, 2001, 2002 Fabrice Bellard
5
* This file is part of FFmpeg.
5
* This file is part of Libav.
7
* FFmpeg is free software; you can redistribute it and/or
7
* Libav is free software; you can redistribute it and/or
8
8
* modify it under the terms of the GNU Lesser General Public
9
9
* License as published by the Free Software Foundation; either
10
10
* version 2.1 of the License, or (at your option) any later version.
12
* FFmpeg is distributed in the hope that it will be useful,
12
* Libav is distributed in the hope that it will be useful,
13
13
* but WITHOUT ANY WARRANTY; without even the implied warranty of
14
14
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
15
15
* Lesser General Public License for more details.
17
17
* You should have received a copy of the GNU Lesser General Public
18
* License along with FFmpeg; if not, write to the Free Software
18
* License along with Libav; if not, write to the Free Software
19
19
* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
27
27
#ifndef AVCODEC_AC3_H
28
28
#define AVCODEC_AC3_H
32
30
#define AC3_MAX_CODED_FRAME_SIZE 3840 /* in bytes */
33
31
#define AC3_MAX_CHANNELS 6 /* including LFE channel */
35
#define NB_BLOCKS 6 /* number of PCM blocks inside an AC-3 frame */
36
#define AC3_FRAME_SIZE (NB_BLOCKS * 256)
33
#define AC3_MAX_COEFS 256
34
#define AC3_BLOCK_SIZE 256
35
#define AC3_MAX_BLOCKS 6
36
#define AC3_FRAME_SIZE (AC3_MAX_BLOCKS * 256)
37
#define AC3_WINDOW_SIZE (AC3_BLOCK_SIZE * 2)
38
#define AC3_CRITICAL_BANDS 50
39
#define AC3_MAX_CPL_BANDS 18
38
43
/* exponent encoding strategy */
39
44
#define EXP_REUSE 0
51
/* pre-defined gain values */
52
#define LEVEL_PLUS_3DB 1.4142135623730950
53
#define LEVEL_PLUS_1POINT5DB 1.1892071150027209
54
#define LEVEL_MINUS_1POINT5DB 0.8408964152537145
55
#define LEVEL_MINUS_3DB 0.7071067811865476
56
#define LEVEL_MINUS_4POINT5DB 0.5946035575013605
57
#define LEVEL_MINUS_6DB 0.5000000000000000
58
#define LEVEL_MINUS_9DB 0.3535533905932738
59
#define LEVEL_ZERO 0.0000000000000000
60
#define LEVEL_ONE 1.0000000000000000
46
62
/** Delta bit allocation strategy */
111
128
EAC3_FRAME_TYPE_RESERVED
114
void ac3_common_init(void);
131
void ff_ac3_common_init(void);
117
* Calculates the log power-spectral density of the input signal.
134
* Calculate the log power-spectral density of the input signal.
118
135
* This gives a rough estimate of signal power in the frequency domain by using
119
136
* the spectral envelope (exponents). The psd is also separately grouped
120
137
* into critical bands for use in the calculating the masking curve.
131
148
int16_t *band_psd);
134
* Calculates the masking curve.
151
* Calculate the masking curve.
135
152
* First, the excitation is calculated using parameters in s and the signal
136
153
* power in each critical band. The excitation is compared with a predefined
137
154
* hearing threshold table to produce the masking curve. If delta bit
158
175
uint8_t *dba_lengths, uint8_t *dba_values,
162
* Calculates bit allocation pointers.
163
* The SNR is the difference between the masking curve and the signal. AC-3
164
* uses this value for each frequency bin to allocate bits. The snroffset
165
* parameter is a global adjustment to the SNR for all bins.
167
* @param[in] mask masking curve
168
* @param[in] psd signal power for each frequency bin
169
* @param[in] start starting bin location
170
* @param[in] end ending bin location
171
* @param[in] snr_offset SNR adjustment
172
* @param[in] floor noise floor
173
* @param[in] bap_tab look-up table for bit allocation pointers
174
* @param[out] bap bit allocation pointers
176
void ff_ac3_bit_alloc_calc_bap(int16_t *mask, int16_t *psd, int start, int end,
177
int snr_offset, int floor,
178
const uint8_t *bap_tab, uint8_t *bap);
180
void ac3_parametric_bit_allocation(AC3BitAllocParameters *s, uint8_t *bap,
181
int8_t *exp, int start, int end,
182
int snr_offset, int fast_gain, int is_lfe,
183
int dba_mode, int dba_nsegs,
184
uint8_t *dba_offsets, uint8_t *dba_lengths,
185
uint8_t *dba_values);
187
178
#endif /* AVCODEC_AC3_H */