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