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