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