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