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