sh4 optimized idct & bswap patch by (BERO <bero at geocities dot co dot jp>)
[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
2ad1516a 847
144f0625 848 /**
64863965
MN
849 * slice count.
850 * - encoding: set by lavc
851 * - decoding: set by user (or 0)
144f0625
MN
852 */
853 int slice_count;
854 /**
64863965
MN
855 * slice offsets in the frame in bytes.
856 * - encoding: set/allocated by lavc
857 * - decoding: set/allocated by user (or NULL)
144f0625
MN
858 */
859 int *slice_offset;
860
4d2858de 861 /**
64863965
MN
862 * error concealment flags.
863 * - encoding: unused
864 * - decoding: set by user
4d2858de
MN
865 */
866 int error_concealment;
867#define FF_EC_GUESS_MVS 1
868#define FF_EC_DEBLOCK 2
869
6b72ac63 870 /**
bec89a84 871 * dsp_mask could be add used to disable unwanted CPU features
8350df97 872 * CPU features (i.e. MMX, SSE. ...)
bec89a84
ZK
873 *
874 * with FORCE flag you may instead enable given CPU features
875 * (Dangerous: usable in case of misdetection, improper usage however will
876 * result into program crash)
877 */
878 unsigned dsp_mask;
879#define FF_MM_FORCE 0x80000000 /* force usage of selected flags (OR) */
880 /* lower 16 bits - CPU features */
881#ifdef HAVE_MMX
882#define FF_MM_MMX 0x0001 /* standard MMX */
883#define FF_MM_3DNOW 0x0004 /* AMD 3DNOW */
884#define FF_MM_MMXEXT 0x0002 /* SSE integer functions or AMD MMX ext */
885#define FF_MM_SSE 0x0008 /* SSE functions */
886#define FF_MM_SSE2 0x0010 /* PIV SSE2 functions */
887#endif /* HAVE_MMX */
11f18faf
MN
888
889 /**
64863965
MN
890 * bits per sample/pixel from the demuxer (needed for huffyuv).
891 * - encoding: set by lavc
892 * - decoding: set by user
11f18faf
MN
893 */
894 int bits_per_sample;
895
896 /**
64863965
MN
897 * prediction method (needed for huffyuv).
898 * - encoding: set by user
899 * - decoding: unused
11f18faf
MN
900 */
901 int prediction_method;
902#define FF_PRED_LEFT 0
903#define FF_PRED_PLANE 1
904#define FF_PRED_MEDIAN 2
5d3cea3a
MN
905
906 /**
64863965
MN
907 * aspect ratio (0 if unknown).
908 * - encoding: set by user.
909 * - decoding: set by lavc.
5d3cea3a
MN
910 */
911 float aspect_ratio;
1e491e29
MN
912
913 /**
64863965
MN
914 * the picture in the bitstream.
915 * - encoding: set by lavc
916 * - decoding: set by lavc
1e491e29 917 */
492cd3a9 918 AVFrame *coded_frame;
c8c437bc
MN
919
920 /**
64863965
MN
921 * debug.
922 * - encoding: set by user.
923 * - decoding: set by user.
c8c437bc
MN
924 */
925 int debug;
926#define FF_DEBUG_PICT_INFO 1
927#define FF_DEBUG_RC 2
928#define FF_DEBUG_BITSTREAM 4
929#define FF_DEBUG_MB_TYPE 8
930#define FF_DEBUG_QP 16
931#define FF_DEBUG_MV 32
41773b73
MN
932#define FF_DEBUG_VIS_MV 0x00000040
933#define FF_DEBUG_SKIP 0x00000080
934#define FF_DEBUG_STARTCODE 0x00000100
935#define FF_DEBUG_PTS 0x00000200
46b4feec 936#define FF_DEBUG_ER 0x00000400
0da71265 937#define FF_DEBUG_MMCO 0x00000800
140cb663
MN
938
939 /**
64863965
MN
940 * error.
941 * - encoding: set by lavc if flags&CODEC_FLAG_PSNR
942 * - decoding: unused
140cb663
MN
943 */
944 uint64_t error[4];
17a70fde
MN
945
946 /**
64863965
MN
947 * minimum MB quantizer.
948 * - encoding: set by user.
949 * - decoding: unused
17a70fde
MN
950 */
951 int mb_qmin;
952
953 /**
64863965
MN
954 * maximum MB quantizer.
955 * - encoding: set by user.
956 * - decoding: unused
17a70fde
MN
957 */
958 int mb_qmax;
1457ab52
MN
959
960 /**
64863965
MN
961 * motion estimation compare function.
962 * - encoding: set by user.
963 * - decoding: unused
1457ab52
MN
964 */
965 int me_cmp;
966 /**
64863965
MN
967 * subpixel motion estimation compare function.
968 * - encoding: set by user.
969 * - decoding: unused
1457ab52
MN
970 */
971 int me_sub_cmp;
972 /**
64863965
MN
973 * macroblock compare function (not supported yet).
974 * - encoding: set by user.
975 * - decoding: unused
1457ab52
MN
976 */
977 int mb_cmp;
978#define FF_CMP_SAD 0
979#define FF_CMP_SSE 1
980#define FF_CMP_SATD 2
981#define FF_CMP_DCT 3
982#define FF_CMP_PSNR 4
983#define FF_CMP_BIT 5
984#define FF_CMP_RD 6
985#define FF_CMP_ZERO 7
986#define FF_CMP_CHROMA 256
987
988 /**
64863965
MN
989 * ME diamond size & shape.
990 * - encoding: set by user.
991 * - decoding: unused
1457ab52
MN
992 */
993 int dia_size;
b07a5980
MN
994
995 /**
64863965
MN
996 * amount of previous MV predictors (2a+1 x 2a+1 square).
997 * - encoding: set by user.
998 * - decoding: unused
b07a5980
MN
999 */
1000 int last_predictor_count;
70ac76c0 1001
f5fb6b34 1002 /**
64863965
MN
1003 * pre pass for motion estimation.
1004 * - encoding: set by user.
1005 * - decoding: unused
f5fb6b34
MN
1006 */
1007 int pre_me;
b07a5980 1008
70ac76c0 1009 /**
64863965
MN
1010 * motion estimation pre pass compare function.
1011 * - encoding: set by user.
1012 * - decoding: unused
70ac76c0
MN
1013 */
1014 int me_pre_cmp;
826f429a 1015
70ac76c0 1016 /**
64863965
MN
1017 * ME pre pass diamond size & shape.
1018 * - encoding: set by user.
1019 * - decoding: unused
70ac76c0
MN
1020 */
1021 int pre_dia_size;
1022
826f429a 1023 /**
64863965
MN
1024 * subpel ME quality.
1025 * - encoding: set by user.
1026 * - decoding: unused
826f429a
MN
1027 */
1028 int me_subpel_quality;
1029
a33c7159 1030 /**
64863965 1031 * callback to negotiate the pixelFormat.
a33c7159
MN
1032 * @param fmt is the list of formats which are supported by the codec,
1033 * its terminated by -1 as 0 is a valid format, the formats are ordered by quality
1034 * the first is allways the native one
1035 * @return the choosen format
64863965
MN
1036 * - encoding: unused
1037 * - decoding: set by user, if not set then the native format will always be choosen
a33c7159
MN
1038 */
1039 enum PixelFormat (*get_format)(struct AVCodecContext *s, enum PixelFormat * fmt);
e2f9490e
FB
1040
1041 /**
1042 * DTG active format information (additionnal aspect ratio
1043 * information only used in DVB MPEG2 transport streams). 0 if
1044 * not set.
1045 *
64863965
MN
1046 * - encoding: unused.
1047 * - decoding: set by decoder
e2f9490e
FB
1048 */
1049 int dtg_active_format;
1050#define FF_DTG_AFD_SAME 8
1051#define FF_DTG_AFD_4_3 9
1052#define FF_DTG_AFD_16_9 10
1053#define FF_DTG_AFD_14_9 11
1054#define FF_DTG_AFD_4_3_SP_14_9 13
1055#define FF_DTG_AFD_16_9_SP_14_9 14
1056#define FF_DTG_AFD_SP_4_3 15
1057
ebbcdc9a
MN
1058 /**
1059 * Maximum motion estimation search range in subpel units.
1060 * if 0 then no limit
1061 *
64863965
MN
1062 * - encoding: set by user.
1063 * - decoding: unused.
ebbcdc9a 1064 */
59e0ac8e 1065 int me_range;
ebbcdc9a 1066
65f7062d
MN
1067 /**
1068 * frame_rate_base.
1069 * for variable fps this is 1
1070 * - encoding: set by user.
1071 * - decoding: set by lavc.
1072 * @todo move this after frame_rate
1073 */
65f7062d 1074
1984f635
MN
1075 int frame_rate_base;
1076 /**
1077 * intra quantizer bias.
1078 * - encoding: set by user.
1079 * - decoding: unused
1080 */
1081 int intra_quant_bias;
1082#define FF_DEFAULT_QUANT_BIAS 999999
1083
1084 /**
1085 * inter quantizer bias.
1086 * - encoding: set by user.
1087 * - decoding: unused
1088 */
1089 int inter_quant_bias;
5cd62665
ZK
1090
1091 /**
1092 * color table ID.
1093 * - encoding: unused.
1094 * - decoding: which clrtable should be used for 8bit RGB images
1095 * table have to be stored somewhere FIXME
1096 */
1097 int color_table_id;
1984f635 1098
d90cf87b
MN
1099 /**
1100 * internal_buffer count.
1101 * Dont touch, used by lavc default_get_buffer()
1102 */
1103 int internal_buffer_count;
1104
1105 /**
1106 * internal_buffers.
1107 * Dont touch, used by lavc default_get_buffer()
1108 */
1109 void *internal_buffer;
de6d9b64
FB
1110} AVCodecContext;
1111
97d96aaa 1112
64863965
MN
1113/**
1114 * AVOption.
1115 */
97d96aaa
ZK
1116typedef struct AVOption {
1117 /** options' name */
1118 const char *name; /* if name is NULL, it indicates a link to next */
bec89a84
ZK
1119 /** short English text help or const struct AVOption* subpointer */
1120 const char *help; // const struct AVOption* sub;
97d96aaa
ZK
1121 /** offset to context structure where the parsed value should be stored */
1122 int offset;
1123 /** options' type */
1124 int type;
64863965
MN
1125#define FF_OPT_TYPE_BOOL 1 ///< boolean - true,1,on (or simply presence)
1126#define FF_OPT_TYPE_DOUBLE 2 ///< double
1127#define FF_OPT_TYPE_INT 3 ///< integer
1128#define FF_OPT_TYPE_STRING 4 ///< string (finished with \0)
1129#define FF_OPT_TYPE_MASK 0x1f ///< mask for types - upper bits are various flags
97d96aaa
ZK
1130//#define FF_OPT_TYPE_EXPERT 0x20 // flag for expert option
1131#define FF_OPT_TYPE_FLAG (FF_OPT_TYPE_BOOL | 0x40)
1132#define FF_OPT_TYPE_RCOVERRIDE (FF_OPT_TYPE_STRING | 0x80)
1133 /** min value (min == max -> no limits) */
1134 double min;
1135 /** maximum value for double/int */
1136 double max;
1137 /** default boo [0,1]l/double/int value */
1138 double defval;
1139 /**
1140 * default string value (with optional semicolon delimited extra option-list
1141 * i.e. option1;option2;option3
1142 * defval might select other then first argument as default
1143 */
1144 const char *defstr;
97d96aaa
ZK
1145#define FF_OPT_MAX_DEPTH 10
1146} AVOption;
1147
64863965 1148/**
bec89a84
ZK
1149 * Parse option(s) and sets fields in passed structure
1150 * @param strct structure where the parsed results will be written
1151 * @param list list with AVOptions
1152 * @param opts string with options for parsing
1153 */
1154int avoption_parse(void* strct, const AVOption* list, const char* opts);
1155
1156
1157/**
64863965
MN
1158 * AVCodec.
1159 */
de6d9b64 1160typedef struct AVCodec {
18f77016 1161 const char *name;
5d234974 1162 enum CodecType type;
de6d9b64
FB
1163 int id;
1164 int priv_data_size;
1165 int (*init)(AVCodecContext *);
0c1a9eda 1166 int (*encode)(AVCodecContext *, uint8_t *buf, int buf_size, void *data);
de6d9b64 1167 int (*close)(AVCodecContext *);
0fd90455 1168 int (*decode)(AVCodecContext *, void *outdata, int *outdata_size,
0c1a9eda 1169 uint8_t *buf, int buf_size);
bf89e6b1 1170 int capabilities;
97d96aaa 1171 const AVOption *options;
de6d9b64
FB
1172 struct AVCodec *next;
1173} AVCodec;
1174
97d96aaa 1175/**
d7425f59
MN
1176 * four components are given, that's all.
1177 * the last component is alpha
1178 */
de6d9b64 1179typedef struct AVPicture {
0c1a9eda 1180 uint8_t *data[4];
d7425f59 1181 int linesize[4];
de6d9b64
FB
1182} AVPicture;
1183
1184extern AVCodec ac3_encoder;
1185extern AVCodec mp2_encoder;
9d36bdc9 1186extern AVCodec mp3lame_encoder;
81e0d0b4 1187extern AVCodec oggvorbis_encoder;
de6d9b64
FB
1188extern AVCodec mpeg1video_encoder;
1189extern AVCodec h263_encoder;
1190extern AVCodec h263p_encoder;
1191extern AVCodec rv10_encoder;
1192extern AVCodec mjpeg_encoder;
bf89e6b1 1193extern AVCodec mpeg4_encoder;
84afee34
MN
1194extern AVCodec msmpeg4v1_encoder;
1195extern AVCodec msmpeg4v2_encoder;
1196extern AVCodec msmpeg4v3_encoder;
0151a6f5
MN
1197extern AVCodec wmv1_encoder;
1198extern AVCodec wmv2_encoder;
11f18faf 1199extern AVCodec huffyuv_encoder;
0da71265 1200extern AVCodec h264_encoder;
de6d9b64
FB
1201
1202extern AVCodec h263_decoder;
bf89e6b1 1203extern AVCodec mpeg4_decoder;
84afee34
MN
1204extern AVCodec msmpeg4v1_decoder;
1205extern AVCodec msmpeg4v2_decoder;
1206extern AVCodec msmpeg4v3_decoder;
e1a9dbff 1207extern AVCodec wmv1_decoder;
0151a6f5 1208extern AVCodec wmv2_decoder;
de6d9b64
FB
1209extern AVCodec mpeg_decoder;
1210extern AVCodec h263i_decoder;
1211extern AVCodec rv10_decoder;
be8ffec9 1212extern AVCodec svq1_decoder;
8b82a956 1213extern AVCodec svq3_decoder;
020fcc94
FB
1214extern AVCodec dvvideo_decoder;
1215extern AVCodec dvaudio_decoder;
bc8d1857
FB
1216extern AVCodec wmav1_decoder;
1217extern AVCodec wmav2_decoder;
4e66ab3b 1218extern AVCodec mjpeg_decoder;
b135d9fb 1219extern AVCodec mjpegb_decoder;
4b1f4f23 1220extern AVCodec mp2_decoder;
a96b68b7 1221extern AVCodec mp3_decoder;
3f95e843
FR
1222extern AVCodec mace3_decoder;
1223extern AVCodec mace6_decoder;
11f18faf 1224extern AVCodec huffyuv_decoder;
3aca208a 1225extern AVCodec oggvorbis_decoder;
f70f7c6d 1226extern AVCodec cyuv_decoder;
0da71265 1227extern AVCodec h264_decoder;
deabd4fd 1228extern AVCodec indeo3_decoder;
d86053a4 1229extern AVCodec vp3_decoder;
891f64b3 1230extern AVCodec amr_nb_decoder;
280bd7b7
ZK
1231extern AVCodec aac_decoder;
1232extern AVCodec mpeg4aac_decoder;
de6d9b64 1233
a96b68b7
FB
1234/* pcm codecs */
1235#define PCM_CODEC(id, name) \
1236extern AVCodec name ## _decoder; \
f11d3f23 1237extern AVCodec name ## _encoder
a96b68b7
FB
1238
1239PCM_CODEC(CODEC_ID_PCM_S16LE, pcm_s16le);
1240PCM_CODEC(CODEC_ID_PCM_S16BE, pcm_s16be);
1241PCM_CODEC(CODEC_ID_PCM_U16LE, pcm_u16le);
1242PCM_CODEC(CODEC_ID_PCM_U16BE, pcm_u16be);
1243PCM_CODEC(CODEC_ID_PCM_S8, pcm_s8);
1244PCM_CODEC(CODEC_ID_PCM_U8, pcm_u8);
1245PCM_CODEC(CODEC_ID_PCM_ALAW, pcm_alaw);
1246PCM_CODEC(CODEC_ID_PCM_MULAW, pcm_mulaw);
1247
0147f198
FR
1248/* adpcm codecs */
1249
1250PCM_CODEC(CODEC_ID_ADPCM_IMA_QT, adpcm_ima_qt);
1251PCM_CODEC(CODEC_ID_ADPCM_IMA_WAV, adpcm_ima_wav);
1252PCM_CODEC(CODEC_ID_ADPCM_MS, adpcm_ms);
1253
a96b68b7
FB
1254#undef PCM_CODEC
1255
1256/* dummy raw video codec */
63167088
RS
1257extern AVCodec rawvideo_encoder;
1258extern AVCodec rawvideo_decoder;
de6d9b64
FB
1259
1260/* the following codecs use external GPL libs */
de6d9b64
FB
1261extern AVCodec ac3_decoder;
1262
1263/* resample.c */
1264
1265struct ReSampleContext;
1266
1267typedef struct ReSampleContext ReSampleContext;
1268
1269ReSampleContext *audio_resample_init(int output_channels, int input_channels,
1270 int output_rate, int input_rate);
1271int audio_resample(ReSampleContext *s, short *output, short *input, int nb_samples);
1272void audio_resample_close(ReSampleContext *s);
1273
1274/* YUV420 format is assumed ! */
1275
1276struct ImgReSampleContext;
1277
1278typedef struct ImgReSampleContext ImgReSampleContext;
1279
1280ImgReSampleContext *img_resample_init(int output_width, int output_height,
1281 int input_width, int input_height);
ab6d194a
MN
1282
1283ImgReSampleContext *img_resample_full_init(int owidth, int oheight,
1284 int iwidth, int iheight,
1285 int topBand, int bottomBand,
1286 int leftBand, int rightBand);
1287
de6d9b64
FB
1288void img_resample(ImgReSampleContext *s,
1289 AVPicture *output, AVPicture *input);
1290
1291void img_resample_close(ImgReSampleContext *s);
1292
0c1a9eda 1293int avpicture_fill(AVPicture *picture, uint8_t *ptr,
2d1a4094 1294 int pix_fmt, int width, int height);
63167088
RS
1295int avpicture_layout(AVPicture* src, int pix_fmt, int width, int height,
1296 unsigned char *dest, int dest_size);
219b06c6 1297int avpicture_get_size(int pix_fmt, int width, int height);
dab64ebc
FB
1298void avcodec_get_chroma_sub_sample(int pix_fmt, int *h_shift, int *v_shift);
1299const char *avcodec_get_pix_fmt_name(int pix_fmt);
63167088 1300enum PixelFormat avcodec_get_pix_fmt(const char* name);
219b06c6 1301
fab21997
FB
1302#define FF_LOSS_RESOLUTION 0x0001 /* loss due to resolution change */
1303#define FF_LOSS_DEPTH 0x0002 /* loss due to color depth change */
1304#define FF_LOSS_COLORSPACE 0x0004 /* loss due to color space conversion */
1305#define FF_LOSS_ALPHA 0x0008 /* loss of alpha bits */
1306#define FF_LOSS_COLORQUANT 0x0010 /* loss due to color quantization */
1307#define FF_LOSS_CHROMA 0x0020 /* loss of chroma (e.g. rgb to gray conversion) */
1308
1309int avcodec_get_pix_fmt_loss(int dst_pix_fmt, int src_pix_fmt,
1310 int has_alpha);
1311int avcodec_find_best_pix_fmt(int pix_fmt_mask, int src_pix_fmt,
1312 int has_alpha, int *loss_ptr);
1313
0469baf1
FB
1314#define FF_ALPHA_TRANSP 0x0001 /* image has some totally transparent pixels */
1315#define FF_ALPHA_SEMI_TRANSP 0x0002 /* image has some transparent pixels */
1316int img_get_alpha_info(AVPicture *src, int pix_fmt, int width, int height);
1317
219b06c6
FB
1318/* convert among pixel formats */
1319int img_convert(AVPicture *dst, int dst_pix_fmt,
1320 AVPicture *src, int pix_fmt,
1321 int width, int height);
1322
1323/* deinterlace a picture */
1324int avpicture_deinterlace(AVPicture *dst, AVPicture *src,
de6d9b64
FB
1325 int pix_fmt, int width, int height);
1326
1327/* external high level API */
1328
1329extern AVCodec *first_avcodec;
1330
156e5023 1331/* returns LIBAVCODEC_VERSION_INT constant */
51a49663 1332unsigned avcodec_version(void);
8bceb6af 1333/* returns LIBAVCODEC_BUILD constant */
51a49663 1334unsigned avcodec_build(void);
de6d9b64
FB
1335void avcodec_init(void);
1336
1337void register_avcodec(AVCodec *format);
1338AVCodec *avcodec_find_encoder(enum CodecID id);
98f3b098 1339AVCodec *avcodec_find_encoder_by_name(const char *name);
de6d9b64
FB
1340AVCodec *avcodec_find_decoder(enum CodecID id);
1341AVCodec *avcodec_find_decoder_by_name(const char *name);
1342void avcodec_string(char *buf, int buf_size, AVCodecContext *enc, int encode);
1343
1e491e29 1344void avcodec_get_context_defaults(AVCodecContext *s);
7ffbb60e 1345AVCodecContext *avcodec_alloc_context(void);
492cd3a9 1346AVFrame *avcodec_alloc_frame(void);
1e491e29 1347
492cd3a9
MN
1348int avcodec_default_get_buffer(AVCodecContext *s, AVFrame *pic);
1349void avcodec_default_release_buffer(AVCodecContext *s, AVFrame *pic);
d90cf87b 1350void avcodec_default_free_buffers(AVCodecContext *s);
1e491e29 1351
de6d9b64 1352int avcodec_open(AVCodecContext *avctx, AVCodec *codec);
0c1a9eda 1353int avcodec_decode_audio(AVCodecContext *avctx, int16_t *samples,
de6d9b64 1354 int *frame_size_ptr,
0c1a9eda 1355 uint8_t *buf, int buf_size);
492cd3a9 1356int avcodec_decode_video(AVCodecContext *avctx, AVFrame *picture,
de6d9b64 1357 int *got_picture_ptr,
0c1a9eda
ZK
1358 uint8_t *buf, int buf_size);
1359int avcodec_parse_frame(AVCodecContext *avctx, uint8_t **pdata,
917e06c8 1360 int *data_size_ptr,
0c1a9eda
ZK
1361 uint8_t *buf, int buf_size);
1362int avcodec_encode_audio(AVCodecContext *avctx, uint8_t *buf, int buf_size,
de6d9b64 1363 const short *samples);
0c1a9eda 1364int avcodec_encode_video(AVCodecContext *avctx, uint8_t *buf, int buf_size,
492cd3a9 1365 const AVFrame *pict);
de6d9b64
FB
1366
1367int avcodec_close(AVCodecContext *avctx);
1368
1369void avcodec_register_all(void);
a96b68b7 1370
1c2a8c7f
MN
1371void avcodec_flush_buffers(AVCodecContext *avctx);
1372
14bea432
MN
1373/* misc usefull functions */
1374/**
1375 * reduce a fraction.
1376 * this is usefull for framerate calculations
1377 * @param max the maximum allowed for dst_nom & dst_den
1378 * @return 1 if exact, 0 otherwise
1379 */
1380int av_reduce(int *dst_nom, int *dst_den, int64_t nom, int64_t den, int64_t max);
1381
1382/**
1383 * rescale a 64bit integer.
1384 * a simple a*b/c isnt possible as it can overflow
1385 */
1386int64_t av_rescale(int64_t a, int b, int c);
628d601b 1387
628d601b 1388
e8f14793
ZK
1389/**
1390 * Interface for 0.5.0 version
1391 *
1392 * do not even think about it's usage for this moment
1393 */
1394
1395typedef struct {
64863965 1396 /// compressed size used from given memory buffer
e8f14793
ZK
1397 int size;
1398 /// I/P/B frame type
1399 int frame_type;
1400} avc_enc_result_t;
1401
1402/**
1403 * Commands
1404 * order can't be changed - once it was defined
1405 */
1406typedef enum {
1407 // general commands
1408 AVC_OPEN_BY_NAME = 0xACA000,
1409 AVC_OPEN_BY_CODEC_ID,
1410 AVC_OPEN_BY_FOURCC,
1411 AVC_CLOSE,
1412
1413 AVC_FLUSH,
1414 // pin - struct { uint8_t* src, uint_t src_size }
1415 // pout - struct { AVPicture* img, consumed_bytes,
1416 AVC_DECODE,
1417 // pin - struct { AVPicture* img, uint8_t* dest, uint_t dest_size }
1418 // pout - uint_t used_from_dest_size
1419 AVC_ENCODE,
1420
1421 // query/get video commands
1422 AVC_GET_VERSION = 0xACB000,
1423 AVC_GET_WIDTH,
1424 AVC_GET_HEIGHT,
1425 AVC_GET_DELAY,
1426 AVC_GET_QUANT_TABLE,
1427 // ...
1428
1429 // query/get audio commands
1430 AVC_GET_FRAME_SIZE = 0xABC000,
1431
1432 // maybe define some simple structure which
1433 // might be passed to the user - but they can't
1434 // contain any codec specific parts and these
1435 // calls are usualy necessary only few times
1436
1437 // set video commands
1438 AVC_SET_WIDTH = 0xACD000,
1439 AVC_SET_HEIGHT,
1440
1441 // set video encoding commands
1442 AVC_SET_FRAME_RATE = 0xACD800,
1443 AVC_SET_QUALITY,
1444 AVC_SET_HURRY_UP,
1445
1446 // set audio commands
1447 AVC_SET_SAMPLE_RATE = 0xACE000,
1448 AVC_SET_CHANNELS,
1449
1450} avc_cmd_t;
1451
1452/**
1453 * \param handle allocated private structure by libavcodec
1454 * for initialization pass NULL - will be returned pout
1455 * user is supposed to know nothing about its structure
1456 * \param cmd type of operation to be performed
1457 * \param pint input parameter
1458 * \param pout output parameter
1459 *
1460 * \returns command status - eventually for query command it might return
1461 * integer resulting value
1462 */
1463int avcodec(void* handle, avc_cmd_t cmd, void* pin, void* pout);
1464
544eb99c 1465/* memory */
18f77016
ZK
1466void *av_malloc(unsigned int size);
1467void *av_mallocz(unsigned int size);
8e1e6f31 1468void *av_realloc(void *ptr, unsigned int size);
544eb99c 1469void av_free(void *ptr);
8e1e6f31 1470char *av_strdup(const char *s);
544eb99c
FB
1471void __av_freep(void **ptr);
1472#define av_freep(p) __av_freep((void **)(p))
97d96aaa 1473void *av_fast_realloc(void *ptr, unsigned int *size, unsigned int min_size);
855ea723
ZK
1474/* for static data only */
1475/* call av_free_static to release all staticaly allocated tables */
628d601b 1476void av_free_static(void);
855ea723
ZK
1477void *__av_mallocz_static(void** location, unsigned int size);
1478#define av_mallocz_static(p, s) __av_mallocz_static((void **)(p), s)
544eb99c 1479
02d697aa
ZK
1480#ifdef __cplusplus
1481}
1482#endif
1483
a96b68b7 1484#endif /* AVCODEC_H */