16 #define LIBAVCODEC_VERSION_INT 0x000406
17 #define LIBAVCODEC_VERSION "0.4.6"
18 #define LIBAVCODEC_BUILD 4671
19 #define LIBAVCODEC_BUILD_STR "4671"
21 #define LIBAVCODEC_IDENT "FFmpeg" LIBAVCODEC_VERSION "b" LIBAVCODEC_BUILD_STR
65 /* various pcm "codecs" */
75 /* various adpcm codecs */
76 CODEC_ID_ADPCM_IMA_QT,
77 CODEC_ID_ADPCM_IMA_WAV,
89 CODEC_TYPE_UNKNOWN = -1,
98 PIX_FMT_YUV420P, ///< Planar YUV 4:2:0 (1 Cr & Cb sample per 2x2 Y samples)
100 PIX_FMT_RGB24, ///< Packed pixel, 3 bytes per pixel, RGBRGB...
101 PIX_FMT_BGR24, ///< Packed pixel, 3 bytes per pixel, BGRBGR...
102 PIX_FMT_YUV422P, ///< Planar YUV 4:2:2 (1 Cr & Cb sample per 2x1 Y samples)
103 PIX_FMT_YUV444P, ///< Planar YUV 4:4:4 (1 Cr & Cb sample per 1x1 Y samples)
104 PIX_FMT_RGBA32, ///< Packed pixel, 4 bytes per pixel, BGRABGRA...
105 PIX_FMT_YUV410P, ///< Planar YUV 4:1:0 (1 Cr & Cb sample per 4x4 Y samples)
106 PIX_FMT_YUV411P, ///< Planar YUV 4:1:1 (1 Cr & Cb sample per 4x1 Y samples)
107 PIX_FMT_RGB565, ///< always stored in cpu endianness
108 PIX_FMT_RGB555, ///< always stored in cpu endianness, most significant bit to 1
110 PIX_FMT_MONOWHITE, ///< 0 is white
111 PIX_FMT_MONOBLACK, ///< 0 is black
112 PIX_FMT_PAL8, ///< 8 bit with RGBA palette
113 PIX_FMT_YUVJ420P, ///< Planar YUV 4:2:0 full scale (jpeg)
114 PIX_FMT_YUVJ422P, ///< Planar YUV 4:2:2 full scale (jpeg)
115 PIX_FMT_YUVJ444P, ///< Planar YUV 4:4:4 full scale (jpeg)
119 /* currently unused, may be used if 24/32 bits samples ever supported */
121 SAMPLE_FMT_S16 = 0, ///< signed 16 bits
125 #define AVCODEC_MAX_AUDIO_FRAME_SIZE 131072
128 * Required number of additionally allocated bytes at the end of the input bitstream for decoding.
129 * this is mainly needed because some optimized bitstream readers read
130 * 32 or 64 bit at once and could read over the end<br>
131 * Note, if the first 23 bits of the additional bytes are not 0 then damaged
132 * MPEG bitstreams could cause overread and segfault
134 #define FF_INPUT_BUFFER_PADDING_SIZE 8
136 /* motion estimation type, EPZS by default */
146 typedef struct RcOverride{
149 int qscale; // if this is 0 then quality_factor will be used instead
150 float quality_factor;
153 /* only for ME compatiblity with old apps */
154 extern int motion_estimation_method;
156 /* ME algos sorted by quality */
157 static const int Motion_Est_QTab[] = { ME_ZERO, ME_PHODS, ME_LOG,
158 ME_X1, ME_EPZS, ME_FULL };
161 #define FF_MAX_B_FRAMES 8
164 these flags can be passed in AVCodecContext.flags before initing
165 Note: note not everything is supported yet
168 #define CODEC_FLAG_HQ 0x0001 ///< brute force MB-type decission mode (slow)
169 #define CODEC_FLAG_QSCALE 0x0002 ///< use fixed qscale
170 #define CODEC_FLAG_4MV 0x0004 ///< 4 MV per MB allowed
171 #define CODEC_FLAG_QPEL 0x0010 ///< use qpel MC
172 #define CODEC_FLAG_GMC 0x0020 ///< use GMC
173 #define CODEC_FLAG_PART 0x0080 ///< use data partitioning
174 /* parent program gurantees that the input for b-frame containing streams is not written to
175 for at least s->max_b_frames+1 frames, if this is not set than the input will be copied */
176 #define CODEC_FLAG_INPUT_PRESERVED 0x0100
177 #define CODEC_FLAG_PASS1 0x0200 ///< use internal 2pass ratecontrol in first pass mode
178 #define CODEC_FLAG_PASS2 0x0400 ///< use internal 2pass ratecontrol in second pass mode
179 #define CODEC_FLAG_EXTERN_HUFF 0x1000 ///< use external huffman table (for mjpeg)
180 #define CODEC_FLAG_GRAY 0x2000 ///< only decode/encode grayscale
181 #define CODEC_FLAG_EMU_EDGE 0x4000///< dont draw edges
182 #define CODEC_FLAG_PSNR 0x8000 ///< error[?] variables will be set during encoding
183 #define CODEC_FLAG_TRUNCATED 0x00010000 /** input bitstream might be truncated at a random location instead
184 of only at frame boundaries */
185 #define CODEC_FLAG_NORMALIZE_AQP 0x00020000 ///< normalize adaptive quantization
186 #define CODEC_FLAG_INTERLACED_DCT 0x00040000 ///< use interlaced dct
187 #define CODEC_FLAG_LOW_DELAY 0x00080000 ///< force low delay
188 #define CODEC_FLAG_ALT_SCAN 0x00100000 ///< use alternate scan
189 #define CODEC_FLAG_TRELLIS_QUANT 0x00200000 ///< use trellis quantization
190 #define CODEC_FLAG_GLOBAL_HEADER 0x00400000 ///< place global headers in extradata instead of every keyframe
191 #define CODEC_FLAG_BITEXACT 0x00800000 ///< use only bitexact stuff (except (i)dct)
192 /* Fx : Flag for h263+ extra options */
193 #define CODEC_FLAG_H263P_AIC 0x01000000 ///< Advanced intra coding
194 #define CODEC_FLAG_H263P_UMV 0x02000000 ///< Unlimited motion vector
195 /* For advanced prediction mode, we reuse the 4MV flag */
196 /* Unsupported options :
197 * Syntax Arithmetic coding (SAC)
198 * Deblocking filter internal loop
200 * Reference Picture Selection
201 * Independant Segment Decoding
202 * Alternative Inter * VLC
203 * Modified Quantization */
205 /* codec capabilities */
207 #define CODEC_CAP_DRAW_HORIZ_BAND 0x0001 ///< decoder can use draw_horiz_band callback
209 * Codec uses get_buffer() for allocating buffers.
210 * direct rendering method 1
212 #define CODEC_CAP_DR1 0x0002
213 /* if 'parse_only' field is true, then avcodec_parse_frame() can be
215 #define CODEC_CAP_PARSE_ONLY 0x0004
216 #define CODEC_CAP_TRUNCATED 0x0008
218 #define FF_COMMON_FRAME \
220 * pointer to the picture planes.\
221 * this might be different from the first allocated byte\
228 * pointer to the first allocated byte of the picture. can be used in get_buffer/release_buffer\
229 * this isnt used by lavc unless the default get/release_buffer() is used\
235 * 1 -> keyframe, 0-> not\
236 * - encoding: set by lavc\
237 * - decoding: set by lavc\
242 * picture type of the frame, see ?_TYPE below.\
243 * - encoding: set by lavc for coded_picture (and set by user for input)\
244 * - decoding: set by lavc\
249 * presentation timestamp in micro seconds (time when frame should be shown to user)\
250 * if 0 then the frame_rate will be used as reference\
251 * - encoding: MUST be set by user\
252 * - decoding: set by lavc\
257 * picture number in bitstream order.\
258 * - encoding: set by\
259 * - decoding: set by lavc\
261 int coded_picture_number;\
263 * picture number in display order.\
264 * - encoding: set by\
265 * - decoding: set by lavc\
267 int display_picture_number;\
270 * quality (between 1 (good) and 31 (bad)) \
271 * - encoding: set by lavc for coded_picture (and set by user for input)\
272 * - decoding: set by lavc\
277 * buffer age (1->was last buffer and dint change, 2->..., ...).\
278 * set to something large if the buffer has not been used yet \
279 * - encoding: unused\
280 * - decoding: MUST be set by get_buffer()\
285 * is this picture used as reference\
286 * - encoding: unused\
287 * - decoding: set by lavc (before get_buffer() call))\
293 * - encoding: unused\
294 * - decoding: set by lavc\
296 int8_t *qscale_table;\
299 * - encoding: unused\
300 * - decoding: set by lavc\
305 * mbskip_table[mb]>=1 if MB didnt change\
306 * stride= mb_width = (width+15)>>4\
307 * - encoding: unused\
308 * - decoding: set by lavc\
310 uint8_t *mbskip_table;\
313 * for some private data of the user\
314 * - encoding: unused\
315 * - decoding: set by user\
321 * - encoding: set by lavc if flags&CODEC_FLAG_PSNR\
322 * - decoding: unused\
327 * type of the buffer (to keep track of who has to dealloc data[*])\
328 * - encoding: set by the one who allocs it\
329 * - decoding: set by the one who allocs it\
330 * Note: user allocated (direct rendering) & internal buffers can not coexist currently\
335 * when decoding, this signal how much the picture must be delayed.\
336 * extra_delay = repeat_pict / (2*fps)\
337 * - encoding: unused\
338 * - decoding: set by lavc\
347 #define FF_QSCALE_TYPE_MPEG1 0
348 #define FF_QSCALE_TYPE_MPEG2 1
350 #define FF_BUFFER_TYPE_INTERNAL 1
351 #define FF_BUFFER_TYPE_USER 2 ///< Direct rendering buffers
352 #define FF_BUFFER_TYPE_SHARED 4 ///< buffer from somewher else, dont dealloc
355 #define FF_I_TYPE 1 // Intra
356 #define FF_P_TYPE 2 // Predicted
357 #define FF_B_TYPE 3 // Bi-dir predicted
358 #define FF_S_TYPE 4 // S(GMC)-VOP MPEG4
365 typedef struct AVFrame {
369 #define DEFAULT_FRAME_RATE_BASE 1001000
372 * main external api structure.
374 typedef struct AVCodecContext {
376 * the average bitrate.
377 * - encoding: set by user. unused for constant quantizer encoding
378 * - decoding: set by lavc. 0 or some bitrate if this info is available in the stream
383 * number of bits the bitstream is allowed to diverge from the reference.
384 * the reference can be CBR (for CBR pass1) or VBR (for pass2)
385 * - encoding: set by user. unused for constant quantizer encoding
388 int bit_rate_tolerance;
392 * - encoding: set by user.
393 * - decoding: set by user.
398 * some codecs needs additionnal format info. It is stored here
399 * - encoding: set by user.
400 * - decoding: set by lavc. (FIXME is this ok?)
405 * motion estimation algorithm used for video coding.
406 * - encoding: MUST be set by user.
412 * some codecs need / can use extra-data like huffman tables.
413 * mjpeg: huffman tables
414 * rv10: additional flags
415 * mpeg4: global headers (they can be in the bitstream or here)
416 * - encoding: set/allocated/freed by lavc.
417 * - decoding: set/allocated/freed by user.
424 * frames per sec multiplied by frame_rate_base.
425 * for variable fps this is the precission, so if the timestamps
426 * can be specified in msec precssion then this is 1000*frame_rate_base
427 * - encoding: MUST be set by user
428 * - decoding: set by lavc. 0 or the frame_rate if available
434 * - encoding: MUST be set by user.
435 * - decoding: set by user, some codecs might override / change it during playback
439 #define FF_ASPECT_SQUARE 1
440 #define FF_ASPECT_4_3_625 2
441 #define FF_ASPECT_4_3_525 3
442 #define FF_ASPECT_16_9_625 4
443 #define FF_ASPECT_16_9_525 5
444 #define FF_ASPECT_EXTENDED 15
447 * the number of pictures in a group of pitures, or 0 for intra_only.
448 * - encoding: set by user.
454 * pixel format, see PIX_FMT_xxx.
456 * - decoding: set by lavc.
458 enum PixelFormat pix_fmt;
461 * Frame rate emulation. If not zero lower layer (i.e. format handler)
462 * has to read frames at native frame rate.
463 * - encoding: set by user.
464 * - decoding: unused.
469 * if non NULL, 'draw_horiz_band' is called by the libavcodec
470 * decoder to draw an horizontal band. It improve cache usage. Not
471 * all codecs can do that. You must check the codec capabilities
474 * - decoding: set by user.
475 * @param height the height of the slice
476 * @param y the y position of the slice
477 * @param type 1->top field, 2->bottom field, 3->frame
478 * @param offset offset into the AVFrame.data from which the slice should be read
480 void (*draw_horiz_band)(struct AVCodecContext *s,
481 AVFrame *src, int offset[4],
482 int y, int type, int height);
485 int sample_rate; ///< samples per sec
487 int sample_fmt; ///< sample format, currenly unused
489 /* the following data should not be initialized */
490 int frame_size; ///< in samples, initialized when calling 'init'
491 int frame_number; ///< audio or video frame number
492 int real_pict_num; ///< returns the real picture number of previous encoded frame
495 * number of frames the decoded output will be delayed relative to
497 * - encoding: set by lavc.
502 /* - encoding parameters */
503 float qcompress; ///< amount of qscale change between easy & hard scenes (0.0-1.0)
504 float qblur; ///< amount of qscale smoothing over time (0.0-1.0)
508 * - encoding: set by user.
515 * - encoding: set by user.
521 * maximum quantizer difference etween frames.
522 * - encoding: set by user.
528 * maximum number of b frames between non b frames.
529 * note: the output will be delayed by max_b_frames+1 relative to the input
530 * - encoding: set by user.
536 * qscale factor between ip and b frames.
537 * - encoding: set by user.
540 float b_quant_factor;
542 /** obsolete FIXME remove */
544 int b_frame_strategy;
549 * - decoding: set by user. 1-> skip b frames, 2-> skip idct/dequant too, 5-> skip everything except header
553 struct AVCodec *codec;
557 /* The following data is for RTP friendly coding */
558 /* By now only H.263/H.263+/MPEG4 coder honours this */
559 int rtp_mode; /* 1 for activate RTP friendly-mode */
560 /* highers numbers represent more error-prone */
561 /* enviroments, by now just "1" exist */
563 int rtp_payload_size; /* The size of the RTP payload, the coder will */
564 /* do it's best to deliver a chunk with size */
565 /* below rtp_payload_size, the chunk will start */
566 /* with a start code on some codecs like H.263 */
567 /* This doesn't take account of any particular */
568 /* headers inside the transmited RTP payload */
571 /* The RTP callcack: This function is called */
572 /* every time the encoder as a packet to send */
573 /* Depends on the encoder if the data starts */
574 /* with a Start Code (it should) H.263 does */
575 void (*rtp_callback)(void *data, int size, int packet_number);
577 /* statistics, used for 2-pass encoding */
588 * number of bits used for the previously encoded frame.
589 * - encoding: set by lavc
595 * private data of the user, can be used to carry app specific stuff.
596 * - encoding: set by user
597 * - decoding: set by user
602 enum CodecType codec_type; /* see CODEC_TYPE_xxx */
603 enum CodecID codec_id; /* see CODEC_ID_xxx */
606 * fourcc (LSB first, so "ABCD" -> ('D'<<24) + ('C'<<16) + ('B'<<8) + 'A').
607 * this is used to workaround some encoder bugs
609 * - decoding: set by user, will be converted to upper case by lavc during init
611 unsigned int codec_tag;
614 * workaround bugs in encoders which sometimes cannot be detected automatically.
616 * - decoding: set by user
619 #define FF_BUG_AUTODETECT 1 ///< autodetection
620 #define FF_BUG_OLD_MSMPEG4 2
621 #define FF_BUG_XVID_ILACE 4
622 #define FF_BUG_UMP4 8
623 #define FF_BUG_NO_PADDING 16
624 #define FF_BUG_AC_VLC 32
625 #define FF_BUG_QPEL_CHROMA 64
626 #define FF_BUG_STD_QPEL 128
627 #define FF_BUG_QPEL_CHROMA2 256
628 #define FF_BUG_DIRECT_BLOCKSIZE 512
629 #define FF_BUG_EDGE 1024
630 //#define FF_BUG_FAKE_SCALABILITY 16 //autodetection should work 100%
633 * luma single coeff elimination threshold.
634 * - encoding: set by user
637 int luma_elim_threshold;
640 * chroma single coeff elimination threshold.
641 * - encoding: set by user
644 int chroma_elim_threshold;
647 * strictly follow the std (MPEG4, ...).
648 * - encoding: set by user
651 int strict_std_compliance;
654 * qscale offset between ip and b frames.
655 * if > 0 then the last p frame quantizer will be used (q= lastp_q*factor+offset)
656 * if < 0 then normal ratecontrol will be done (q= -normal_q*factor+offset)
657 * - encoding: set by user.
660 float b_quant_offset;
663 * error resilience higher values will detect more errors but may missdetect
664 * some more or less valid parts as errors.
666 * - decoding: set by user
668 int error_resilience;
669 #define FF_ER_CAREFULL 1
670 #define FF_ER_COMPLIANT 2
671 #define FF_ER_AGGRESSIVE 3
672 #define FF_ER_VERY_AGGRESSIVE 4
675 * called at the beginning of each frame to get a buffer for it.
676 * if pic.reference is set then the frame will be read later by lavc
677 * width and height should be rounded up to the next multiple of 16
679 * - decoding: set by lavc, user can override
681 int (*get_buffer)(struct AVCodecContext *c, AVFrame *pic);
684 * called to release buffers which where allocated with get_buffer.
685 * a released buffer can be reused in get_buffer()
686 * pic.data[*] must be set to NULL
688 * - decoding: set by lavc, user can override
690 void (*release_buffer)(struct AVCodecContext *c, AVFrame *pic);
693 * is 1 if the decoded stream contains b frames, 0 otherwise.
695 * - decoding: set by lavc
699 int block_align; ///< used by some WAV based audio codecs
701 int parse_only; /* - decoding only: if true, only parsing is done
702 (function avcodec_parse_frame()). The frame
703 data is returned. Only MPEG codecs support this now. */
706 * 0-> h263 quant 1-> mpeg quant.
707 * - encoding: set by user.
713 * pass1 encoding statistics output buffer.
714 * - encoding: set by lavc
720 * pass2 encoding statistics input buffer.
721 * concatenated stuff from stats_out of pass1 should be placed here
722 * - encoding: allocated/set/freed by user
728 * ratecontrol qmin qmax limiting method.
729 * 0-> clipping, 1-> use a nice continous function to limit qscale wthin qmin/qmax
730 * - encoding: set by user.
739 * ratecontrol override, see RcOverride.
740 * - encoding: allocated/set/freed by user.
743 RcOverride *rc_override;
744 int rc_override_count;
747 * rate control equation.
748 * - encoding: set by user
755 * - encoding: set by user.
762 * - encoding: set by user.
768 * decoder bitstream buffer size.
769 * - encoding: set by user.
773 float rc_buffer_aggressivity;
776 * qscale factor between p and i frames.
777 * - encoding: set by user.
780 float i_quant_factor;
783 * qscale offset between p and i frames.
784 * if > 0 then the last p frame quantizer will be used (q= lastp_q*factor+offset)
785 * if < 0 then normal ratecontrol will be done (q= -normal_q*factor+offset)
786 * - encoding: set by user.
789 float i_quant_offset;
792 * initial complexity for pass1 ratecontrol.
793 * - encoding: set by user.
796 float rc_initial_cplx;
799 * dct algorithm, see FF_DCT_* below.
800 * - encoding: set by user
804 #define FF_DCT_AUTO 0
805 #define FF_DCT_FASTINT 1
808 #define FF_DCT_MLIB 4
809 #define FF_DCT_ALTIVEC 5
812 * luminance masking (0-> disabled).
813 * - encoding: set by user
819 * temporary complexity masking (0-> disabled).
820 * - encoding: set by user
823 float temporal_cplx_masking;
826 * spatial complexity masking (0-> disabled).
827 * - encoding: set by user
830 float spatial_cplx_masking;
833 * p block masking (0-> disabled).
834 * - encoding: set by user
840 * darkness masking (0-> disabled).
841 * - encoding: set by user
847 /* for binary compatibility */
851 * idct algorithm, see FF_IDCT_* below.
852 * - encoding: set by user
853 * - decoding: set by user
856 #define FF_IDCT_AUTO 0
857 #define FF_IDCT_INT 1
858 #define FF_IDCT_SIMPLE 2
859 #define FF_IDCT_SIMPLEMMX 3
860 #define FF_IDCT_LIBMPEG2MMX 4
861 #define FF_IDCT_PS2 5
862 #define FF_IDCT_MLIB 6
863 #define FF_IDCT_ARM 7
864 #define FF_IDCT_ALTIVEC 8
865 #define FF_IDCT_SH4 9
866 #define FF_IDCT_SIMPLEARM 10
870 * - encoding: set by lavc
871 * - decoding: set by user (or 0)
875 * slice offsets in the frame in bytes.
876 * - encoding: set/allocated by lavc
877 * - decoding: set/allocated by user (or NULL)
882 * error concealment flags.
884 * - decoding: set by user
886 int error_concealment;
887 #define FF_EC_GUESS_MVS 1
888 #define FF_EC_DEBLOCK 2
891 * dsp_mask could be add used to disable unwanted CPU features
892 * CPU features (i.e. MMX, SSE. ...)
894 * with FORCE flag you may instead enable given CPU features
895 * (Dangerous: usable in case of misdetection, improper usage however will
896 * result into program crash)
899 #define FF_MM_FORCE 0x80000000 /* force usage of selected flags (OR) */
900 /* lower 16 bits - CPU features */
902 #define FF_MM_MMX 0x0001 /* standard MMX */
903 #define FF_MM_3DNOW 0x0004 /* AMD 3DNOW */
904 #define FF_MM_MMXEXT 0x0002 /* SSE integer functions or AMD MMX ext */
905 #define FF_MM_SSE 0x0008 /* SSE functions */
906 #define FF_MM_SSE2 0x0010 /* PIV SSE2 functions */
907 #endif /* HAVE_MMX */
910 * bits per sample/pixel from the demuxer (needed for huffyuv).
911 * - encoding: set by lavc
912 * - decoding: set by user
917 * prediction method (needed for huffyuv).
918 * - encoding: set by user
921 int prediction_method;
922 #define FF_PRED_LEFT 0
923 #define FF_PRED_PLANE 1
924 #define FF_PRED_MEDIAN 2
927 * aspect ratio (0 if unknown).
928 * - encoding: set by user.
929 * - decoding: set by lavc.
934 * the picture in the bitstream.
935 * - encoding: set by lavc
936 * - decoding: set by lavc
938 AVFrame *coded_frame;
942 * - encoding: set by user.
943 * - decoding: set by user.
946 #define FF_DEBUG_PICT_INFO 1
947 #define FF_DEBUG_RC 2
948 #define FF_DEBUG_BITSTREAM 4
949 #define FF_DEBUG_MB_TYPE 8
950 #define FF_DEBUG_QP 16
951 #define FF_DEBUG_MV 32
952 #define FF_DEBUG_VIS_MV 0x00000040
953 #define FF_DEBUG_SKIP 0x00000080
954 #define FF_DEBUG_STARTCODE 0x00000100
955 #define FF_DEBUG_PTS 0x00000200
956 #define FF_DEBUG_ER 0x00000400
957 #define FF_DEBUG_MMCO 0x00000800
961 * - encoding: set by lavc if flags&CODEC_FLAG_PSNR
967 * minimum MB quantizer.
968 * - encoding: set by user.
974 * maximum MB quantizer.
975 * - encoding: set by user.
981 * motion estimation compare function.
982 * - encoding: set by user.
987 * subpixel motion estimation compare function.
988 * - encoding: set by user.
993 * macroblock compare function (not supported yet).
994 * - encoding: set by user.
1000 #define FF_CMP_SATD 2
1001 #define FF_CMP_DCT 3
1002 #define FF_CMP_PSNR 4
1003 #define FF_CMP_BIT 5
1005 #define FF_CMP_ZERO 7
1006 #define FF_CMP_CHROMA 256
1009 * ME diamond size & shape.
1010 * - encoding: set by user.
1011 * - decoding: unused
1016 * amount of previous MV predictors (2a+1 x 2a+1 square).
1017 * - encoding: set by user.
1018 * - decoding: unused
1020 int last_predictor_count;
1023 * pre pass for motion estimation.
1024 * - encoding: set by user.
1025 * - decoding: unused
1030 * motion estimation pre pass compare function.
1031 * - encoding: set by user.
1032 * - decoding: unused
1037 * ME pre pass diamond size & shape.
1038 * - encoding: set by user.
1039 * - decoding: unused
1044 * subpel ME quality.
1045 * - encoding: set by user.
1046 * - decoding: unused
1048 int me_subpel_quality;
1051 * callback to negotiate the pixelFormat.
1052 * @param fmt is the list of formats which are supported by the codec,
1053 * its terminated by -1 as 0 is a valid format, the formats are ordered by quality
1054 * the first is allways the native one
1055 * @return the choosen format
1056 * - encoding: unused
1057 * - decoding: set by user, if not set then the native format will always be choosen
1059 enum PixelFormat (*get_format)(struct AVCodecContext *s, enum PixelFormat * fmt);
1062 * DTG active format information (additionnal aspect ratio
1063 * information only used in DVB MPEG2 transport streams). 0 if
1066 * - encoding: unused.
1067 * - decoding: set by decoder
1069 int dtg_active_format;
1070 #define FF_DTG_AFD_SAME 8
1071 #define FF_DTG_AFD_4_3 9
1072 #define FF_DTG_AFD_16_9 10
1073 #define FF_DTG_AFD_14_9 11
1074 #define FF_DTG_AFD_4_3_SP_14_9 13
1075 #define FF_DTG_AFD_16_9_SP_14_9 14
1076 #define FF_DTG_AFD_SP_4_3 15
1079 * Maximum motion estimation search range in subpel units.
1080 * if 0 then no limit
1082 * - encoding: set by user.
1083 * - decoding: unused.
1089 * for variable fps this is 1
1090 * - encoding: set by user.
1091 * - decoding: set by lavc.
1092 * @todo move this after frame_rate
1095 int frame_rate_base;
1097 * intra quantizer bias.
1098 * - encoding: set by user.
1099 * - decoding: unused
1101 int intra_quant_bias;
1102 #define FF_DEFAULT_QUANT_BIAS 999999
1105 * inter quantizer bias.
1106 * - encoding: set by user.
1107 * - decoding: unused
1109 int inter_quant_bias;
1113 * - encoding: unused.
1114 * - decoding: which clrtable should be used for 8bit RGB images
1115 * table have to be stored somewhere FIXME
1120 * internal_buffer count.
1121 * Dont touch, used by lavc default_get_buffer()
1123 int internal_buffer_count;
1127 * Dont touch, used by lavc default_get_buffer()
1129 void *internal_buffer;
1131 #define FF_QUALITY_SCALE 256
1133 * global quality for codecs which cannot change it per frame.
1134 * this should be proportional to MPEG1/2/4 qscale.
1135 * - encoding: set by user.
1136 * - decoding: unused
1140 #define FF_CODER_TYPE_VLC 0
1141 #define FF_CODER_TYPE_AC 1
1144 * - encoding: set by user.
1145 * - decoding: unused
1151 * - encoding: set by user.
1152 * - decoding: unused
1158 * - encoding: unused
1159 * - decoding: set by user.
1162 #define SLICE_FLAG_CODED_ORDER 0x0001 ///< draw_horiz_band() is called in coded order instead of display
1163 #define SLICE_FLAG_ALLOW_FIELD 0x0002 ///< allow draw_horiz_band() with field slices (MPEG2 field pics)
1164 #define SLICE_FLAG_ALLOW_PLANE 0x0004 ///< allow draw_horiz_band() with 1 component at a time (SVQ1)
1172 typedef struct AVOption {
1173 /** options' name */
1174 const char *name; /* if name is NULL, it indicates a link to next */
1175 /** short English text help or const struct AVOption* subpointer */
1176 const char *help; // const struct AVOption* sub;
1177 /** offset to context structure where the parsed value should be stored */
1179 /** options' type */
1181 #define FF_OPT_TYPE_BOOL 1 ///< boolean - true,1,on (or simply presence)
1182 #define FF_OPT_TYPE_DOUBLE 2 ///< double
1183 #define FF_OPT_TYPE_INT 3 ///< integer
1184 #define FF_OPT_TYPE_STRING 4 ///< string (finished with \0)
1185 #define FF_OPT_TYPE_MASK 0x1f ///< mask for types - upper bits are various flags
1186 //#define FF_OPT_TYPE_EXPERT 0x20 // flag for expert option
1187 #define FF_OPT_TYPE_FLAG (FF_OPT_TYPE_BOOL | 0x40)
1188 #define FF_OPT_TYPE_RCOVERRIDE (FF_OPT_TYPE_STRING | 0x80)
1189 /** min value (min == max -> no limits) */
1191 /** maximum value for double/int */
1193 /** default boo [0,1]l/double/int value */
1196 * default string value (with optional semicolon delimited extra option-list
1197 * i.e. option1;option2;option3
1198 * defval might select other then first argument as default
1201 #define FF_OPT_MAX_DEPTH 10
1205 * Parse option(s) and sets fields in passed structure
1206 * @param strct structure where the parsed results will be written
1207 * @param list list with AVOptions
1208 * @param opts string with options for parsing
1210 int avoption_parse(void* strct, const AVOption* list, const char* opts);
1216 typedef struct AVCodec {
1218 enum CodecType type;
1221 int (*init)(AVCodecContext *);
1222 int (*encode)(AVCodecContext *, uint8_t *buf, int buf_size, void *data);
1223 int (*close)(AVCodecContext *);
1224 int (*decode)(AVCodecContext *, void *outdata, int *outdata_size,
1225 uint8_t *buf, int buf_size);
1227 const AVOption *options;
1228 struct AVCodec *next;
1229 void (*flush)(AVCodecContext *);
1233 * four components are given, that's all.
1234 * the last component is alpha
1236 typedef struct AVPicture {
1238 int linesize[4]; ///< number of bytes per line
1241 extern AVCodec ac3_encoder;
1242 extern AVCodec mp2_encoder;
1243 extern AVCodec mp3lame_encoder;
1244 extern AVCodec oggvorbis_encoder;
1245 extern AVCodec mpeg1video_encoder;
1246 extern AVCodec h263_encoder;
1247 extern AVCodec h263p_encoder;
1248 extern AVCodec flv_encoder;
1249 extern AVCodec rv10_encoder;
1250 extern AVCodec mjpeg_encoder;
1251 extern AVCodec ljpeg_encoder;
1252 extern AVCodec mpeg4_encoder;
1253 extern AVCodec msmpeg4v1_encoder;
1254 extern AVCodec msmpeg4v2_encoder;
1255 extern AVCodec msmpeg4v3_encoder;
1256 extern AVCodec wmv1_encoder;
1257 extern AVCodec wmv2_encoder;
1258 extern AVCodec huffyuv_encoder;
1259 extern AVCodec h264_encoder;
1260 extern AVCodec asv1_encoder;
1261 extern AVCodec vcr1_encoder;
1262 extern AVCodec ffv1_encoder;
1264 extern AVCodec h263_decoder;
1265 extern AVCodec mpeg4_decoder;
1266 extern AVCodec msmpeg4v1_decoder;
1267 extern AVCodec msmpeg4v2_decoder;
1268 extern AVCodec msmpeg4v3_decoder;
1269 extern AVCodec wmv1_decoder;
1270 extern AVCodec wmv2_decoder;
1271 extern AVCodec mpeg_decoder;
1272 extern AVCodec h263i_decoder;
1273 extern AVCodec flv_decoder;
1274 extern AVCodec rv10_decoder;
1275 extern AVCodec svq1_decoder;
1276 extern AVCodec svq3_decoder;
1277 extern AVCodec dvvideo_decoder;
1278 extern AVCodec dvaudio_decoder;
1279 extern AVCodec wmav1_decoder;
1280 extern AVCodec wmav2_decoder;
1281 extern AVCodec mjpeg_decoder;
1282 extern AVCodec mjpegb_decoder;
1283 extern AVCodec mp2_decoder;
1284 extern AVCodec mp3_decoder;
1285 extern AVCodec mace3_decoder;
1286 extern AVCodec mace6_decoder;
1287 extern AVCodec huffyuv_decoder;
1288 extern AVCodec oggvorbis_decoder;
1289 extern AVCodec cyuv_decoder;
1290 extern AVCodec h264_decoder;
1291 extern AVCodec indeo3_decoder;
1292 extern AVCodec vp3_decoder;
1293 extern AVCodec amr_nb_decoder;
1294 extern AVCodec amr_nb_encoder;
1295 extern AVCodec aac_decoder;
1296 extern AVCodec mpeg4aac_decoder;
1297 extern AVCodec asv1_decoder;
1298 extern AVCodec vcr1_decoder;
1299 extern AVCodec ffv1_decoder;
1300 extern AVCodec fourxm_decoder;
1301 extern AVCodec ra_144_decoder;
1302 extern AVCodec ra_288_decoder;
1305 #define PCM_CODEC(id, name) \
1306 extern AVCodec name ## _decoder; \
1307 extern AVCodec name ## _encoder
1309 PCM_CODEC(CODEC_ID_PCM_S16LE, pcm_s16le);
1310 PCM_CODEC(CODEC_ID_PCM_S16BE, pcm_s16be);
1311 PCM_CODEC(CODEC_ID_PCM_U16LE, pcm_u16le);
1312 PCM_CODEC(CODEC_ID_PCM_U16BE, pcm_u16be);
1313 PCM_CODEC(CODEC_ID_PCM_S8, pcm_s8);
1314 PCM_CODEC(CODEC_ID_PCM_U8, pcm_u8);
1315 PCM_CODEC(CODEC_ID_PCM_ALAW, pcm_alaw);
1316 PCM_CODEC(CODEC_ID_PCM_MULAW, pcm_mulaw);
1320 PCM_CODEC(CODEC_ID_ADPCM_IMA_QT, adpcm_ima_qt);
1321 PCM_CODEC(CODEC_ID_ADPCM_IMA_WAV, adpcm_ima_wav);
1322 PCM_CODEC(CODEC_ID_ADPCM_MS, adpcm_ms);
1323 PCM_CODEC(CODEC_ID_ADPCM_4XM, adpcm_4xm);
1327 /* dummy raw video codec */
1328 extern AVCodec rawvideo_encoder;
1329 extern AVCodec rawvideo_decoder;
1331 /* the following codecs use external GPL libs */
1332 extern AVCodec ac3_decoder;
1336 struct ReSampleContext;
1338 typedef struct ReSampleContext ReSampleContext;
1340 ReSampleContext *audio_resample_init(int output_channels, int input_channels,
1341 int output_rate, int input_rate);
1342 int audio_resample(ReSampleContext *s, short *output, short *input, int nb_samples);
1343 void audio_resample_close(ReSampleContext *s);
1345 /* YUV420 format is assumed ! */
1347 struct ImgReSampleContext;
1349 typedef struct ImgReSampleContext ImgReSampleContext;
1351 ImgReSampleContext *img_resample_init(int output_width, int output_height,
1352 int input_width, int input_height);
1354 ImgReSampleContext *img_resample_full_init(int owidth, int oheight,
1355 int iwidth, int iheight,
1356 int topBand, int bottomBand,
1357 int leftBand, int rightBand);
1359 void img_resample(ImgReSampleContext *s,
1360 AVPicture *output, AVPicture *input);
1362 void img_resample_close(ImgReSampleContext *s);
1364 int avpicture_fill(AVPicture *picture, uint8_t *ptr,
1365 int pix_fmt, int width, int height);
1366 int avpicture_layout(AVPicture* src, int pix_fmt, int width, int height,
1367 unsigned char *dest, int dest_size);
1368 int avpicture_get_size(int pix_fmt, int width, int height);
1369 void avcodec_get_chroma_sub_sample(int pix_fmt, int *h_shift, int *v_shift);
1370 const char *avcodec_get_pix_fmt_name(int pix_fmt);
1371 enum PixelFormat avcodec_get_pix_fmt(const char* name);
1373 #define FF_LOSS_RESOLUTION 0x0001 /* loss due to resolution change */
1374 #define FF_LOSS_DEPTH 0x0002 /* loss due to color depth change */
1375 #define FF_LOSS_COLORSPACE 0x0004 /* loss due to color space conversion */
1376 #define FF_LOSS_ALPHA 0x0008 /* loss of alpha bits */
1377 #define FF_LOSS_COLORQUANT 0x0010 /* loss due to color quantization */
1378 #define FF_LOSS_CHROMA 0x0020 /* loss of chroma (e.g. rgb to gray conversion) */
1380 int avcodec_get_pix_fmt_loss(int dst_pix_fmt, int src_pix_fmt,
1382 int avcodec_find_best_pix_fmt(int pix_fmt_mask, int src_pix_fmt,
1383 int has_alpha, int *loss_ptr);
1385 #define FF_ALPHA_TRANSP 0x0001 /* image has some totally transparent pixels */
1386 #define FF_ALPHA_SEMI_TRANSP 0x0002 /* image has some transparent pixels */
1387 int img_get_alpha_info(AVPicture *src, int pix_fmt, int width, int height);
1389 /* convert among pixel formats */
1390 int img_convert(AVPicture *dst, int dst_pix_fmt,
1391 AVPicture *src, int pix_fmt,
1392 int width, int height);
1394 /* deinterlace a picture */
1395 int avpicture_deinterlace(AVPicture *dst, AVPicture *src,
1396 int pix_fmt, int width, int height);
1398 /* external high level API */
1400 extern AVCodec *first_avcodec;
1402 /* returns LIBAVCODEC_VERSION_INT constant */
1403 unsigned avcodec_version(void);
1404 /* returns LIBAVCODEC_BUILD constant */
1405 unsigned avcodec_build(void);
1406 void avcodec_init(void);
1408 void register_avcodec(AVCodec *format);
1409 AVCodec *avcodec_find_encoder(enum CodecID id);
1410 AVCodec *avcodec_find_encoder_by_name(const char *name);
1411 AVCodec *avcodec_find_decoder(enum CodecID id);
1412 AVCodec *avcodec_find_decoder_by_name(const char *name);
1413 void avcodec_string(char *buf, int buf_size, AVCodecContext *enc, int encode);
1415 void avcodec_get_context_defaults(AVCodecContext *s);
1416 AVCodecContext *avcodec_alloc_context(void);
1417 AVFrame *avcodec_alloc_frame(void);
1419 int avcodec_default_get_buffer(AVCodecContext *s, AVFrame *pic);
1420 void avcodec_default_release_buffer(AVCodecContext *s, AVFrame *pic);
1421 void avcodec_default_free_buffers(AVCodecContext *s);
1424 * opens / inits the AVCodecContext.
1427 int avcodec_open(AVCodecContext *avctx, AVCodec *codec);
1429 int avcodec_decode_audio(AVCodecContext *avctx, int16_t *samples,
1430 int *frame_size_ptr,
1431 uint8_t *buf, int buf_size);
1432 int avcodec_decode_video(AVCodecContext *avctx, AVFrame *picture,
1433 int *got_picture_ptr,
1434 uint8_t *buf, int buf_size);
1435 int avcodec_parse_frame(AVCodecContext *avctx, uint8_t **pdata,
1437 uint8_t *buf, int buf_size);
1438 int avcodec_encode_audio(AVCodecContext *avctx, uint8_t *buf, int buf_size,
1439 const short *samples);
1440 int avcodec_encode_video(AVCodecContext *avctx, uint8_t *buf, int buf_size,
1441 const AVFrame *pict);
1443 int avcodec_close(AVCodecContext *avctx);
1445 void avcodec_register_all(void);
1447 void avcodec_flush_buffers(AVCodecContext *avctx);
1449 /* misc usefull functions */
1452 * returns a single letter to describe the picture type
1454 char av_get_pict_type_char(int pict_type);
1457 * reduce a fraction.
1458 * this is usefull for framerate calculations
1459 * @param max the maximum allowed for dst_nom & dst_den
1460 * @return 1 if exact, 0 otherwise
1462 int av_reduce(int *dst_nom, int *dst_den, int64_t nom, int64_t den, int64_t max);
1465 * rescale a 64bit integer.
1466 * a simple a*b/c isnt possible as it can overflow
1468 int64_t av_rescale(int64_t a, int b, int c);
1472 * Interface for 0.5.0 version
1474 * do not even think about it's usage for this moment
1478 /// compressed size used from given memory buffer
1480 /// I/P/B frame type
1486 * order can't be changed - once it was defined
1490 AVC_OPEN_BY_NAME = 0xACA000,
1491 AVC_OPEN_BY_CODEC_ID,
1496 // pin - struct { uint8_t* src, uint_t src_size }
1497 // pout - struct { AVPicture* img, consumed_bytes,
1499 // pin - struct { AVPicture* img, uint8_t* dest, uint_t dest_size }
1500 // pout - uint_t used_from_dest_size
1503 // query/get video commands
1504 AVC_GET_VERSION = 0xACB000,
1508 AVC_GET_QUANT_TABLE,
1511 // query/get audio commands
1512 AVC_GET_FRAME_SIZE = 0xABC000,
1514 // maybe define some simple structure which
1515 // might be passed to the user - but they can't
1516 // contain any codec specific parts and these
1517 // calls are usualy necessary only few times
1519 // set video commands
1520 AVC_SET_WIDTH = 0xACD000,
1523 // set video encoding commands
1524 AVC_SET_FRAME_RATE = 0xACD800,
1528 // set audio commands
1529 AVC_SET_SAMPLE_RATE = 0xACE000,
1535 * \param handle allocated private structure by libavcodec
1536 * for initialization pass NULL - will be returned pout
1537 * user is supposed to know nothing about its structure
1538 * \param cmd type of operation to be performed
1539 * \param pint input parameter
1540 * \param pout output parameter
1542 * \returns command status - eventually for query command it might return
1543 * integer resulting value
1545 int avcodec(void* handle, avc_cmd_t cmd, void* pin, void* pout);
1548 void *av_malloc(unsigned int size);
1549 void *av_mallocz(unsigned int size);
1550 void *av_realloc(void *ptr, unsigned int size);
1551 void av_free(void *ptr);
1552 char *av_strdup(const char *s);
1553 void __av_freep(void **ptr);
1554 #define av_freep(p) __av_freep((void **)(p))
1555 void *av_fast_realloc(void *ptr, unsigned int *size, unsigned int min_size);
1556 /* for static data only */
1557 /* call av_free_static to release all staticaly allocated tables */
1558 void av_free_static(void);
1559 void *__av_mallocz_static(void** location, unsigned int size);
1560 #define av_mallocz_static(p, s) __av_mallocz_static((void **)(p), s)
1566 #endif /* AVCODEC_H */