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