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