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