16 #define LIBAVCODEC_VERSION_INT 0x000406
17 #define LIBAVCODEC_VERSION "0.4.6"
18 #define LIBAVCODEC_BUILD 4665
19 #define LIBAVCODEC_BUILD_STR "4665"
21 #define LIBAVCODEC_IDENT "FFmpeg" LIBAVCODEC_VERSION "b" LIBAVCODEC_BUILD_STR
55 /* various pcm "codecs" */
65 /* various adpcm codecs */
66 CODEC_ID_ADPCM_IMA_QT,
67 CODEC_ID_ADPCM_IMA_WAV,
72 CODEC_TYPE_UNKNOWN = -1,
83 PIX_FMT_RGB24, ///< 3 bytes, R is first
84 PIX_FMT_BGR24, ///< 3 bytes, B is first
87 PIX_FMT_RGBA32, ///< always stored in cpu endianness
90 PIX_FMT_RGB565, ///< always stored in cpu endianness
91 PIX_FMT_RGB555, ///< always stored in cpu endianness, most significant bit to 1
93 PIX_FMT_MONOWHITE, ///< 0 is white
94 PIX_FMT_MONOBLACK, ///< 0 is black
95 PIX_FMT_PAL8, ///< 8 bit with RGBA palette
96 PIX_FMT_YUVJ420P, ///< YUV full scale (jpeg)
97 PIX_FMT_YUVJ422P, ///< YUV full scale (jpeg)
98 PIX_FMT_YUVJ444P, ///< YUV full scale (jpeg)
102 /* currently unused, may be used if 24/32 bits samples ever supported */
104 SAMPLE_FMT_S16 = 0, ///< signed 16 bits
108 #define AVCODEC_MAX_AUDIO_FRAME_SIZE 131072
111 * Required number of zero bytes at the end of the input bitstream for decoding.
112 * to avoid overreading (and possibly segfaulting)
114 #define FF_INPUT_BUFFER_PADDING_SIZE 8
116 /* motion estimation type, EPZS by default */
126 typedef struct RcOverride{
129 int qscale; // if this is 0 then quality_factor will be used instead
130 float quality_factor;
133 /* only for ME compatiblity with old apps */
134 extern int motion_estimation_method;
136 /* ME algos sorted by quality */
137 static const int Motion_Est_QTab[] = { ME_ZERO, ME_PHODS, ME_LOG,
138 ME_X1, ME_EPZS, ME_FULL };
141 #define FF_MAX_B_FRAMES 8
144 these flags can be passed in AVCodecContext.flags before initing
145 Note: note not everything is supported yet
148 #define CODEC_FLAG_HQ 0x0001 ///< brute force MB-type decission mode (slow)
149 #define CODEC_FLAG_QSCALE 0x0002 ///< use fixed qscale
150 #define CODEC_FLAG_4MV 0x0004 ///< 4 MV per MB allowed
151 #define CODEC_FLAG_QPEL 0x0010 ///< use qpel MC
152 #define CODEC_FLAG_GMC 0x0020 ///< use GMC
153 #define CODEC_FLAG_PART 0x0080 ///< use data partitioning
154 /* parent program gurantees that the input for b-frame containing streams is not written to
155 for at least s->max_b_frames+1 frames, if this is not set than the input will be copied */
156 #define CODEC_FLAG_INPUT_PRESERVED 0x0100
157 #define CODEC_FLAG_PASS1 0x0200 ///< use internal 2pass ratecontrol in first pass mode
158 #define CODEC_FLAG_PASS2 0x0400 ///< use internal 2pass ratecontrol in second pass mode
159 #define CODEC_FLAG_EXTERN_HUFF 0x1000 ///< use external huffman table (for mjpeg)
160 #define CODEC_FLAG_GRAY 0x2000 ///< only decode/encode grayscale
161 #define CODEC_FLAG_EMU_EDGE 0x4000///< dont draw edges
162 #define CODEC_FLAG_PSNR 0x8000 ///< error[?] variables will be set during encoding
163 #define CODEC_FLAG_TRUNCATED 0x00010000 /** input bitstream might be truncated at a random location instead
164 of only at frame boundaries */
165 #define CODEC_FLAG_NORMALIZE_AQP 0x00020000 ///< normalize adaptive quantization
166 #define CODEC_FLAG_INTERLACED_DCT 0x00040000 ///< use interlaced dct
167 #define CODEC_FLAG_LOW_DELAY 0x00080000 ///< force low delay / will fail on b frames
168 #define CODEC_FLAG_ALT_SCAN 0x00100000 ///< use alternate scan
169 #define CODEC_FLAG_TRELLIS_QUANT 0x00200000 ///< use trellis quantization
170 #define CODEC_FLAG_GLOBAL_HEADER 0x00400000 ///< place global headers in extradata instead of every keyframe
171 #define CODEC_FLAG_BITEXACT 0x00800000 ///< use only bitexact stuff (except (i)dct)
172 /* Fx : Flag for h263+ extra options */
173 #define CODEC_FLAG_H263P_AIC 0x01000000 ///< Advanced intra coding
174 #define CODEC_FLAG_H263P_UMV 0x02000000 ///< Unlimited motion vector
175 /* For advanced prediction mode, we reuse the 4MV flag */
176 /* Unsupported options :
177 * Syntax Arithmetic coding (SAC)
178 * Deblocking filter internal loop
180 * Reference Picture Selection
181 * Independant Segment Decoding
182 * Alternative Inter * VLC
183 * Modified Quantization */
185 /* codec capabilities */
187 #define CODEC_CAP_DRAW_HORIZ_BAND 0x0001 ///< decoder can use draw_horiz_band callback
189 * Codec uses get_buffer() for allocating buffers.
190 * direct rendering method 1
192 #define CODEC_CAP_DR1 0x0002
193 /* if 'parse_only' field is true, then avcodec_parse_frame() can be
195 #define CODEC_CAP_PARSE_ONLY 0x0004
196 #define CODEC_CAP_TRUNCATED 0x0008
198 #define FF_COMMON_FRAME \
200 * pointer to the picture planes.\
201 * this might be different from the first allocated byte\
208 * pointer to the first allocated byte of the picture. can be used in get_buffer/release_buffer\
209 * this isnt used by lavc unless the default get/release_buffer() is used\
215 * 1 -> keyframe, 0-> not\
216 * - encoding: set by lavc\
217 * - decoding: set by lavc\
222 * picture type of the frame, see ?_TYPE below.\
223 * - encoding: set by lavc for coded_picture (and set by user for input)\
224 * - decoding: set by lavc\
229 * presentation timestamp in micro seconds (time when frame should be shown to user)\
230 * if 0 then the frame_rate will be used as reference\
231 * - encoding: MUST be set by user\
232 * - decoding: set by lavc\
237 * picture number in bitstream order.\
238 * - encoding: set by\
239 * - decoding: set by lavc\
241 int coded_picture_number;\
243 * picture number in display order.\
244 * - encoding: set by\
245 * - decoding: set by lavc\
247 int display_picture_number;\
250 * quality (between 1 (good) and 31 (bad)) \
251 * - encoding: set by lavc for coded_picture (and set by user for input)\
252 * - decoding: set by lavc\
257 * buffer age (1->was last buffer and dint change, 2->..., ...).\
258 * set to something large if the buffer has not been used yet \
259 * - encoding: unused\
260 * - decoding: MUST be set by get_buffer()\
265 * is this picture used as reference\
266 * - encoding: unused\
267 * - decoding: set by lavc (before get_buffer() call))\
273 * - encoding: unused\
274 * - decoding: set by lavc\
276 int8_t *qscale_table;\
279 * - encoding: unused\
280 * - decoding: set by lavc\
285 * mbskip_table[mb]>=1 if MB didnt change\
286 * stride= mb_width = (width+15)>>4\
287 * - encoding: unused\
288 * - decoding: set by lavc\
290 uint8_t *mbskip_table;\
293 * for some private data of the user\
294 * - encoding: unused\
295 * - decoding: set by user\
301 * - encoding: set by lavc if flags&CODEC_FLAG_PSNR\
302 * - decoding: unused\
307 * type of the buffer (to keep track of who has to dealloc data[*])\
308 * - encoding: set by the one who allocs it\
309 * - decoding: set by the one who allocs it\
310 * Note: user allocated (direct rendering) & internal buffers can not coexist currently\
315 * when decoding, this signal how much the picture must be delayed.\
316 * extra_delay = repeat_pict / (2*fps)\
317 * - encoding: unused\
318 * - decoding: set by lavc\
327 #define FF_QSCALE_TYPE_MPEG1 0
328 #define FF_QSCALE_TYPE_MPEG2 1
330 #define FF_BUFFER_TYPE_INTERNAL 1
331 #define FF_BUFFER_TYPE_USER 2 ///< Direct rendering buffers
332 #define FF_BUFFER_TYPE_SHARED 4 ///< buffer from somewher else, dont dealloc
335 #define FF_I_TYPE 1 // Intra
336 #define FF_P_TYPE 2 // Predicted
337 #define FF_B_TYPE 3 // Bi-dir predicted
338 #define FF_S_TYPE 4 // S(GMC)-VOP MPEG4
345 typedef struct AVFrame {
349 #define DEFAULT_FRAME_RATE_BASE 1001000
352 * main external api structure.
354 typedef struct AVCodecContext {
356 * the average bitrate.
357 * - encoding: set by user. unused for constant quantizer encoding
358 * - decoding: set by lavc. 0 or some bitrate if this info is available in the stream
363 * number of bits the bitstream is allowed to diverge from the reference.
364 * the reference can be CBR (for CBR pass1) or VBR (for pass2)
365 * - encoding: set by user. unused for constant quantizer encoding
368 int bit_rate_tolerance;
372 * - encoding: set by user.
373 * - decoding: set by user.
378 * some codecs needs additionnal format info. It is stored here
379 * - encoding: set by user.
380 * - decoding: set by lavc. (FIXME is this ok?)
385 * motion estimation algorithm used for video coding.
386 * - encoding: MUST be set by user.
392 * some codecs need / can use extra-data like huffman tables.
393 * mjpeg: huffman tables
394 * rv10: additional flags
395 * mpeg4: global headers (they can be in the bitstream or here)
396 * - encoding: set/allocated/freed by lavc.
397 * - decoding: set/allocated/freed by user.
404 * frames per sec multiplied by frame_rate_base.
405 * for variable fps this is the precission, so if the timestamps
406 * can be specified in msec precssion then this is 1000*frame_rate_base
407 * - encoding: MUST be set by user
408 * - decoding: set by lavc. 0 or the frame_rate if available
414 * - encoding: MUST be set by user.
415 * - decoding: set by user, some codecs might override / change it during playback
419 #define FF_ASPECT_SQUARE 1
420 #define FF_ASPECT_4_3_625 2
421 #define FF_ASPECT_4_3_525 3
422 #define FF_ASPECT_16_9_625 4
423 #define FF_ASPECT_16_9_525 5
424 #define FF_ASPECT_EXTENDED 15
427 * the number of pictures in a group of pitures, or 0 for intra_only.
428 * - encoding: set by user.
434 * pixel format, see PIX_FMT_xxx.
436 * - decoding: set by lavc.
438 enum PixelFormat pix_fmt;
441 * Frame rate emulation. If not zero lower layer (i.e. format handler)
442 * has to read frames at native frame rate.
443 * - encoding: set by user.
444 * - decoding: unused.
449 * if non NULL, 'draw_horiz_band' is called by the libavcodec
450 * decoder to draw an horizontal band. It improve cache usage. Not
451 * all codecs can do that. You must check the codec capabilities
454 * - decoding: set by user.
456 void (*draw_horiz_band)(struct AVCodecContext *s,
457 uint8_t **src_ptr, int linesize,
458 int y, int width, int height);
461 int sample_rate; ///< samples per sec
463 int sample_fmt; ///< sample format, currenly unused
465 /* the following data should not be initialized */
466 int frame_size; ///< in samples, initialized when calling 'init'
467 int frame_number; ///< audio or video frame number
468 int real_pict_num; ///< returns the real picture number of previous encoded frame
471 * number of frames the decoded output will be delayed relative to
473 * - encoding: set by lavc.
478 /* - encoding parameters */
479 float qcompress; ///< amount of qscale change between easy & hard scenes (0.0-1.0)
480 float qblur; ///< amount of qscale smoothing over time (0.0-1.0)
484 * - encoding: set by user.
491 * - encoding: set by user.
497 * maximum quantizer difference etween frames.
498 * - encoding: set by user.
504 * maximum number of b frames between non b frames.
505 * note: the output will be delayed by max_b_frames+1 relative to the input
506 * - encoding: set by user.
512 * qscale factor between ip and b frames.
513 * - encoding: set by user.
516 float b_quant_factor;
518 /** obsolete FIXME remove */
520 int b_frame_strategy;
525 * - decoding: set by user. 1-> skip b frames, 2-> skip idct/dequant too, 5-> skip everything except header
529 struct AVCodec *codec;
533 /* The following data is for RTP friendly coding */
534 /* By now only H.263/H.263+/MPEG4 coder honours this */
535 int rtp_mode; /* 1 for activate RTP friendly-mode */
536 /* highers numbers represent more error-prone */
537 /* enviroments, by now just "1" exist */
539 int rtp_payload_size; /* The size of the RTP payload, the coder will */
540 /* do it's best to deliver a chunk with size */
541 /* below rtp_payload_size, the chunk will start */
542 /* with a start code on some codecs like H.263 */
543 /* This doesn't take account of any particular */
544 /* headers inside the transmited RTP payload */
547 /* The RTP callcack: This function is called */
548 /* every time the encoder as a packet to send */
549 /* Depends on the encoder if the data starts */
550 /* with a Start Code (it should) H.263 does */
551 void (*rtp_callback)(void *data, int size, int packet_number);
553 /* statistics, used for 2-pass encoding */
564 * number of bits used for the previously encoded frame.
565 * - encoding: set by lavc
571 * private data of the user, can be used to carry app specific stuff.
572 * - encoding: set by user
573 * - decoding: set by user
578 enum CodecType codec_type; /* see CODEC_TYPE_xxx */
579 enum CodecID codec_id; /* see CODEC_ID_xxx */
582 * fourcc (LSB first, so "ABCD" -> ('D'<<24) + ('C'<<16) + ('B'<<8) + 'A').
583 * this is used to workaround some encoder bugs
585 * - decoding: set by user, will be converted to upper case by lavc during init
587 unsigned int codec_tag;
590 * workaround bugs in encoders which sometimes cannot be detected automatically.
592 * - decoding: set by user
595 #define FF_BUG_AUTODETECT 1 ///< autodetection
596 #define FF_BUG_OLD_MSMPEG4 2
597 #define FF_BUG_XVID_ILACE 4
598 #define FF_BUG_UMP4 8
599 #define FF_BUG_NO_PADDING 16
600 #define FF_BUG_AC_VLC 32
601 #define FF_BUG_QPEL_CHROMA 64
602 #define FF_BUG_STD_QPEL 128
603 #define FF_BUG_QPEL_CHROMA2 256
604 #define FF_BUG_DIRECT_BLOCKSIZE 512
605 #define FF_BUG_EDGE 1024
606 //#define FF_BUG_FAKE_SCALABILITY 16 //autodetection should work 100%
609 * luma single coeff elimination threshold.
610 * - encoding: set by user
613 int luma_elim_threshold;
616 * chroma single coeff elimination threshold.
617 * - encoding: set by user
620 int chroma_elim_threshold;
623 * strictly follow the std (MPEG4, ...).
624 * - encoding: set by user
627 int strict_std_compliance;
630 * qscale offset between ip and b frames.
631 * if > 0 then the last p frame quantizer will be used (q= lastp_q*factor+offset)
632 * if < 0 then normal ratecontrol will be done (q= -normal_q*factor+offset)
633 * - encoding: set by user.
636 float b_quant_offset;
639 * error resilience higher values will detect more errors but may missdetect
640 * some more or less valid parts as errors.
642 * - decoding: set by user
644 int error_resilience;
645 #define FF_ER_CAREFULL 1
646 #define FF_ER_COMPLIANT 2
647 #define FF_ER_AGGRESSIVE 3
648 #define FF_ER_VERY_AGGRESSIVE 4
651 * called at the beginning of each frame to get a buffer for it.
652 * if pic.reference is set then the frame will be read later by lavc
654 * - decoding: set by lavc, user can override
656 int (*get_buffer)(struct AVCodecContext *c, AVFrame *pic);
659 * called to release buffers which where allocated with get_buffer.
660 * a released buffer can be reused in get_buffer()
661 * pic.data[*] must be set to NULL
663 * - decoding: set by lavc, user can override
665 void (*release_buffer)(struct AVCodecContext *c, AVFrame *pic);
668 * is 1 if the decoded stream contains b frames, 0 otherwise.
670 * - decoding: set by lavc
674 int block_align; ///< used by some WAV based audio codecs
676 int parse_only; /* - decoding only: if true, only parsing is done
677 (function avcodec_parse_frame()). The frame
678 data is returned. Only MPEG codecs support this now. */
681 * 0-> h263 quant 1-> mpeg quant.
682 * - encoding: set by user.
688 * pass1 encoding statistics output buffer.
689 * - encoding: set by lavc
695 * pass2 encoding statistics input buffer.
696 * concatenated stuff from stats_out of pass1 should be placed here
697 * - encoding: allocated/set/freed by user
703 * ratecontrol qmin qmax limiting method.
704 * 0-> clipping, 1-> use a nice continous function to limit qscale wthin qmin/qmax
705 * - encoding: set by user.
714 * ratecontrol override, see RcOverride.
715 * - encoding: allocated/set/freed by user.
718 RcOverride *rc_override;
719 int rc_override_count;
722 * rate control equation.
723 * - encoding: set by user
730 * - encoding: set by user.
737 * - encoding: set by user.
743 * decoder bitstream buffer size.
744 * - encoding: set by user.
748 float rc_buffer_aggressivity;
751 * qscale factor between p and i frames.
752 * - encoding: set by user.
755 float i_quant_factor;
758 * qscale offset between p and i frames.
759 * if > 0 then the last p frame quantizer will be used (q= lastp_q*factor+offset)
760 * if < 0 then normal ratecontrol will be done (q= -normal_q*factor+offset)
761 * - encoding: set by user.
764 float i_quant_offset;
767 * initial complexity for pass1 ratecontrol.
768 * - encoding: set by user.
771 float rc_initial_cplx;
774 * dct algorithm, see FF_DCT_* below.
775 * - encoding: set by user
779 #define FF_DCT_AUTO 0
780 #define FF_DCT_FASTINT 1
783 #define FF_DCT_MLIB 4
784 #define FF_DCT_ALTIVEC 5
787 * luminance masking (0-> disabled).
788 * - encoding: set by user
794 * temporary complexity masking (0-> disabled).
795 * - encoding: set by user
798 float temporal_cplx_masking;
801 * spatial complexity masking (0-> disabled).
802 * - encoding: set by user
805 float spatial_cplx_masking;
808 * p block masking (0-> disabled).
809 * - encoding: set by user
815 * darkness masking (0-> disabled).
816 * - encoding: set by user
822 /* for binary compatibility */
826 * idct algorithm, see FF_IDCT_* below.
827 * - encoding: set by user
828 * - decoding: set by user
831 #define FF_IDCT_AUTO 0
832 #define FF_IDCT_INT 1
833 #define FF_IDCT_SIMPLE 2
834 #define FF_IDCT_SIMPLEMMX 3
835 #define FF_IDCT_LIBMPEG2MMX 4
836 #define FF_IDCT_PS2 5
837 #define FF_IDCT_MLIB 6
838 #define FF_IDCT_ARM 7
839 #define FF_IDCT_ALTIVEC 8
843 * - encoding: set by lavc
844 * - decoding: set by user (or 0)
848 * slice offsets in the frame in bytes.
849 * - encoding: set/allocated by lavc
850 * - decoding: set/allocated by user (or NULL)
855 * error concealment flags.
857 * - decoding: set by user
859 int error_concealment;
860 #define FF_EC_GUESS_MVS 1
861 #define FF_EC_DEBLOCK 2
864 * dsp_mask could be add used to disable unwanted CPU features
865 * CPU features (i.e. MMX, SSE. ...)
867 * with FORCE flag you may instead enable given CPU features
868 * (Dangerous: usable in case of misdetection, improper usage however will
869 * result into program crash)
872 #define FF_MM_FORCE 0x80000000 /* force usage of selected flags (OR) */
873 /* lower 16 bits - CPU features */
875 #define FF_MM_MMX 0x0001 /* standard MMX */
876 #define FF_MM_3DNOW 0x0004 /* AMD 3DNOW */
877 #define FF_MM_MMXEXT 0x0002 /* SSE integer functions or AMD MMX ext */
878 #define FF_MM_SSE 0x0008 /* SSE functions */
879 #define FF_MM_SSE2 0x0010 /* PIV SSE2 functions */
880 #endif /* HAVE_MMX */
883 * bits per sample/pixel from the demuxer (needed for huffyuv).
884 * - encoding: set by lavc
885 * - decoding: set by user
890 * prediction method (needed for huffyuv).
891 * - encoding: set by user
894 int prediction_method;
895 #define FF_PRED_LEFT 0
896 #define FF_PRED_PLANE 1
897 #define FF_PRED_MEDIAN 2
900 * aspect ratio (0 if unknown).
901 * - encoding: set by user.
902 * - decoding: set by lavc.
907 * the picture in the bitstream.
908 * - encoding: set by lavc
909 * - decoding: set by lavc
911 AVFrame *coded_frame;
915 * - encoding: set by user.
916 * - decoding: set by user.
919 #define FF_DEBUG_PICT_INFO 1
920 #define FF_DEBUG_RC 2
921 #define FF_DEBUG_BITSTREAM 4
922 #define FF_DEBUG_MB_TYPE 8
923 #define FF_DEBUG_QP 16
924 #define FF_DEBUG_MV 32
925 #define FF_DEBUG_VIS_MV 0x00000040
926 #define FF_DEBUG_SKIP 0x00000080
927 #define FF_DEBUG_STARTCODE 0x00000100
928 #define FF_DEBUG_PTS 0x00000200
929 #define FF_DEBUG_ER 0x00000400
930 #define FF_DEBUG_MMCO 0x00000800
934 * - encoding: set by lavc if flags&CODEC_FLAG_PSNR
940 * minimum MB quantizer.
941 * - encoding: set by user.
947 * maximum MB quantizer.
948 * - encoding: set by user.
954 * motion estimation compare function.
955 * - encoding: set by user.
960 * subpixel motion estimation compare function.
961 * - encoding: set by user.
966 * macroblock compare function (not supported yet).
967 * - encoding: set by user.
973 #define FF_CMP_SATD 2
975 #define FF_CMP_PSNR 4
978 #define FF_CMP_ZERO 7
979 #define FF_CMP_CHROMA 256
982 * ME diamond size & shape.
983 * - encoding: set by user.
989 * amount of previous MV predictors (2a+1 x 2a+1 square).
990 * - encoding: set by user.
993 int last_predictor_count;
996 * pre pass for motion estimation.
997 * - encoding: set by user.
1003 * motion estimation pre pass compare function.
1004 * - encoding: set by user.
1005 * - decoding: unused
1010 * ME pre pass diamond size & shape.
1011 * - encoding: set by user.
1012 * - decoding: unused
1017 * subpel ME quality.
1018 * - encoding: set by user.
1019 * - decoding: unused
1021 int me_subpel_quality;
1024 * callback to negotiate the pixelFormat.
1025 * @param fmt is the list of formats which are supported by the codec,
1026 * its terminated by -1 as 0 is a valid format, the formats are ordered by quality
1027 * the first is allways the native one
1028 * @return the choosen format
1029 * - encoding: unused
1030 * - decoding: set by user, if not set then the native format will always be choosen
1032 enum PixelFormat (*get_format)(struct AVCodecContext *s, enum PixelFormat * fmt);
1035 * DTG active format information (additionnal aspect ratio
1036 * information only used in DVB MPEG2 transport streams). 0 if
1039 * - encoding: unused.
1040 * - decoding: set by decoder
1042 int dtg_active_format;
1043 #define FF_DTG_AFD_SAME 8
1044 #define FF_DTG_AFD_4_3 9
1045 #define FF_DTG_AFD_16_9 10
1046 #define FF_DTG_AFD_14_9 11
1047 #define FF_DTG_AFD_4_3_SP_14_9 13
1048 #define FF_DTG_AFD_16_9_SP_14_9 14
1049 #define FF_DTG_AFD_SP_4_3 15
1052 * Maximum motion estimation search range in subpel units.
1053 * if 0 then no limit
1055 * - encoding: set by user.
1056 * - decoding: unused.
1062 * for variable fps this is 1
1063 * - encoding: set by user.
1064 * - decoding: set by lavc.
1065 * @todo move this after frame_rate
1068 int frame_rate_base;
1070 * intra quantizer bias.
1071 * - encoding: set by user.
1072 * - decoding: unused
1074 int intra_quant_bias;
1075 #define FF_DEFAULT_QUANT_BIAS 999999
1078 * inter quantizer bias.
1079 * - encoding: set by user.
1080 * - decoding: unused
1082 int inter_quant_bias;
1090 typedef struct AVOption {
1091 /** options' name */
1092 const char *name; /* if name is NULL, it indicates a link to next */
1093 /** short English text help or const struct AVOption* subpointer */
1094 const char *help; // const struct AVOption* sub;
1095 /** offset to context structure where the parsed value should be stored */
1097 /** options' type */
1099 #define FF_OPT_TYPE_BOOL 1 ///< boolean - true,1,on (or simply presence)
1100 #define FF_OPT_TYPE_DOUBLE 2 ///< double
1101 #define FF_OPT_TYPE_INT 3 ///< integer
1102 #define FF_OPT_TYPE_STRING 4 ///< string (finished with \0)
1103 #define FF_OPT_TYPE_MASK 0x1f ///< mask for types - upper bits are various flags
1104 //#define FF_OPT_TYPE_EXPERT 0x20 // flag for expert option
1105 #define FF_OPT_TYPE_FLAG (FF_OPT_TYPE_BOOL | 0x40)
1106 #define FF_OPT_TYPE_RCOVERRIDE (FF_OPT_TYPE_STRING | 0x80)
1107 /** min value (min == max -> no limits) */
1109 /** maximum value for double/int */
1111 /** default boo [0,1]l/double/int value */
1114 * default string value (with optional semicolon delimited extra option-list
1115 * i.e. option1;option2;option3
1116 * defval might select other then first argument as default
1119 #define FF_OPT_MAX_DEPTH 10
1123 * Parse option(s) and sets fields in passed structure
1124 * @param strct structure where the parsed results will be written
1125 * @param list list with AVOptions
1126 * @param opts string with options for parsing
1128 int avoption_parse(void* strct, const AVOption* list, const char* opts);
1134 typedef struct AVCodec {
1139 int (*init)(AVCodecContext *);
1140 int (*encode)(AVCodecContext *, uint8_t *buf, int buf_size, void *data);
1141 int (*close)(AVCodecContext *);
1142 int (*decode)(AVCodecContext *, void *outdata, int *outdata_size,
1143 uint8_t *buf, int buf_size);
1145 const AVOption *options;
1146 struct AVCodec *next;
1150 * four components are given, that's all.
1151 * the last component is alpha
1153 typedef struct AVPicture {
1158 extern AVCodec ac3_encoder;
1159 extern AVCodec mp2_encoder;
1160 extern AVCodec mp3lame_encoder;
1161 extern AVCodec oggvorbis_encoder;
1162 extern AVCodec mpeg1video_encoder;
1163 extern AVCodec h263_encoder;
1164 extern AVCodec h263p_encoder;
1165 extern AVCodec rv10_encoder;
1166 extern AVCodec mjpeg_encoder;
1167 extern AVCodec mpeg4_encoder;
1168 extern AVCodec msmpeg4v1_encoder;
1169 extern AVCodec msmpeg4v2_encoder;
1170 extern AVCodec msmpeg4v3_encoder;
1171 extern AVCodec wmv1_encoder;
1172 extern AVCodec wmv2_encoder;
1173 extern AVCodec huffyuv_encoder;
1174 extern AVCodec h264_encoder;
1176 extern AVCodec h263_decoder;
1177 extern AVCodec mpeg4_decoder;
1178 extern AVCodec msmpeg4v1_decoder;
1179 extern AVCodec msmpeg4v2_decoder;
1180 extern AVCodec msmpeg4v3_decoder;
1181 extern AVCodec wmv1_decoder;
1182 extern AVCodec wmv2_decoder;
1183 extern AVCodec mpeg_decoder;
1184 extern AVCodec h263i_decoder;
1185 extern AVCodec rv10_decoder;
1186 extern AVCodec svq1_decoder;
1187 extern AVCodec dvvideo_decoder;
1188 extern AVCodec dvaudio_decoder;
1189 extern AVCodec wmav1_decoder;
1190 extern AVCodec wmav2_decoder;
1191 extern AVCodec mjpeg_decoder;
1192 extern AVCodec mjpegb_decoder;
1193 extern AVCodec mp2_decoder;
1194 extern AVCodec mp3_decoder;
1195 extern AVCodec mace3_decoder;
1196 extern AVCodec mace6_decoder;
1197 extern AVCodec huffyuv_decoder;
1198 extern AVCodec oggvorbis_decoder;
1199 extern AVCodec cyuv_decoder;
1200 extern AVCodec h264_decoder;
1201 extern AVCodec indeo3_decoder;
1204 #define PCM_CODEC(id, name) \
1205 extern AVCodec name ## _decoder; \
1206 extern AVCodec name ## _encoder
1208 PCM_CODEC(CODEC_ID_PCM_S16LE, pcm_s16le);
1209 PCM_CODEC(CODEC_ID_PCM_S16BE, pcm_s16be);
1210 PCM_CODEC(CODEC_ID_PCM_U16LE, pcm_u16le);
1211 PCM_CODEC(CODEC_ID_PCM_U16BE, pcm_u16be);
1212 PCM_CODEC(CODEC_ID_PCM_S8, pcm_s8);
1213 PCM_CODEC(CODEC_ID_PCM_U8, pcm_u8);
1214 PCM_CODEC(CODEC_ID_PCM_ALAW, pcm_alaw);
1215 PCM_CODEC(CODEC_ID_PCM_MULAW, pcm_mulaw);
1219 PCM_CODEC(CODEC_ID_ADPCM_IMA_QT, adpcm_ima_qt);
1220 PCM_CODEC(CODEC_ID_ADPCM_IMA_WAV, adpcm_ima_wav);
1221 PCM_CODEC(CODEC_ID_ADPCM_MS, adpcm_ms);
1225 /* dummy raw video codec */
1226 extern AVCodec rawvideo_codec;
1228 /* the following codecs use external GPL libs */
1229 extern AVCodec ac3_decoder;
1233 struct ReSampleContext;
1235 typedef struct ReSampleContext ReSampleContext;
1237 ReSampleContext *audio_resample_init(int output_channels, int input_channels,
1238 int output_rate, int input_rate);
1239 int audio_resample(ReSampleContext *s, short *output, short *input, int nb_samples);
1240 void audio_resample_close(ReSampleContext *s);
1242 /* YUV420 format is assumed ! */
1244 struct ImgReSampleContext;
1246 typedef struct ImgReSampleContext ImgReSampleContext;
1248 ImgReSampleContext *img_resample_init(int output_width, int output_height,
1249 int input_width, int input_height);
1251 ImgReSampleContext *img_resample_full_init(int owidth, int oheight,
1252 int iwidth, int iheight,
1253 int topBand, int bottomBand,
1254 int leftBand, int rightBand);
1256 void img_resample(ImgReSampleContext *s,
1257 AVPicture *output, AVPicture *input);
1259 void img_resample_close(ImgReSampleContext *s);
1261 int avpicture_fill(AVPicture *picture, uint8_t *ptr,
1262 int pix_fmt, int width, int height);
1263 int avpicture_get_size(int pix_fmt, int width, int height);
1264 void avcodec_get_chroma_sub_sample(int pix_fmt, int *h_shift, int *v_shift);
1265 const char *avcodec_get_pix_fmt_name(int pix_fmt);
1267 #define FF_LOSS_RESOLUTION 0x0001 /* loss due to resolution change */
1268 #define FF_LOSS_DEPTH 0x0002 /* loss due to color depth change */
1269 #define FF_LOSS_COLORSPACE 0x0004 /* loss due to color space conversion */
1270 #define FF_LOSS_ALPHA 0x0008 /* loss of alpha bits */
1271 #define FF_LOSS_COLORQUANT 0x0010 /* loss due to color quantization */
1272 #define FF_LOSS_CHROMA 0x0020 /* loss of chroma (e.g. rgb to gray conversion) */
1274 int avcodec_get_pix_fmt_loss(int dst_pix_fmt, int src_pix_fmt,
1276 int avcodec_find_best_pix_fmt(int pix_fmt_mask, int src_pix_fmt,
1277 int has_alpha, int *loss_ptr);
1279 /* convert among pixel formats */
1280 int img_convert(AVPicture *dst, int dst_pix_fmt,
1281 AVPicture *src, int pix_fmt,
1282 int width, int height);
1284 /* deinterlace a picture */
1285 int avpicture_deinterlace(AVPicture *dst, AVPicture *src,
1286 int pix_fmt, int width, int height);
1288 /* external high level API */
1290 extern AVCodec *first_avcodec;
1292 /* returns LIBAVCODEC_VERSION_INT constant */
1293 unsigned avcodec_version(void);
1294 /* returns LIBAVCODEC_BUILD constant */
1295 unsigned avcodec_build(void);
1296 void avcodec_init(void);
1298 void register_avcodec(AVCodec *format);
1299 AVCodec *avcodec_find_encoder(enum CodecID id);
1300 AVCodec *avcodec_find_encoder_by_name(const char *name);
1301 AVCodec *avcodec_find_decoder(enum CodecID id);
1302 AVCodec *avcodec_find_decoder_by_name(const char *name);
1303 void avcodec_string(char *buf, int buf_size, AVCodecContext *enc, int encode);
1305 void avcodec_get_context_defaults(AVCodecContext *s);
1306 AVCodecContext *avcodec_alloc_context(void);
1307 AVFrame *avcodec_alloc_frame(void);
1309 int avcodec_default_get_buffer(AVCodecContext *s, AVFrame *pic);
1310 void avcodec_default_release_buffer(AVCodecContext *s, AVFrame *pic);
1312 int avcodec_open(AVCodecContext *avctx, AVCodec *codec);
1313 int avcodec_decode_audio(AVCodecContext *avctx, int16_t *samples,
1314 int *frame_size_ptr,
1315 uint8_t *buf, int buf_size);
1316 int avcodec_decode_video(AVCodecContext *avctx, AVFrame *picture,
1317 int *got_picture_ptr,
1318 uint8_t *buf, int buf_size);
1319 int avcodec_parse_frame(AVCodecContext *avctx, uint8_t **pdata,
1321 uint8_t *buf, int buf_size);
1322 int avcodec_encode_audio(AVCodecContext *avctx, uint8_t *buf, int buf_size,
1323 const short *samples);
1324 int avcodec_encode_video(AVCodecContext *avctx, uint8_t *buf, int buf_size,
1325 const AVFrame *pict);
1327 int avcodec_close(AVCodecContext *avctx);
1329 void avcodec_register_all(void);
1331 void avcodec_flush_buffers(AVCodecContext *avctx);
1333 /* misc usefull functions */
1335 * reduce a fraction.
1336 * this is usefull for framerate calculations
1337 * @param max the maximum allowed for dst_nom & dst_den
1338 * @return 1 if exact, 0 otherwise
1340 int av_reduce(int *dst_nom, int *dst_den, int64_t nom, int64_t den, int64_t max);
1343 * rescale a 64bit integer.
1344 * a simple a*b/c isnt possible as it can overflow
1346 int64_t av_rescale(int64_t a, int b, int c);
1350 * Interface for 0.5.0 version
1352 * do not even think about it's usage for this moment
1356 /// compressed size used from given memory buffer
1358 /// I/P/B frame type
1364 * order can't be changed - once it was defined
1368 AVC_OPEN_BY_NAME = 0xACA000,
1369 AVC_OPEN_BY_CODEC_ID,
1374 // pin - struct { uint8_t* src, uint_t src_size }
1375 // pout - struct { AVPicture* img, consumed_bytes,
1377 // pin - struct { AVPicture* img, uint8_t* dest, uint_t dest_size }
1378 // pout - uint_t used_from_dest_size
1381 // query/get video commands
1382 AVC_GET_VERSION = 0xACB000,
1386 AVC_GET_QUANT_TABLE,
1389 // query/get audio commands
1390 AVC_GET_FRAME_SIZE = 0xABC000,
1392 // maybe define some simple structure which
1393 // might be passed to the user - but they can't
1394 // contain any codec specific parts and these
1395 // calls are usualy necessary only few times
1397 // set video commands
1398 AVC_SET_WIDTH = 0xACD000,
1401 // set video encoding commands
1402 AVC_SET_FRAME_RATE = 0xACD800,
1406 // set audio commands
1407 AVC_SET_SAMPLE_RATE = 0xACE000,
1413 * \param handle allocated private structure by libavcodec
1414 * for initialization pass NULL - will be returned pout
1415 * user is supposed to know nothing about its structure
1416 * \param cmd type of operation to be performed
1417 * \param pint input parameter
1418 * \param pout output parameter
1420 * \returns command status - eventually for query command it might return
1421 * integer resulting value
1423 int avcodec(void* handle, avc_cmd_t cmd, void* pin, void* pout);
1426 void *av_malloc(unsigned int size);
1427 void *av_mallocz(unsigned int size);
1428 void *av_realloc(void *ptr, unsigned int size);
1429 void av_free(void *ptr);
1430 char *av_strdup(const char *s);
1431 void __av_freep(void **ptr);
1432 #define av_freep(p) __av_freep((void **)(p))
1433 void *av_fast_realloc(void *ptr, unsigned int *size, unsigned int min_size);
1434 /* for static data only */
1435 /* call av_free_static to release all staticaly allocated tables */
1436 void av_free_static(void);
1437 void *__av_mallocz_static(void** location, unsigned int size);
1438 #define av_mallocz_static(p, s) __av_mallocz_static((void **)(p), s)
1444 #endif /* AVCODEC_H */