* fixing a typo ;-)
[libav.git] / libavcodec / avcodec.h
CommitLineData
a96b68b7
FB
1#ifndef AVCODEC_H
2#define AVCODEC_H
3
36df8805
MN
4/**
5 * @file avcodec.h
d33c949c 6 * external api header.
36df8805
MN
7 */
8
9
02d697aa
ZK
10#ifdef __cplusplus
11extern "C" {
12#endif
13
de6d9b64
FB
14#include "common.h"
15
7b7d86f1
FB
16#define FFMPEG_VERSION_INT 0x000408
17#define FFMPEG_VERSION "0.4.8"
541ae140 18#define LIBAVCODEC_BUILD 4679
4b1f4f23 19
7b7d86f1
FB
20#define LIBAVCODEC_VERSION_INT FFMPEG_VERSION_INT
21#define LIBAVCODEC_VERSION FFMPEG_VERSION
22
23#define AV_STRINGIFY(s) AV_TOSTRING(s)
24#define AV_TOSTRING(s) #s
25#define LIBAVCODEC_IDENT "FFmpeg" LIBAVCODEC_VERSION "b" AV_STRINGIFY(LIBAVCODEC_BUILD)
ce2749d2 26
de6d9b64
FB
27enum CodecID {
28 CODEC_ID_NONE,
29 CODEC_ID_MPEG1VIDEO,
dcedf586 30 CODEC_ID_MPEG2VIDEO, /* prefered ID for MPEG Video 1 or 2 decoding */
fb364ada 31 CODEC_ID_MPEG2VIDEO_XVMC,
de6d9b64
FB
32 CODEC_ID_H263,
33 CODEC_ID_RV10,
34 CODEC_ID_MP2,
dcedf586 35 CODEC_ID_MP3, /* prefered ID for MPEG Audio layer 1, 2 or3 decoding */
81e0d0b4 36 CODEC_ID_VORBIS,
de6d9b64
FB
37 CODEC_ID_AC3,
38 CODEC_ID_MJPEG,
b135d9fb 39 CODEC_ID_MJPEGB,
b1e6b355 40 CODEC_ID_LJPEG,
bf89e6b1 41 CODEC_ID_MPEG4,
de6d9b64 42 CODEC_ID_RAWVIDEO,
84afee34
MN
43 CODEC_ID_MSMPEG4V1,
44 CODEC_ID_MSMPEG4V2,
45 CODEC_ID_MSMPEG4V3,
e1a9dbff 46 CODEC_ID_WMV1,
b50eef3a 47 CODEC_ID_WMV2,
de6d9b64
FB
48 CODEC_ID_H263P,
49 CODEC_ID_H263I,
d4f5d74a 50 CODEC_ID_FLV1,
be8ffec9 51 CODEC_ID_SVQ1,
8b82a956 52 CODEC_ID_SVQ3,
020fcc94
FB
53 CODEC_ID_DVVIDEO,
54 CODEC_ID_DVAUDIO,
bc8d1857
FB
55 CODEC_ID_WMAV1,
56 CODEC_ID_WMAV2,
3f95e843
FR
57 CODEC_ID_MACE3,
58 CODEC_ID_MACE6,
11f18faf 59 CODEC_ID_HUFFYUV,
f70f7c6d 60 CODEC_ID_CYUV,
0da71265 61 CODEC_ID_H264,
deabd4fd 62 CODEC_ID_INDEO3,
d86053a4 63 CODEC_ID_VP3,
280bd7b7
ZK
64 CODEC_ID_AAC,
65 CODEC_ID_MPEG4AAC,
3d2e8cce 66 CODEC_ID_ASV1,
9b56edf5 67 CODEC_ID_ASV2,
5e20f836 68 CODEC_ID_FFV1,
e2a7bb28 69 CODEC_ID_4XM,
be3564ed 70 CODEC_ID_VCR1,
3aff069b 71 CODEC_ID_CLJR,
c3bf0288 72 CODEC_ID_MDEC,
3ef8be2b
MM
73 CODEC_ID_ROQ,
74 CODEC_ID_INTERPLAY_VIDEO,
9937e686
MM
75 CODEC_ID_XAN_WC3,
76 CODEC_ID_XAN_WC4,
a96b68b7
FB
77
78 /* various pcm "codecs" */
79 CODEC_ID_PCM_S16LE,
80 CODEC_ID_PCM_S16BE,
81 CODEC_ID_PCM_U16LE,
82 CODEC_ID_PCM_U16BE,
83 CODEC_ID_PCM_S8,
84 CODEC_ID_PCM_U8,
85 CODEC_ID_PCM_MULAW,
86 CODEC_ID_PCM_ALAW,
0147f198
FR
87
88 /* various adpcm codecs */
89 CODEC_ID_ADPCM_IMA_QT,
90 CODEC_ID_ADPCM_IMA_WAV,
9937e686
MM
91 CODEC_ID_ADPCM_IMA_DK3,
92 CODEC_ID_ADPCM_IMA_DK4,
0147f198 93 CODEC_ID_ADPCM_MS,
e2a7bb28 94 CODEC_ID_ADPCM_4XM,
891f64b3 95
96 /* AMR */
97 CODEC_ID_AMR_NB,
b8414bbd
NK
98 /* RealAudio codecs*/
99 CODEC_ID_RA_144,
100 CODEC_ID_RA_288,
3ef8be2b
MM
101
102 /* various DPCM codecs */
103 CODEC_ID_ROQ_DPCM,
104 CODEC_ID_INTERPLAY_DPCM,
9937e686 105 CODEC_ID_XAN_DPCM,
de6d9b64 106};
dcedf586
FB
107
108/* CODEC_ID_MP3LAME is absolete */
109#define CODEC_ID_MP3LAME CODEC_ID_MP3
de6d9b64
FB
110
111enum CodecType {
4a663d80 112 CODEC_TYPE_UNKNOWN = -1,
de6d9b64
FB
113 CODEC_TYPE_VIDEO,
114 CODEC_TYPE_AUDIO,
115};
116
64863965 117/**
0f371e3e
MM
118 * Pixel format. Notes:
119 *
120 * PIX_FMT_RGBA32 is handled in an endian-specific manner. A RGBA
121 * color is put together as:
122 * (A << 24) | (R << 16) | (G << 8) | B
123 * This is stored as BGRA on little endian CPU architectures and ARGB on
124 * big endian CPUs.
125 *
126 * When the pixel format is palettized RGB (PIX_FMT_PAL8), the palettized
127 * image data is stored in AVFrame.data[0]. The palette is transported in
128 * AVFrame.data[1] and, is 1024 bytes long (256 4-byte entries) and is
129 * formatted the same as in PIX_FMT_RGBA32 described above (i.e., it is
130 * also endian-specific).
64863965 131 */
de6d9b64 132enum PixelFormat {
cd394651
MN
133 PIX_FMT_YUV420P, ///< Planar YUV 4:2:0 (1 Cr & Cb sample per 2x2 Y samples)
134 PIX_FMT_YUV422,
135 PIX_FMT_RGB24, ///< Packed pixel, 3 bytes per pixel, RGBRGB...
136 PIX_FMT_BGR24, ///< Packed pixel, 3 bytes per pixel, BGRBGR...
137 PIX_FMT_YUV422P, ///< Planar YUV 4:2:2 (1 Cr & Cb sample per 2x1 Y samples)
138 PIX_FMT_YUV444P, ///< Planar YUV 4:4:4 (1 Cr & Cb sample per 1x1 Y samples)
0f371e3e 139 PIX_FMT_RGBA32, ///< Packed pixel, 4 bytes per pixel, BGRABGRA..., stored in cpu endianness
cd394651
MN
140 PIX_FMT_YUV410P, ///< Planar YUV 4:1:0 (1 Cr & Cb sample per 4x4 Y samples)
141 PIX_FMT_YUV411P, ///< Planar YUV 4:1:1 (1 Cr & Cb sample per 4x1 Y samples)
64863965
MN
142 PIX_FMT_RGB565, ///< always stored in cpu endianness
143 PIX_FMT_RGB555, ///< always stored in cpu endianness, most significant bit to 1
dab64ebc 144 PIX_FMT_GRAY8,
64863965
MN
145 PIX_FMT_MONOWHITE, ///< 0 is white
146 PIX_FMT_MONOBLACK, ///< 0 is black
147 PIX_FMT_PAL8, ///< 8 bit with RGBA palette
cd394651
MN
148 PIX_FMT_YUVJ420P, ///< Planar YUV 4:2:0 full scale (jpeg)
149 PIX_FMT_YUVJ422P, ///< Planar YUV 4:2:2 full scale (jpeg)
150 PIX_FMT_YUVJ444P, ///< Planar YUV 4:4:4 full scale (jpeg)
fb364ada
IK
151 PIX_FMT_XVMC_MPEG2_MC,///< XVideo Motion Acceleration via common packet passing(xvmc_render.h)
152 PIX_FMT_XVMC_MPEG2_IDCT,
dab64ebc 153 PIX_FMT_NB,
de6d9b64
FB
154};
155
a96b68b7
FB
156/* currently unused, may be used if 24/32 bits samples ever supported */
157enum SampleFormat {
64863965 158 SAMPLE_FMT_S16 = 0, ///< signed 16 bits
a96b68b7
FB
159};
160
de6d9b64 161/* in bytes */
bc8d1857 162#define AVCODEC_MAX_AUDIO_FRAME_SIZE 131072
de6d9b64 163
d7425f59 164/**
cf713bb8
MN
165 * Required number of additionally allocated bytes at the end of the input bitstream for decoding.
166 * this is mainly needed because some optimized bitstream readers read
167 * 32 or 64 bit at once and could read over the end<br>
168 * Note, if the first 23 bits of the additional bytes are not 0 then damaged
169 * MPEG bitstreams could cause overread and segfault
d7425f59
MN
170 */
171#define FF_INPUT_BUFFER_PADDING_SIZE 8
172
e4986da9
J
173/* motion estimation type, EPZS by default */
174enum Motion_Est_ID {
101bea5f 175 ME_ZERO = 1,
e4986da9
J
176 ME_FULL,
177 ME_LOG,
178 ME_PHODS,
179 ME_EPZS,
180 ME_X1
181};
182
ce980a95
MN
183typedef struct RcOverride{
184 int start_frame;
185 int end_frame;
186 int qscale; // if this is 0 then quality_factor will be used instead
187 float quality_factor;
188} RcOverride;
189
101bea5f
J
190/* only for ME compatiblity with old apps */
191extern int motion_estimation_method;
192
e4986da9 193/* ME algos sorted by quality */
bc6caae2
J
194static const int Motion_Est_QTab[] = { ME_ZERO, ME_PHODS, ME_LOG,
195 ME_X1, ME_EPZS, ME_FULL };
de6d9b64 196
28db7fce 197
4e00e76b 198#define FF_MAX_B_FRAMES 8
9dbcbd92 199
a949d72e
MN
200/* encoding support
201 these flags can be passed in AVCodecContext.flags before initing
202 Note: note not everything is supported yet
203*/
de6d9b64 204
64863965
MN
205#define CODEC_FLAG_QSCALE 0x0002 ///< use fixed qscale
206#define CODEC_FLAG_4MV 0x0004 ///< 4 MV per MB allowed
207#define CODEC_FLAG_QPEL 0x0010 ///< use qpel MC
208#define CODEC_FLAG_GMC 0x0020 ///< use GMC
209#define CODEC_FLAG_PART 0x0080 ///< use data partitioning
9dbcbd92
MN
210/* parent program gurantees that the input for b-frame containing streams is not written to
211 for at least s->max_b_frames+1 frames, if this is not set than the input will be copied */
8b4c7dbc 212#define CODEC_FLAG_INPUT_PRESERVED 0x0100
64863965
MN
213#define CODEC_FLAG_PASS1 0x0200 ///< use internal 2pass ratecontrol in first pass mode
214#define CODEC_FLAG_PASS2 0x0400 ///< use internal 2pass ratecontrol in second pass mode
215#define CODEC_FLAG_EXTERN_HUFF 0x1000 ///< use external huffman table (for mjpeg)
216#define CODEC_FLAG_GRAY 0x2000 ///< only decode/encode grayscale
217#define CODEC_FLAG_EMU_EDGE 0x4000///< dont draw edges
218#define CODEC_FLAG_PSNR 0x8000 ///< error[?] variables will be set during encoding
219#define CODEC_FLAG_TRUNCATED 0x00010000 /** input bitstream might be truncated at a random location instead
d7425f59 220 of only at frame boundaries */
64863965
MN
221#define CODEC_FLAG_NORMALIZE_AQP 0x00020000 ///< normalize adaptive quantization
222#define CODEC_FLAG_INTERLACED_DCT 0x00040000 ///< use interlaced dct
3bb07d61 223#define CODEC_FLAG_LOW_DELAY 0x00080000 ///< force low delay
64863965
MN
224#define CODEC_FLAG_ALT_SCAN 0x00100000 ///< use alternate scan
225#define CODEC_FLAG_TRELLIS_QUANT 0x00200000 ///< use trellis quantization
226#define CODEC_FLAG_GLOBAL_HEADER 0x00400000 ///< place global headers in extradata instead of every keyframe
227#define CODEC_FLAG_BITEXACT 0x00800000 ///< use only bitexact stuff (except (i)dct)
21e59552 228/* Fx : Flag for h263+ extra options */
64863965
MN
229#define CODEC_FLAG_H263P_AIC 0x01000000 ///< Advanced intra coding
230#define CODEC_FLAG_H263P_UMV 0x02000000 ///< Unlimited motion vector
21e59552
MN
231/* For advanced prediction mode, we reuse the 4MV flag */
232/* Unsupported options :
233 * Syntax Arithmetic coding (SAC)
234 * Deblocking filter internal loop
235 * Slice structured
236 * Reference Picture Selection
237 * Independant Segment Decoding
238 * Alternative Inter * VLC
239 * Modified Quantization */
240/* /Fx */
bf89e6b1
FB
241/* codec capabilities */
242
64863965 243#define CODEC_CAP_DRAW_HORIZ_BAND 0x0001 ///< decoder can use draw_horiz_band callback
6814a25c
MN
244/**
245 * Codec uses get_buffer() for allocating buffers.
246 * direct rendering method 1
247 */
248#define CODEC_CAP_DR1 0x0002
917e06c8
FB
249/* if 'parse_only' field is true, then avcodec_parse_frame() can be
250 used */
251#define CODEC_CAP_PARSE_ONLY 0x0004
d7425f59 252#define CODEC_CAP_TRUNCATED 0x0008
bf89e6b1 253
492cd3a9 254#define FF_COMMON_FRAME \
b536d0aa
MN
255 /**\
256 * pointer to the picture planes.\
257 * this might be different from the first allocated byte\
258 * - encoding: \
259 * - decoding: \
260 */\
1e491e29
MN
261 uint8_t *data[4];\
262 int linesize[4];\
263 /**\
32db2b1d 264 * pointer to the first allocated byte of the picture. can be used in get_buffer/release_buffer\
1e491e29 265 * this isnt used by lavc unless the default get/release_buffer() is used\
64863965
MN
266 * - encoding: \
267 * - decoding: \
1e491e29
MN
268 */\
269 uint8_t *base[4];\
270 /**\
271 * 1 -> keyframe, 0-> not\
64863965
MN
272 * - encoding: set by lavc\
273 * - decoding: set by lavc\
1e491e29
MN
274 */\
275 int key_frame;\
276\
277 /**\
0da71265 278 * picture type of the frame, see ?_TYPE below.\
64863965
MN
279 * - encoding: set by lavc for coded_picture (and set by user for input)\
280 * - decoding: set by lavc\
1e491e29
MN
281 */\
282 int pict_type;\
283\
284 /**\
285 * presentation timestamp in micro seconds (time when frame should be shown to user)\
286 * if 0 then the frame_rate will be used as reference\
64863965
MN
287 * - encoding: MUST be set by user\
288 * - decoding: set by lavc\
1e491e29 289 */\
be6784dc 290 int64_t pts;\
1e491e29
MN
291\
292 /**\
293 * picture number in bitstream order.\
64863965
MN
294 * - encoding: set by\
295 * - decoding: set by lavc\
1e491e29
MN
296 */\
297 int coded_picture_number;\
298 /**\
1e491e29 299 * picture number in display order.\
64863965
MN
300 * - encoding: set by\
301 * - decoding: set by lavc\
1e491e29
MN
302 */\
303 int display_picture_number;\
304\
305 /**\
306 * quality (between 1 (good) and 31 (bad)) \
64863965
MN
307 * - encoding: set by lavc for coded_picture (and set by user for input)\
308 * - decoding: set by lavc\
1e491e29
MN
309 */\
310 float quality; \
311\
312 /**\
313 * buffer age (1->was last buffer and dint change, 2->..., ...).\
314 * set to something large if the buffer has not been used yet \
64863965
MN
315 * - encoding: unused\
316 * - decoding: MUST be set by get_buffer()\
1e491e29
MN
317 */\
318 int age;\
319\
320 /**\
321 * is this picture used as reference\
64863965
MN
322 * - encoding: unused\
323 * - decoding: set by lavc (before get_buffer() call))\
1e491e29
MN
324 */\
325 int reference;\
326\
327 /**\
328 * QP table\
64863965
MN
329 * - encoding: unused\
330 * - decoding: set by lavc\
1e491e29
MN
331 */\
332 int8_t *qscale_table;\
333 /**\
334 * QP store stride\
64863965
MN
335 * - encoding: unused\
336 * - decoding: set by lavc\
1e491e29
MN
337 */\
338 int qstride;\
339\
340 /**\
341 * mbskip_table[mb]>=1 if MB didnt change\
342 * stride= mb_width = (width+15)>>4\
64863965
MN
343 * - encoding: unused\
344 * - decoding: set by lavc\
1e491e29
MN
345 */\
346 uint8_t *mbskip_table;\
347\
348 /**\
349 * for some private data of the user\
64863965
MN
350 * - encoding: unused\
351 * - decoding: set by user\
1e491e29
MN
352 */\
353 void *opaque;\
140cb663
MN
354\
355 /**\
356 * error\
64863965
MN
357 * - encoding: set by lavc if flags&CODEC_FLAG_PSNR\
358 * - decoding: unused\
140cb663
MN
359 */\
360 uint64_t error[4];\
4e00e76b
MN
361\
362 /**\
363 * type of the buffer (to keep track of who has to dealloc data[*])\
64863965
MN
364 * - encoding: set by the one who allocs it\
365 * - decoding: set by the one who allocs it\
3db320ea 366 * Note: user allocated (direct rendering) & internal buffers can not coexist currently\
4e00e76b
MN
367 */\
368 int type;\
2ec23b6d
MN
369 \
370 /**\
371 * when decoding, this signal how much the picture must be delayed.\
372 * extra_delay = repeat_pict / (2*fps)\
64863965
MN
373 * - encoding: unused\
374 * - decoding: set by lavc\
2ec23b6d 375 */\
0426af31
MN
376 int repeat_pict;\
377 \
378 /**\
379 * \
380 */\
381 int qscale_type;\
2ec23b6d 382
0426af31
MN
383#define FF_QSCALE_TYPE_MPEG1 0
384#define FF_QSCALE_TYPE_MPEG2 1
4e00e76b
MN
385
386#define FF_BUFFER_TYPE_INTERNAL 1
9b56edf5
MN
387#define FF_BUFFER_TYPE_USER 2 ///< Direct rendering buffers (image is (de)allocated by user)
388#define FF_BUFFER_TYPE_SHARED 4 ///< buffer from somewher else, dont dealloc image (data/base)
389#define FF_BUFFER_TYPE_COPY 8 ///< just a (modified) copy of some other buffer, dont dealloc anything
4e00e76b 390
1e491e29 391
140cb663
MN
392#define FF_I_TYPE 1 // Intra
393#define FF_P_TYPE 2 // Predicted
394#define FF_B_TYPE 3 // Bi-dir predicted
395#define FF_S_TYPE 4 // S(GMC)-VOP MPEG4
0da71265
MN
396#define FF_SI_TYPE 5
397#define FF_SP_TYPE 6
1e491e29 398
0da71265
MN
399/**
400 * Audio Video Frame.
401 */
492cd3a9
MN
402typedef struct AVFrame {
403 FF_COMMON_FRAME
404} AVFrame;
1e491e29 405
14bea432 406#define DEFAULT_FRAME_RATE_BASE 1001000
d33c949c
MN
407
408/**
409 * main external api structure.
410 */
de6d9b64 411typedef struct AVCodecContext {
b71901e6 412 /**
64863965
MN
413 * the average bitrate.
414 * - encoding: set by user. unused for constant quantizer encoding
415 * - decoding: set by lavc. 0 or some bitrate if this info is available in the stream
b71901e6 416 */
de6d9b64 417 int bit_rate;
b71901e6
MN
418
419 /**
64863965 420 * number of bits the bitstream is allowed to diverge from the reference.
b71901e6 421 * the reference can be CBR (for CBR pass1) or VBR (for pass2)
64863965
MN
422 * - encoding: set by user. unused for constant quantizer encoding
423 * - decoding: unused
b71901e6
MN
424 */
425 int bit_rate_tolerance;
426
427 /**
64863965
MN
428 * CODEC_FLAG_*.
429 * - encoding: set by user.
430 * - decoding: set by user.
b71901e6 431 */
de6d9b64 432 int flags;
b71901e6
MN
433
434 /**
435 * some codecs needs additionnal format info. It is stored here
64863965
MN
436 * - encoding: set by user.
437 * - decoding: set by lavc. (FIXME is this ok?)
b71901e6
MN
438 */
439 int sub_id;
440
441 /**
64863965
MN
442 * motion estimation algorithm used for video coding.
443 * - encoding: MUST be set by user.
444 * - decoding: unused
b71901e6
MN
445 */
446 int me_method;
447
448 /**
64863965 449 * some codecs need / can use extra-data like huffman tables.
b71901e6
MN
450 * mjpeg: huffman tables
451 * rv10: additional flags
b704e742 452 * mpeg4: global headers (they can be in the bitstream or here)
64863965
MN
453 * - encoding: set/allocated/freed by lavc.
454 * - decoding: set/allocated/freed by user.
b71901e6 455 */
e84c31dc
A
456 void *extradata;
457 int extradata_size;
458
de6d9b64 459 /* video only */
b71901e6 460 /**
14bea432 461 * frames per sec multiplied by frame_rate_base.
b71901e6 462 * for variable fps this is the precission, so if the timestamps
14bea432 463 * can be specified in msec precssion then this is 1000*frame_rate_base
64863965
MN
464 * - encoding: MUST be set by user
465 * - decoding: set by lavc. 0 or the frame_rate if available
b71901e6
MN
466 */
467 int frame_rate;
14bea432
MN
468
469 /**
64863965
MN
470 * width / height.
471 * - encoding: MUST be set by user.
472 * - decoding: set by user, some codecs might override / change it during playback
b71901e6 473 */
de6d9b64 474 int width, height;
b71901e6 475
2efe097a
MN
476#define FF_ASPECT_SQUARE 1
477#define FF_ASPECT_4_3_625 2
478#define FF_ASPECT_4_3_525 3
479#define FF_ASPECT_16_9_625 4
480#define FF_ASPECT_16_9_525 5
e769f053 481#define FF_ASPECT_EXTENDED 15
b71901e6
MN
482
483 /**
64863965
MN
484 * the number of pictures in a group of pitures, or 0 for intra_only.
485 * - encoding: set by user.
486 * - decoding: unused
b71901e6
MN
487 */
488 int gop_size;
489
490 /**
64863965 491 * pixel format, see PIX_FMT_xxx.
36b58e85
RS
492 * - encoding: FIXME: used by ffmpeg to decide whether an pix_fmt
493 * conversion is in order. This only works for
494 * codecs with one supported pix_fmt, we should
495 * do something for a generic case as well.
64863965 496 * - decoding: set by lavc.
b71901e6 497 */
e4eadb4b 498 enum PixelFormat pix_fmt;
bdfcbbed
MK
499
500 /**
501 * Frame rate emulation. If not zero lower layer (i.e. format handler)
502 * has to read frames at native frame rate.
503 * - encoding: set by user.
504 * - decoding: unused.
505 */
506 int rate_emu;
507
b71901e6
MN
508 /**
509 * if non NULL, 'draw_horiz_band' is called by the libavcodec
510 * decoder to draw an horizontal band. It improve cache usage. Not
511 * all codecs can do that. You must check the codec capabilities
512 * before
64863965
MN
513 * - encoding: unused
514 * - decoding: set by user.
3bb07d61
MN
515 * @param height the height of the slice
516 * @param y the y position of the slice
517 * @param type 1->top field, 2->bottom field, 3->frame
518 * @param offset offset into the AVFrame.data from which the slice should be read
b71901e6 519 */
bf89e6b1 520 void (*draw_horiz_band)(struct AVCodecContext *s,
7a06ff14 521 AVFrame *src, int offset[4],
3bb07d61 522 int y, int type, int height);
bf89e6b1 523
de6d9b64 524 /* audio only */
64863965 525 int sample_rate; ///< samples per sec
de6d9b64 526 int channels;
64863965 527 int sample_fmt; ///< sample format, currenly unused
de6d9b64
FB
528
529 /* the following data should not be initialized */
64863965
MN
530 int frame_size; ///< in samples, initialized when calling 'init'
531 int frame_number; ///< audio or video frame number
532 int real_pict_num; ///< returns the real picture number of previous encoded frame
1e491e29 533
b71901e6 534 /**
b71901e6 535 * number of frames the decoded output will be delayed relative to
64863965
MN
536 * the encoded input.
537 * - encoding: set by lavc.
538 * - decoding: unused
b71901e6
MN
539 */
540 int delay;
1ff662cc 541
64863965
MN
542 /* - encoding parameters */
543 float qcompress; ///< amount of qscale change between easy & hard scenes (0.0-1.0)
544 float qblur; ///< amount of qscale smoothing over time (0.0-1.0)
b71901e6
MN
545
546 /**
64863965
MN
547 * minimum quantizer.
548 * - encoding: set by user.
549 * - decoding: unused
b71901e6
MN
550 */
551 int qmin;
552
553 /**
64863965
MN
554 * maximum quantizer.
555 * - encoding: set by user.
556 * - decoding: unused
b71901e6
MN
557 */
558 int qmax;
559
560 /**
64863965
MN
561 * maximum quantizer difference etween frames.
562 * - encoding: set by user.
563 * - decoding: unused
b71901e6
MN
564 */
565 int max_qdiff;
566
567 /**
64863965 568 * maximum number of b frames between non b frames.
b71901e6 569 * note: the output will be delayed by max_b_frames+1 relative to the input
64863965
MN
570 * - encoding: set by user.
571 * - decoding: unused
b71901e6
MN
572 */
573 int max_b_frames;
574
575 /**
64863965
MN
576 * qscale factor between ip and b frames.
577 * - encoding: set by user.
578 * - decoding: unused
b71901e6
MN
579 */
580 float b_quant_factor;
581
582 /** obsolete FIXME remove */
583 int rc_strategy;
8b4c7dbc 584 int b_frame_strategy;
9dbcbd92 585
b71901e6 586 /**
64863965
MN
587 * hurry up amount.
588 * - encoding: unused
589 * - decoding: set by user. 1-> skip b frames, 2-> skip idct/dequant too, 5-> skip everything except header
b71901e6
MN
590 */
591 int hurry_up;
2417652e 592
de6d9b64 593 struct AVCodec *codec;
b71901e6 594
de6d9b64
FB
595 void *priv_data;
596
644d98a4 597 /* The following data is for RTP friendly coding */
1f6b6e50 598 /* By now only H.263/H.263+/MPEG4 coder honours this */
644d98a4
J
599 int rtp_mode; /* 1 for activate RTP friendly-mode */
600 /* highers numbers represent more error-prone */
601 /* enviroments, by now just "1" exist */
602
603 int rtp_payload_size; /* The size of the RTP payload, the coder will */
604 /* do it's best to deliver a chunk with size */
605 /* below rtp_payload_size, the chunk will start */
606 /* with a start code on some codecs like H.263 */
607 /* This doesn't take account of any particular */
608 /* headers inside the transmited RTP payload */
81401c1f
J
609
610
611 /* The RTP callcack: This function is called */
612 /* every time the encoder as a packet to send */
613 /* Depends on the encoder if the data starts */
614 /* with a Start Code (it should) H.263 does */
615 void (*rtp_callback)(void *data, int size, int packet_number);
616
098eefe1
MN
617 /* statistics, used for 2-pass encoding */
618 int mv_bits;
619 int header_bits;
620 int i_tex_bits;
621 int p_tex_bits;
622 int i_count;
623 int p_count;
624 int skip_count;
b71901e6
MN
625 int misc_bits;
626
627 /**
64863965
MN
628 * number of bits used for the previously encoded frame.
629 * - encoding: set by lavc
7004ffb3 630 * - decoding: unused
b71901e6 631 */
098eefe1 632 int frame_bits;
7004ffb3 633
b71901e6 634 /**
64863965
MN
635 * private data of the user, can be used to carry app specific stuff.
636 * - encoding: set by user
637 * - decoding: set by user
b71901e6
MN
638 */
639 void *opaque;
640
de6d9b64 641 char codec_name[32];
4a663d80
PG
642 enum CodecType codec_type; /* see CODEC_TYPE_xxx */
643 enum CodecID codec_id; /* see CODEC_ID_xxx */
7004ffb3
MN
644
645 /**
646 * fourcc (LSB first, so "ABCD" -> ('D'<<24) + ('C'<<16) + ('B'<<8) + 'A').
647 * this is used to workaround some encoder bugs
bd5a6020 648 * - encoding: set by user, if not then the default based on codec_id will be used
7004ffb3
MN
649 * - decoding: set by user, will be converted to upper case by lavc during init
650 */
651 unsigned int codec_tag;
92ba5ffb 652
b71901e6 653 /**
64863965
MN
654 * workaround bugs in encoders which sometimes cannot be detected automatically.
655 * - encoding: unused
656 * - decoding: set by user
b71901e6
MN
657 */
658 int workaround_bugs;
64863965 659#define FF_BUG_AUTODETECT 1 ///< autodetection
4d2858de
MN
660#define FF_BUG_OLD_MSMPEG4 2
661#define FF_BUG_XVID_ILACE 4
662#define FF_BUG_UMP4 8
663#define FF_BUG_NO_PADDING 16
664#define FF_BUG_AC_VLC 32
03e93d35 665#define FF_BUG_QPEL_CHROMA 64
db794953 666#define FF_BUG_STD_QPEL 128
36df8805 667#define FF_BUG_QPEL_CHROMA2 256
c40c3482 668#define FF_BUG_DIRECT_BLOCKSIZE 512
1c6dcb0f 669#define FF_BUG_EDGE 1024
4d2858de
MN
670//#define FF_BUG_FAKE_SCALABILITY 16 //autodetection should work 100%
671
b71901e6 672 /**
64863965
MN
673 * luma single coeff elimination threshold.
674 * - encoding: set by user
675 * - decoding: unused
b71901e6 676 */
1f6b6e50 677 int luma_elim_threshold;
b71901e6
MN
678
679 /**
64863965
MN
680 * chroma single coeff elimination threshold.
681 * - encoding: set by user
682 * - decoding: unused
b71901e6 683 */
1f6b6e50 684 int chroma_elim_threshold;
b71901e6
MN
685
686 /**
64863965
MN
687 * strictly follow the std (MPEG4, ...).
688 * - encoding: set by user
689 * - decoding: unused
b71901e6
MN
690 */
691 int strict_std_compliance;
692
693 /**
64863965 694 * qscale offset between ip and b frames.
b3a391e8
MN
695 * if > 0 then the last p frame quantizer will be used (q= lastp_q*factor+offset)
696 * if < 0 then normal ratecontrol will be done (q= -normal_q*factor+offset)
64863965
MN
697 * - encoding: set by user.
698 * - decoding: unused
b71901e6
MN
699 */
700 float b_quant_offset;
701
702 /**
ce3bcaed 703 * error resilience higher values will detect more errors but may missdetect
64863965
MN
704 * some more or less valid parts as errors.
705 * - encoding: unused
706 * - decoding: set by user
b71901e6 707 */
1f6b6e50 708 int error_resilience;
ce3bcaed
MN
709#define FF_ER_CAREFULL 1
710#define FF_ER_COMPLIANT 2
711#define FF_ER_AGGRESSIVE 3
712#define FF_ER_VERY_AGGRESSIVE 4
ae72cda6 713
6b72ac63 714 /**
1e491e29
MN
715 * called at the beginning of each frame to get a buffer for it.
716 * if pic.reference is set then the frame will be read later by lavc
3bb07d61 717 * width and height should be rounded up to the next multiple of 16
64863965
MN
718 * - encoding: unused
719 * - decoding: set by lavc, user can override
b71901e6 720 */
492cd3a9 721 int (*get_buffer)(struct AVCodecContext *c, AVFrame *pic);
b71901e6
MN
722
723 /**
1e491e29
MN
724 * called to release buffers which where allocated with get_buffer.
725 * a released buffer can be reused in get_buffer()
726 * pic.data[*] must be set to NULL
64863965
MN
727 * - encoding: unused
728 * - decoding: set by lavc, user can override
b71901e6 729 */
492cd3a9 730 void (*release_buffer)(struct AVCodecContext *c, AVFrame *pic);
0fd90455 731
b71901e6 732 /**
64863965
MN
733 * is 1 if the decoded stream contains b frames, 0 otherwise.
734 * - encoding: unused
735 * - decoding: set by lavc
b71901e6
MN
736 */
737 int has_b_frames;
b71901e6 738
64863965 739 int block_align; ///< used by some WAV based audio codecs
ce980a95 740
64863965 741 int parse_only; /* - decoding only: if true, only parsing is done
917e06c8
FB
742 (function avcodec_parse_frame()). The frame
743 data is returned. Only MPEG codecs support this now. */
ce980a95 744
b71901e6 745 /**
e4eadb4b 746 * 0-> h263 quant 1-> mpeg quant.
64863965
MN
747 * - encoding: set by user.
748 * - decoding: unused
b71901e6
MN
749 */
750 int mpeg_quant;
ce980a95 751
b71901e6 752 /**
64863965
MN
753 * pass1 encoding statistics output buffer.
754 * - encoding: set by lavc
755 * - decoding: unused
b71901e6 756 */
64863965 757 char *stats_out;
b71901e6
MN
758
759 /**
760 * pass2 encoding statistics input buffer.
761 * concatenated stuff from stats_out of pass1 should be placed here
64863965
MN
762 * - encoding: allocated/set/freed by user
763 * - decoding: unused
b71901e6
MN
764 */
765 char *stats_in;
766
767 /**
64863965 768 * ratecontrol qmin qmax limiting method.
b71901e6 769 * 0-> clipping, 1-> use a nice continous function to limit qscale wthin qmin/qmax
64863965
MN
770 * - encoding: set by user.
771 * - decoding: unused
b71901e6 772 */
ce980a95 773 float rc_qsquish;
b71901e6 774
ce980a95
MN
775 float rc_qmod_amp;
776 int rc_qmod_freq;
b71901e6
MN
777
778 /**
64863965
MN
779 * ratecontrol override, see RcOverride.
780 * - encoding: allocated/set/freed by user.
781 * - decoding: unused
b71901e6 782 */
ce980a95
MN
783 RcOverride *rc_override;
784 int rc_override_count;
b71901e6
MN
785
786 /**
64863965
MN
787 * rate control equation.
788 * - encoding: set by user
789 * - decoding: unused
b71901e6 790 */
ce980a95 791 char *rc_eq;
b71901e6
MN
792
793 /**
64863965
MN
794 * maximum bitrate.
795 * - encoding: set by user.
796 * - decoding: unused
b71901e6 797 */
ce980a95 798 int rc_max_rate;
b71901e6
MN
799
800 /**
64863965
MN
801 * minimum bitrate.
802 * - encoding: set by user.
803 * - decoding: unused
b71901e6 804 */
ce980a95 805 int rc_min_rate;
b71901e6
MN
806
807 /**
64863965
MN
808 * decoder bitstream buffer size.
809 * - encoding: set by user.
810 * - decoding: unused
b71901e6 811 */
ce980a95
MN
812 int rc_buffer_size;
813 float rc_buffer_aggressivity;
b71901e6
MN
814
815 /**
64863965
MN
816 * qscale factor between p and i frames.
817 * - encoding: set by user.
818 * - decoding: unused
b71901e6
MN
819 */
820 float i_quant_factor;
821
822 /**
64863965 823 * qscale offset between p and i frames.
b3a391e8
MN
824 * if > 0 then the last p frame quantizer will be used (q= lastp_q*factor+offset)
825 * if < 0 then normal ratecontrol will be done (q= -normal_q*factor+offset)
64863965
MN
826 * - encoding: set by user.
827 * - decoding: unused
b71901e6
MN
828 */
829 float i_quant_offset;
830
831 /**
64863965
MN
832 * initial complexity for pass1 ratecontrol.
833 * - encoding: set by user.
834 * - decoding: unused
b71901e6 835 */
ce980a95 836 float rc_initial_cplx;
917e06c8 837
b71901e6 838 /**
64863965
MN
839 * dct algorithm, see FF_DCT_* below.
840 * - encoding: set by user
841 * - decoding: unused
b71901e6 842 */
28db7fce 843 int dct_algo;
c7e07931 844#define FF_DCT_AUTO 0
28db7fce 845#define FF_DCT_FASTINT 1
c7e07931
MO
846#define FF_DCT_INT 2
847#define FF_DCT_MMX 3
848#define FF_DCT_MLIB 4
05c4072b 849#define FF_DCT_ALTIVEC 5
c5d309f2
MN
850
851 /**
64863965
MN
852 * luminance masking (0-> disabled).
853 * - encoding: set by user
854 * - decoding: unused
c5d309f2
MN
855 */
856 float lumi_masking;
857
858 /**
64863965
MN
859 * temporary complexity masking (0-> disabled).
860 * - encoding: set by user
861 * - decoding: unused
c5d309f2
MN
862 */
863 float temporal_cplx_masking;
864
865 /**
64863965
MN
866 * spatial complexity masking (0-> disabled).
867 * - encoding: set by user
868 * - decoding: unused
c5d309f2
MN
869 */
870 float spatial_cplx_masking;
871
872 /**
64863965
MN
873 * p block masking (0-> disabled).
874 * - encoding: set by user
875 * - decoding: unused
c5d309f2
MN
876 */
877 float p_masking;
15415af4 878
5e746b99 879 /**
64863965
MN
880 * darkness masking (0-> disabled).
881 * - encoding: set by user
882 * - decoding: unused
5e746b99
MN
883 */
884 float dark_masking;
0c2dd16e 885
3a694b04
NK
886
887 /* for binary compatibility */
888 int unused;
889
0c2dd16e 890 /**
64863965
MN
891 * idct algorithm, see FF_IDCT_* below.
892 * - encoding: set by user
893 * - decoding: set by user
2ad1516a
MN
894 */
895 int idct_algo;
896#define FF_IDCT_AUTO 0
897#define FF_IDCT_INT 1
898#define FF_IDCT_SIMPLE 2
899#define FF_IDCT_SIMPLEMMX 3
900#define FF_IDCT_LIBMPEG2MMX 4
901#define FF_IDCT_PS2 5
902#define FF_IDCT_MLIB 6
903#define FF_IDCT_ARM 7
05c4072b 904#define FF_IDCT_ALTIVEC 8
b82cdc72 905#define FF_IDCT_SH4 9
bd7d1ea7 906#define FF_IDCT_SIMPLEARM 10
2ad1516a 907
144f0625 908 /**
64863965
MN
909 * slice count.
910 * - encoding: set by lavc
911 * - decoding: set by user (or 0)
144f0625
MN
912 */
913 int slice_count;
914 /**
64863965
MN
915 * slice offsets in the frame in bytes.
916 * - encoding: set/allocated by lavc
917 * - decoding: set/allocated by user (or NULL)
144f0625
MN
918 */
919 int *slice_offset;
920
4d2858de 921 /**
64863965
MN
922 * error concealment flags.
923 * - encoding: unused
924 * - decoding: set by user
4d2858de
MN
925 */
926 int error_concealment;
927#define FF_EC_GUESS_MVS 1
928#define FF_EC_DEBLOCK 2
929
6b72ac63 930 /**
bec89a84 931 * dsp_mask could be add used to disable unwanted CPU features
8350df97 932 * CPU features (i.e. MMX, SSE. ...)
bec89a84
ZK
933 *
934 * with FORCE flag you may instead enable given CPU features
935 * (Dangerous: usable in case of misdetection, improper usage however will
936 * result into program crash)
937 */
938 unsigned dsp_mask;
939#define FF_MM_FORCE 0x80000000 /* force usage of selected flags (OR) */
940 /* lower 16 bits - CPU features */
941#ifdef HAVE_MMX
942#define FF_MM_MMX 0x0001 /* standard MMX */
943#define FF_MM_3DNOW 0x0004 /* AMD 3DNOW */
944#define FF_MM_MMXEXT 0x0002 /* SSE integer functions or AMD MMX ext */
945#define FF_MM_SSE 0x0008 /* SSE functions */
946#define FF_MM_SSE2 0x0010 /* PIV SSE2 functions */
947#endif /* HAVE_MMX */
11f18faf
MN
948
949 /**
64863965
MN
950 * bits per sample/pixel from the demuxer (needed for huffyuv).
951 * - encoding: set by lavc
952 * - decoding: set by user
11f18faf
MN
953 */
954 int bits_per_sample;
955
956 /**
64863965
MN
957 * prediction method (needed for huffyuv).
958 * - encoding: set by user
959 * - decoding: unused
11f18faf
MN
960 */
961 int prediction_method;
962#define FF_PRED_LEFT 0
963#define FF_PRED_PLANE 1
964#define FF_PRED_MEDIAN 2
5d3cea3a
MN
965
966 /**
64863965
MN
967 * aspect ratio (0 if unknown).
968 * - encoding: set by user.
969 * - decoding: set by lavc.
5d3cea3a
MN
970 */
971 float aspect_ratio;
1e491e29
MN
972
973 /**
64863965
MN
974 * the picture in the bitstream.
975 * - encoding: set by lavc
976 * - decoding: set by lavc
1e491e29 977 */
492cd3a9 978 AVFrame *coded_frame;
c8c437bc
MN
979
980 /**
64863965
MN
981 * debug.
982 * - encoding: set by user.
983 * - decoding: set by user.
c8c437bc
MN
984 */
985 int debug;
986#define FF_DEBUG_PICT_INFO 1
987#define FF_DEBUG_RC 2
988#define FF_DEBUG_BITSTREAM 4
989#define FF_DEBUG_MB_TYPE 8
990#define FF_DEBUG_QP 16
991#define FF_DEBUG_MV 32
41773b73
MN
992#define FF_DEBUG_VIS_MV 0x00000040
993#define FF_DEBUG_SKIP 0x00000080
994#define FF_DEBUG_STARTCODE 0x00000100
995#define FF_DEBUG_PTS 0x00000200
46b4feec 996#define FF_DEBUG_ER 0x00000400
0da71265 997#define FF_DEBUG_MMCO 0x00000800
8fc6c2b5 998#define FF_DEBUG_BUGS 0x00001000
140cb663
MN
999
1000 /**
64863965
MN
1001 * error.
1002 * - encoding: set by lavc if flags&CODEC_FLAG_PSNR
1003 * - decoding: unused
140cb663
MN
1004 */
1005 uint64_t error[4];
17a70fde
MN
1006
1007 /**
64863965
MN
1008 * minimum MB quantizer.
1009 * - encoding: set by user.
1010 * - decoding: unused
17a70fde
MN
1011 */
1012 int mb_qmin;
1013
1014 /**
64863965
MN
1015 * maximum MB quantizer.
1016 * - encoding: set by user.
1017 * - decoding: unused
17a70fde
MN
1018 */
1019 int mb_qmax;
1457ab52
MN
1020
1021 /**
64863965
MN
1022 * motion estimation compare function.
1023 * - encoding: set by user.
1024 * - decoding: unused
1457ab52
MN
1025 */
1026 int me_cmp;
1027 /**
64863965
MN
1028 * subpixel motion estimation compare function.
1029 * - encoding: set by user.
1030 * - decoding: unused
1457ab52
MN
1031 */
1032 int me_sub_cmp;
1033 /**
64863965
MN
1034 * macroblock compare function (not supported yet).
1035 * - encoding: set by user.
1036 * - decoding: unused
1457ab52
MN
1037 */
1038 int mb_cmp;
1039#define FF_CMP_SAD 0
1040#define FF_CMP_SSE 1
1041#define FF_CMP_SATD 2
1042#define FF_CMP_DCT 3
1043#define FF_CMP_PSNR 4
1044#define FF_CMP_BIT 5
1045#define FF_CMP_RD 6
1046#define FF_CMP_ZERO 7
1047#define FF_CMP_CHROMA 256
1048
1049 /**
64863965
MN
1050 * ME diamond size & shape.
1051 * - encoding: set by user.
1052 * - decoding: unused
1457ab52
MN
1053 */
1054 int dia_size;
b07a5980
MN
1055
1056 /**
64863965
MN
1057 * amount of previous MV predictors (2a+1 x 2a+1 square).
1058 * - encoding: set by user.
1059 * - decoding: unused
b07a5980
MN
1060 */
1061 int last_predictor_count;
70ac76c0 1062
f5fb6b34 1063 /**
64863965
MN
1064 * pre pass for motion estimation.
1065 * - encoding: set by user.
1066 * - decoding: unused
f5fb6b34
MN
1067 */
1068 int pre_me;
b07a5980 1069
70ac76c0 1070 /**
64863965
MN
1071 * motion estimation pre pass compare function.
1072 * - encoding: set by user.
1073 * - decoding: unused
70ac76c0
MN
1074 */
1075 int me_pre_cmp;
826f429a 1076
70ac76c0 1077 /**
64863965
MN
1078 * ME pre pass diamond size & shape.
1079 * - encoding: set by user.
1080 * - decoding: unused
70ac76c0
MN
1081 */
1082 int pre_dia_size;
1083
826f429a 1084 /**
64863965
MN
1085 * subpel ME quality.
1086 * - encoding: set by user.
1087 * - decoding: unused
826f429a
MN
1088 */
1089 int me_subpel_quality;
1090
a33c7159 1091 /**
64863965 1092 * callback to negotiate the pixelFormat.
a33c7159
MN
1093 * @param fmt is the list of formats which are supported by the codec,
1094 * its terminated by -1 as 0 is a valid format, the formats are ordered by quality
1095 * the first is allways the native one
1096 * @return the choosen format
64863965
MN
1097 * - encoding: unused
1098 * - decoding: set by user, if not set then the native format will always be choosen
a33c7159
MN
1099 */
1100 enum PixelFormat (*get_format)(struct AVCodecContext *s, enum PixelFormat * fmt);
e2f9490e
FB
1101
1102 /**
1103 * DTG active format information (additionnal aspect ratio
1104 * information only used in DVB MPEG2 transport streams). 0 if
1105 * not set.
1106 *
64863965
MN
1107 * - encoding: unused.
1108 * - decoding: set by decoder
e2f9490e
FB
1109 */
1110 int dtg_active_format;
1111#define FF_DTG_AFD_SAME 8
1112#define FF_DTG_AFD_4_3 9
1113#define FF_DTG_AFD_16_9 10
1114#define FF_DTG_AFD_14_9 11
1115#define FF_DTG_AFD_4_3_SP_14_9 13
1116#define FF_DTG_AFD_16_9_SP_14_9 14
1117#define FF_DTG_AFD_SP_4_3 15
1118
ebbcdc9a
MN
1119 /**
1120 * Maximum motion estimation search range in subpel units.
1121 * if 0 then no limit
1122 *
64863965
MN
1123 * - encoding: set by user.
1124 * - decoding: unused.
ebbcdc9a 1125 */
59e0ac8e 1126 int me_range;
ebbcdc9a 1127
65f7062d
MN
1128 /**
1129 * frame_rate_base.
1130 * for variable fps this is 1
1131 * - encoding: set by user.
1132 * - decoding: set by lavc.
1133 * @todo move this after frame_rate
1134 */
65f7062d 1135
1984f635
MN
1136 int frame_rate_base;
1137 /**
1138 * intra quantizer bias.
1139 * - encoding: set by user.
1140 * - decoding: unused
1141 */
1142 int intra_quant_bias;
1143#define FF_DEFAULT_QUANT_BIAS 999999
1144
1145 /**
1146 * inter quantizer bias.
1147 * - encoding: set by user.
1148 * - decoding: unused
1149 */
1150 int inter_quant_bias;
5cd62665
ZK
1151
1152 /**
1153 * color table ID.
1154 * - encoding: unused.
1155 * - decoding: which clrtable should be used for 8bit RGB images
1156 * table have to be stored somewhere FIXME
1157 */
1158 int color_table_id;
1984f635 1159
d90cf87b
MN
1160 /**
1161 * internal_buffer count.
1162 * Dont touch, used by lavc default_get_buffer()
1163 */
1164 int internal_buffer_count;
1165
1166 /**
1167 * internal_buffers.
1168 * Dont touch, used by lavc default_get_buffer()
1169 */
1170 void *internal_buffer;
3d2e8cce
MN
1171
1172#define FF_QUALITY_SCALE 256
1173 /**
1174 * global quality for codecs which cannot change it per frame.
1175 * this should be proportional to MPEG1/2/4 qscale.
1176 * - encoding: set by user.
1177 * - decoding: unused
1178 */
1179 int global_quality;
11e659c2
MN
1180
1181#define FF_CODER_TYPE_VLC 0
1182#define FF_CODER_TYPE_AC 1
1183 /**
1184 * coder type
1185 * - encoding: set by user.
1186 * - decoding: unused
1187 */
1188 int coder_type;
1189
1190 /**
1191 * context model
1192 * - encoding: set by user.
1193 * - decoding: unused
1194 */
1195 int context_model;
3bb07d61
MN
1196
1197 /**
1198 * slice flags
1199 * - encoding: unused
1200 * - decoding: set by user.
1201 */
1202 int slice_flags;
1203#define SLICE_FLAG_CODED_ORDER 0x0001 ///< draw_horiz_band() is called in coded order instead of display
1204#define SLICE_FLAG_ALLOW_FIELD 0x0002 ///< allow draw_horiz_band() with field slices (MPEG2 field pics)
1205#define SLICE_FLAG_ALLOW_PLANE 0x0004 ///< allow draw_horiz_band() with 1 component at a time (SVQ1)
1206
fb364ada
IK
1207 /**
1208 * XVideo Motion Acceleration
1209 * - encoding: forbidden
1210 * - decoding: set by decoder
1211 */
1212 int xvmc_acceleration;
7d1c3fc1
MN
1213
1214 /**
1215 * macroblock decision mode
1216 * - encoding: set by user.
1217 * - decoding: unused
1218 */
1219 int mb_decision;
1220#define FF_MB_DECISION_SIMPLE 0 ///< uses mb_cmp
1221#define FF_MB_DECISION_BITS 1 ///< chooses the one which needs the fewest bits
1222#define FF_MB_DECISION_RD 2 ///< rate distoration
d6eb3c50
MN
1223
1224 /**
1225 * custom intra quantization matrix
1226 * - encoding: set by user, can be NULL
1227 * - decoding: set by lavc
1228 */
1229 uint16_t *intra_matrix;
1230
1231 /**
1232 * custom inter quantization matrix
1233 * - encoding: set by user, can be NULL
1234 * - decoding: set by lavc
1235 */
1236 uint16_t *inter_matrix;
7d1c3fc1 1237
541ae140
MN
1238 /**
1239 * fourcc from the AVI stream header (LSB first, so "ABCD" -> ('D'<<24) + ('C'<<16) + ('B'<<8) + 'A').
1240 * this is used to workaround some encoder bugs
1241 * - encoding: unused
1242 * - decoding: set by user, will be converted to upper case by lavc during init
1243 */
1244 unsigned int stream_codec_tag;
de6d9b64
FB
1245} AVCodecContext;
1246
97d96aaa 1247
64863965
MN
1248/**
1249 * AVOption.
1250 */
97d96aaa
ZK
1251typedef struct AVOption {
1252 /** options' name */
1253 const char *name; /* if name is NULL, it indicates a link to next */
bec89a84
ZK
1254 /** short English text help or const struct AVOption* subpointer */
1255 const char *help; // const struct AVOption* sub;
97d96aaa
ZK
1256 /** offset to context structure where the parsed value should be stored */
1257 int offset;
1258 /** options' type */
1259 int type;
64863965
MN
1260#define FF_OPT_TYPE_BOOL 1 ///< boolean - true,1,on (or simply presence)
1261#define FF_OPT_TYPE_DOUBLE 2 ///< double
1262#define FF_OPT_TYPE_INT 3 ///< integer
1263#define FF_OPT_TYPE_STRING 4 ///< string (finished with \0)
1264#define FF_OPT_TYPE_MASK 0x1f ///< mask for types - upper bits are various flags
97d96aaa
ZK
1265//#define FF_OPT_TYPE_EXPERT 0x20 // flag for expert option
1266#define FF_OPT_TYPE_FLAG (FF_OPT_TYPE_BOOL | 0x40)
1267#define FF_OPT_TYPE_RCOVERRIDE (FF_OPT_TYPE_STRING | 0x80)
1268 /** min value (min == max -> no limits) */
1269 double min;
1270 /** maximum value for double/int */
1271 double max;
1272 /** default boo [0,1]l/double/int value */
1273 double defval;
1274 /**
1275 * default string value (with optional semicolon delimited extra option-list
1276 * i.e. option1;option2;option3
1277 * defval might select other then first argument as default
1278 */
1279 const char *defstr;
97d96aaa
ZK
1280#define FF_OPT_MAX_DEPTH 10
1281} AVOption;
1282
64863965 1283/**
bec89a84
ZK
1284 * Parse option(s) and sets fields in passed structure
1285 * @param strct structure where the parsed results will be written
1286 * @param list list with AVOptions
1287 * @param opts string with options for parsing
1288 */
1289int avoption_parse(void* strct, const AVOption* list, const char* opts);
1290
1291
1292/**
64863965
MN
1293 * AVCodec.
1294 */
de6d9b64 1295typedef struct AVCodec {
18f77016 1296 const char *name;
5d234974 1297 enum CodecType type;
de6d9b64
FB
1298 int id;
1299 int priv_data_size;
1300 int (*init)(AVCodecContext *);
0c1a9eda 1301 int (*encode)(AVCodecContext *, uint8_t *buf, int buf_size, void *data);
de6d9b64 1302 int (*close)(AVCodecContext *);
0fd90455 1303 int (*decode)(AVCodecContext *, void *outdata, int *outdata_size,
0c1a9eda 1304 uint8_t *buf, int buf_size);
bf89e6b1 1305 int capabilities;
97d96aaa 1306 const AVOption *options;
de6d9b64 1307 struct AVCodec *next;
7a06ff14 1308 void (*flush)(AVCodecContext *);
de6d9b64
FB
1309} AVCodec;
1310
97d96aaa 1311/**
d7425f59
MN
1312 * four components are given, that's all.
1313 * the last component is alpha
1314 */
de6d9b64 1315typedef struct AVPicture {
0c1a9eda 1316 uint8_t *data[4];
cd394651 1317 int linesize[4]; ///< number of bytes per line
de6d9b64
FB
1318} AVPicture;
1319
ba118447
MM
1320/**
1321 * AVPaletteControl
1322 * This structure defines a method for communicating palette changes
1323 * between and demuxer and a decoder.
1324 */
1325typedef struct AVPaletteControl {
1326
1327 /* demuxer sets this to 1 to indicate the palette has changed;
1328 * decoder resets to 0 */
1329 int palette_changed;
1330
1331 /* 256 3-byte RGB palette entries; the components should be
1332 * formatted in the buffer as "RGBRGB..." and should be scaled to
1333 * 8 bits if they originally represented 6-bit VGA palette
1334 * components */
1335 unsigned char palette[256 * 3];
1336
1337} AVPaletteControl;
1338
de6d9b64
FB
1339extern AVCodec ac3_encoder;
1340extern AVCodec mp2_encoder;
9d36bdc9 1341extern AVCodec mp3lame_encoder;
81e0d0b4 1342extern AVCodec oggvorbis_encoder;
de6d9b64 1343extern AVCodec mpeg1video_encoder;
029911d1 1344extern AVCodec mpeg2video_encoder;
de6d9b64
FB
1345extern AVCodec h263_encoder;
1346extern AVCodec h263p_encoder;
d4f5d74a 1347extern AVCodec flv_encoder;
de6d9b64
FB
1348extern AVCodec rv10_encoder;
1349extern AVCodec mjpeg_encoder;
b1e6b355 1350extern AVCodec ljpeg_encoder;
bf89e6b1 1351extern AVCodec mpeg4_encoder;
84afee34
MN
1352extern AVCodec msmpeg4v1_encoder;
1353extern AVCodec msmpeg4v2_encoder;
1354extern AVCodec msmpeg4v3_encoder;
0151a6f5
MN
1355extern AVCodec wmv1_encoder;
1356extern AVCodec wmv2_encoder;
11f18faf 1357extern AVCodec huffyuv_encoder;
0da71265 1358extern AVCodec h264_encoder;
3d2e8cce 1359extern AVCodec asv1_encoder;
9b56edf5 1360extern AVCodec asv2_encoder;
be3564ed 1361extern AVCodec vcr1_encoder;
5e20f836 1362extern AVCodec ffv1_encoder;
c3bf0288 1363extern AVCodec mdec_encoder;
de6d9b64
FB
1364
1365extern AVCodec h263_decoder;
bf89e6b1 1366extern AVCodec mpeg4_decoder;
84afee34
MN
1367extern AVCodec msmpeg4v1_decoder;
1368extern AVCodec msmpeg4v2_decoder;
1369extern AVCodec msmpeg4v3_decoder;
e1a9dbff 1370extern AVCodec wmv1_decoder;
0151a6f5 1371extern AVCodec wmv2_decoder;
922bc38d
MN
1372extern AVCodec mpeg1video_decoder;
1373extern AVCodec mpeg2video_decoder;
fb364ada 1374extern AVCodec mpeg_xvmc_decoder;
de6d9b64 1375extern AVCodec h263i_decoder;
d4f5d74a 1376extern AVCodec flv_decoder;
de6d9b64 1377extern AVCodec rv10_decoder;
be8ffec9 1378extern AVCodec svq1_decoder;
8b82a956 1379extern AVCodec svq3_decoder;
020fcc94
FB
1380extern AVCodec dvvideo_decoder;
1381extern AVCodec dvaudio_decoder;
bc8d1857
FB
1382extern AVCodec wmav1_decoder;
1383extern AVCodec wmav2_decoder;
4e66ab3b 1384extern AVCodec mjpeg_decoder;
b135d9fb 1385extern AVCodec mjpegb_decoder;
4b1f4f23 1386extern AVCodec mp2_decoder;
a96b68b7 1387extern AVCodec mp3_decoder;
3f95e843
FR
1388extern AVCodec mace3_decoder;
1389extern AVCodec mace6_decoder;
11f18faf 1390extern AVCodec huffyuv_decoder;
3aca208a 1391extern AVCodec oggvorbis_decoder;
f70f7c6d 1392extern AVCodec cyuv_decoder;
0da71265 1393extern AVCodec h264_decoder;
deabd4fd 1394extern AVCodec indeo3_decoder;
d86053a4 1395extern AVCodec vp3_decoder;
891f64b3 1396extern AVCodec amr_nb_decoder;
bc634f6f 1397extern AVCodec amr_nb_encoder;
280bd7b7
ZK
1398extern AVCodec aac_decoder;
1399extern AVCodec mpeg4aac_decoder;
3d2e8cce 1400extern AVCodec asv1_decoder;
9b56edf5 1401extern AVCodec asv2_decoder;
be3564ed 1402extern AVCodec vcr1_decoder;
3aff069b 1403extern AVCodec cljr_decoder;
5e20f836 1404extern AVCodec ffv1_decoder;
8809cfee 1405extern AVCodec fourxm_decoder;
c3bf0288 1406extern AVCodec mdec_decoder;
3ef8be2b
MM
1407extern AVCodec roq_decoder;
1408extern AVCodec interplay_video_decoder;
9937e686 1409extern AVCodec xan_wc3_decoder;
b8414bbd
NK
1410extern AVCodec ra_144_decoder;
1411extern AVCodec ra_288_decoder;
3ef8be2b
MM
1412extern AVCodec roq_dpcm_decoder;
1413extern AVCodec interplay_dpcm_decoder;
9937e686 1414extern AVCodec xan_dpcm_decoder;
de6d9b64 1415
a96b68b7
FB
1416/* pcm codecs */
1417#define PCM_CODEC(id, name) \
1418extern AVCodec name ## _decoder; \
f11d3f23 1419extern AVCodec name ## _encoder
a96b68b7
FB
1420
1421PCM_CODEC(CODEC_ID_PCM_S16LE, pcm_s16le);
1422PCM_CODEC(CODEC_ID_PCM_S16BE, pcm_s16be);
1423PCM_CODEC(CODEC_ID_PCM_U16LE, pcm_u16le);
1424PCM_CODEC(CODEC_ID_PCM_U16BE, pcm_u16be);
1425PCM_CODEC(CODEC_ID_PCM_S8, pcm_s8);
1426PCM_CODEC(CODEC_ID_PCM_U8, pcm_u8);
1427PCM_CODEC(CODEC_ID_PCM_ALAW, pcm_alaw);
1428PCM_CODEC(CODEC_ID_PCM_MULAW, pcm_mulaw);
1429
0147f198
FR
1430/* adpcm codecs */
1431
1432PCM_CODEC(CODEC_ID_ADPCM_IMA_QT, adpcm_ima_qt);
1433PCM_CODEC(CODEC_ID_ADPCM_IMA_WAV, adpcm_ima_wav);
9937e686
MM
1434PCM_CODEC(CODEC_ID_ADPCM_IMA_DK3, adpcm_ima_dk3);
1435PCM_CODEC(CODEC_ID_ADPCM_IMA_DK4, adpcm_ima_dk4);
0147f198 1436PCM_CODEC(CODEC_ID_ADPCM_MS, adpcm_ms);
4b465299 1437PCM_CODEC(CODEC_ID_ADPCM_4XM, adpcm_4xm);
0147f198 1438
a96b68b7
FB
1439#undef PCM_CODEC
1440
1441/* dummy raw video codec */
63167088
RS
1442extern AVCodec rawvideo_encoder;
1443extern AVCodec rawvideo_decoder;
de6d9b64
FB
1444
1445/* the following codecs use external GPL libs */
de6d9b64
FB
1446extern AVCodec ac3_decoder;
1447
1448/* resample.c */
1449
1450struct ReSampleContext;
1451
1452typedef struct ReSampleContext ReSampleContext;
1453
1454ReSampleContext *audio_resample_init(int output_channels, int input_channels,
1455 int output_rate, int input_rate);
1456int audio_resample(ReSampleContext *s, short *output, short *input, int nb_samples);
1457void audio_resample_close(ReSampleContext *s);
1458
1459/* YUV420 format is assumed ! */
1460
1461struct ImgReSampleContext;
1462
1463typedef struct ImgReSampleContext ImgReSampleContext;
1464
1465ImgReSampleContext *img_resample_init(int output_width, int output_height,
1466 int input_width, int input_height);
ab6d194a
MN
1467
1468ImgReSampleContext *img_resample_full_init(int owidth, int oheight,
1469 int iwidth, int iheight,
1470 int topBand, int bottomBand,
1471 int leftBand, int rightBand);
1472
de6d9b64
FB
1473void img_resample(ImgReSampleContext *s,
1474 AVPicture *output, AVPicture *input);
1475
1476void img_resample_close(ImgReSampleContext *s);
1477
0c1a9eda 1478int avpicture_fill(AVPicture *picture, uint8_t *ptr,
2d1a4094 1479 int pix_fmt, int width, int height);
63167088
RS
1480int avpicture_layout(AVPicture* src, int pix_fmt, int width, int height,
1481 unsigned char *dest, int dest_size);
219b06c6 1482int avpicture_get_size(int pix_fmt, int width, int height);
dab64ebc
FB
1483void avcodec_get_chroma_sub_sample(int pix_fmt, int *h_shift, int *v_shift);
1484const char *avcodec_get_pix_fmt_name(int pix_fmt);
63167088 1485enum PixelFormat avcodec_get_pix_fmt(const char* name);
219b06c6 1486
fab21997
FB
1487#define FF_LOSS_RESOLUTION 0x0001 /* loss due to resolution change */
1488#define FF_LOSS_DEPTH 0x0002 /* loss due to color depth change */
1489#define FF_LOSS_COLORSPACE 0x0004 /* loss due to color space conversion */
1490#define FF_LOSS_ALPHA 0x0008 /* loss of alpha bits */
1491#define FF_LOSS_COLORQUANT 0x0010 /* loss due to color quantization */
1492#define FF_LOSS_CHROMA 0x0020 /* loss of chroma (e.g. rgb to gray conversion) */
1493
1494int avcodec_get_pix_fmt_loss(int dst_pix_fmt, int src_pix_fmt,
1495 int has_alpha);
1496int avcodec_find_best_pix_fmt(int pix_fmt_mask, int src_pix_fmt,
1497 int has_alpha, int *loss_ptr);
1498
0469baf1
FB
1499#define FF_ALPHA_TRANSP 0x0001 /* image has some totally transparent pixels */
1500#define FF_ALPHA_SEMI_TRANSP 0x0002 /* image has some transparent pixels */
1501int img_get_alpha_info(AVPicture *src, int pix_fmt, int width, int height);
1502
219b06c6
FB
1503/* convert among pixel formats */
1504int img_convert(AVPicture *dst, int dst_pix_fmt,
1505 AVPicture *src, int pix_fmt,
1506 int width, int height);
1507
1508/* deinterlace a picture */
1509int avpicture_deinterlace(AVPicture *dst, AVPicture *src,
de6d9b64
FB
1510 int pix_fmt, int width, int height);
1511
1512/* external high level API */
1513
1514extern AVCodec *first_avcodec;
1515
156e5023 1516/* returns LIBAVCODEC_VERSION_INT constant */
51a49663 1517unsigned avcodec_version(void);
8bceb6af 1518/* returns LIBAVCODEC_BUILD constant */
51a49663 1519unsigned avcodec_build(void);
de6d9b64
FB
1520void avcodec_init(void);
1521
1522void register_avcodec(AVCodec *format);
1523AVCodec *avcodec_find_encoder(enum CodecID id);
98f3b098 1524AVCodec *avcodec_find_encoder_by_name(const char *name);
de6d9b64
FB
1525AVCodec *avcodec_find_decoder(enum CodecID id);
1526AVCodec *avcodec_find_decoder_by_name(const char *name);
1527void avcodec_string(char *buf, int buf_size, AVCodecContext *enc, int encode);
1528
1e491e29 1529void avcodec_get_context_defaults(AVCodecContext *s);
7ffbb60e 1530AVCodecContext *avcodec_alloc_context(void);
492cd3a9 1531AVFrame *avcodec_alloc_frame(void);
1e491e29 1532
492cd3a9
MN
1533int avcodec_default_get_buffer(AVCodecContext *s, AVFrame *pic);
1534void avcodec_default_release_buffer(AVCodecContext *s, AVFrame *pic);
d90cf87b 1535void avcodec_default_free_buffers(AVCodecContext *s);
1e491e29 1536
7a06ff14
MN
1537/**
1538 * opens / inits the AVCodecContext.
1539 * not thread save!
1540 */
de6d9b64 1541int avcodec_open(AVCodecContext *avctx, AVCodec *codec);
7a06ff14 1542
0c1a9eda 1543int avcodec_decode_audio(AVCodecContext *avctx, int16_t *samples,
de6d9b64 1544 int *frame_size_ptr,
0c1a9eda 1545 uint8_t *buf, int buf_size);
492cd3a9 1546int avcodec_decode_video(AVCodecContext *avctx, AVFrame *picture,
de6d9b64 1547 int *got_picture_ptr,
0c1a9eda
ZK
1548 uint8_t *buf, int buf_size);
1549int avcodec_parse_frame(AVCodecContext *avctx, uint8_t **pdata,
917e06c8 1550 int *data_size_ptr,
0c1a9eda
ZK
1551 uint8_t *buf, int buf_size);
1552int avcodec_encode_audio(AVCodecContext *avctx, uint8_t *buf, int buf_size,
de6d9b64 1553 const short *samples);
0c1a9eda 1554int avcodec_encode_video(AVCodecContext *avctx, uint8_t *buf, int buf_size,
492cd3a9 1555 const AVFrame *pict);
de6d9b64
FB
1556
1557int avcodec_close(AVCodecContext *avctx);
1558
1559void avcodec_register_all(void);
a96b68b7 1560
1c2a8c7f
MN
1561void avcodec_flush_buffers(AVCodecContext *avctx);
1562
14bea432 1563/* misc usefull functions */
d8085ea7
MN
1564
1565/**
1566 * returns a single letter to describe the picture type
1567 */
1568char av_get_pict_type_char(int pict_type);
1569
14bea432
MN
1570/**
1571 * reduce a fraction.
1572 * this is usefull for framerate calculations
1573 * @param max the maximum allowed for dst_nom & dst_den
1574 * @return 1 if exact, 0 otherwise
1575 */
1576int av_reduce(int *dst_nom, int *dst_den, int64_t nom, int64_t den, int64_t max);
1577
1578/**
1579 * rescale a 64bit integer.
1580 * a simple a*b/c isnt possible as it can overflow
1581 */
1582int64_t av_rescale(int64_t a, int b, int c);
628d601b 1583
628d601b 1584
e8f14793
ZK
1585/**
1586 * Interface for 0.5.0 version
1587 *
1588 * do not even think about it's usage for this moment
1589 */
1590
1591typedef struct {
64863965 1592 /// compressed size used from given memory buffer
e8f14793
ZK
1593 int size;
1594 /// I/P/B frame type
1595 int frame_type;
1596} avc_enc_result_t;
1597
1598/**
1599 * Commands
1600 * order can't be changed - once it was defined
1601 */
1602typedef enum {
1603 // general commands
1604 AVC_OPEN_BY_NAME = 0xACA000,
1605 AVC_OPEN_BY_CODEC_ID,
1606 AVC_OPEN_BY_FOURCC,
1607 AVC_CLOSE,
1608
1609 AVC_FLUSH,
1610 // pin - struct { uint8_t* src, uint_t src_size }
1611 // pout - struct { AVPicture* img, consumed_bytes,
1612 AVC_DECODE,
1613 // pin - struct { AVPicture* img, uint8_t* dest, uint_t dest_size }
1614 // pout - uint_t used_from_dest_size
1615 AVC_ENCODE,
1616
1617 // query/get video commands
1618 AVC_GET_VERSION = 0xACB000,
1619 AVC_GET_WIDTH,
1620 AVC_GET_HEIGHT,
1621 AVC_GET_DELAY,
1622 AVC_GET_QUANT_TABLE,
1623 // ...
1624
1625 // query/get audio commands
1626 AVC_GET_FRAME_SIZE = 0xABC000,
1627
1628 // maybe define some simple structure which
1629 // might be passed to the user - but they can't
1630 // contain any codec specific parts and these
1631 // calls are usualy necessary only few times
1632
1633 // set video commands
1634 AVC_SET_WIDTH = 0xACD000,
1635 AVC_SET_HEIGHT,
1636
1637 // set video encoding commands
1638 AVC_SET_FRAME_RATE = 0xACD800,
1639 AVC_SET_QUALITY,
1640 AVC_SET_HURRY_UP,
1641
1642 // set audio commands
1643 AVC_SET_SAMPLE_RATE = 0xACE000,
1644 AVC_SET_CHANNELS,
1645
1646} avc_cmd_t;
1647
1648/**
1649 * \param handle allocated private structure by libavcodec
1650 * for initialization pass NULL - will be returned pout
1651 * user is supposed to know nothing about its structure
1652 * \param cmd type of operation to be performed
1653 * \param pint input parameter
1654 * \param pout output parameter
1655 *
1656 * \returns command status - eventually for query command it might return
1657 * integer resulting value
1658 */
1659int avcodec(void* handle, avc_cmd_t cmd, void* pin, void* pout);
1660
544eb99c 1661/* memory */
e4eadb4b 1662void *av_malloc(unsigned int size);
18f77016 1663void *av_mallocz(unsigned int size);
8e1e6f31 1664void *av_realloc(void *ptr, unsigned int size);
544eb99c 1665void av_free(void *ptr);
8e1e6f31 1666char *av_strdup(const char *s);
544eb99c
FB
1667void __av_freep(void **ptr);
1668#define av_freep(p) __av_freep((void **)(p))
97d96aaa 1669void *av_fast_realloc(void *ptr, unsigned int *size, unsigned int min_size);
855ea723
ZK
1670/* for static data only */
1671/* call av_free_static to release all staticaly allocated tables */
628d601b 1672void av_free_static(void);
855ea723
ZK
1673void *__av_mallocz_static(void** location, unsigned int size);
1674#define av_mallocz_static(p, s) __av_mallocz_static((void **)(p), s)
544eb99c 1675
02d697aa
ZK
1676#ifdef __cplusplus
1677}
1678#endif
1679
a96b68b7 1680#endif /* AVCODEC_H */