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