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