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