16 #define LIBAVCODEC_VERSION_INT 0x000406
17 #define LIBAVCODEC_VERSION "0.4.6"
18 #define LIBAVCODEC_BUILD 4669
19 #define LIBAVCODEC_BUILD_STR "4669"
21 #define LIBAVCODEC_IDENT "FFmpeg" LIBAVCODEC_VERSION "b" LIBAVCODEC_BUILD_STR
63 /* various pcm "codecs" */
73 /* various adpcm codecs */
74 CODEC_ID_ADPCM_IMA_QT,
75 CODEC_ID_ADPCM_IMA_WAV,
87 CODEC_TYPE_UNKNOWN = -1,
96 PIX_FMT_YUV420P, ///< Planar YUV 4:2:0 (1 Cr & Cb sample per 2x2 Y samples)
98 PIX_FMT_RGB24, ///< Packed pixel, 3 bytes per pixel, RGBRGB...
99 PIX_FMT_BGR24, ///< Packed pixel, 3 bytes per pixel, BGRBGR...
100 PIX_FMT_YUV422P, ///< Planar YUV 4:2:2 (1 Cr & Cb sample per 2x1 Y samples)
101 PIX_FMT_YUV444P, ///< Planar YUV 4:4:4 (1 Cr & Cb sample per 1x1 Y samples)
102 PIX_FMT_RGBA32, ///< Packed pixel, 4 bytes per pixel, BGRABGRA...
103 PIX_FMT_YUV410P, ///< Planar YUV 4:1:0 (1 Cr & Cb sample per 4x4 Y samples)
104 PIX_FMT_YUV411P, ///< Planar YUV 4:1:1 (1 Cr & Cb sample per 4x1 Y samples)
105 PIX_FMT_RGB565, ///< always stored in cpu endianness
106 PIX_FMT_RGB555, ///< always stored in cpu endianness, most significant bit to 1
108 PIX_FMT_MONOWHITE, ///< 0 is white
109 PIX_FMT_MONOBLACK, ///< 0 is black
110 PIX_FMT_PAL8, ///< 8 bit with RGBA palette
111 PIX_FMT_YUVJ420P, ///< Planar YUV 4:2:0 full scale (jpeg)
112 PIX_FMT_YUVJ422P, ///< Planar YUV 4:2:2 full scale (jpeg)
113 PIX_FMT_YUVJ444P, ///< Planar YUV 4:4:4 full scale (jpeg)
117 /* currently unused, may be used if 24/32 bits samples ever supported */
119 SAMPLE_FMT_S16 = 0, ///< signed 16 bits
123 #define AVCODEC_MAX_AUDIO_FRAME_SIZE 131072
126 * Required number of additionally allocated bytes at the end of the input bitstream for decoding.
127 * this is mainly needed because some optimized bitstream readers read
128 * 32 or 64 bit at once and could read over the end<br>
129 * Note, if the first 23 bits of the additional bytes are not 0 then damaged
130 * MPEG bitstreams could cause overread and segfault
132 #define FF_INPUT_BUFFER_PADDING_SIZE 8
134 /* motion estimation type, EPZS by default */
144 typedef struct RcOverride{
147 int qscale; // if this is 0 then quality_factor will be used instead
148 float quality_factor;
151 /* only for ME compatiblity with old apps */
152 extern int motion_estimation_method;
154 /* ME algos sorted by quality */
155 static const int Motion_Est_QTab[] = { ME_ZERO, ME_PHODS, ME_LOG,
156 ME_X1, ME_EPZS, ME_FULL };
159 #define FF_MAX_B_FRAMES 8
162 these flags can be passed in AVCodecContext.flags before initing
163 Note: note not everything is supported yet
166 #define CODEC_FLAG_HQ 0x0001 ///< brute force MB-type decission mode (slow)
167 #define CODEC_FLAG_QSCALE 0x0002 ///< use fixed qscale
168 #define CODEC_FLAG_4MV 0x0004 ///< 4 MV per MB allowed
169 #define CODEC_FLAG_QPEL 0x0010 ///< use qpel MC
170 #define CODEC_FLAG_GMC 0x0020 ///< use GMC
171 #define CODEC_FLAG_PART 0x0080 ///< use data partitioning
172 /* parent program gurantees that the input for b-frame containing streams is not written to
173 for at least s->max_b_frames+1 frames, if this is not set than the input will be copied */
174 #define CODEC_FLAG_INPUT_PRESERVED 0x0100
175 #define CODEC_FLAG_PASS1 0x0200 ///< use internal 2pass ratecontrol in first pass mode
176 #define CODEC_FLAG_PASS2 0x0400 ///< use internal 2pass ratecontrol in second pass mode
177 #define CODEC_FLAG_EXTERN_HUFF 0x1000 ///< use external huffman table (for mjpeg)
178 #define CODEC_FLAG_GRAY 0x2000 ///< only decode/encode grayscale
179 #define CODEC_FLAG_EMU_EDGE 0x4000///< dont draw edges
180 #define CODEC_FLAG_PSNR 0x8000 ///< error[?] variables will be set during encoding
181 #define CODEC_FLAG_TRUNCATED 0x00010000 /** input bitstream might be truncated at a random location instead
182 of only at frame boundaries */
183 #define CODEC_FLAG_NORMALIZE_AQP 0x00020000 ///< normalize adaptive quantization
184 #define CODEC_FLAG_INTERLACED_DCT 0x00040000 ///< use interlaced dct
185 #define CODEC_FLAG_LOW_DELAY 0x00080000 ///< force low delay / will fail on b frames
186 #define CODEC_FLAG_ALT_SCAN 0x00100000 ///< use alternate scan
187 #define CODEC_FLAG_TRELLIS_QUANT 0x00200000 ///< use trellis quantization
188 #define CODEC_FLAG_GLOBAL_HEADER 0x00400000 ///< place global headers in extradata instead of every keyframe
189 #define CODEC_FLAG_BITEXACT 0x00800000 ///< use only bitexact stuff (except (i)dct)
190 /* Fx : Flag for h263+ extra options */
191 #define CODEC_FLAG_H263P_AIC 0x01000000 ///< Advanced intra coding
192 #define CODEC_FLAG_H263P_UMV 0x02000000 ///< Unlimited motion vector
193 /* For advanced prediction mode, we reuse the 4MV flag */
194 /* Unsupported options :
195 * Syntax Arithmetic coding (SAC)
196 * Deblocking filter internal loop
198 * Reference Picture Selection
199 * Independant Segment Decoding
200 * Alternative Inter * VLC
201 * Modified Quantization */
203 /* codec capabilities */
205 #define CODEC_CAP_DRAW_HORIZ_BAND 0x0001 ///< decoder can use draw_horiz_band callback
207 * Codec uses get_buffer() for allocating buffers.
208 * direct rendering method 1
210 #define CODEC_CAP_DR1 0x0002
211 /* if 'parse_only' field is true, then avcodec_parse_frame() can be
213 #define CODEC_CAP_PARSE_ONLY 0x0004
214 #define CODEC_CAP_TRUNCATED 0x0008
216 #define FF_COMMON_FRAME \
218 * pointer to the picture planes.\
219 * this might be different from the first allocated byte\
226 * pointer to the first allocated byte of the picture. can be used in get_buffer/release_buffer\
227 * this isnt used by lavc unless the default get/release_buffer() is used\
233 * 1 -> keyframe, 0-> not\
234 * - encoding: set by lavc\
235 * - decoding: set by lavc\
240 * picture type of the frame, see ?_TYPE below.\
241 * - encoding: set by lavc for coded_picture (and set by user for input)\
242 * - decoding: set by lavc\
247 * presentation timestamp in micro seconds (time when frame should be shown to user)\
248 * if 0 then the frame_rate will be used as reference\
249 * - encoding: MUST be set by user\
250 * - decoding: set by lavc\
255 * picture number in bitstream order.\
256 * - encoding: set by\
257 * - decoding: set by lavc\
259 int coded_picture_number;\
261 * picture number in display order.\
262 * - encoding: set by\
263 * - decoding: set by lavc\
265 int display_picture_number;\
268 * quality (between 1 (good) and 31 (bad)) \
269 * - encoding: set by lavc for coded_picture (and set by user for input)\
270 * - decoding: set by lavc\
275 * buffer age (1->was last buffer and dint change, 2->..., ...).\
276 * set to something large if the buffer has not been used yet \
277 * - encoding: unused\
278 * - decoding: MUST be set by get_buffer()\
283 * is this picture used as reference\
284 * - encoding: unused\
285 * - decoding: set by lavc (before get_buffer() call))\
291 * - encoding: unused\
292 * - decoding: set by lavc\
294 int8_t *qscale_table;\
297 * - encoding: unused\
298 * - decoding: set by lavc\
303 * mbskip_table[mb]>=1 if MB didnt change\
304 * stride= mb_width = (width+15)>>4\
305 * - encoding: unused\
306 * - decoding: set by lavc\
308 uint8_t *mbskip_table;\
311 * for some private data of the user\
312 * - encoding: unused\
313 * - decoding: set by user\
319 * - encoding: set by lavc if flags&CODEC_FLAG_PSNR\
320 * - decoding: unused\
325 * type of the buffer (to keep track of who has to dealloc data[*])\
326 * - encoding: set by the one who allocs it\
327 * - decoding: set by the one who allocs it\
328 * Note: user allocated (direct rendering) & internal buffers can not coexist currently\
333 * when decoding, this signal how much the picture must be delayed.\
334 * extra_delay = repeat_pict / (2*fps)\
335 * - encoding: unused\
336 * - decoding: set by lavc\
345 #define FF_QSCALE_TYPE_MPEG1 0
346 #define FF_QSCALE_TYPE_MPEG2 1
348 #define FF_BUFFER_TYPE_INTERNAL 1
349 #define FF_BUFFER_TYPE_USER 2 ///< Direct rendering buffers
350 #define FF_BUFFER_TYPE_SHARED 4 ///< buffer from somewher else, dont dealloc
353 #define FF_I_TYPE 1 // Intra
354 #define FF_P_TYPE 2 // Predicted
355 #define FF_B_TYPE 3 // Bi-dir predicted
356 #define FF_S_TYPE 4 // S(GMC)-VOP MPEG4
363 typedef struct AVFrame {
367 #define DEFAULT_FRAME_RATE_BASE 1001000
370 * main external api structure.
372 typedef struct AVCodecContext {
374 * the average bitrate.
375 * - encoding: set by user. unused for constant quantizer encoding
376 * - decoding: set by lavc. 0 or some bitrate if this info is available in the stream
381 * number of bits the bitstream is allowed to diverge from the reference.
382 * the reference can be CBR (for CBR pass1) or VBR (for pass2)
383 * - encoding: set by user. unused for constant quantizer encoding
386 int bit_rate_tolerance;
390 * - encoding: set by user.
391 * - decoding: set by user.
396 * some codecs needs additionnal format info. It is stored here
397 * - encoding: set by user.
398 * - decoding: set by lavc. (FIXME is this ok?)
403 * motion estimation algorithm used for video coding.
404 * - encoding: MUST be set by user.
410 * some codecs need / can use extra-data like huffman tables.
411 * mjpeg: huffman tables
412 * rv10: additional flags
413 * mpeg4: global headers (they can be in the bitstream or here)
414 * - encoding: set/allocated/freed by lavc.
415 * - decoding: set/allocated/freed by user.
422 * frames per sec multiplied by frame_rate_base.
423 * for variable fps this is the precission, so if the timestamps
424 * can be specified in msec precssion then this is 1000*frame_rate_base
425 * - encoding: MUST be set by user
426 * - decoding: set by lavc. 0 or the frame_rate if available
432 * - encoding: MUST be set by user.
433 * - decoding: set by user, some codecs might override / change it during playback
437 #define FF_ASPECT_SQUARE 1
438 #define FF_ASPECT_4_3_625 2
439 #define FF_ASPECT_4_3_525 3
440 #define FF_ASPECT_16_9_625 4
441 #define FF_ASPECT_16_9_525 5
442 #define FF_ASPECT_EXTENDED 15
445 * the number of pictures in a group of pitures, or 0 for intra_only.
446 * - encoding: set by user.
452 * pixel format, see PIX_FMT_xxx.
454 * - decoding: set by lavc.
456 enum PixelFormat pix_fmt;
459 * Frame rate emulation. If not zero lower layer (i.e. format handler)
460 * has to read frames at native frame rate.
461 * - encoding: set by user.
462 * - decoding: unused.
467 * if non NULL, 'draw_horiz_band' is called by the libavcodec
468 * decoder to draw an horizontal band. It improve cache usage. Not
469 * all codecs can do that. You must check the codec capabilities
472 * - decoding: set by user.
474 void (*draw_horiz_band)(struct AVCodecContext *s,
475 uint8_t **src_ptr, int linesize,
476 int y, int width, int height);
479 int sample_rate; ///< samples per sec
481 int sample_fmt; ///< sample format, currenly unused
483 /* the following data should not be initialized */
484 int frame_size; ///< in samples, initialized when calling 'init'
485 int frame_number; ///< audio or video frame number
486 int real_pict_num; ///< returns the real picture number of previous encoded frame
489 * number of frames the decoded output will be delayed relative to
491 * - encoding: set by lavc.
496 /* - encoding parameters */
497 float qcompress; ///< amount of qscale change between easy & hard scenes (0.0-1.0)
498 float qblur; ///< amount of qscale smoothing over time (0.0-1.0)
502 * - encoding: set by user.
509 * - encoding: set by user.
515 * maximum quantizer difference etween frames.
516 * - encoding: set by user.
522 * maximum number of b frames between non b frames.
523 * note: the output will be delayed by max_b_frames+1 relative to the input
524 * - encoding: set by user.
530 * qscale factor between ip and b frames.
531 * - encoding: set by user.
534 float b_quant_factor;
536 /** obsolete FIXME remove */
538 int b_frame_strategy;
543 * - decoding: set by user. 1-> skip b frames, 2-> skip idct/dequant too, 5-> skip everything except header
547 struct AVCodec *codec;
551 /* The following data is for RTP friendly coding */
552 /* By now only H.263/H.263+/MPEG4 coder honours this */
553 int rtp_mode; /* 1 for activate RTP friendly-mode */
554 /* highers numbers represent more error-prone */
555 /* enviroments, by now just "1" exist */
557 int rtp_payload_size; /* The size of the RTP payload, the coder will */
558 /* do it's best to deliver a chunk with size */
559 /* below rtp_payload_size, the chunk will start */
560 /* with a start code on some codecs like H.263 */
561 /* This doesn't take account of any particular */
562 /* headers inside the transmited RTP payload */
565 /* The RTP callcack: This function is called */
566 /* every time the encoder as a packet to send */
567 /* Depends on the encoder if the data starts */
568 /* with a Start Code (it should) H.263 does */
569 void (*rtp_callback)(void *data, int size, int packet_number);
571 /* statistics, used for 2-pass encoding */
582 * number of bits used for the previously encoded frame.
583 * - encoding: set by lavc
589 * private data of the user, can be used to carry app specific stuff.
590 * - encoding: set by user
591 * - decoding: set by user
596 enum CodecType codec_type; /* see CODEC_TYPE_xxx */
597 enum CodecID codec_id; /* see CODEC_ID_xxx */
600 * fourcc (LSB first, so "ABCD" -> ('D'<<24) + ('C'<<16) + ('B'<<8) + 'A').
601 * this is used to workaround some encoder bugs
603 * - decoding: set by user, will be converted to upper case by lavc during init
605 unsigned int codec_tag;
608 * workaround bugs in encoders which sometimes cannot be detected automatically.
610 * - decoding: set by user
613 #define FF_BUG_AUTODETECT 1 ///< autodetection
614 #define FF_BUG_OLD_MSMPEG4 2
615 #define FF_BUG_XVID_ILACE 4
616 #define FF_BUG_UMP4 8
617 #define FF_BUG_NO_PADDING 16
618 #define FF_BUG_AC_VLC 32
619 #define FF_BUG_QPEL_CHROMA 64
620 #define FF_BUG_STD_QPEL 128
621 #define FF_BUG_QPEL_CHROMA2 256
622 #define FF_BUG_DIRECT_BLOCKSIZE 512
623 #define FF_BUG_EDGE 1024
624 //#define FF_BUG_FAKE_SCALABILITY 16 //autodetection should work 100%
627 * luma single coeff elimination threshold.
628 * - encoding: set by user
631 int luma_elim_threshold;
634 * chroma single coeff elimination threshold.
635 * - encoding: set by user
638 int chroma_elim_threshold;
641 * strictly follow the std (MPEG4, ...).
642 * - encoding: set by user
645 int strict_std_compliance;
648 * qscale offset between ip and b frames.
649 * if > 0 then the last p frame quantizer will be used (q= lastp_q*factor+offset)
650 * if < 0 then normal ratecontrol will be done (q= -normal_q*factor+offset)
651 * - encoding: set by user.
654 float b_quant_offset;
657 * error resilience higher values will detect more errors but may missdetect
658 * some more or less valid parts as errors.
660 * - decoding: set by user
662 int error_resilience;
663 #define FF_ER_CAREFULL 1
664 #define FF_ER_COMPLIANT 2
665 #define FF_ER_AGGRESSIVE 3
666 #define FF_ER_VERY_AGGRESSIVE 4
669 * called at the beginning of each frame to get a buffer for it.
670 * if pic.reference is set then the frame will be read later by lavc
672 * - decoding: set by lavc, user can override
674 int (*get_buffer)(struct AVCodecContext *c, AVFrame *pic);
677 * called to release buffers which where allocated with get_buffer.
678 * a released buffer can be reused in get_buffer()
679 * pic.data[*] must be set to NULL
681 * - decoding: set by lavc, user can override
683 void (*release_buffer)(struct AVCodecContext *c, AVFrame *pic);
686 * is 1 if the decoded stream contains b frames, 0 otherwise.
688 * - decoding: set by lavc
692 int block_align; ///< used by some WAV based audio codecs
694 int parse_only; /* - decoding only: if true, only parsing is done
695 (function avcodec_parse_frame()). The frame
696 data is returned. Only MPEG codecs support this now. */
699 * 0-> h263 quant 1-> mpeg quant.
700 * - encoding: set by user.
706 * pass1 encoding statistics output buffer.
707 * - encoding: set by lavc
713 * pass2 encoding statistics input buffer.
714 * concatenated stuff from stats_out of pass1 should be placed here
715 * - encoding: allocated/set/freed by user
721 * ratecontrol qmin qmax limiting method.
722 * 0-> clipping, 1-> use a nice continous function to limit qscale wthin qmin/qmax
723 * - encoding: set by user.
732 * ratecontrol override, see RcOverride.
733 * - encoding: allocated/set/freed by user.
736 RcOverride *rc_override;
737 int rc_override_count;
740 * rate control equation.
741 * - encoding: set by user
748 * - encoding: set by user.
755 * - encoding: set by user.
761 * decoder bitstream buffer size.
762 * - encoding: set by user.
766 float rc_buffer_aggressivity;
769 * qscale factor between p and i frames.
770 * - encoding: set by user.
773 float i_quant_factor;
776 * qscale offset between p and i frames.
777 * if > 0 then the last p frame quantizer will be used (q= lastp_q*factor+offset)
778 * if < 0 then normal ratecontrol will be done (q= -normal_q*factor+offset)
779 * - encoding: set by user.
782 float i_quant_offset;
785 * initial complexity for pass1 ratecontrol.
786 * - encoding: set by user.
789 float rc_initial_cplx;
792 * dct algorithm, see FF_DCT_* below.
793 * - encoding: set by user
797 #define FF_DCT_AUTO 0
798 #define FF_DCT_FASTINT 1
801 #define FF_DCT_MLIB 4
802 #define FF_DCT_ALTIVEC 5
805 * luminance masking (0-> disabled).
806 * - encoding: set by user
812 * temporary complexity masking (0-> disabled).
813 * - encoding: set by user
816 float temporal_cplx_masking;
819 * spatial complexity masking (0-> disabled).
820 * - encoding: set by user
823 float spatial_cplx_masking;
826 * p block masking (0-> disabled).
827 * - encoding: set by user
833 * darkness masking (0-> disabled).
834 * - encoding: set by user
840 /* for binary compatibility */
844 * idct algorithm, see FF_IDCT_* below.
845 * - encoding: set by user
846 * - decoding: set by user
849 #define FF_IDCT_AUTO 0
850 #define FF_IDCT_INT 1
851 #define FF_IDCT_SIMPLE 2
852 #define FF_IDCT_SIMPLEMMX 3
853 #define FF_IDCT_LIBMPEG2MMX 4
854 #define FF_IDCT_PS2 5
855 #define FF_IDCT_MLIB 6
856 #define FF_IDCT_ARM 7
857 #define FF_IDCT_ALTIVEC 8
858 #define FF_IDCT_SH4 9
859 #define FF_IDCT_SIMPLEARM 10
863 * - encoding: set by lavc
864 * - decoding: set by user (or 0)
868 * slice offsets in the frame in bytes.
869 * - encoding: set/allocated by lavc
870 * - decoding: set/allocated by user (or NULL)
875 * error concealment flags.
877 * - decoding: set by user
879 int error_concealment;
880 #define FF_EC_GUESS_MVS 1
881 #define FF_EC_DEBLOCK 2
884 * dsp_mask could be add used to disable unwanted CPU features
885 * CPU features (i.e. MMX, SSE. ...)
887 * with FORCE flag you may instead enable given CPU features
888 * (Dangerous: usable in case of misdetection, improper usage however will
889 * result into program crash)
892 #define FF_MM_FORCE 0x80000000 /* force usage of selected flags (OR) */
893 /* lower 16 bits - CPU features */
895 #define FF_MM_MMX 0x0001 /* standard MMX */
896 #define FF_MM_3DNOW 0x0004 /* AMD 3DNOW */
897 #define FF_MM_MMXEXT 0x0002 /* SSE integer functions or AMD MMX ext */
898 #define FF_MM_SSE 0x0008 /* SSE functions */
899 #define FF_MM_SSE2 0x0010 /* PIV SSE2 functions */
900 #endif /* HAVE_MMX */
903 * bits per sample/pixel from the demuxer (needed for huffyuv).
904 * - encoding: set by lavc
905 * - decoding: set by user
910 * prediction method (needed for huffyuv).
911 * - encoding: set by user
914 int prediction_method;
915 #define FF_PRED_LEFT 0
916 #define FF_PRED_PLANE 1
917 #define FF_PRED_MEDIAN 2
920 * aspect ratio (0 if unknown).
921 * - encoding: set by user.
922 * - decoding: set by lavc.
927 * the picture in the bitstream.
928 * - encoding: set by lavc
929 * - decoding: set by lavc
931 AVFrame *coded_frame;
935 * - encoding: set by user.
936 * - decoding: set by user.
939 #define FF_DEBUG_PICT_INFO 1
940 #define FF_DEBUG_RC 2
941 #define FF_DEBUG_BITSTREAM 4
942 #define FF_DEBUG_MB_TYPE 8
943 #define FF_DEBUG_QP 16
944 #define FF_DEBUG_MV 32
945 #define FF_DEBUG_VIS_MV 0x00000040
946 #define FF_DEBUG_SKIP 0x00000080
947 #define FF_DEBUG_STARTCODE 0x00000100
948 #define FF_DEBUG_PTS 0x00000200
949 #define FF_DEBUG_ER 0x00000400
950 #define FF_DEBUG_MMCO 0x00000800
954 * - encoding: set by lavc if flags&CODEC_FLAG_PSNR
960 * minimum MB quantizer.
961 * - encoding: set by user.
967 * maximum MB quantizer.
968 * - encoding: set by user.
974 * motion estimation compare function.
975 * - encoding: set by user.
980 * subpixel motion estimation compare function.
981 * - encoding: set by user.
986 * macroblock compare function (not supported yet).
987 * - encoding: set by user.
993 #define FF_CMP_SATD 2
995 #define FF_CMP_PSNR 4
998 #define FF_CMP_ZERO 7
999 #define FF_CMP_CHROMA 256
1002 * ME diamond size & shape.
1003 * - encoding: set by user.
1004 * - decoding: unused
1009 * amount of previous MV predictors (2a+1 x 2a+1 square).
1010 * - encoding: set by user.
1011 * - decoding: unused
1013 int last_predictor_count;
1016 * pre pass for motion estimation.
1017 * - encoding: set by user.
1018 * - decoding: unused
1023 * motion estimation pre pass compare function.
1024 * - encoding: set by user.
1025 * - decoding: unused
1030 * ME pre pass diamond size & shape.
1031 * - encoding: set by user.
1032 * - decoding: unused
1037 * subpel ME quality.
1038 * - encoding: set by user.
1039 * - decoding: unused
1041 int me_subpel_quality;
1044 * callback to negotiate the pixelFormat.
1045 * @param fmt is the list of formats which are supported by the codec,
1046 * its terminated by -1 as 0 is a valid format, the formats are ordered by quality
1047 * the first is allways the native one
1048 * @return the choosen format
1049 * - encoding: unused
1050 * - decoding: set by user, if not set then the native format will always be choosen
1052 enum PixelFormat (*get_format)(struct AVCodecContext *s, enum PixelFormat * fmt);
1055 * DTG active format information (additionnal aspect ratio
1056 * information only used in DVB MPEG2 transport streams). 0 if
1059 * - encoding: unused.
1060 * - decoding: set by decoder
1062 int dtg_active_format;
1063 #define FF_DTG_AFD_SAME 8
1064 #define FF_DTG_AFD_4_3 9
1065 #define FF_DTG_AFD_16_9 10
1066 #define FF_DTG_AFD_14_9 11
1067 #define FF_DTG_AFD_4_3_SP_14_9 13
1068 #define FF_DTG_AFD_16_9_SP_14_9 14
1069 #define FF_DTG_AFD_SP_4_3 15
1072 * Maximum motion estimation search range in subpel units.
1073 * if 0 then no limit
1075 * - encoding: set by user.
1076 * - decoding: unused.
1082 * for variable fps this is 1
1083 * - encoding: set by user.
1084 * - decoding: set by lavc.
1085 * @todo move this after frame_rate
1088 int frame_rate_base;
1090 * intra quantizer bias.
1091 * - encoding: set by user.
1092 * - decoding: unused
1094 int intra_quant_bias;
1095 #define FF_DEFAULT_QUANT_BIAS 999999
1098 * inter quantizer bias.
1099 * - encoding: set by user.
1100 * - decoding: unused
1102 int inter_quant_bias;
1106 * - encoding: unused.
1107 * - decoding: which clrtable should be used for 8bit RGB images
1108 * table have to be stored somewhere FIXME
1113 * internal_buffer count.
1114 * Dont touch, used by lavc default_get_buffer()
1116 int internal_buffer_count;
1120 * Dont touch, used by lavc default_get_buffer()
1122 void *internal_buffer;
1124 #define FF_QUALITY_SCALE 256
1126 * global quality for codecs which cannot change it per frame.
1127 * this should be proportional to MPEG1/2/4 qscale.
1128 * - encoding: set by user.
1129 * - decoding: unused
1133 #define FF_CODER_TYPE_VLC 0
1134 #define FF_CODER_TYPE_AC 1
1137 * - encoding: set by user.
1138 * - decoding: unused
1144 * - encoding: set by user.
1145 * - decoding: unused
1154 typedef struct AVOption {
1155 /** options' name */
1156 const char *name; /* if name is NULL, it indicates a link to next */
1157 /** short English text help or const struct AVOption* subpointer */
1158 const char *help; // const struct AVOption* sub;
1159 /** offset to context structure where the parsed value should be stored */
1161 /** options' type */
1163 #define FF_OPT_TYPE_BOOL 1 ///< boolean - true,1,on (or simply presence)
1164 #define FF_OPT_TYPE_DOUBLE 2 ///< double
1165 #define FF_OPT_TYPE_INT 3 ///< integer
1166 #define FF_OPT_TYPE_STRING 4 ///< string (finished with \0)
1167 #define FF_OPT_TYPE_MASK 0x1f ///< mask for types - upper bits are various flags
1168 //#define FF_OPT_TYPE_EXPERT 0x20 // flag for expert option
1169 #define FF_OPT_TYPE_FLAG (FF_OPT_TYPE_BOOL | 0x40)
1170 #define FF_OPT_TYPE_RCOVERRIDE (FF_OPT_TYPE_STRING | 0x80)
1171 /** min value (min == max -> no limits) */
1173 /** maximum value for double/int */
1175 /** default boo [0,1]l/double/int value */
1178 * default string value (with optional semicolon delimited extra option-list
1179 * i.e. option1;option2;option3
1180 * defval might select other then first argument as default
1183 #define FF_OPT_MAX_DEPTH 10
1187 * Parse option(s) and sets fields in passed structure
1188 * @param strct structure where the parsed results will be written
1189 * @param list list with AVOptions
1190 * @param opts string with options for parsing
1192 int avoption_parse(void* strct, const AVOption* list, const char* opts);
1198 typedef struct AVCodec {
1200 enum CodecType type;
1203 int (*init)(AVCodecContext *);
1204 int (*encode)(AVCodecContext *, uint8_t *buf, int buf_size, void *data);
1205 int (*close)(AVCodecContext *);
1206 int (*decode)(AVCodecContext *, void *outdata, int *outdata_size,
1207 uint8_t *buf, int buf_size);
1209 const AVOption *options;
1210 struct AVCodec *next;
1214 * four components are given, that's all.
1215 * the last component is alpha
1217 typedef struct AVPicture {
1219 int linesize[4]; ///< number of bytes per line
1222 extern AVCodec ac3_encoder;
1223 extern AVCodec mp2_encoder;
1224 extern AVCodec mp3lame_encoder;
1225 extern AVCodec oggvorbis_encoder;
1226 extern AVCodec mpeg1video_encoder;
1227 extern AVCodec h263_encoder;
1228 extern AVCodec h263p_encoder;
1229 extern AVCodec rv10_encoder;
1230 extern AVCodec mjpeg_encoder;
1231 extern AVCodec ljpeg_encoder;
1232 extern AVCodec mpeg4_encoder;
1233 extern AVCodec msmpeg4v1_encoder;
1234 extern AVCodec msmpeg4v2_encoder;
1235 extern AVCodec msmpeg4v3_encoder;
1236 extern AVCodec wmv1_encoder;
1237 extern AVCodec wmv2_encoder;
1238 extern AVCodec huffyuv_encoder;
1239 extern AVCodec h264_encoder;
1240 extern AVCodec asv1_encoder;
1241 extern AVCodec ffv1_encoder;
1243 extern AVCodec h263_decoder;
1244 extern AVCodec mpeg4_decoder;
1245 extern AVCodec msmpeg4v1_decoder;
1246 extern AVCodec msmpeg4v2_decoder;
1247 extern AVCodec msmpeg4v3_decoder;
1248 extern AVCodec wmv1_decoder;
1249 extern AVCodec wmv2_decoder;
1250 extern AVCodec mpeg_decoder;
1251 extern AVCodec h263i_decoder;
1252 extern AVCodec rv10_decoder;
1253 extern AVCodec svq1_decoder;
1254 extern AVCodec svq3_decoder;
1255 extern AVCodec dvvideo_decoder;
1256 extern AVCodec dvaudio_decoder;
1257 extern AVCodec wmav1_decoder;
1258 extern AVCodec wmav2_decoder;
1259 extern AVCodec mjpeg_decoder;
1260 extern AVCodec mjpegb_decoder;
1261 extern AVCodec mp2_decoder;
1262 extern AVCodec mp3_decoder;
1263 extern AVCodec mace3_decoder;
1264 extern AVCodec mace6_decoder;
1265 extern AVCodec huffyuv_decoder;
1266 extern AVCodec oggvorbis_decoder;
1267 extern AVCodec cyuv_decoder;
1268 extern AVCodec h264_decoder;
1269 extern AVCodec indeo3_decoder;
1270 extern AVCodec vp3_decoder;
1271 extern AVCodec amr_nb_decoder;
1272 extern AVCodec amr_nb_encoder;
1273 extern AVCodec aac_decoder;
1274 extern AVCodec mpeg4aac_decoder;
1275 extern AVCodec asv1_decoder;
1276 extern AVCodec ffv1_decoder;
1277 extern AVCodec fourxm_decoder;
1278 extern AVCodec ra_144_decoder;
1279 extern AVCodec ra_288_decoder;
1282 #define PCM_CODEC(id, name) \
1283 extern AVCodec name ## _decoder; \
1284 extern AVCodec name ## _encoder
1286 PCM_CODEC(CODEC_ID_PCM_S16LE, pcm_s16le);
1287 PCM_CODEC(CODEC_ID_PCM_S16BE, pcm_s16be);
1288 PCM_CODEC(CODEC_ID_PCM_U16LE, pcm_u16le);
1289 PCM_CODEC(CODEC_ID_PCM_U16BE, pcm_u16be);
1290 PCM_CODEC(CODEC_ID_PCM_S8, pcm_s8);
1291 PCM_CODEC(CODEC_ID_PCM_U8, pcm_u8);
1292 PCM_CODEC(CODEC_ID_PCM_ALAW, pcm_alaw);
1293 PCM_CODEC(CODEC_ID_PCM_MULAW, pcm_mulaw);
1297 PCM_CODEC(CODEC_ID_ADPCM_IMA_QT, adpcm_ima_qt);
1298 PCM_CODEC(CODEC_ID_ADPCM_IMA_WAV, adpcm_ima_wav);
1299 PCM_CODEC(CODEC_ID_ADPCM_MS, adpcm_ms);
1300 PCM_CODEC(CODEC_ID_ADPCM_4XM, adpcm_4xm);
1304 /* dummy raw video codec */
1305 extern AVCodec rawvideo_encoder;
1306 extern AVCodec rawvideo_decoder;
1308 /* the following codecs use external GPL libs */
1309 extern AVCodec ac3_decoder;
1313 struct ReSampleContext;
1315 typedef struct ReSampleContext ReSampleContext;
1317 ReSampleContext *audio_resample_init(int output_channels, int input_channels,
1318 int output_rate, int input_rate);
1319 int audio_resample(ReSampleContext *s, short *output, short *input, int nb_samples);
1320 void audio_resample_close(ReSampleContext *s);
1322 /* YUV420 format is assumed ! */
1324 struct ImgReSampleContext;
1326 typedef struct ImgReSampleContext ImgReSampleContext;
1328 ImgReSampleContext *img_resample_init(int output_width, int output_height,
1329 int input_width, int input_height);
1331 ImgReSampleContext *img_resample_full_init(int owidth, int oheight,
1332 int iwidth, int iheight,
1333 int topBand, int bottomBand,
1334 int leftBand, int rightBand);
1336 void img_resample(ImgReSampleContext *s,
1337 AVPicture *output, AVPicture *input);
1339 void img_resample_close(ImgReSampleContext *s);
1341 int avpicture_fill(AVPicture *picture, uint8_t *ptr,
1342 int pix_fmt, int width, int height);
1343 int avpicture_layout(AVPicture* src, int pix_fmt, int width, int height,
1344 unsigned char *dest, int dest_size);
1345 int avpicture_get_size(int pix_fmt, int width, int height);
1346 void avcodec_get_chroma_sub_sample(int pix_fmt, int *h_shift, int *v_shift);
1347 const char *avcodec_get_pix_fmt_name(int pix_fmt);
1348 enum PixelFormat avcodec_get_pix_fmt(const char* name);
1350 #define FF_LOSS_RESOLUTION 0x0001 /* loss due to resolution change */
1351 #define FF_LOSS_DEPTH 0x0002 /* loss due to color depth change */
1352 #define FF_LOSS_COLORSPACE 0x0004 /* loss due to color space conversion */
1353 #define FF_LOSS_ALPHA 0x0008 /* loss of alpha bits */
1354 #define FF_LOSS_COLORQUANT 0x0010 /* loss due to color quantization */
1355 #define FF_LOSS_CHROMA 0x0020 /* loss of chroma (e.g. rgb to gray conversion) */
1357 int avcodec_get_pix_fmt_loss(int dst_pix_fmt, int src_pix_fmt,
1359 int avcodec_find_best_pix_fmt(int pix_fmt_mask, int src_pix_fmt,
1360 int has_alpha, int *loss_ptr);
1362 #define FF_ALPHA_TRANSP 0x0001 /* image has some totally transparent pixels */
1363 #define FF_ALPHA_SEMI_TRANSP 0x0002 /* image has some transparent pixels */
1364 int img_get_alpha_info(AVPicture *src, int pix_fmt, int width, int height);
1366 /* convert among pixel formats */
1367 int img_convert(AVPicture *dst, int dst_pix_fmt,
1368 AVPicture *src, int pix_fmt,
1369 int width, int height);
1371 /* deinterlace a picture */
1372 int avpicture_deinterlace(AVPicture *dst, AVPicture *src,
1373 int pix_fmt, int width, int height);
1375 /* external high level API */
1377 extern AVCodec *first_avcodec;
1379 /* returns LIBAVCODEC_VERSION_INT constant */
1380 unsigned avcodec_version(void);
1381 /* returns LIBAVCODEC_BUILD constant */
1382 unsigned avcodec_build(void);
1383 void avcodec_init(void);
1385 void register_avcodec(AVCodec *format);
1386 AVCodec *avcodec_find_encoder(enum CodecID id);
1387 AVCodec *avcodec_find_encoder_by_name(const char *name);
1388 AVCodec *avcodec_find_decoder(enum CodecID id);
1389 AVCodec *avcodec_find_decoder_by_name(const char *name);
1390 void avcodec_string(char *buf, int buf_size, AVCodecContext *enc, int encode);
1392 void avcodec_get_context_defaults(AVCodecContext *s);
1393 AVCodecContext *avcodec_alloc_context(void);
1394 AVFrame *avcodec_alloc_frame(void);
1396 int avcodec_default_get_buffer(AVCodecContext *s, AVFrame *pic);
1397 void avcodec_default_release_buffer(AVCodecContext *s, AVFrame *pic);
1398 void avcodec_default_free_buffers(AVCodecContext *s);
1400 int avcodec_open(AVCodecContext *avctx, AVCodec *codec);
1401 int avcodec_decode_audio(AVCodecContext *avctx, int16_t *samples,
1402 int *frame_size_ptr,
1403 uint8_t *buf, int buf_size);
1404 int avcodec_decode_video(AVCodecContext *avctx, AVFrame *picture,
1405 int *got_picture_ptr,
1406 uint8_t *buf, int buf_size);
1407 int avcodec_parse_frame(AVCodecContext *avctx, uint8_t **pdata,
1409 uint8_t *buf, int buf_size);
1410 int avcodec_encode_audio(AVCodecContext *avctx, uint8_t *buf, int buf_size,
1411 const short *samples);
1412 int avcodec_encode_video(AVCodecContext *avctx, uint8_t *buf, int buf_size,
1413 const AVFrame *pict);
1415 int avcodec_close(AVCodecContext *avctx);
1417 void avcodec_register_all(void);
1419 void avcodec_flush_buffers(AVCodecContext *avctx);
1421 /* misc usefull functions */
1424 * returns a single letter to describe the picture type
1426 char av_get_pict_type_char(int pict_type);
1429 * reduce a fraction.
1430 * this is usefull for framerate calculations
1431 * @param max the maximum allowed for dst_nom & dst_den
1432 * @return 1 if exact, 0 otherwise
1434 int av_reduce(int *dst_nom, int *dst_den, int64_t nom, int64_t den, int64_t max);
1437 * rescale a 64bit integer.
1438 * a simple a*b/c isnt possible as it can overflow
1440 int64_t av_rescale(int64_t a, int b, int c);
1444 * Interface for 0.5.0 version
1446 * do not even think about it's usage for this moment
1450 /// compressed size used from given memory buffer
1452 /// I/P/B frame type
1458 * order can't be changed - once it was defined
1462 AVC_OPEN_BY_NAME = 0xACA000,
1463 AVC_OPEN_BY_CODEC_ID,
1468 // pin - struct { uint8_t* src, uint_t src_size }
1469 // pout - struct { AVPicture* img, consumed_bytes,
1471 // pin - struct { AVPicture* img, uint8_t* dest, uint_t dest_size }
1472 // pout - uint_t used_from_dest_size
1475 // query/get video commands
1476 AVC_GET_VERSION = 0xACB000,
1480 AVC_GET_QUANT_TABLE,
1483 // query/get audio commands
1484 AVC_GET_FRAME_SIZE = 0xABC000,
1486 // maybe define some simple structure which
1487 // might be passed to the user - but they can't
1488 // contain any codec specific parts and these
1489 // calls are usualy necessary only few times
1491 // set video commands
1492 AVC_SET_WIDTH = 0xACD000,
1495 // set video encoding commands
1496 AVC_SET_FRAME_RATE = 0xACD800,
1500 // set audio commands
1501 AVC_SET_SAMPLE_RATE = 0xACE000,
1507 * \param handle allocated private structure by libavcodec
1508 * for initialization pass NULL - will be returned pout
1509 * user is supposed to know nothing about its structure
1510 * \param cmd type of operation to be performed
1511 * \param pint input parameter
1512 * \param pout output parameter
1514 * \returns command status - eventually for query command it might return
1515 * integer resulting value
1517 int avcodec(void* handle, avc_cmd_t cmd, void* pin, void* pout);
1520 void *av_malloc(unsigned int size);
1521 void *av_mallocz(unsigned int size);
1522 void *av_realloc(void *ptr, unsigned int size);
1523 void av_free(void *ptr);
1524 char *av_strdup(const char *s);
1525 void __av_freep(void **ptr);
1526 #define av_freep(p) __av_freep((void **)(p))
1527 void *av_fast_realloc(void *ptr, unsigned int *size, unsigned int min_size);
1528 /* for static data only */
1529 /* call av_free_static to release all staticaly allocated tables */
1530 void av_free_static(void);
1531 void *__av_mallocz_static(void** location, unsigned int size);
1532 #define av_mallocz_static(p, s) __av_mallocz_static((void **)(p), s)
1538 #endif /* AVCODEC_H */