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