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