FFmpeg  1.2.12
ac3enc.h
Go to the documentation of this file.
1 /*
2  * AC-3 encoder & E-AC-3 encoder common header
3  * Copyright (c) 2000 Fabrice Bellard
4  * Copyright (c) 2006-2010 Justin Ruggles <justin.ruggles@gmail.com>
5  *
6  * This file is part of Libav.
7  *
8  * Libav is free software; you can redistribute it and/or
9  * modify it under the terms of the GNU Lesser General Public
10  * License as published by the Free Software Foundation; either
11  * version 2.1 of the License, or (at your option) any later version.
12  *
13  * Libav is distributed in the hope that it will be useful,
14  * but WITHOUT ANY WARRANTY; without even the implied warranty of
15  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
16  * Lesser General Public License for more details.
17  *
18  * You should have received a copy of the GNU Lesser General Public
19  * License along with Libav; if not, write to the Free Software
20  * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
21  */
22 
28 #ifndef AVCODEC_AC3ENC_H
29 #define AVCODEC_AC3ENC_H
30 
31 #include <stdint.h>
32 
33 #include "libavutil/float_dsp.h"
34 #include "ac3.h"
35 #include "ac3dsp.h"
36 #include "avcodec.h"
37 #include "dsputil.h"
38 #include "put_bits.h"
39 #include "fft.h"
40 
41 #ifndef CONFIG_AC3ENC_FLOAT
42 #define CONFIG_AC3ENC_FLOAT 0
43 #endif
44 
45 #define OFFSET(param) offsetof(AC3EncodeContext, options.param)
46 #define AC3ENC_PARAM (AV_OPT_FLAG_AUDIO_PARAM | AV_OPT_FLAG_ENCODING_PARAM)
47 
48 #define AC3ENC_TYPE_AC3_FIXED 0
49 #define AC3ENC_TYPE_AC3 1
50 #define AC3ENC_TYPE_EAC3 2
51 
52 #if CONFIG_AC3ENC_FLOAT
53 #define AC3_NAME(x) ff_ac3_float_ ## x
54 #define MAC_COEF(d,a,b) ((d)+=(a)*(b))
55 #define COEF_MIN (-16777215.0/16777216.0)
56 #define COEF_MAX ( 16777215.0/16777216.0)
57 #define NEW_CPL_COORD_THRESHOLD 0.03
58 typedef float SampleType;
59 typedef float CoefType;
60 typedef float CoefSumType;
61 #else
62 #define AC3_NAME(x) ff_ac3_fixed_ ## x
63 #define MAC_COEF(d,a,b) MAC64(d,a,b)
64 #define COEF_MIN -16777215
65 #define COEF_MAX 16777215
66 #define NEW_CPL_COORD_THRESHOLD 503317
67 typedef int16_t SampleType;
68 typedef int32_t CoefType;
69 typedef int64_t CoefSumType;
70 #endif
71 
72 /* common option values */
73 #define AC3ENC_OPT_NONE -1
74 #define AC3ENC_OPT_AUTO -1
75 #define AC3ENC_OPT_OFF 0
76 #define AC3ENC_OPT_ON 1
77 #define AC3ENC_OPT_NOT_INDICATED 0
78 #define AC3ENC_OPT_MODE_ON 2
79 #define AC3ENC_OPT_MODE_OFF 1
80 
81 /* specific option values */
82 #define AC3ENC_OPT_LARGE_ROOM 1
83 #define AC3ENC_OPT_SMALL_ROOM 2
84 #define AC3ENC_OPT_DOWNMIX_LTRT 1
85 #define AC3ENC_OPT_DOWNMIX_LORO 2
86 #define AC3ENC_OPT_ADCONV_STANDARD 0
87 #define AC3ENC_OPT_ADCONV_HDCD 1
88 
89 
93 typedef struct AC3EncOptions {
94  /* AC-3 metadata options*/
104  int original;
117 
118  /* other encoding options */
123 } AC3EncOptions;
124 
128 typedef struct AC3Block {
133  int16_t **psd;
134  int16_t **band_psd;
135  int16_t **mask;
136  uint16_t **qmant;
152 } AC3Block;
153 
157 typedef struct AC3EncodeContext {
167 
169 
171  int eac3;
174 
175  int bit_rate;
177 
183  uint16_t crc_inv[2];
184  int64_t bits_written;
185  int64_t samples_written;
186 
188  int channels;
189  int lfe_on;
195 
202 
203  int cutoff;
207 
208  int cpl_on;
213 
215 
216  /* bitrate allocation control */
229 
238  int16_t *psd_buffer;
239  int16_t *band_psd_buffer;
240  int16_t *mask_buffer;
241  int16_t *qmant_buffer;
244 
251 
252  /* fixed vs. float function pointers */
254  int (*mdct_init)(struct AC3EncodeContext *s);
255 
256  /* fixed vs. float templated function pointers */
258 
259  /* AC-3 vs. E-AC-3 function pointers */
262 
263 
264 extern const uint64_t ff_ac3_channel_layouts[19];
265 
267 
269 
271 
273 
275 
277 
279 
281 
283 
285 
286 void ff_ac3_output_frame(AC3EncodeContext *s, unsigned char *frame);
287 
288 
289 /* prototypes for functions in ac3enc_fixed.c and ac3enc_float.c */
290 
293 
296 
297 
298 /* prototypes for functions in ac3enc_template.c */
299 
302 
304  const AVFrame *frame, int *got_packet_ptr);
306  const AVFrame *frame, int *got_packet_ptr);
307 
308 #endif /* AVCODEC_AC3ENC_H */