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