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