~ubuntu-branches/ubuntu/oneiric/libav/oneiric

« back to all changes in this revision

Viewing changes to libavcodec/ac3.h

  • Committer: Bazaar Package Importer
  • Author(s): Reinhard Tartler
  • Date: 2011-04-30 14:27:42 UTC
  • mfrom: (1.1.2 experimental)
  • Revision ID: james.westby@ubuntu.com-20110430142742-quvblxk1tj6adlh5
Tags: 4:0.7~b1-1ubuntu1
* Merge from debian. Remaining changes:
  - don't build against libfaad, libdirac, librtmp and libopenjpeg
    (all in universe)
  - explicitly --enable-pic on powerpc, cf. LP #654666
  - different arm configure bits that should probably better be
    merged into debian
* Cherry-picked from git: 
  - install doc/APIChanges and refer to them in NEWS.Debian (Closes: #623682)
  - don't try to install non-existing documentation, fixes FTBFS on powerpc

Show diffs side-by-side

added added

removed removed

Lines of Context:
2
2
 * Common code between the AC-3 encoder and decoder
3
3
 * Copyright (c) 2000, 2001, 2002 Fabrice Bellard
4
4
 *
5
 
 * This file is part of FFmpeg.
 
5
 * This file is part of Libav.
6
6
 *
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.
11
11
 *
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.
16
16
 *
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
20
20
 */
21
21
 
27
27
#ifndef AVCODEC_AC3_H
28
28
#define AVCODEC_AC3_H
29
29
 
30
 
#include "ac3tab.h"
31
 
 
32
30
#define AC3_MAX_CODED_FRAME_SIZE 3840 /* in bytes */
33
31
#define AC3_MAX_CHANNELS 6 /* including LFE channel */
34
32
 
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
 
40
 
 
41
#include "ac3tab.h"
37
42
 
38
43
/* exponent encoding strategy */
39
44
#define EXP_REUSE 0
43
48
#define EXP_D25   2
44
49
#define EXP_D45   3
45
50
 
 
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
 
61
 
46
62
/** Delta bit allocation strategy */
47
63
typedef enum {
48
64
    DBA_REUSE = 0,
82
98
    uint16_t crc1;
83
99
    uint8_t sr_code;
84
100
    uint8_t bitstream_id;
 
101
    uint8_t bitstream_mode;
85
102
    uint8_t channel_mode;
86
103
    uint8_t lfe_on;
87
104
    uint8_t frame_type;
111
128
    EAC3_FRAME_TYPE_RESERVED
112
129
} EAC3FrameType;
113
130
 
114
 
void ac3_common_init(void);
 
131
void ff_ac3_common_init(void);
115
132
 
116
133
/**
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);
132
149
 
133
150
/**
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,
159
176
                               int16_t *mask);
160
177
 
161
 
/**
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.
166
 
 *
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
175
 
 */
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);
179
 
 
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);
186
 
 
187
178
#endif /* AVCODEC_AC3_H */