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