64080cf5ebb84203c83e3096185129d5641d9723
[libav.git] / libavcodec / avcodec.h
1 #ifndef AVCODEC_H
2 #define AVCODEC_H
3
4 /**
5 * @file avcodec.h
6 * external api header.
7 */
8
9
10 #ifdef __cplusplus
11 extern "C" {
12 #endif
13
14 #include "common.h"
15 #include "rational.h"
16 #include <sys/types.h> /* size_t */
17
18 #define FFMPEG_VERSION_INT 0x000409
19 #define FFMPEG_VERSION "0.4.9-pre1"
20 #define LIBAVCODEC_BUILD 4752
21
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)
28
29 #define AV_NOPTS_VALUE int64_t_C(0x8000000000000000)
30 #define AV_TIME_BASE 1000000
31
32 enum CodecID {
33 CODEC_ID_NONE,
34 CODEC_ID_MPEG1VIDEO,
35 CODEC_ID_MPEG2VIDEO, /* prefered ID for MPEG Video 1 or 2 decoding */
36 CODEC_ID_MPEG2VIDEO_XVMC,
37 CODEC_ID_H261,
38 CODEC_ID_H263,
39 CODEC_ID_RV10,
40 CODEC_ID_RV20,
41 CODEC_ID_MJPEG,
42 CODEC_ID_MJPEGB,
43 CODEC_ID_LJPEG,
44 CODEC_ID_SP5X,
45 CODEC_ID_MPEG4,
46 CODEC_ID_RAWVIDEO,
47 CODEC_ID_MSMPEG4V1,
48 CODEC_ID_MSMPEG4V2,
49 CODEC_ID_MSMPEG4V3,
50 CODEC_ID_WMV1,
51 CODEC_ID_WMV2,
52 CODEC_ID_H263P,
53 CODEC_ID_H263I,
54 CODEC_ID_FLV1,
55 CODEC_ID_SVQ1,
56 CODEC_ID_SVQ3,
57 CODEC_ID_DVVIDEO,
58 CODEC_ID_HUFFYUV,
59 CODEC_ID_CYUV,
60 CODEC_ID_H264,
61 CODEC_ID_INDEO3,
62 CODEC_ID_VP3,
63 CODEC_ID_THEORA,
64 CODEC_ID_ASV1,
65 CODEC_ID_ASV2,
66 CODEC_ID_FFV1,
67 CODEC_ID_4XM,
68 CODEC_ID_VCR1,
69 CODEC_ID_CLJR,
70 CODEC_ID_MDEC,
71 CODEC_ID_ROQ,
72 CODEC_ID_INTERPLAY_VIDEO,
73 CODEC_ID_XAN_WC3,
74 CODEC_ID_XAN_WC4,
75 CODEC_ID_RPZA,
76 CODEC_ID_CINEPAK,
77 CODEC_ID_WS_VQA,
78 CODEC_ID_MSRLE,
79 CODEC_ID_MSVIDEO1,
80 CODEC_ID_IDCIN,
81 CODEC_ID_8BPS,
82 CODEC_ID_SMC,
83 CODEC_ID_FLIC,
84 CODEC_ID_TRUEMOTION1,
85 CODEC_ID_VMDVIDEO,
86 CODEC_ID_MSZH,
87 CODEC_ID_ZLIB,
88 CODEC_ID_QTRLE,
89 CODEC_ID_SNOW,
90 CODEC_ID_TSCC,
91 CODEC_ID_ULTI,
92 CODEC_ID_QDRAW,
93 CODEC_ID_VIXL,
94 CODEC_ID_QPEG,
95 CODEC_ID_XVID,
96 CODEC_ID_PNG,
97 CODEC_ID_PPM,
98 CODEC_ID_PBM,
99 CODEC_ID_PGM,
100 CODEC_ID_PGMYUV,
101 CODEC_ID_PAM,
102 CODEC_ID_FFVHUFF,
103 CODEC_ID_RV30,
104 CODEC_ID_RV40,
105 CODEC_ID_VC9,
106 CODEC_ID_WMV3,
107 CODEC_ID_LOCO,
108 CODEC_ID_WNV1,
109 CODEC_ID_AASC,
110
111 /* various pcm "codecs" */
112 CODEC_ID_PCM_S16LE= 0x10000,
113 CODEC_ID_PCM_S16BE,
114 CODEC_ID_PCM_U16LE,
115 CODEC_ID_PCM_U16BE,
116 CODEC_ID_PCM_S8,
117 CODEC_ID_PCM_U8,
118 CODEC_ID_PCM_MULAW,
119 CODEC_ID_PCM_ALAW,
120
121 /* various adpcm codecs */
122 CODEC_ID_ADPCM_IMA_QT= 0x11000,
123 CODEC_ID_ADPCM_IMA_WAV,
124 CODEC_ID_ADPCM_IMA_DK3,
125 CODEC_ID_ADPCM_IMA_DK4,
126 CODEC_ID_ADPCM_IMA_WS,
127 CODEC_ID_ADPCM_IMA_SMJPEG,
128 CODEC_ID_ADPCM_MS,
129 CODEC_ID_ADPCM_4XM,
130 CODEC_ID_ADPCM_XA,
131 CODEC_ID_ADPCM_ADX,
132 CODEC_ID_ADPCM_EA,
133 CODEC_ID_ADPCM_G726,
134 CODEC_ID_ADPCM_CT,
135 CODEC_ID_ADPCM_SWF,
136
137 /* AMR */
138 CODEC_ID_AMR_NB= 0x12000,
139 CODEC_ID_AMR_WB,
140
141 /* RealAudio codecs*/
142 CODEC_ID_RA_144= 0x13000,
143 CODEC_ID_RA_288,
144
145 /* various DPCM codecs */
146 CODEC_ID_ROQ_DPCM= 0x14000,
147 CODEC_ID_INTERPLAY_DPCM,
148 CODEC_ID_XAN_DPCM,
149 CODEC_ID_SOL_DPCM,
150
151 CODEC_ID_MP2= 0x15000,
152 CODEC_ID_MP3, /* prefered ID for MPEG Audio layer 1, 2 or3 decoding */
153 CODEC_ID_AAC,
154 CODEC_ID_MPEG4AAC,
155 CODEC_ID_AC3,
156 CODEC_ID_DTS,
157 CODEC_ID_VORBIS,
158 CODEC_ID_DVAUDIO,
159 CODEC_ID_WMAV1,
160 CODEC_ID_WMAV2,
161 CODEC_ID_MACE3,
162 CODEC_ID_MACE6,
163 CODEC_ID_VMDAUDIO,
164 CODEC_ID_SONIC,
165 CODEC_ID_SONIC_LS,
166 CODEC_ID_FLAC,
167 CODEC_ID_MP3ADU,
168 CODEC_ID_MP3ON4,
169 CODEC_ID_SHORTEN,
170 CODEC_ID_ALAC,
171 CODEC_ID_WESTWOOD_SND1,
172
173 CODEC_ID_OGGTHEORA= 0x16000,
174
175 CODEC_ID_MPEG2TS= 0x20000, /* _FAKE_ codec to indicate a raw MPEG2 transport
176 stream (only used by libavformat) */
177 };
178
179 /* CODEC_ID_MP3LAME is absolete */
180 #define CODEC_ID_MP3LAME CODEC_ID_MP3
181
182 enum CodecType {
183 CODEC_TYPE_UNKNOWN = -1,
184 CODEC_TYPE_VIDEO,
185 CODEC_TYPE_AUDIO,
186 CODEC_TYPE_DATA,
187 };
188
189 /**
190 * Pixel format. Notes:
191 *
192 * PIX_FMT_RGBA32 is handled in an endian-specific manner. A RGBA
193 * color is put together as:
194 * (A << 24) | (R << 16) | (G << 8) | B
195 * This is stored as BGRA on little endian CPU architectures and ARGB on
196 * big endian CPUs.
197 *
198 * When the pixel format is palettized RGB (PIX_FMT_PAL8), the palettized
199 * image data is stored in AVFrame.data[0]. The palette is transported in
200 * AVFrame.data[1] and, is 1024 bytes long (256 4-byte entries) and is
201 * formatted the same as in PIX_FMT_RGBA32 described above (i.e., it is
202 * also endian-specific). Note also that the individual RGB palette
203 * components stored in AVFrame.data[1] should be in the range 0..255.
204 * This is important as many custom PAL8 video codecs that were designed
205 * to run on the IBM VGA graphics adapter use 6-bit palette components.
206 */
207 enum PixelFormat {
208 PIX_FMT_YUV420P, ///< Planar YUV 4:2:0 (1 Cr & Cb sample per 2x2 Y samples)
209 PIX_FMT_YUV422, ///< Packed pixel, Y0 Cb Y1 Cr
210 PIX_FMT_RGB24, ///< Packed pixel, 3 bytes per pixel, RGBRGB...
211 PIX_FMT_BGR24, ///< Packed pixel, 3 bytes per pixel, BGRBGR...
212 PIX_FMT_YUV422P, ///< Planar YUV 4:2:2 (1 Cr & Cb sample per 2x1 Y samples)
213 PIX_FMT_YUV444P, ///< Planar YUV 4:4:4 (1 Cr & Cb sample per 1x1 Y samples)
214 PIX_FMT_RGBA32, ///< Packed pixel, 4 bytes per pixel, BGRABGRA..., stored in cpu endianness
215 PIX_FMT_YUV410P, ///< Planar YUV 4:1:0 (1 Cr & Cb sample per 4x4 Y samples)
216 PIX_FMT_YUV411P, ///< Planar YUV 4:1:1 (1 Cr & Cb sample per 4x1 Y samples)
217 PIX_FMT_RGB565, ///< always stored in cpu endianness
218 PIX_FMT_RGB555, ///< always stored in cpu endianness, most significant bit to 1
219 PIX_FMT_GRAY8,
220 PIX_FMT_MONOWHITE, ///< 0 is white
221 PIX_FMT_MONOBLACK, ///< 0 is black
222 PIX_FMT_PAL8, ///< 8 bit with RGBA palette
223 PIX_FMT_YUVJ420P, ///< Planar YUV 4:2:0 full scale (jpeg)
224 PIX_FMT_YUVJ422P, ///< Planar YUV 4:2:2 full scale (jpeg)
225 PIX_FMT_YUVJ444P, ///< Planar YUV 4:4:4 full scale (jpeg)
226 PIX_FMT_XVMC_MPEG2_MC,///< XVideo Motion Acceleration via common packet passing(xvmc_render.h)
227 PIX_FMT_XVMC_MPEG2_IDCT,
228 PIX_FMT_UYVY422, ///< Packed pixel, Cb Y0 Cr Y1
229 PIX_FMT_UYVY411, ///< Packed pixel, Cb Y0 Y1 Cr Y2 Y3
230 PIX_FMT_NB,
231 };
232
233 /* currently unused, may be used if 24/32 bits samples ever supported */
234 enum SampleFormat {
235 SAMPLE_FMT_S16 = 0, ///< signed 16 bits
236 SAMPLE_FMT_S32, ///< signed 32 bits
237 SAMPLE_FMT_FLT, ///< float
238 SAMPLE_FMT_DBL, ///< double
239 };
240
241 /* in bytes */
242 #define AVCODEC_MAX_AUDIO_FRAME_SIZE 131072
243
244 /**
245 * Required number of additionally allocated bytes at the end of the input bitstream for decoding.
246 * this is mainly needed because some optimized bitstream readers read
247 * 32 or 64 bit at once and could read over the end<br>
248 * Note, if the first 23 bits of the additional bytes are not 0 then damaged
249 * MPEG bitstreams could cause overread and segfault
250 */
251 #define FF_INPUT_BUFFER_PADDING_SIZE 8
252
253 /**
254 * minimum encoding buffer size.
255 * used to avoid some checks during header writing
256 */
257 #define FF_MIN_BUFFER_SIZE 16384
258
259 /* motion estimation type, EPZS by default */
260 enum Motion_Est_ID {
261 ME_ZERO = 1,
262 ME_FULL,
263 ME_LOG,
264 ME_PHODS,
265 ME_EPZS,
266 ME_X1
267 };
268
269 enum AVRounding {
270 AV_ROUND_ZERO = 0, ///< round toward zero
271 AV_ROUND_INF = 1, ///< round away from zero
272 AV_ROUND_DOWN = 2, ///< round toward -infinity
273 AV_ROUND_UP = 3, ///< round toward +infinity
274 AV_ROUND_NEAR_INF = 5, ///< round to nearest and halfway cases away from zero
275 };
276
277 typedef struct RcOverride{
278 int start_frame;
279 int end_frame;
280 int qscale; // if this is 0 then quality_factor will be used instead
281 float quality_factor;
282 } RcOverride;
283
284 /* only for ME compatiblity with old apps */
285 extern int motion_estimation_method;
286
287 #define FF_MAX_B_FRAMES 8
288
289 /* encoding support
290 these flags can be passed in AVCodecContext.flags before initing
291 Note: note not everything is supported yet
292 */
293
294 #define CODEC_FLAG_QSCALE 0x0002 ///< use fixed qscale
295 #define CODEC_FLAG_4MV 0x0004 ///< 4 MV per MB allowed / Advanced prediction for H263
296 #define CODEC_FLAG_QPEL 0x0010 ///< use qpel MC
297 #define CODEC_FLAG_GMC 0x0020 ///< use GMC
298 #define CODEC_FLAG_MV0 0x0040 ///< always try a MB with MV=<0,0>
299 #define CODEC_FLAG_PART 0x0080 ///< use data partitioning
300 /* parent program gurantees that the input for b-frame containing streams is not written to
301 for at least s->max_b_frames+1 frames, if this is not set than the input will be copied */
302 #define CODEC_FLAG_INPUT_PRESERVED 0x0100
303 #define CODEC_FLAG_PASS1 0x0200 ///< use internal 2pass ratecontrol in first pass mode
304 #define CODEC_FLAG_PASS2 0x0400 ///< use internal 2pass ratecontrol in second pass mode
305 #define CODEC_FLAG_EXTERN_HUFF 0x1000 ///< use external huffman table (for mjpeg)
306 #define CODEC_FLAG_GRAY 0x2000 ///< only decode/encode grayscale
307 #define CODEC_FLAG_EMU_EDGE 0x4000///< dont draw edges
308 #define CODEC_FLAG_PSNR 0x8000 ///< error[?] variables will be set during encoding
309 #define CODEC_FLAG_TRUNCATED 0x00010000 /** input bitstream might be truncated at a random location instead
310 of only at frame boundaries */
311 #define CODEC_FLAG_NORMALIZE_AQP 0x00020000 ///< normalize adaptive quantization
312 #define CODEC_FLAG_INTERLACED_DCT 0x00040000 ///< use interlaced dct
313 #define CODEC_FLAG_LOW_DELAY 0x00080000 ///< force low delay
314 #define CODEC_FLAG_ALT_SCAN 0x00100000 ///< use alternate scan
315 #define CODEC_FLAG_TRELLIS_QUANT 0x00200000 ///< use trellis quantization
316 #define CODEC_FLAG_GLOBAL_HEADER 0x00400000 ///< place global headers in extradata instead of every keyframe
317 #define CODEC_FLAG_BITEXACT 0x00800000 ///< use only bitexact stuff (except (i)dct)
318 /* Fx : Flag for h263+ extra options */
319 #define CODEC_FLAG_H263P_AIC 0x01000000 ///< H263 Advanced intra coding / MPEG4 AC prediction (remove this)
320 #define CODEC_FLAG_AC_PRED 0x01000000 ///< H263 Advanced intra coding / MPEG4 AC prediction
321 #define CODEC_FLAG_H263P_UMV 0x02000000 ///< Unlimited motion vector
322 #define CODEC_FLAG_CBP_RD 0x04000000 ///< use rate distortion optimization for cbp
323 #define CODEC_FLAG_QP_RD 0x08000000 ///< use rate distortion optimization for qp selectioon
324 #define CODEC_FLAG_H263P_AIV 0x00000008 ///< H263 Alternative inter vlc
325 #define CODEC_FLAG_OBMC 0x00000001 ///< OBMC
326 #define CODEC_FLAG_LOOP_FILTER 0x00000800 ///< loop filter
327 #define CODEC_FLAG_H263P_SLICE_STRUCT 0x10000000
328 #define CODEC_FLAG_INTERLACED_ME 0x20000000 ///< interlaced motion estimation
329 #define CODEC_FLAG_SVCD_SCAN_OFFSET 0x40000000 ///< will reserve space for SVCD scan offset user data
330 #define CODEC_FLAG_CLOSED_GOP 0x80000000
331 #define CODEC_FLAG2_FAST 0x00000001 ///< allow non spec compliant speedup tricks
332 #define CODEC_FLAG2_STRICT_GOP 0x00000002 ///< strictly enforce GOP size
333 #define CODEC_FLAG2_NO_OUTPUT 0x00000004 ///< skip bitstream encoding
334
335 /* Unsupported options :
336 * Syntax Arithmetic coding (SAC)
337 * Reference Picture Selection
338 * Independant Segment Decoding */
339 /* /Fx */
340 /* codec capabilities */
341
342 #define CODEC_CAP_DRAW_HORIZ_BAND 0x0001 ///< decoder can use draw_horiz_band callback
343 /**
344 * Codec uses get_buffer() for allocating buffers.
345 * direct rendering method 1
346 */
347 #define CODEC_CAP_DR1 0x0002
348 /* if 'parse_only' field is true, then avcodec_parse_frame() can be
349 used */
350 #define CODEC_CAP_PARSE_ONLY 0x0004
351 #define CODEC_CAP_TRUNCATED 0x0008
352 /* codec can export data for HW decoding (XvMC) */
353 #define CODEC_CAP_HWACCEL 0x0010
354 /**
355 * codec has a non zero delay and needs to be feeded with NULL at the end to get the delayed data.
356 * if this is not set, the codec is guranteed to never be feeded with NULL data
357 */
358 #define CODEC_CAP_DELAY 0x0020
359
360 //the following defines might change, so dont expect compatibility if u use them
361 #define MB_TYPE_INTRA4x4 0x0001
362 #define MB_TYPE_INTRA16x16 0x0002 //FIXME h264 specific
363 #define MB_TYPE_INTRA_PCM 0x0004 //FIXME h264 specific
364 #define MB_TYPE_16x16 0x0008
365 #define MB_TYPE_16x8 0x0010
366 #define MB_TYPE_8x16 0x0020
367 #define MB_TYPE_8x8 0x0040
368 #define MB_TYPE_INTERLACED 0x0080
369 #define MB_TYPE_DIRECT2 0x0100 //FIXME
370 #define MB_TYPE_ACPRED 0x0200
371 #define MB_TYPE_GMC 0x0400
372 #define MB_TYPE_SKIP 0x0800
373 #define MB_TYPE_P0L0 0x1000
374 #define MB_TYPE_P1L0 0x2000
375 #define MB_TYPE_P0L1 0x4000
376 #define MB_TYPE_P1L1 0x8000
377 #define MB_TYPE_L0 (MB_TYPE_P0L0 | MB_TYPE_P1L0)
378 #define MB_TYPE_L1 (MB_TYPE_P0L1 | MB_TYPE_P1L1)
379 #define MB_TYPE_L0L1 (MB_TYPE_L0 | MB_TYPE_L1)
380 #define MB_TYPE_QUANT 0x00010000
381 #define MB_TYPE_CBP 0x00020000
382 //Note bits 24-31 are reserved for codec specific use (h264 ref0, mpeg1 0mv, ...)
383
384 /**
385 * Pan Scan area.
386 * this specifies the area which should be displayed. Note there may be multiple such areas for one frame
387 */
388 typedef struct AVPanScan{
389 /**
390 * id.
391 * - encoding: set by user.
392 * - decoding: set by lavc
393 */
394 int id;
395
396 /**
397 * width and height in 1/16 pel
398 * - encoding: set by user.
399 * - decoding: set by lavc
400 */
401 int width;
402 int height;
403
404 /**
405 * position of the top left corner in 1/16 pel for up to 3 fields/frames.
406 * - encoding: set by user.
407 * - decoding: set by lavc
408 */
409 int16_t position[3][2];
410 }AVPanScan;
411
412 #define FF_COMMON_FRAME \
413 /**\
414 * pointer to the picture planes.\
415 * this might be different from the first allocated byte\
416 * - encoding: \
417 * - decoding: \
418 */\
419 uint8_t *data[4];\
420 int linesize[4];\
421 /**\
422 * pointer to the first allocated byte of the picture. can be used in get_buffer/release_buffer\
423 * this isnt used by lavc unless the default get/release_buffer() is used\
424 * - encoding: \
425 * - decoding: \
426 */\
427 uint8_t *base[4];\
428 /**\
429 * 1 -> keyframe, 0-> not\
430 * - encoding: set by lavc\
431 * - decoding: set by lavc\
432 */\
433 int key_frame;\
434 \
435 /**\
436 * picture type of the frame, see ?_TYPE below.\
437 * - encoding: set by lavc for coded_picture (and set by user for input)\
438 * - decoding: set by lavc\
439 */\
440 int pict_type;\
441 \
442 /**\
443 * presentation timestamp in AV_TIME_BASE (=micro seconds currently) (time when frame should be shown to user)\
444 * if AV_NOPTS_VALUE then the frame_rate will be used as reference\
445 * - encoding: MUST be set by user\
446 * - decoding: set by lavc\
447 */\
448 int64_t pts;\
449 \
450 /**\
451 * picture number in bitstream order.\
452 * - encoding: set by\
453 * - decoding: set by lavc\
454 */\
455 int coded_picture_number;\
456 /**\
457 * picture number in display order.\
458 * - encoding: set by\
459 * - decoding: set by lavc\
460 */\
461 int display_picture_number;\
462 \
463 /**\
464 * quality (between 1 (good) and FF_LAMBDA_MAX (bad)) \
465 * - encoding: set by lavc for coded_picture (and set by user for input)\
466 * - decoding: set by lavc\
467 */\
468 int quality; \
469 \
470 /**\
471 * buffer age (1->was last buffer and dint change, 2->..., ...).\
472 * set to INT_MAX if the buffer has not been used yet \
473 * - encoding: unused\
474 * - decoding: MUST be set by get_buffer()\
475 */\
476 int age;\
477 \
478 /**\
479 * is this picture used as reference\
480 * - encoding: unused\
481 * - decoding: set by lavc (before get_buffer() call))\
482 */\
483 int reference;\
484 \
485 /**\
486 * QP table\
487 * - encoding: unused\
488 * - decoding: set by lavc\
489 */\
490 int8_t *qscale_table;\
491 /**\
492 * QP store stride\
493 * - encoding: unused\
494 * - decoding: set by lavc\
495 */\
496 int qstride;\
497 \
498 /**\
499 * mbskip_table[mb]>=1 if MB didnt change\
500 * stride= mb_width = (width+15)>>4\
501 * - encoding: unused\
502 * - decoding: set by lavc\
503 */\
504 uint8_t *mbskip_table;\
505 \
506 /**\
507 * Motion vector table.\
508 * @code\
509 * example:\
510 * int mv_sample_log2= 4 - motion_subsample_log2;\
511 * int mb_width= (width+15)>>4;\
512 * int mv_stride= (mb_width << mv_sample_log2) + 1;\
513 * motion_val[direction][x + y*mv_stride][0->mv_x, 1->mv_y];\
514 * @endcode\
515 * - encoding: set by user\
516 * - decoding: set by lavc\
517 */\
518 int16_t (*motion_val[2])[2];\
519 \
520 /**\
521 * Macroblock type table\
522 * mb_type_base + mb_width + 2\
523 * - encoding: set by user\
524 * - decoding: set by lavc\
525 */\
526 uint32_t *mb_type;\
527 \
528 /**\
529 * log2 of the size of the block which a single vector in motion_val represents: \
530 * (4->16x16, 3->8x8, 2-> 4x4, 1-> 2x2)\
531 * - encoding: unused\
532 * - decoding: set by lavc\
533 */\
534 uint8_t motion_subsample_log2;\
535 \
536 /**\
537 * for some private data of the user\
538 * - encoding: unused\
539 * - decoding: set by user\
540 */\
541 void *opaque;\
542 \
543 /**\
544 * error\
545 * - encoding: set by lavc if flags&CODEC_FLAG_PSNR\
546 * - decoding: unused\
547 */\
548 uint64_t error[4];\
549 \
550 /**\
551 * type of the buffer (to keep track of who has to dealloc data[*])\
552 * - encoding: set by the one who allocs it\
553 * - decoding: set by the one who allocs it\
554 * Note: user allocated (direct rendering) & internal buffers can not coexist currently\
555 */\
556 int type;\
557 \
558 /**\
559 * when decoding, this signal how much the picture must be delayed.\
560 * extra_delay = repeat_pict / (2*fps)\
561 * - encoding: unused\
562 * - decoding: set by lavc\
563 */\
564 int repeat_pict;\
565 \
566 /**\
567 * \
568 */\
569 int qscale_type;\
570 \
571 /**\
572 * The content of the picture is interlaced.\
573 * - encoding: set by user\
574 * - decoding: set by lavc (default 0)\
575 */\
576 int interlaced_frame;\
577 \
578 /**\
579 * if the content is interlaced, is top field displayed first.\
580 * - encoding: set by user\
581 * - decoding: set by lavc\
582 */\
583 int top_field_first;\
584 \
585 /**\
586 * Pan scan.\
587 * - encoding: set by user\
588 * - decoding: set by lavc\
589 */\
590 AVPanScan *pan_scan;\
591 \
592 /**\
593 * tell user application that palette has changed from previous frame.\
594 * - encoding: ??? (no palette-enabled encoder yet)\
595 * - decoding: set by lavc (default 0)\
596 */\
597 int palette_has_changed;\
598 \
599 /**\
600 * Codec suggestion on buffer type if != 0\
601 * - encoding: unused\
602 * - decoding: set by lavc (before get_buffer() call))\
603 */\
604 int buffer_hints;\
605 \
606 /**\
607 * DCT coeffitients\
608 * - encoding: unused\
609 * - decoding: set by lavc\
610 */\
611 short *dct_coeff;\
612 \
613 /**\
614 * Motion referece frame index\
615 * - encoding: set by user\
616 * - decoding: set by lavc\
617 */\
618 int8_t *ref_index[2];
619
620 #define FF_QSCALE_TYPE_MPEG1 0
621 #define FF_QSCALE_TYPE_MPEG2 1
622
623 #define FF_BUFFER_TYPE_INTERNAL 1
624 #define FF_BUFFER_TYPE_USER 2 ///< Direct rendering buffers (image is (de)allocated by user)
625 #define FF_BUFFER_TYPE_SHARED 4 ///< buffer from somewher else, dont dealloc image (data/base), all other tables are not shared
626 #define FF_BUFFER_TYPE_COPY 8 ///< just a (modified) copy of some other buffer, dont dealloc anything
627
628
629 #define FF_I_TYPE 1 // Intra
630 #define FF_P_TYPE 2 // Predicted
631 #define FF_B_TYPE 3 // Bi-dir predicted
632 #define FF_S_TYPE 4 // S(GMC)-VOP MPEG4
633 #define FF_SI_TYPE 5
634 #define FF_SP_TYPE 6
635
636 #define FF_BUFFER_HINTS_VALID 0x01 // Buffer hints value is meaningful (if 0 ignore)
637 #define FF_BUFFER_HINTS_READABLE 0x02 // Codec will read from buffer
638 #define FF_BUFFER_HINTS_PRESERVE 0x04 // User must not alter buffer content
639 #define FF_BUFFER_HINTS_REUSABLE 0x08 // Codec will reuse the buffer (update)
640
641 /**
642 * Audio Video Frame.
643 */
644 typedef struct AVFrame {
645 FF_COMMON_FRAME
646 } AVFrame;
647
648 #define DEFAULT_FRAME_RATE_BASE 1001000
649
650 /**
651 * Used by av_log
652 */
653 typedef struct AVCLASS AVClass;
654 struct AVCLASS {
655 const char* class_name;
656 const char* (*item_name)(void*); /* actually passing a pointer to an AVCodecContext
657 or AVFormatContext, which begin with an AVClass.
658 Needed because av_log is in libavcodec and has no visibility
659 of AVIn/OutputFormat */
660 };
661
662 /**
663 * main external api structure.
664 */
665 typedef struct AVCodecContext {
666 /**
667 * Info on struct for av_log
668 * - set by avcodec_alloc_context
669 */
670 AVClass *av_class;
671 /**
672 * the average bitrate.
673 * - encoding: set by user. unused for constant quantizer encoding
674 * - decoding: set by lavc. 0 or some bitrate if this info is available in the stream
675 */
676 int bit_rate;
677
678 /**
679 * number of bits the bitstream is allowed to diverge from the reference.
680 * the reference can be CBR (for CBR pass1) or VBR (for pass2)
681 * - encoding: set by user. unused for constant quantizer encoding
682 * - decoding: unused
683 */
684 int bit_rate_tolerance;
685
686 /**
687 * CODEC_FLAG_*.
688 * - encoding: set by user.
689 * - decoding: set by user.
690 */
691 int flags;
692
693 /**
694 * some codecs needs additionnal format info. It is stored here
695 * - encoding: set by user.
696 * - decoding: set by lavc. (FIXME is this ok?)
697 */
698 int sub_id;
699
700 /**
701 * motion estimation algorithm used for video coding.
702 * - encoding: MUST be set by user.
703 * - decoding: unused
704 */
705 int me_method;
706
707 /**
708 * some codecs need / can use extra-data like huffman tables.
709 * mjpeg: huffman tables
710 * rv10: additional flags
711 * mpeg4: global headers (they can be in the bitstream or here)
712 * the allocated memory should be FF_INPUT_BUFFER_PADDING_SIZE bytes larger
713 * then extradata_size to avoid prolems if its read with the bitstream reader
714 * - encoding: set/allocated/freed by lavc.
715 * - decoding: set/allocated/freed by user.
716 */
717 void *extradata;
718 int extradata_size;
719
720 /* video only */
721 /**
722 * frames per sec multiplied by frame_rate_base.
723 * for variable fps this is the precission, so if the timestamps
724 * can be specified in msec precssion then this is 1000*frame_rate_base
725 * - encoding: MUST be set by user
726 * - decoding: set by lavc. 0 or the frame_rate if available
727 */
728 int frame_rate;
729
730 /**
731 * picture width / height.
732 * - encoding: MUST be set by user.
733 * - decoding: set by lavc.
734 * Note, for compatibility its possible to set this instead of
735 * coded_width/height before decoding
736 */
737 int width, height;
738
739 #define FF_ASPECT_EXTENDED 15
740
741 /**
742 * the number of pictures in a group of pitures, or 0 for intra_only.
743 * - encoding: set by user.
744 * - decoding: unused
745 */
746 int gop_size;
747
748 /**
749 * pixel format, see PIX_FMT_xxx.
750 * - encoding: set by user.
751 * - decoding: set by lavc.
752 */
753 enum PixelFormat pix_fmt;
754
755 /**
756 * Frame rate emulation. If not zero lower layer (i.e. format handler)
757 * has to read frames at native frame rate.
758 * - encoding: set by user.
759 * - decoding: unused.
760 */
761 int rate_emu;
762
763 /**
764 * if non NULL, 'draw_horiz_band' is called by the libavcodec
765 * decoder to draw an horizontal band. It improve cache usage. Not
766 * all codecs can do that. You must check the codec capabilities
767 * before
768 * - encoding: unused
769 * - decoding: set by user.
770 * @param height the height of the slice
771 * @param y the y position of the slice
772 * @param type 1->top field, 2->bottom field, 3->frame
773 * @param offset offset into the AVFrame.data from which the slice should be read
774 */
775 void (*draw_horiz_band)(struct AVCodecContext *s,
776 const AVFrame *src, int offset[4],
777 int y, int type, int height);
778
779 /* audio only */
780 int sample_rate; ///< samples per sec
781 int channels;
782
783 /**
784 * audio sample format.
785 * - encoding: set by user.
786 * - decoding: set by lavc.
787 */
788 enum SampleFormat sample_fmt; ///< sample format, currenly unused
789
790 /* the following data should not be initialized */
791 int frame_size; ///< in samples, initialized when calling 'init'
792 int frame_number; ///< audio or video frame number
793 int real_pict_num; ///< returns the real picture number of previous encoded frame
794
795 /**
796 * number of frames the decoded output will be delayed relative to
797 * the encoded input.
798 * - encoding: set by lavc.
799 * - decoding: unused
800 */
801 int delay;
802
803 /* - encoding parameters */
804 float qcompress; ///< amount of qscale change between easy & hard scenes (0.0-1.0)
805 float qblur; ///< amount of qscale smoothing over time (0.0-1.0)
806
807 /**
808 * minimum quantizer.
809 * - encoding: set by user.
810 * - decoding: unused
811 */
812 int qmin;
813
814 /**
815 * maximum quantizer.
816 * - encoding: set by user.
817 * - decoding: unused
818 */
819 int qmax;
820
821 /**
822 * maximum quantizer difference etween frames.
823 * - encoding: set by user.
824 * - decoding: unused
825 */
826 int max_qdiff;
827
828 /**
829 * maximum number of b frames between non b frames.
830 * note: the output will be delayed by max_b_frames+1 relative to the input
831 * - encoding: set by user.
832 * - decoding: unused
833 */
834 int max_b_frames;
835
836 /**
837 * qscale factor between ip and b frames.
838 * - encoding: set by user.
839 * - decoding: unused
840 */
841 float b_quant_factor;
842
843 /** obsolete FIXME remove */
844 int rc_strategy;
845 int b_frame_strategy;
846
847 /**
848 * hurry up amount.
849 * - encoding: unused
850 * - decoding: set by user. 1-> skip b frames, 2-> skip idct/dequant too, 5-> skip everything except header
851 */
852 int hurry_up;
853
854 struct AVCodec *codec;
855
856 void *priv_data;
857
858 /* unused, FIXME remove*/
859 int rtp_mode;
860
861 int rtp_payload_size; /* The size of the RTP payload, the coder will */
862 /* do it's best to deliver a chunk with size */
863 /* below rtp_payload_size, the chunk will start */
864 /* with a start code on some codecs like H.263 */
865 /* This doesn't take account of any particular */
866 /* headers inside the transmited RTP payload */
867
868
869 /* The RTP callcack: This function is called */
870 /* every time the encoder as a packet to send */
871 /* Depends on the encoder if the data starts */
872 /* with a Start Code (it should) H.263 does. */
873 /* mb_nb contains the number of macroblocks */
874 /* encoded in the RTP payload */
875 void (*rtp_callback)(struct AVCodecContext *avctx, void *data, int size, int mb_nb);
876
877 /* statistics, used for 2-pass encoding */
878 int mv_bits;
879 int header_bits;
880 int i_tex_bits;
881 int p_tex_bits;
882 int i_count;
883 int p_count;
884 int skip_count;
885 int misc_bits;
886
887 /**
888 * number of bits used for the previously encoded frame.
889 * - encoding: set by lavc
890 * - decoding: unused
891 */
892 int frame_bits;
893
894 /**
895 * private data of the user, can be used to carry app specific stuff.
896 * - encoding: set by user
897 * - decoding: set by user
898 */
899 void *opaque;
900
901 char codec_name[32];
902 enum CodecType codec_type; /* see CODEC_TYPE_xxx */
903 enum CodecID codec_id; /* see CODEC_ID_xxx */
904
905 /**
906 * fourcc (LSB first, so "ABCD" -> ('D'<<24) + ('C'<<16) + ('B'<<8) + 'A').
907 * this is used to workaround some encoder bugs
908 * - encoding: set by user, if not then the default based on codec_id will be used
909 * - decoding: set by user, will be converted to upper case by lavc during init
910 */
911 unsigned int codec_tag;
912
913 /**
914 * workaround bugs in encoders which sometimes cannot be detected automatically.
915 * - encoding: set by user
916 * - decoding: set by user
917 */
918 int workaround_bugs;
919 #define FF_BUG_AUTODETECT 1 ///< autodetection
920 #define FF_BUG_OLD_MSMPEG4 2
921 #define FF_BUG_XVID_ILACE 4
922 #define FF_BUG_UMP4 8
923 #define FF_BUG_NO_PADDING 16
924 #define FF_BUG_AMV 32
925 #define FF_BUG_AC_VLC 0 ///< will be removed, libavcodec can now handle these non compliant files by default
926 #define FF_BUG_QPEL_CHROMA 64
927 #define FF_BUG_STD_QPEL 128
928 #define FF_BUG_QPEL_CHROMA2 256
929 #define FF_BUG_DIRECT_BLOCKSIZE 512
930 #define FF_BUG_EDGE 1024
931 #define FF_BUG_HPEL_CHROMA 2048
932 #define FF_BUG_DC_CLIP 4096
933 #define FF_BUG_MS 8192 ///< workaround various bugs in microsofts broken decoders
934 //#define FF_BUG_FAKE_SCALABILITY 16 //autodetection should work 100%
935
936 /**
937 * luma single coeff elimination threshold.
938 * - encoding: set by user
939 * - decoding: unused
940 */
941 int luma_elim_threshold;
942
943 /**
944 * chroma single coeff elimination threshold.
945 * - encoding: set by user
946 * - decoding: unused
947 */
948 int chroma_elim_threshold;
949
950 /**
951 * strictly follow the std (MPEG4, ...).
952 * - encoding: set by user
953 * - decoding: unused
954 */
955 int strict_std_compliance;
956
957 /**
958 * qscale offset between ip and b frames.
959 * if > 0 then the last p frame quantizer will be used (q= lastp_q*factor+offset)
960 * if < 0 then normal ratecontrol will be done (q= -normal_q*factor+offset)
961 * - encoding: set by user.
962 * - decoding: unused
963 */
964 float b_quant_offset;
965
966 /**
967 * error resilience higher values will detect more errors but may missdetect
968 * some more or less valid parts as errors.
969 * - encoding: unused
970 * - decoding: set by user
971 */
972 int error_resilience;
973 #define FF_ER_CAREFULL 1
974 #define FF_ER_COMPLIANT 2
975 #define FF_ER_AGGRESSIVE 3
976 #define FF_ER_VERY_AGGRESSIVE 4
977
978 /**
979 * called at the beginning of each frame to get a buffer for it.
980 * if pic.reference is set then the frame will be read later by lavc
981 * avcodec_align_dimensions() should be used to find the required width and
982 * height, as they normally need to be rounded up to the next multiple of 16
983 * - encoding: unused
984 * - decoding: set by lavc, user can override
985 */
986 int (*get_buffer)(struct AVCodecContext *c, AVFrame *pic);
987
988 /**
989 * called to release buffers which where allocated with get_buffer.
990 * a released buffer can be reused in get_buffer()
991 * pic.data[*] must be set to NULL
992 * - encoding: unused
993 * - decoding: set by lavc, user can override
994 */
995 void (*release_buffer)(struct AVCodecContext *c, AVFrame *pic);
996
997 /**
998 * if 1 the stream has a 1 frame delay during decoding.
999 * - encoding: set by lavc
1000 * - decoding: set by lavc
1001 */
1002 int has_b_frames;
1003
1004 int block_align; ///< used by some WAV based audio codecs
1005
1006 int parse_only; /* - decoding only: if true, only parsing is done
1007 (function avcodec_parse_frame()). The frame
1008 data is returned. Only MPEG codecs support this now. */
1009
1010 /**
1011 * 0-> h263 quant 1-> mpeg quant.
1012 * - encoding: set by user.
1013 * - decoding: unused
1014 */
1015 int mpeg_quant;
1016
1017 /**
1018 * pass1 encoding statistics output buffer.
1019 * - encoding: set by lavc
1020 * - decoding: unused
1021 */
1022 char *stats_out;
1023
1024 /**
1025 * pass2 encoding statistics input buffer.
1026 * concatenated stuff from stats_out of pass1 should be placed here
1027 * - encoding: allocated/set/freed by user
1028 * - decoding: unused
1029 */
1030 char *stats_in;
1031
1032 /**
1033 * ratecontrol qmin qmax limiting method.
1034 * 0-> clipping, 1-> use a nice continous function to limit qscale wthin qmin/qmax
1035 * - encoding: set by user.
1036 * - decoding: unused
1037 */
1038 float rc_qsquish;
1039
1040 float rc_qmod_amp;
1041 int rc_qmod_freq;
1042
1043 /**
1044 * ratecontrol override, see RcOverride.
1045 * - encoding: allocated/set/freed by user.
1046 * - decoding: unused
1047 */
1048 RcOverride *rc_override;
1049 int rc_override_count;
1050
1051 /**
1052 * rate control equation.
1053 * - encoding: set by user
1054 * - decoding: unused
1055 */
1056 char *rc_eq;
1057
1058 /**
1059 * maximum bitrate.
1060 * - encoding: set by user.
1061 * - decoding: unused
1062 */
1063 int rc_max_rate;
1064
1065 /**
1066 * minimum bitrate.
1067 * - encoding: set by user.
1068 * - decoding: unused
1069 */
1070 int rc_min_rate;
1071
1072 /**
1073 * decoder bitstream buffer size.
1074 * - encoding: set by user.
1075 * - decoding: unused
1076 */
1077 int rc_buffer_size;
1078 float rc_buffer_aggressivity;
1079
1080 /**
1081 * qscale factor between p and i frames.
1082 * if > 0 then the last p frame quantizer will be used (q= lastp_q*factor+offset)
1083 * if < 0 then normal ratecontrol will be done (q= -normal_q*factor+offset)
1084 * - encoding: set by user.
1085 * - decoding: unused
1086 */
1087 float i_quant_factor;
1088
1089 /**
1090 * qscale offset between p and i frames.
1091 * - encoding: set by user.
1092 * - decoding: unused
1093 */
1094 float i_quant_offset;
1095
1096 /**
1097 * initial complexity for pass1 ratecontrol.
1098 * - encoding: set by user.
1099 * - decoding: unused
1100 */
1101 float rc_initial_cplx;
1102
1103 /**
1104 * dct algorithm, see FF_DCT_* below.
1105 * - encoding: set by user
1106 * - decoding: unused
1107 */
1108 int dct_algo;
1109 #define FF_DCT_AUTO 0
1110 #define FF_DCT_FASTINT 1
1111 #define FF_DCT_INT 2
1112 #define FF_DCT_MMX 3
1113 #define FF_DCT_MLIB 4
1114 #define FF_DCT_ALTIVEC 5
1115 #define FF_DCT_FAAN 6
1116
1117 /**
1118 * luminance masking (0-> disabled).
1119 * - encoding: set by user
1120 * - decoding: unused
1121 */
1122 float lumi_masking;
1123
1124 /**
1125 * temporary complexity masking (0-> disabled).
1126 * - encoding: set by user
1127 * - decoding: unused
1128 */
1129 float temporal_cplx_masking;
1130
1131 /**
1132 * spatial complexity masking (0-> disabled).
1133 * - encoding: set by user
1134 * - decoding: unused
1135 */
1136 float spatial_cplx_masking;
1137
1138 /**
1139 * p block masking (0-> disabled).
1140 * - encoding: set by user
1141 * - decoding: unused
1142 */
1143 float p_masking;
1144
1145 /**
1146 * darkness masking (0-> disabled).
1147 * - encoding: set by user
1148 * - decoding: unused
1149 */
1150 float dark_masking;
1151
1152
1153 /* for binary compatibility */
1154 int unused;
1155
1156 /**
1157 * idct algorithm, see FF_IDCT_* below.
1158 * - encoding: set by user
1159 * - decoding: set by user
1160 */
1161 int idct_algo;
1162 #define FF_IDCT_AUTO 0
1163 #define FF_IDCT_INT 1
1164 #define FF_IDCT_SIMPLE 2
1165 #define FF_IDCT_SIMPLEMMX 3
1166 #define FF_IDCT_LIBMPEG2MMX 4
1167 #define FF_IDCT_PS2 5
1168 #define FF_IDCT_MLIB 6
1169 #define FF_IDCT_ARM 7
1170 #define FF_IDCT_ALTIVEC 8
1171 #define FF_IDCT_SH4 9
1172 #define FF_IDCT_SIMPLEARM 10
1173 #define FF_IDCT_H264 11
1174
1175 /**
1176 * slice count.
1177 * - encoding: set by lavc
1178 * - decoding: set by user (or 0)
1179 */
1180 int slice_count;
1181 /**
1182 * slice offsets in the frame in bytes.
1183 * - encoding: set/allocated by lavc
1184 * - decoding: set/allocated by user (or NULL)
1185 */
1186 int *slice_offset;
1187
1188 /**
1189 * error concealment flags.
1190 * - encoding: unused
1191 * - decoding: set by user
1192 */
1193 int error_concealment;
1194 #define FF_EC_GUESS_MVS 1
1195 #define FF_EC_DEBLOCK 2
1196
1197 /**
1198 * dsp_mask could be add used to disable unwanted CPU features
1199 * CPU features (i.e. MMX, SSE. ...)
1200 *
1201 * with FORCE flag you may instead enable given CPU features
1202 * (Dangerous: usable in case of misdetection, improper usage however will
1203 * result into program crash)
1204 */
1205 unsigned dsp_mask;
1206 #define FF_MM_FORCE 0x80000000 /* force usage of selected flags (OR) */
1207 /* lower 16 bits - CPU features */
1208 #ifdef HAVE_MMX
1209 #define FF_MM_MMX 0x0001 /* standard MMX */
1210 #define FF_MM_3DNOW 0x0004 /* AMD 3DNOW */
1211 #define FF_MM_MMXEXT 0x0002 /* SSE integer functions or AMD MMX ext */
1212 #define FF_MM_SSE 0x0008 /* SSE functions */
1213 #define FF_MM_SSE2 0x0010 /* PIV SSE2 functions */
1214 #define FF_MM_3DNOWEXT 0x0020 /* AMD 3DNowExt */
1215 #endif /* HAVE_MMX */
1216
1217 /**
1218 * bits per sample/pixel from the demuxer (needed for huffyuv).
1219 * - encoding: set by lavc
1220 * - decoding: set by user
1221 */
1222 int bits_per_sample;
1223
1224 /**
1225 * prediction method (needed for huffyuv).
1226 * - encoding: set by user
1227 * - decoding: unused
1228 */
1229 int prediction_method;
1230 #define FF_PRED_LEFT 0
1231 #define FF_PRED_PLANE 1
1232 #define FF_PRED_MEDIAN 2
1233
1234 /**
1235 * sample aspect ratio (0 if unknown).
1236 * numerator and denominator must be relative prime and smaller then 256 for some video standards
1237 * - encoding: set by user.
1238 * - decoding: set by lavc.
1239 */
1240 AVRational sample_aspect_ratio;
1241
1242 /**
1243 * the picture in the bitstream.
1244 * - encoding: set by lavc
1245 * - decoding: set by lavc
1246 */
1247 AVFrame *coded_frame;
1248
1249 /**
1250 * debug.
1251 * - encoding: set by user.
1252 * - decoding: set by user.
1253 */
1254 int debug;
1255 #define FF_DEBUG_PICT_INFO 1
1256 #define FF_DEBUG_RC 2
1257 #define FF_DEBUG_BITSTREAM 4
1258 #define FF_DEBUG_MB_TYPE 8
1259 #define FF_DEBUG_QP 16
1260 #define FF_DEBUG_MV 32
1261 #define FF_DEBUG_DCT_COEFF 0x00000040
1262 #define FF_DEBUG_SKIP 0x00000080
1263 #define FF_DEBUG_STARTCODE 0x00000100
1264 #define FF_DEBUG_PTS 0x00000200
1265 #define FF_DEBUG_ER 0x00000400
1266 #define FF_DEBUG_MMCO 0x00000800
1267 #define FF_DEBUG_BUGS 0x00001000
1268 #define FF_DEBUG_VIS_QP 0x00002000
1269 #define FF_DEBUG_VIS_MB_TYPE 0x00004000
1270
1271 /**
1272 * debug.
1273 * - encoding: set by user.
1274 * - decoding: set by user.
1275 */
1276 int debug_mv;
1277 #define FF_DEBUG_VIS_MV_P_FOR 0x00000001 //visualize forward predicted MVs of P frames
1278 #define FF_DEBUG_VIS_MV_B_FOR 0x00000002 //visualize forward predicted MVs of B frames
1279 #define FF_DEBUG_VIS_MV_B_BACK 0x00000004 //visualize backward predicted MVs of B frames
1280
1281 /**
1282 * error.
1283 * - encoding: set by lavc if flags&CODEC_FLAG_PSNR
1284 * - decoding: unused
1285 */
1286 uint64_t error[4];
1287
1288 /**
1289 * minimum MB quantizer.
1290 * - encoding: unused
1291 * - decoding: unused
1292 */
1293 int mb_qmin;
1294
1295 /**
1296 * maximum MB quantizer.
1297 * - encoding: unused
1298 * - decoding: unused
1299 */
1300 int mb_qmax;
1301
1302 /**
1303 * motion estimation compare function.
1304 * - encoding: set by user.
1305 * - decoding: unused
1306 */
1307 int me_cmp;
1308 /**
1309 * subpixel motion estimation compare function.
1310 * - encoding: set by user.
1311 * - decoding: unused
1312 */
1313 int me_sub_cmp;
1314 /**
1315 * macroblock compare function (not supported yet).
1316 * - encoding: set by user.
1317 * - decoding: unused
1318 */
1319 int mb_cmp;
1320 /**
1321 * interlaced dct compare function
1322 * - encoding: set by user.
1323 * - decoding: unused
1324 */
1325 int ildct_cmp;
1326 #define FF_CMP_SAD 0
1327 #define FF_CMP_SSE 1
1328 #define FF_CMP_SATD 2
1329 #define FF_CMP_DCT 3
1330 #define FF_CMP_PSNR 4
1331 #define FF_CMP_BIT 5
1332 #define FF_CMP_RD 6
1333 #define FF_CMP_ZERO 7
1334 #define FF_CMP_VSAD 8
1335 #define FF_CMP_VSSE 9
1336 #define FF_CMP_NSSE 10
1337 #define FF_CMP_W53 11
1338 #define FF_CMP_W97 12
1339 #define FF_CMP_DCTMAX 13
1340 #define FF_CMP_CHROMA 256
1341
1342 /**
1343 * ME diamond size & shape.
1344 * - encoding: set by user.
1345 * - decoding: unused
1346 */
1347 int dia_size;
1348
1349 /**
1350 * amount of previous MV predictors (2a+1 x 2a+1 square).
1351 * - encoding: set by user.
1352 * - decoding: unused
1353 */
1354 int last_predictor_count;
1355
1356 /**
1357 * pre pass for motion estimation.
1358 * - encoding: set by user.
1359 * - decoding: unused
1360 */
1361 int pre_me;
1362
1363 /**
1364 * motion estimation pre pass compare function.
1365 * - encoding: set by user.
1366 * - decoding: unused
1367 */
1368 int me_pre_cmp;
1369
1370 /**
1371 * ME pre pass diamond size & shape.
1372 * - encoding: set by user.
1373 * - decoding: unused
1374 */
1375 int pre_dia_size;
1376
1377 /**
1378 * subpel ME quality.
1379 * - encoding: set by user.
1380 * - decoding: unused
1381 */
1382 int me_subpel_quality;
1383
1384 /**
1385 * callback to negotiate the pixelFormat.
1386 * @param fmt is the list of formats which are supported by the codec,
1387 * its terminated by -1 as 0 is a valid format, the formats are ordered by quality
1388 * the first is allways the native one
1389 * @return the choosen format
1390 * - encoding: unused
1391 * - decoding: set by user, if not set then the native format will always be choosen
1392 */
1393 enum PixelFormat (*get_format)(struct AVCodecContext *s, const enum PixelFormat * fmt);
1394
1395 /**
1396 * DTG active format information (additionnal aspect ratio
1397 * information only used in DVB MPEG2 transport streams). 0 if
1398 * not set.
1399 *
1400 * - encoding: unused.
1401 * - decoding: set by decoder
1402 */
1403 int dtg_active_format;
1404 #define FF_DTG_AFD_SAME 8
1405 #define FF_DTG_AFD_4_3 9
1406 #define FF_DTG_AFD_16_9 10
1407 #define FF_DTG_AFD_14_9 11
1408 #define FF_DTG_AFD_4_3_SP_14_9 13
1409 #define FF_DTG_AFD_16_9_SP_14_9 14
1410 #define FF_DTG_AFD_SP_4_3 15
1411
1412 /**
1413 * Maximum motion estimation search range in subpel units.
1414 * if 0 then no limit
1415 *
1416 * - encoding: set by user.
1417 * - decoding: unused.
1418 */
1419 int me_range;
1420
1421 /**
1422 * frame_rate_base.
1423 * for variable fps this is 1
1424 * - encoding: set by user.
1425 * - decoding: set by lavc.
1426 * @todo move this after frame_rate
1427 */
1428
1429 int frame_rate_base;
1430 /**
1431 * intra quantizer bias.
1432 * - encoding: set by user.
1433 * - decoding: unused
1434 */
1435 int intra_quant_bias;
1436 #define FF_DEFAULT_QUANT_BIAS 999999
1437
1438 /**
1439 * inter quantizer bias.
1440 * - encoding: set by user.
1441 * - decoding: unused
1442 */
1443 int inter_quant_bias;
1444
1445 /**
1446 * color table ID.
1447 * - encoding: unused.
1448 * - decoding: which clrtable should be used for 8bit RGB images
1449 * table have to be stored somewhere FIXME
1450 */
1451 int color_table_id;
1452
1453 /**
1454 * internal_buffer count.
1455 * Dont touch, used by lavc default_get_buffer()
1456 */
1457 int internal_buffer_count;
1458
1459 /**
1460 * internal_buffers.
1461 * Dont touch, used by lavc default_get_buffer()
1462 */
1463 void *internal_buffer;
1464
1465 #define FF_LAMBDA_SHIFT 7
1466 #define FF_LAMBDA_SCALE (1<<FF_LAMBDA_SHIFT)
1467 #define FF_QP2LAMBDA 118 ///< factor to convert from H.263 QP to lambda
1468 #define FF_LAMBDA_MAX (256*128-1)
1469
1470 #define FF_QUALITY_SCALE FF_LAMBDA_SCALE //FIXME maybe remove
1471 /**
1472 * global quality for codecs which cannot change it per frame.
1473 * this should be proportional to MPEG1/2/4 qscale.
1474 * - encoding: set by user.
1475 * - decoding: unused
1476 */
1477 int global_quality;
1478
1479 #define FF_CODER_TYPE_VLC 0
1480 #define FF_CODER_TYPE_AC 1
1481 /**
1482 * coder type
1483 * - encoding: set by user.
1484 * - decoding: unused
1485 */
1486 int coder_type;
1487
1488 /**
1489 * context model
1490 * - encoding: set by user.
1491 * - decoding: unused
1492 */
1493 int context_model;
1494
1495 /**
1496 * slice flags
1497 * - encoding: unused
1498 * - decoding: set by user.
1499 */
1500 int slice_flags;
1501 #define SLICE_FLAG_CODED_ORDER 0x0001 ///< draw_horiz_band() is called in coded order instead of display
1502 #define SLICE_FLAG_ALLOW_FIELD 0x0002 ///< allow draw_horiz_band() with field slices (MPEG2 field pics)
1503 #define SLICE_FLAG_ALLOW_PLANE 0x0004 ///< allow draw_horiz_band() with 1 component at a time (SVQ1)
1504
1505 /**
1506 * XVideo Motion Acceleration
1507 * - encoding: forbidden
1508 * - decoding: set by decoder
1509 */
1510 int xvmc_acceleration;
1511
1512 /**
1513 * macroblock decision mode
1514 * - encoding: set by user.
1515 * - decoding: unused
1516 */
1517 int mb_decision;
1518 #define FF_MB_DECISION_SIMPLE 0 ///< uses mb_cmp
1519 #define FF_MB_DECISION_BITS 1 ///< chooses the one which needs the fewest bits
1520 #define FF_MB_DECISION_RD 2 ///< rate distoration
1521
1522 /**
1523 * custom intra quantization matrix
1524 * - encoding: set by user, can be NULL
1525 * - decoding: set by lavc
1526 */
1527 uint16_t *intra_matrix;
1528
1529 /**
1530 * custom inter quantization matrix
1531 * - encoding: set by user, can be NULL
1532 * - decoding: set by lavc
1533 */
1534 uint16_t *inter_matrix;
1535
1536 /**
1537 * fourcc from the AVI stream header (LSB first, so "ABCD" -> ('D'<<24) + ('C'<<16) + ('B'<<8) + 'A').
1538 * this is used to workaround some encoder bugs
1539 * - encoding: unused
1540 * - decoding: set by user, will be converted to upper case by lavc during init
1541 */
1542 unsigned int stream_codec_tag;
1543
1544 /**
1545 * scene change detection threshold.
1546 * 0 is default, larger means fewer detected scene changes
1547 * - encoding: set by user.
1548 * - decoding: unused
1549 */
1550 int scenechange_threshold;
1551
1552 /**
1553 * minimum lagrange multipler
1554 * - encoding: set by user.
1555 * - decoding: unused
1556 */
1557 int lmin;
1558
1559 /**
1560 * maximum lagrange multipler
1561 * - encoding: set by user.
1562 * - decoding: unused
1563 */
1564 int lmax;
1565
1566 /**
1567 * Palette control structure
1568 * - encoding: ??? (no palette-enabled encoder yet)
1569 * - decoding: set by user.
1570 */
1571 struct AVPaletteControl *palctrl;
1572
1573 /**
1574 * noise reduction strength
1575 * - encoding: set by user.
1576 * - decoding: unused
1577 */
1578 int noise_reduction;
1579
1580 /**
1581 * called at the beginning of a frame to get cr buffer for it.
1582 * buffer type (size, hints) must be the same. lavc won't check it.
1583 * lavc will pass previous buffer in pic, function should return
1584 * same buffer or new buffer with old frame "painted" into it.
1585 * if pic.data[0] == NULL must behave like get_buffer().
1586 * - encoding: unused
1587 * - decoding: set by lavc, user can override
1588 */
1589 int (*reget_buffer)(struct AVCodecContext *c, AVFrame *pic);
1590
1591 /**
1592 * number of bits which should be loaded into the rc buffer before decoding starts
1593 * - encoding: set by user.
1594 * - decoding: unused
1595 */
1596 int rc_initial_buffer_occupancy;
1597
1598 /**
1599 *
1600 * - encoding: set by user.
1601 * - decoding: unused
1602 */
1603 int inter_threshold;
1604
1605 /**
1606 * CODEC_FLAG2_*.
1607 * - encoding: set by user.
1608 * - decoding: set by user.
1609 */
1610 int flags2;
1611
1612 /**
1613 * simulates errors in the bitstream to test error concealment.
1614 * - encoding: set by user.
1615 * - decoding: unused.
1616 */
1617 int error_rate;
1618
1619 /**
1620 * MP3 antialias algorithm, see FF_AA_* below.
1621 * - encoding: unused
1622 * - decoding: set by user
1623 */
1624 int antialias_algo;
1625 #define FF_AA_AUTO 0
1626 #define FF_AA_FASTINT 1 //not implemented yet
1627 #define FF_AA_INT 2
1628 #define FF_AA_FLOAT 3
1629 /**
1630 * Quantizer noise shaping.
1631 * - encoding: set by user
1632 * - decoding: unused
1633 */
1634 int quantizer_noise_shaping;
1635
1636 /**
1637 * Thread count.
1638 * is used to decide how many independant tasks should be passed to execute()
1639 * - encoding: set by user
1640 * - decoding: set by user
1641 */
1642 int thread_count;
1643
1644 /**
1645 * the codec may call this to execute several independant things. it will return only after
1646 * finishing all tasks, the user may replace this with some multithreaded implementation, the
1647 * default implementation will execute the parts serially
1648 * @param count the number of things to execute
1649 * - encoding: set by lavc, user can override
1650 * - decoding: set by lavc, user can override
1651 */
1652 int (*execute)(struct AVCodecContext *c, int (*func)(struct AVCodecContext *c2, void *arg), void **arg2, int *ret, int count);
1653
1654 /**
1655 * Thread opaque.
1656 * can be used by execute() to store some per AVCodecContext stuff.
1657 * - encoding: set by execute()
1658 * - decoding: set by execute()
1659 */
1660 void *thread_opaque;
1661
1662 /**
1663 * Motion estimation threshold. under which no motion estimation is
1664 * performed, but instead the user specified motion vectors are used
1665 *
1666 * - encoding: set by user
1667 * - decoding: unused
1668 */
1669 int me_threshold;
1670
1671 /**
1672 * Macroblock threshold. under which the user specified macroblock types will be used
1673 * - encoding: set by user
1674 * - decoding: unused
1675 */
1676 int mb_threshold;
1677
1678 /**
1679 * precision of the intra dc coefficient - 8.
1680 * - encoding: set by user
1681 * - decoding: unused
1682 */
1683 int intra_dc_precision;
1684
1685 /**
1686 * noise vs. sse weight for the nsse comparsion function.
1687 * - encoding: set by user
1688 * - decoding: unused
1689 */
1690 int nsse_weight;
1691
1692 /**
1693 * number of macroblock rows at the top which are skiped.
1694 * - encoding: unused
1695 * - decoding: set by user
1696 */
1697 int skip_top;
1698
1699 /**
1700 * number of macroblock rows at the bottom which are skiped.
1701 * - encoding: unused
1702 * - decoding: set by user
1703 */
1704 int skip_bottom;
1705
1706 /**
1707 * profile
1708 * - encoding: set by user
1709 * - decoding: set by lavc
1710 */
1711 int profile;
1712 #define FF_PROFILE_UNKNOWN -99
1713
1714 /**
1715 * level
1716 * - encoding: set by user
1717 * - decoding: set by lavc
1718 */
1719 int level;
1720 #define FF_LEVEL_UNKNOWN -99
1721
1722 /**
1723 * low resolution decoding. 1-> 1/2 size, 2->1/4 size
1724 * - encoding: unused
1725 * - decoding: set by user
1726 */
1727 int lowres;
1728
1729 /**
1730 * bitsream width / height. may be different from width/height if lowres
1731 * or other things are used
1732 * - encoding: unused
1733 * - decoding: set by user before init if known, codec should override / dynamically change if needed
1734 */
1735 int coded_width, coded_height;
1736
1737 /**
1738 * frame skip threshold
1739 * - encoding: set by user
1740 * - decoding: unused
1741 */
1742 int frame_skip_threshold;
1743
1744 /**
1745 * frame skip factor
1746 * - encoding: set by user
1747 * - decoding: unused
1748 */
1749 int frame_skip_factor;
1750
1751 /**
1752 * frame skip exponent
1753 * - encoding: set by user
1754 * - decoding: unused
1755 */
1756 int frame_skip_exp;
1757
1758 /**
1759 * frame skip comparission function
1760 * - encoding: set by user.
1761 * - decoding: unused
1762 */
1763 int frame_skip_cmp;
1764
1765 /**
1766 * border processing masking. raises the quantizer for mbs on the borders
1767 * of the picture.
1768 * - encoding: set by user
1769 * - decoding: unused
1770 */
1771 float border_masking;
1772
1773 /**
1774 * minimum MB lagrange multipler.
1775 * - encoding: set by user.
1776 * - decoding: unused
1777 */
1778 int mb_lmin;
1779
1780 /**
1781 * maximum MB lagrange multipler.
1782 * - encoding: set by user.
1783 * - decoding: unused
1784 */
1785 int mb_lmax;
1786
1787 /**
1788 *
1789 * - encoding: set by user.
1790 * - decoding: unused
1791 */
1792 int me_penalty_compensation;
1793 } AVCodecContext;
1794
1795
1796 /**
1797 * AVOption.
1798 */
1799 typedef struct AVOption {
1800 /** options' name */
1801 const char *name; /* if name is NULL, it indicates a link to next */
1802 /** short English text help or const struct AVOption* subpointer */
1803 const char *help; // const struct AVOption* sub;
1804 /** offset to context structure where the parsed value should be stored */
1805 int offset;
1806 /** options' type */
1807 int type;
1808 #define FF_OPT_TYPE_BOOL 1 ///< boolean - true,1,on (or simply presence)
1809 #define FF_OPT_TYPE_DOUBLE 2 ///< double
1810 #define FF_OPT_TYPE_INT 3 ///< integer
1811 #define FF_OPT_TYPE_STRING 4 ///< string (finished with \0)
1812 #define FF_OPT_TYPE_MASK 0x1f ///< mask for types - upper bits are various flags
1813 //#define FF_OPT_TYPE_EXPERT 0x20 // flag for expert option
1814 #define FF_OPT_TYPE_FLAG (FF_OPT_TYPE_BOOL | 0x40)
1815 #define FF_OPT_TYPE_RCOVERRIDE (FF_OPT_TYPE_STRING | 0x80)
1816 /** min value (min == max -> no limits) */
1817 double min;
1818 /** maximum value for double/int */
1819 double max;
1820 /** default boo [0,1]l/double/int value */
1821 double defval;
1822 /**
1823 * default string value (with optional semicolon delimited extra option-list
1824 * i.e. option1;option2;option3
1825 * defval might select other then first argument as default
1826 */
1827 const char *defstr;
1828 #define FF_OPT_MAX_DEPTH 10
1829 } AVOption;
1830
1831 /**
1832 * AVCodec.
1833 */
1834 typedef struct AVCodec {
1835 const char *name;
1836 enum CodecType type;
1837 enum CodecID id;
1838 int priv_data_size;
1839 int (*init)(AVCodecContext *);
1840 int (*encode)(AVCodecContext *, uint8_t *buf, int buf_size, void *data);
1841 int (*close)(AVCodecContext *);
1842 int (*decode)(AVCodecContext *, void *outdata, int *outdata_size,
1843 uint8_t *buf, int buf_size);
1844 int capabilities;
1845 void *dummy; // FIXME remove next time we break binary compatibility
1846 struct AVCodec *next;
1847 void (*flush)(AVCodecContext *);
1848 const AVRational *supported_framerates; ///array of supported framerates, or NULL if any, array is terminated by {0,0}
1849 const enum PixelFormat *pix_fmts; ///array of supported pixel formats, or NULL if unknown, array is terminanted by -1
1850 } AVCodec;
1851
1852 /**
1853 * four components are given, that's all.
1854 * the last component is alpha
1855 */
1856 typedef struct AVPicture {
1857 uint8_t *data[4];
1858 int linesize[4]; ///< number of bytes per line
1859 } AVPicture;
1860
1861 /**
1862 * AVPaletteControl
1863 * This structure defines a method for communicating palette changes
1864 * between and demuxer and a decoder.
1865 */
1866 #define AVPALETTE_SIZE 1024
1867 #define AVPALETTE_COUNT 256
1868 typedef struct AVPaletteControl {
1869
1870 /* demuxer sets this to 1 to indicate the palette has changed;
1871 * decoder resets to 0 */
1872 int palette_changed;
1873
1874 /* 4-byte ARGB palette entries, stored in native byte order; note that
1875 * the individual palette components should be on a 8-bit scale; if
1876 * the palette data comes from a IBM VGA native format, the component
1877 * data is probably 6 bits in size and needs to be scaled */
1878 unsigned int palette[AVPALETTE_COUNT];
1879
1880 } AVPaletteControl;
1881
1882 extern AVCodec ac3_encoder;
1883 extern AVCodec mp2_encoder;
1884 extern AVCodec mp3lame_encoder;
1885 extern AVCodec oggvorbis_encoder;
1886 extern AVCodec oggtheora_encoder;
1887 extern AVCodec faac_encoder;
1888 extern AVCodec xvid_encoder;
1889 extern AVCodec mpeg1video_encoder;
1890 extern AVCodec mpeg2video_encoder;
1891 extern AVCodec h261_encoder;
1892 extern AVCodec h263_encoder;
1893 extern AVCodec h263p_encoder;
1894 extern AVCodec flv_encoder;
1895 extern AVCodec rv10_encoder;
1896 extern AVCodec rv20_encoder;
1897 extern AVCodec dvvideo_encoder;
1898 extern AVCodec mjpeg_encoder;
1899 extern AVCodec ljpeg_encoder;
1900 extern AVCodec png_encoder;
1901 extern AVCodec ppm_encoder;
1902 extern AVCodec pgm_encoder;
1903 extern AVCodec pgmyuv_encoder;
1904 extern AVCodec pbm_encoder;
1905 extern AVCodec pam_encoder;
1906 extern AVCodec mpeg4_encoder;
1907 extern AVCodec msmpeg4v1_encoder;
1908 extern AVCodec msmpeg4v2_encoder;
1909 extern AVCodec msmpeg4v3_encoder;
1910 extern AVCodec wmv1_encoder;
1911 extern AVCodec wmv2_encoder;
1912 extern AVCodec huffyuv_encoder;
1913 extern AVCodec ffvhuff_encoder;
1914 extern AVCodec h264_encoder;
1915 extern AVCodec asv1_encoder;
1916 extern AVCodec asv2_encoder;
1917 extern AVCodec vcr1_encoder;
1918 extern AVCodec ffv1_encoder;
1919 extern AVCodec snow_encoder;
1920 extern AVCodec mdec_encoder;
1921 extern AVCodec zlib_encoder;
1922 extern AVCodec sonic_encoder;
1923 extern AVCodec sonic_ls_encoder;
1924 extern AVCodec svq1_encoder;
1925 extern AVCodec x264_encoder;
1926
1927 extern AVCodec h263_decoder;
1928 extern AVCodec h261_decoder;
1929 extern AVCodec mpeg4_decoder;
1930 extern AVCodec msmpeg4v1_decoder;
1931 extern AVCodec msmpeg4v2_decoder;
1932 extern AVCodec msmpeg4v3_decoder;
1933 extern AVCodec wmv1_decoder;
1934 extern AVCodec wmv2_decoder;
1935 extern AVCodec vc9_decoder;
1936 extern AVCodec wmv3_decoder;
1937 extern AVCodec mpeg1video_decoder;
1938 extern AVCodec mpeg2video_decoder;
1939 extern AVCodec mpegvideo_decoder;
1940 extern AVCodec mpeg_xvmc_decoder;
1941 extern AVCodec h263i_decoder;
1942 extern AVCodec flv_decoder;
1943 extern AVCodec rv10_decoder;
1944 extern AVCodec rv20_decoder;
1945 extern AVCodec rv30_decoder;
1946 extern AVCodec rv40_decoder;
1947 extern AVCodec svq1_decoder;
1948 extern AVCodec svq3_decoder;
1949 extern AVCodec dvvideo_decoder;
1950 extern AVCodec wmav1_decoder;
1951 extern AVCodec wmav2_decoder;
1952 extern AVCodec mjpeg_decoder;
1953 extern AVCodec mjpegb_decoder;
1954 extern AVCodec sp5x_decoder;
1955 extern AVCodec png_decoder;
1956 extern AVCodec mp2_decoder;
1957 extern AVCodec mp3_decoder;
1958 extern AVCodec mp3adu_decoder;
1959 extern AVCodec mp3on4_decoder;
1960 extern AVCodec mace3_decoder;
1961 extern AVCodec mace6_decoder;
1962 extern AVCodec huffyuv_decoder;
1963 extern AVCodec ffvhuff_decoder;
1964 extern AVCodec oggvorbis_decoder;
1965 extern AVCodec oggtheora_decoder;
1966 extern AVCodec cyuv_decoder;
1967 extern AVCodec h264_decoder;
1968 extern AVCodec indeo3_decoder;
1969 extern AVCodec vp3_decoder;
1970 extern AVCodec theora_decoder;
1971 extern AVCodec amr_nb_decoder;
1972 extern AVCodec amr_nb_encoder;
1973 extern AVCodec amr_wb_encoder;
1974 extern AVCodec amr_wb_decoder;
1975 extern AVCodec aac_decoder;
1976 extern AVCodec mpeg4aac_decoder;
1977 extern AVCodec asv1_decoder;
1978 extern AVCodec asv2_decoder;
1979 extern AVCodec vcr1_decoder;
1980 extern AVCodec cljr_decoder;
1981 extern AVCodec ffv1_decoder;
1982 extern AVCodec snow_decoder;
1983 extern AVCodec fourxm_decoder;
1984 extern AVCodec mdec_decoder;
1985 extern AVCodec roq_decoder;
1986 extern AVCodec interplay_video_decoder;
1987 extern AVCodec xan_wc3_decoder;
1988 extern AVCodec rpza_decoder;
1989 extern AVCodec cinepak_decoder;
1990 extern AVCodec msrle_decoder;
1991 extern AVCodec msvideo1_decoder;
1992 extern AVCodec vqa_decoder;
1993 extern AVCodec idcin_decoder;
1994 extern AVCodec eightbps_decoder;
1995 extern AVCodec smc_decoder;
1996 extern AVCodec flic_decoder;
1997 extern AVCodec vmdvideo_decoder;
1998 extern AVCodec vmdaudio_decoder;
1999 extern AVCodec truemotion1_decoder;
2000 extern AVCodec mszh_decoder;
2001 extern AVCodec zlib_decoder;
2002 extern AVCodec ra_144_decoder;
2003 extern AVCodec ra_288_decoder;
2004 extern AVCodec roq_dpcm_decoder;
2005 extern AVCodec interplay_dpcm_decoder;
2006 extern AVCodec xan_dpcm_decoder;
2007 extern AVCodec sol_dpcm_decoder;
2008 extern AVCodec sonic_decoder;
2009 extern AVCodec qtrle_decoder;
2010 extern AVCodec flac_decoder;
2011 extern AVCodec tscc_decoder;
2012 extern AVCodec ulti_decoder;
2013 extern AVCodec qdraw_decoder;
2014 extern AVCodec xl_decoder;
2015 extern AVCodec qpeg_decoder;
2016 extern AVCodec shorten_decoder;
2017 extern AVCodec loco_decoder;
2018 extern AVCodec wnv1_decoder;
2019 extern AVCodec aasc_decoder;
2020 extern AVCodec alac_decoder;
2021 extern AVCodec ws_snd1_decoder;
2022
2023 /* pcm codecs */
2024 #define PCM_CODEC(id, name) \
2025 extern AVCodec name ## _decoder; \
2026 extern AVCodec name ## _encoder
2027
2028 PCM_CODEC(CODEC_ID_PCM_S16LE, pcm_s16le);
2029 PCM_CODEC(CODEC_ID_PCM_S16BE, pcm_s16be);
2030 PCM_CODEC(CODEC_ID_PCM_U16LE, pcm_u16le);
2031 PCM_CODEC(CODEC_ID_PCM_U16BE, pcm_u16be);
2032 PCM_CODEC(CODEC_ID_PCM_S8, pcm_s8);
2033 PCM_CODEC(CODEC_ID_PCM_U8, pcm_u8);
2034 PCM_CODEC(CODEC_ID_PCM_ALAW, pcm_alaw);
2035 PCM_CODEC(CODEC_ID_PCM_MULAW, pcm_mulaw);
2036
2037 /* adpcm codecs */
2038
2039 PCM_CODEC(CODEC_ID_ADPCM_IMA_QT, adpcm_ima_qt);
2040 PCM_CODEC(CODEC_ID_ADPCM_IMA_WAV, adpcm_ima_wav);
2041 PCM_CODEC(CODEC_ID_ADPCM_IMA_DK3, adpcm_ima_dk3);
2042 PCM_CODEC(CODEC_ID_ADPCM_IMA_DK4, adpcm_ima_dk4);
2043 PCM_CODEC(CODEC_ID_ADPCM_IMA_WS, adpcm_ima_ws);
2044 PCM_CODEC(CODEC_ID_ADPCM_SMJPEG, adpcm_ima_smjpeg);
2045 PCM_CODEC(CODEC_ID_ADPCM_MS, adpcm_ms);
2046 PCM_CODEC(CODEC_ID_ADPCM_4XM, adpcm_4xm);
2047 PCM_CODEC(CODEC_ID_ADPCM_XA, adpcm_xa);
2048 PCM_CODEC(CODEC_ID_ADPCM_ADX, adpcm_adx);
2049 PCM_CODEC(CODEC_ID_ADPCM_EA, adpcm_ea);
2050 PCM_CODEC(CODEC_ID_ADPCM_G726, adpcm_g726);
2051 PCM_CODEC(CODEC_ID_ADPCM_CT, adpcm_ct);
2052 PCM_CODEC(CODEC_ID_ADPCM_SWF, adpcm_swf);
2053
2054 #undef PCM_CODEC
2055
2056 /* dummy raw video codec */
2057 extern AVCodec rawvideo_encoder;
2058 extern AVCodec rawvideo_decoder;
2059
2060 /* the following codecs use external GPL libs */
2061 extern AVCodec ac3_decoder;
2062 extern AVCodec dts_decoder;
2063
2064 /* resample.c */
2065
2066 struct ReSampleContext;
2067 struct AVResampleContext;
2068
2069 typedef struct ReSampleContext ReSampleContext;
2070
2071 ReSampleContext *audio_resample_init(int output_channels, int input_channels,
2072 int output_rate, int input_rate);
2073 int audio_resample(ReSampleContext *s, short *output, short *input, int nb_samples);
2074 void audio_resample_close(ReSampleContext *s);
2075
2076 struct AVResampleContext *av_resample_init(int out_rate, int in_rate, int filter_length, int log2_phase_count, int linear, double cutoff);
2077 int av_resample(struct AVResampleContext *c, short *dst, short *src, int *consumed, int src_size, int dst_size, int update_ctx);
2078 void av_resample_compensate(struct AVResampleContext *c, int sample_delta, int compensation_distance);
2079 void av_resample_close(struct AVResampleContext *c);
2080
2081 /* YUV420 format is assumed ! */
2082
2083 struct ImgReSampleContext;
2084
2085 typedef struct ImgReSampleContext ImgReSampleContext;
2086
2087 ImgReSampleContext *img_resample_init(int output_width, int output_height,
2088 int input_width, int input_height);
2089
2090 ImgReSampleContext *img_resample_full_init(int owidth, int oheight,
2091 int iwidth, int iheight,
2092 int topBand, int bottomBand,
2093 int leftBand, int rightBand,
2094 int padtop, int padbottom,
2095 int padleft, int padright);
2096
2097
2098 void img_resample(ImgReSampleContext *s,
2099 AVPicture *output, const AVPicture *input);
2100
2101 void img_resample_close(ImgReSampleContext *s);
2102
2103 /**
2104 * Allocate memory for a picture. Call avpicture_free to free it.
2105 *
2106 * @param picture the picture to be filled in.
2107 * @param pix_fmt the format of the picture.
2108 * @param width the width of the picture.
2109 * @param height the height of the picture.
2110 * @return 0 if successful, -1 if not.
2111 */
2112 int avpicture_alloc(AVPicture *picture, int pix_fmt, int width, int height);
2113
2114 /* Free a picture previously allocated by avpicture_alloc. */
2115 void avpicture_free(AVPicture *picture);
2116
2117 int avpicture_fill(AVPicture *picture, uint8_t *ptr,
2118 int pix_fmt, int width, int height);
2119 int avpicture_layout(const AVPicture* src, int pix_fmt, int width, int height,
2120 unsigned char *dest, int dest_size);
2121 int avpicture_get_size(int pix_fmt, int width, int height);
2122 void avcodec_get_chroma_sub_sample(int pix_fmt, int *h_shift, int *v_shift);
2123 const char *avcodec_get_pix_fmt_name(int pix_fmt);
2124 void avcodec_set_dimensions(AVCodecContext *s, int width, int height);
2125 enum PixelFormat avcodec_get_pix_fmt(const char* name);
2126 unsigned int avcodec_pix_fmt_to_codec_tag(enum PixelFormat p);
2127
2128 #define FF_LOSS_RESOLUTION 0x0001 /* loss due to resolution change */
2129 #define FF_LOSS_DEPTH 0x0002 /* loss due to color depth change */
2130 #define FF_LOSS_COLORSPACE 0x0004 /* loss due to color space conversion */
2131 #define FF_LOSS_ALPHA 0x0008 /* loss of alpha bits */
2132 #define FF_LOSS_COLORQUANT 0x0010 /* loss due to color quantization */
2133 #define FF_LOSS_CHROMA 0x0020 /* loss of chroma (e.g. rgb to gray conversion) */
2134
2135 int avcodec_get_pix_fmt_loss(int dst_pix_fmt, int src_pix_fmt,
2136 int has_alpha);
2137 int avcodec_find_best_pix_fmt(int pix_fmt_mask, int src_pix_fmt,
2138 int has_alpha, int *loss_ptr);
2139
2140 #define FF_ALPHA_TRANSP 0x0001 /* image has some totally transparent pixels */
2141 #define FF_ALPHA_SEMI_TRANSP 0x0002 /* image has some transparent pixels */
2142 int img_get_alpha_info(const AVPicture *src,
2143 int pix_fmt, int width, int height);
2144
2145 /* convert among pixel formats */
2146 int img_convert(AVPicture *dst, int dst_pix_fmt,
2147 const AVPicture *src, int pix_fmt,
2148 int width, int height);
2149
2150 /* deinterlace a picture */
2151 int avpicture_deinterlace(AVPicture *dst, const AVPicture *src,
2152 int pix_fmt, int width, int height);
2153
2154 /* external high level API */
2155
2156 extern AVCodec *first_avcodec;
2157
2158 /* returns LIBAVCODEC_VERSION_INT constant */
2159 unsigned avcodec_version(void);
2160 /* returns LIBAVCODEC_BUILD constant */
2161 unsigned avcodec_build(void);
2162 void avcodec_init(void);
2163
2164 void register_avcodec(AVCodec *format);
2165 AVCodec *avcodec_find_encoder(enum CodecID id);
2166 AVCodec *avcodec_find_encoder_by_name(const char *name);
2167 AVCodec *avcodec_find_decoder(enum CodecID id);
2168 AVCodec *avcodec_find_decoder_by_name(const char *name);
2169 void avcodec_string(char *buf, int buf_size, AVCodecContext *enc, int encode);
2170
2171 void avcodec_get_context_defaults(AVCodecContext *s);
2172 AVCodecContext *avcodec_alloc_context(void);
2173 void avcodec_get_frame_defaults(AVFrame *pic);
2174 AVFrame *avcodec_alloc_frame(void);
2175
2176 int avcodec_default_get_buffer(AVCodecContext *s, AVFrame *pic);
2177 void avcodec_default_release_buffer(AVCodecContext *s, AVFrame *pic);
2178 int avcodec_default_reget_buffer(AVCodecContext *s, AVFrame *pic);
2179 void avcodec_align_dimensions(AVCodecContext *s, int *width, int *height);
2180 int avcodec_check_dimensions(void *av_log_ctx, unsigned int w, unsigned int h);
2181 enum PixelFormat avcodec_default_get_format(struct AVCodecContext *s, const enum PixelFormat * fmt);
2182
2183 int avcodec_thread_init(AVCodecContext *s, int thread_count);
2184 void avcodec_thread_free(AVCodecContext *s);
2185 int avcodec_thread_execute(AVCodecContext *s, int (*func)(AVCodecContext *c2, void *arg2),void **arg, int *ret, int count);
2186 int avcodec_default_execute(AVCodecContext *c, int (*func)(AVCodecContext *c2, void *arg2),void **arg, int *ret, int count);
2187 //FIXME func typedef
2188
2189 /**
2190 * opens / inits the AVCodecContext.
2191 * not thread save!
2192 */
2193 int avcodec_open(AVCodecContext *avctx, AVCodec *codec);
2194
2195 int avcodec_decode_audio(AVCodecContext *avctx, int16_t *samples,
2196 int *frame_size_ptr,
2197 uint8_t *buf, int buf_size);
2198 int avcodec_decode_video(AVCodecContext *avctx, AVFrame *picture,
2199 int *got_picture_ptr,
2200 uint8_t *buf, int buf_size);
2201 int avcodec_parse_frame(AVCodecContext *avctx, uint8_t **pdata,
2202 int *data_size_ptr,
2203 uint8_t *buf, int buf_size);
2204 int avcodec_encode_audio(AVCodecContext *avctx, uint8_t *buf, int buf_size,
2205 const short *samples);
2206 int avcodec_encode_video(AVCodecContext *avctx, uint8_t *buf, int buf_size,
2207 const AVFrame *pict);
2208
2209 int avcodec_close(AVCodecContext *avctx);
2210
2211 void avcodec_register_all(void);
2212
2213 void avcodec_flush_buffers(AVCodecContext *avctx);
2214
2215 void avcodec_default_free_buffers(AVCodecContext *s);
2216
2217 /* misc usefull functions */
2218
2219 /**
2220 * returns a single letter to describe the picture type
2221 */
2222 char av_get_pict_type_char(int pict_type);
2223
2224 /**
2225 * reduce a fraction.
2226 * this is usefull for framerate calculations
2227 * @param max the maximum allowed for dst_nom & dst_den
2228 * @return 1 if exact, 0 otherwise
2229 */
2230 int av_reduce(int *dst_nom, int *dst_den, int64_t nom, int64_t den, int64_t max);
2231
2232 /**
2233 * rescale a 64bit integer with rounding to nearest.
2234 * a simple a*b/c isnt possible as it can overflow
2235 */
2236 int64_t av_rescale(int64_t a, int64_t b, int64_t c);
2237
2238 /**
2239 * rescale a 64bit integer with specified rounding.
2240 * a simple a*b/c isnt possible as it can overflow
2241 */
2242 int64_t av_rescale_rnd(int64_t a, int64_t b, int64_t c, enum AVRounding);
2243
2244 /* frame parsing */
2245 typedef struct AVCodecParserContext {
2246 void *priv_data;
2247 struct AVCodecParser *parser;
2248 int64_t frame_offset; /* offset of the current frame */
2249 int64_t cur_offset; /* current offset
2250 (incremented by each av_parser_parse()) */
2251 int64_t last_frame_offset; /* offset of the last frame */
2252 /* video info */
2253 int pict_type; /* XXX: put it back in AVCodecContext */
2254 int repeat_pict; /* XXX: put it back in AVCodecContext */
2255 int64_t pts; /* pts of the current frame */
2256 int64_t dts; /* dts of the current frame */
2257
2258 /* private data */
2259 int64_t last_pts;
2260 int64_t last_dts;
2261 int fetch_timestamp;
2262
2263 #define AV_PARSER_PTS_NB 4
2264 int cur_frame_start_index;
2265 int64_t cur_frame_offset[AV_PARSER_PTS_NB];
2266 int64_t cur_frame_pts[AV_PARSER_PTS_NB];
2267 int64_t cur_frame_dts[AV_PARSER_PTS_NB];
2268 } AVCodecParserContext;
2269
2270 typedef struct AVCodecParser {
2271 int codec_ids[5]; /* several codec IDs are permitted */
2272 int priv_data_size;
2273 int (*parser_init)(AVCodecParserContext *s);
2274 int (*parser_parse)(AVCodecParserContext *s,
2275 AVCodecContext *avctx,
2276 uint8_t **poutbuf, int *poutbuf_size,
2277 const uint8_t *buf, int buf_size);
2278 void (*parser_close)(AVCodecParserContext *s);
2279 struct AVCodecParser *next;
2280 } AVCodecParser;
2281
2282 extern AVCodecParser *av_first_parser;
2283
2284 void av_register_codec_parser(AVCodecParser *parser);
2285 AVCodecParserContext *av_parser_init(int codec_id);
2286 int av_parser_parse(AVCodecParserContext *s,
2287 AVCodecContext *avctx,
2288 uint8_t **poutbuf, int *poutbuf_size,
2289 const uint8_t *buf, int buf_size,
2290 int64_t pts, int64_t dts);
2291 void av_parser_close(AVCodecParserContext *s);
2292
2293 extern AVCodecParser mpegvideo_parser;
2294 extern AVCodecParser mpeg4video_parser;
2295 extern AVCodecParser h261_parser;
2296 extern AVCodecParser h263_parser;
2297 extern AVCodecParser h264_parser;
2298 extern AVCodecParser mjpeg_parser;
2299 extern AVCodecParser pnm_parser;
2300 extern AVCodecParser mpegaudio_parser;
2301 extern AVCodecParser ac3_parser;
2302
2303 /* memory */
2304 void *av_malloc(unsigned int size);
2305 void *av_mallocz(unsigned int size);
2306 void *av_realloc(void *ptr, unsigned int size);
2307 void av_free(void *ptr);
2308 char *av_strdup(const char *s);
2309 void av_freep(void *ptr);
2310 void *av_fast_realloc(void *ptr, unsigned int *size, unsigned int min_size);
2311 /* for static data only */
2312 /* call av_free_static to release all staticaly allocated tables */
2313 void av_free_static(void);
2314 void *av_mallocz_static(unsigned int size);
2315 void *av_realloc_static(void *ptr, unsigned int size);
2316
2317 /* add by bero : in adx.c */
2318 int is_adx(const unsigned char *buf,size_t bufsize);
2319
2320 void img_copy(AVPicture *dst, const AVPicture *src,
2321 int pix_fmt, int width, int height);
2322
2323 /* av_log API */
2324
2325 #include <stdarg.h>
2326
2327 #define AV_LOG_QUIET -1
2328 #define AV_LOG_ERROR 0
2329 #define AV_LOG_INFO 1
2330 #define AV_LOG_DEBUG 2
2331
2332 #ifdef __GNUC__
2333 extern void av_log(void*, int level, const char *fmt, ...) __attribute__ ((__format__ (__printf__, 3, 4)));
2334 #else
2335 extern void av_log(void*, int level, const char *fmt, ...);
2336 #endif
2337
2338 extern void av_vlog(void*, int level, const char *fmt, va_list);
2339 extern int av_log_get_level(void);
2340 extern void av_log_set_level(int);
2341 extern void av_log_set_callback(void (*)(void*, int, const char*, va_list));
2342
2343 /* endian macros */
2344 #if !defined(BE_16) || !defined(BE_32) || !defined(LE_16) || !defined(LE_32)
2345 #define BE_16(x) ((((uint8_t*)(x))[0] << 8) | ((uint8_t*)(x))[1])
2346 #define BE_32(x) ((((uint8_t*)(x))[0] << 24) | \
2347 (((uint8_t*)(x))[1] << 16) | \
2348 (((uint8_t*)(x))[2] << 8) | \
2349 ((uint8_t*)(x))[3])
2350 #define LE_16(x) ((((uint8_t*)(x))[1] << 8) | ((uint8_t*)(x))[0])
2351 #define LE_32(x) ((((uint8_t*)(x))[3] << 24) | \
2352 (((uint8_t*)(x))[2] << 16) | \
2353 (((uint8_t*)(x))[1] << 8) | \
2354 ((uint8_t*)(x))[0])
2355 #endif
2356
2357 #ifdef __cplusplus
2358 }
2359 #endif
2360
2361 #endif /* AVCODEC_H */