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