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