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