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