summaryrefslogtreecommitdiff
path: root/audio_codec/libflac/avcodec.h (plain)
blob: 1bdcb3c35d4303cbe560d527b60a53a3e66c698f
1/*
2 * copyright (c) 2001 Fabrice Bellard
3 *
4 * This file is part of FFmpeg.
5 *
6 * FFmpeg is free software; you can redistribute it and/or
7 * modify it under the terms of the GNU Lesser General Public
8 * License as published by the Free Software Foundation; either
9 * version 2.1 of the License, or (at your option) any later version.
10 *
11 * FFmpeg is distributed in the hope that it will be useful,
12 * but WITHOUT ANY WARRANTY; without even the implied warranty of
13 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
14 * Lesser General Public License for more details.
15 *
16 * You should have received a copy of the GNU Lesser General Public
17 * License along with FFmpeg; if not, write to the Free Software
18 * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
19 */
20
21#ifndef AVCODEC_AVCODEC_H
22#define AVCODEC_AVCODEC_H
23
24#ifndef __MW__
25#include <inttypes.h>
26#else
27#include <core/types.h>
28#endif
29
30
31#define FF_INPUT_BUFFER_PADDING_SIZE 8
32
33enum CodecID {
34 CODEC_ID_NONE,
35
36 /* various PCM "codecs" */
37 CODEC_ID_PCM_S16LE = 0x10000,
38 CODEC_ID_PCM_S16BE,
39 CODEC_ID_PCM_U16LE,
40 CODEC_ID_PCM_U16BE,
41 CODEC_ID_PCM_S8,
42 CODEC_ID_PCM_U8,
43 CODEC_ID_PCM_MULAW,
44 CODEC_ID_PCM_ALAW,
45 CODEC_ID_PCM_S32LE,
46 CODEC_ID_PCM_S32BE,
47 CODEC_ID_PCM_U32LE,
48 CODEC_ID_PCM_U32BE,
49 CODEC_ID_PCM_S24LE,
50 CODEC_ID_PCM_S24BE,
51 CODEC_ID_PCM_U24LE,
52 CODEC_ID_PCM_U24BE,
53 CODEC_ID_PCM_S24DAUD,
54 CODEC_ID_PCM_ZORK,
55 CODEC_ID_PCM_S16LE_PLANAR,
56 CODEC_ID_PCM_DVD,
57 CODEC_ID_PCM_F32BE,
58 CODEC_ID_PCM_F32LE,
59 CODEC_ID_PCM_F64BE,
60 CODEC_ID_PCM_F64LE,
61 CODEC_ID_PCM_BLURAY,
62
63 /* various ADPCM codecs */
64 CODEC_ID_ADPCM_IMA_QT = 0x11000,
65 CODEC_ID_ADPCM_IMA_WAV,
66 CODEC_ID_ADPCM_IMA_DK3,
67 CODEC_ID_ADPCM_IMA_DK4,
68 CODEC_ID_ADPCM_IMA_WS,
69 CODEC_ID_ADPCM_IMA_SMJPEG,
70 CODEC_ID_ADPCM_MS,
71 CODEC_ID_ADPCM_4XM,
72 CODEC_ID_ADPCM_XA,
73 CODEC_ID_ADPCM_ADX,
74 CODEC_ID_ADPCM_EA,
75 CODEC_ID_ADPCM_G726,
76 CODEC_ID_ADPCM_CT,
77 CODEC_ID_ADPCM_SWF,
78 CODEC_ID_ADPCM_YAMAHA,
79 CODEC_ID_ADPCM_SBPRO_4,
80 CODEC_ID_ADPCM_SBPRO_3,
81 CODEC_ID_ADPCM_SBPRO_2,
82 CODEC_ID_ADPCM_THP,
83 CODEC_ID_ADPCM_IMA_AMV,
84 CODEC_ID_ADPCM_EA_R1,
85 CODEC_ID_ADPCM_EA_R3,
86 CODEC_ID_ADPCM_EA_R2,
87 CODEC_ID_ADPCM_IMA_EA_SEAD,
88 CODEC_ID_ADPCM_IMA_EA_EACS,
89 CODEC_ID_ADPCM_EA_XAS,
90 CODEC_ID_ADPCM_EA_MAXIS_XA,
91 CODEC_ID_ADPCM_IMA_ISS,
92
93 /* AMR */
94 CODEC_ID_AMR_NB = 0x12000,
95 CODEC_ID_AMR_WB,
96
97 /* RealAudio codecs*/
98 CODEC_ID_RA_144 = 0x13000,
99 CODEC_ID_RA_288,
100
101 /* various DPCM codecs */
102 CODEC_ID_ROQ_DPCM = 0x14000,
103 CODEC_ID_INTERPLAY_DPCM,
104 CODEC_ID_XAN_DPCM,
105 CODEC_ID_SOL_DPCM,
106
107 /* audio codecs */
108 CODEC_ID_MP2 = 0x15000,
109 CODEC_ID_MP3, ///< preferred ID for decoding MPEG audio layer 1, 2 or 3
110 CODEC_ID_AAC,
111 CODEC_ID_AC3,
112 CODEC_ID_DTS,
113 CODEC_ID_VORBIS,
114 CODEC_ID_DVAUDIO,
115 CODEC_ID_WMAV1,
116 CODEC_ID_WMAV2,
117 CODEC_ID_MACE3,
118 CODEC_ID_MACE6,
119 CODEC_ID_VMDAUDIO,
120 CODEC_ID_SONIC,
121 CODEC_ID_SONIC_LS,
122 CODEC_ID_FLAC,
123 CODEC_ID_MP3ADU,
124 CODEC_ID_MP3ON4,
125 CODEC_ID_SHORTEN,
126 CODEC_ID_ALAC,
127 CODEC_ID_WESTWOOD_SND1,
128 CODEC_ID_GSM, ///< as in Berlin toast format
129 CODEC_ID_QDM2,
130 CODEC_ID_COOK,
131 CODEC_ID_TRUESPEECH,
132 CODEC_ID_TTA,
133 CODEC_ID_SMACKAUDIO,
134 CODEC_ID_QCELP,
135 CODEC_ID_WAVPACK,
136 CODEC_ID_DSICINAUDIO,
137 CODEC_ID_IMC,
138 CODEC_ID_MUSEPACK7,
139 CODEC_ID_MLP,
140 CODEC_ID_GSM_MS, /* as found in WAV */
141 CODEC_ID_ATRAC3,
142 CODEC_ID_VOXWARE,
143 CODEC_ID_APE,
144 CODEC_ID_NELLYMOSER,
145 CODEC_ID_MUSEPACK8,
146 CODEC_ID_SPEEX,
147 CODEC_ID_WMAVOICE,
148 CODEC_ID_WMAPRO,
149 CODEC_ID_WMALOSSLESS,
150 CODEC_ID_ATRAC3P,
151 CODEC_ID_EAC3,
152 CODEC_ID_SIPR,
153 CODEC_ID_MP1,
154 CODEC_ID_TWINVQ,
155 CODEC_ID_TRUEHD,
156 CODEC_ID_MP4ALS,
157 CODEC_ID_ATRAC1,
158
159 /* subtitle codecs */
160 CODEC_ID_DVD_SUBTITLE = 0x17000,
161 CODEC_ID_DVB_SUBTITLE,
162 CODEC_ID_TEXT, ///< raw UTF-8 text
163 CODEC_ID_XSUB,
164 CODEC_ID_SSA,
165 CODEC_ID_MOV_TEXT,
166 CODEC_ID_HDMV_PGS_SUBTITLE,
167 CODEC_ID_DVB_TELETEXT,
168
169 /* other specific kind of codecs (generally used for attachments) */
170 CODEC_ID_TTF = 0x18000,
171
172 CODEC_ID_PROBE = 0x19000, ///< codec_id is not known (like CODEC_ID_NONE) but lavf should attempt to identify it
173
174 CODEC_ID_MPEG2TS = 0x20000, /**< _FAKE_ codec to indicate a raw MPEG-2 TS
175 * stream (only used by libavformat) */
176};
177
178enum SampleFormat {
179 SAMPLE_FMT_NONE = -1,
180 SAMPLE_FMT_U8, ///< unsigned 8 bits
181 SAMPLE_FMT_S16, ///< signed 16 bits
182 SAMPLE_FMT_S32, ///< signed 32 bits
183 SAMPLE_FMT_FLT, ///< float
184 SAMPLE_FMT_DBL, ///< double
185 SAMPLE_FMT_NB ///< Number of sample formats. DO NOT USE if dynamically linking to libavcodec
186};
187
188enum CodecType {
189 CODEC_TYPE_UNKNOWN = -1,
190 CODEC_TYPE_VIDEO,
191 CODEC_TYPE_AUDIO,
192 CODEC_TYPE_DATA,
193 CODEC_TYPE_SUBTITLE,
194 CODEC_TYPE_ATTACHMENT,
195 CODEC_TYPE_NB
196};
197
198/* Audio channel masks */
199#define CH_FRONT_LEFT 0x00000001
200#define CH_FRONT_RIGHT 0x00000002
201#define CH_FRONT_CENTER 0x00000004
202#define CH_LOW_FREQUENCY 0x00000008
203#define CH_BACK_LEFT 0x00000010
204#define CH_BACK_RIGHT 0x00000020
205#define CH_FRONT_LEFT_OF_CENTER 0x00000040
206#define CH_FRONT_RIGHT_OF_CENTER 0x00000080
207#define CH_BACK_CENTER 0x00000100
208#define CH_SIDE_LEFT 0x00000200
209#define CH_SIDE_RIGHT 0x00000400
210#define CH_TOP_CENTER 0x00000800
211#define CH_TOP_FRONT_LEFT 0x00001000
212#define CH_TOP_FRONT_CENTER 0x00002000
213#define CH_TOP_FRONT_RIGHT 0x00004000
214#define CH_TOP_BACK_LEFT 0x00008000
215#define CH_TOP_BACK_CENTER 0x00010000
216#define CH_TOP_BACK_RIGHT 0x00020000
217#define CH_STEREO_LEFT 0x20000000 ///< Stereo downmix.
218#define CH_STEREO_RIGHT 0x40000000 ///< See CH_STEREO_LEFT.
219
220/* Audio channel convenience macros */
221#define CH_LAYOUT_MONO (CH_FRONT_CENTER)
222#define CH_LAYOUT_STEREO (CH_FRONT_LEFT|CH_FRONT_RIGHT)
223#define CH_LAYOUT_2_1 (CH_LAYOUT_STEREO|CH_BACK_CENTER)
224#define CH_LAYOUT_SURROUND (CH_LAYOUT_STEREO|CH_FRONT_CENTER)
225#define CH_LAYOUT_4POINT0 (CH_LAYOUT_SURROUND|CH_BACK_CENTER)
226#define CH_LAYOUT_2_2 (CH_LAYOUT_STEREO|CH_SIDE_LEFT|CH_SIDE_RIGHT)
227#define CH_LAYOUT_QUAD (CH_LAYOUT_STEREO|CH_BACK_LEFT|CH_BACK_RIGHT)
228#define CH_LAYOUT_5POINT0 (CH_LAYOUT_SURROUND|CH_SIDE_LEFT|CH_SIDE_RIGHT)
229#define CH_LAYOUT_5POINT1 (CH_LAYOUT_5POINT0|CH_LOW_FREQUENCY)
230#define CH_LAYOUT_5POINT0_BACK (CH_LAYOUT_SURROUND|CH_BACK_LEFT|CH_BACK_RIGHT)
231#define CH_LAYOUT_5POINT1_BACK (CH_LAYOUT_5POINT0_BACK|CH_LOW_FREQUENCY)
232#define CH_LAYOUT_7POINT0 (CH_LAYOUT_5POINT0|CH_BACK_LEFT|CH_BACK_RIGHT)
233#define CH_LAYOUT_7POINT1 (CH_LAYOUT_5POINT1|CH_BACK_LEFT|CH_BACK_RIGHT)
234#define CH_LAYOUT_7POINT1_WIDE (CH_LAYOUT_5POINT1_BACK|\
235 CH_FRONT_LEFT_OF_CENTER|CH_FRONT_RIGHT_OF_CENTER)
236#define CH_LAYOUT_STEREO_DOWNMIX (CH_STEREO_LEFT|CH_STEREO_RIGHT)
237
238/* in bytes */
239#define AVCODEC_MAX_AUDIO_FRAME_SIZE 192000 // 1 second of 48khz 32bit audio
240
241typedef struct AVCodecContext {
242 /**
243 * the average bitrate
244 * - encoding: Set by user; unused for constant quantizer encoding.
245 * - decoding: Set by libavcodec. 0 or some bitrate if this info is available in the stream.
246 */
247 int bit_rate;
248
249 /**
250 * number of bits the bitstream is allowed to diverge from the reference.
251 * the reference can be CBR (for CBR pass1) or VBR (for pass2)
252 * - encoding: Set by user; unused for constant quantizer encoding.
253 * - decoding: unused
254 */
255 int bit_rate_tolerance;
256
257 /**
258 * CODEC_FLAG_*.
259 * - encoding: Set by user.
260 * - decoding: Set by user.
261 */
262 int flags;
263
264 /**
265 * Some codecs need additional format info. It is stored here.
266 * If any muxer uses this then ALL demuxers/parsers AND encoders for the
267 * specific codec MUST set it correctly otherwise stream copy breaks.
268 * In general use of this field by muxers is not recommanded.
269 * - encoding: Set by libavcodec.
270 * - decoding: Set by libavcodec. (FIXME: Is this OK?)
271 */
272 int sub_id;
273
274 /**
275 * Motion estimation algorithm used for video coding.
276 * 1 (zero), 2 (full), 3 (log), 4 (phods), 5 (epzs), 6 (x1), 7 (hex),
277 * 8 (umh), 9 (iter), 10 (tesa) [7, 8, 10 are x264 specific, 9 is snow specific]
278 * - encoding: MUST be set by user.
279 * - decoding: unused
280 */
281 int me_method;
282
283 /**
284 * some codecs need / can use extradata like Huffman tables.
285 * mjpeg: Huffman tables
286 * rv10: additional flags
287 * mpeg4: global headers (they can be in the bitstream or here)
288 * The allocated memory should be FF_INPUT_BUFFER_PADDING_SIZE bytes larger
289 * than extradata_size to avoid prolems if it is read with the bitstream reader.
290 * The bytewise contents of extradata must not depend on the architecture or CPU endianness.
291 * - encoding: Set/allocated/freed by libavcodec.
292 * - decoding: Set/allocated/freed by user.
293 */
294 uint8_t *extradata;
295 int extradata_size;
296
297 /* audio only */
298 int sample_rate; ///< samples per second
299 int channels; ///< number of audio channels
300
301 /**
302 * audio sample format
303 * - encoding: Set by user.
304 * - decoding: Set by libavcodec.
305 */
306 enum SampleFormat sample_fmt; ///< sample format
307
308 /* The following data should not be initialized. */
309 /**
310 * Samples per packet, initialized when calling 'init'.
311 */
312 int frame_size;
313 int frame_number; ///< audio or video frame number
314
315 char codec_name[32];
316 enum CodecType codec_type; /* see CODEC_TYPE_xxx */
317 enum CodecID codec_id; /* see CODEC_ID_xxx */
318
319 /**
320 * Bits per sample/pixel of internal libavcodec pixel/sample format.
321 * This field is applicable only when sample_fmt is SAMPLE_FMT_S32.
322 * - encoding: set by user.
323 * - decoding: set by libavcodec.
324 */
325 int bits_per_raw_sample;
326
327 int block_align;
328
329 /**
330 * Audio channel layout.
331 * - encoding: set by user.
332 * - decoding: set by libavcodec.
333 */
334 int64_t channel_layout;
335} AVCodecContext;
336
337#endif /* AVCODEC_AVCODEC_H */
338