24 /* various pcm "codecs" */
34 #define CODEC_ID_MSMPEG4 CODEC_ID_MSMPEG4V3
51 /* currently unused, may be used if 24/32 bits samples ever supported */
53 SAMPLE_FMT_S16
= 0, /* signed 16 bits */
57 #define AVCODEC_MAX_AUDIO_FRAME_SIZE 18432
59 /* motion estimation type, EPZS by default */
69 /* only for ME compatiblity with old apps */
70 extern int motion_estimation_method
;
72 /* ME algos sorted by quality */
73 static const int Motion_Est_QTab
[] = { -4, -1, -2, 1, 0, -3 };
75 /* encoding support */
76 /* note not everything is supported yet */
78 #define CODEC_FLAG_HQ 0x0001 /* high quality (non real time) encoding */
79 #define CODEC_FLAG_QSCALE 0x0002 /* use fixed qscale */
80 #define CODEC_FLAG_4MV 0x0004 /* 4 MV per MB allowed */
81 #define CODEC_FLAG_B 0x0008 /* use B frames */
82 #define CODEC_FLAG_QPEL 0x0010 /* use qpel MC */
83 #define CODEC_FLAG_GMC 0x0020 /* use GMC */
84 #define CODEC_FLAG_TYPE 0x0040 /* fixed I/P frame type, from avctx->key_frame */
86 /* codec capabilities */
88 /* decoder can use draw_horiz_band callback */
89 #define CODEC_CAP_DRAW_HORIZ_BAND 0x0001
91 #define FRAME_RATE_BASE 10000
93 typedef struct AVCodecContext
{
95 int bit_rate_tolerance
; /* amount of +- bits (>0)*/
97 int sub_id
; /* some codecs needs additionnal format info. It is
100 int me_method
; /* ME algorithm used for video coding */
103 int frame_rate
; /* frames per sec multiplied by FRAME_RATE_BASE */
105 int aspect_ratio_info
;
106 #define FF_ASPECT_SQUARE 1
107 #define FF_ASPECT_4_3_625 2
108 #define FF_ASPECT_4_3_525 3
109 #define FF_ASPECT_16_9_625 4
110 #define FF_ASPECT_16_9_525 5
111 int gop_size
; /* 0 = intra only */
112 enum PixelFormat pix_fmt
; /* pixel format, see PIX_FMT_xxx */
114 /* if non NULL, 'draw_horiz_band' is called by the libavcodec
115 decoder to draw an horizontal band. It improve cache usage. Not
116 all codecs can do that. You must check the codec capabilities
118 void (*draw_horiz_band
)(struct AVCodecContext
*s
,
119 UINT8
**src_ptr
, int linesize
,
120 int y
, int width
, int height
);
123 int sample_rate
; /* samples per sec */
125 int sample_fmt
; /* sample format, currenly unused */
127 /* the following data should not be initialized */
128 int frame_size
; /* in samples, initialized when calling 'init' */
129 int frame_number
; /* audio or video frame number */
130 int key_frame
; /* true if the previous compressed frame was
131 a key frame (intra, or seekable) */
132 int quality
; /* quality of the previous encoded frame
133 (between 1 (good) and 31 (bad)) */
134 float qcompress
; /* amount of qscale change between easy & hard scenes (0.0-1.0)*/
135 float qblur
; /* amount of qscale smoothing over time (0.0-1.0) */
136 int qmin
; /* min qscale */
137 int qmax
; /* max qscale */
138 int max_qdiff
; /* max qscale difference between frames */
140 struct AVCodec
*codec
;
143 /* The following data is for RTP friendly coding */
144 /* By now only H.263/H.263+ coder honours this */
145 int rtp_mode
; /* 1 for activate RTP friendly-mode */
146 /* highers numbers represent more error-prone */
147 /* enviroments, by now just "1" exist */
149 int rtp_payload_size
; /* The size of the RTP payload, the coder will */
150 /* do it's best to deliver a chunk with size */
151 /* below rtp_payload_size, the chunk will start */
152 /* with a start code on some codecs like H.263 */
153 /* This doesn't take account of any particular */
154 /* headers inside the transmited RTP payload */
157 /* The RTP callcack: This function is called */
158 /* every time the encoder as a packet to send */
159 /* Depends on the encoder if the data starts */
160 /* with a Start Code (it should) H.263 does */
161 void (*rtp_callback
)(void *data
, int size
, int packet_number
);
163 /* These are for PSNR calculation, if you set get_psnr to 1 */
164 /* after encoding you will have the PSNR on psnr_y/cb/cr */
170 /* statistics, used for 2-pass encoding */
178 int misc_bits
; // cbp, mb_type
181 /* the following fields are ignored */
182 void *opaque
; /* can be used to carry app specific stuff */
184 int codec_type
; /* see CODEC_TYPE_xxx */
185 int codec_id
; /* see CODEC_ID_xxx */
186 unsigned int codec_tag
; /* codec tag, only used if unknown codec */
189 typedef struct AVCodec
{
194 int (*init
)(AVCodecContext
*);
195 int (*encode
)(AVCodecContext
*, UINT8
*buf
, int buf_size
, void *data
);
196 int (*close
)(AVCodecContext
*);
197 int (*decode
)(AVCodecContext
*, void *outdata
, int *outdata_size
,
198 UINT8
*buf
, int buf_size
);
200 struct AVCodec
*next
;
203 /* three components are given, that's all */
204 typedef struct AVPicture
{
209 extern AVCodec ac3_encoder
;
210 extern AVCodec mp2_encoder
;
211 extern AVCodec mp3lame_encoder
;
212 extern AVCodec mpeg1video_encoder
;
213 extern AVCodec h263_encoder
;
214 extern AVCodec h263p_encoder
;
215 extern AVCodec rv10_encoder
;
216 extern AVCodec mjpeg_encoder
;
217 extern AVCodec mpeg4_encoder
;
218 extern AVCodec msmpeg4v1_encoder
;
219 extern AVCodec msmpeg4v2_encoder
;
220 extern AVCodec msmpeg4v3_encoder
;
222 extern AVCodec h263_decoder
;
223 extern AVCodec mpeg4_decoder
;
224 extern AVCodec msmpeg4v1_decoder
;
225 extern AVCodec msmpeg4v2_decoder
;
226 extern AVCodec msmpeg4v3_decoder
;
227 extern AVCodec wmv1_decoder
;
228 extern AVCodec mpeg_decoder
;
229 extern AVCodec h263i_decoder
;
230 extern AVCodec rv10_decoder
;
231 extern AVCodec mjpeg_decoder
;
232 extern AVCodec mp3_decoder
;
235 #define PCM_CODEC(id, name) \
236 extern AVCodec name ## _decoder; \
237 extern AVCodec name ## _encoder;
239 PCM_CODEC(CODEC_ID_PCM_S16LE
, pcm_s16le
);
240 PCM_CODEC(CODEC_ID_PCM_S16BE
, pcm_s16be
);
241 PCM_CODEC(CODEC_ID_PCM_U16LE
, pcm_u16le
);
242 PCM_CODEC(CODEC_ID_PCM_U16BE
, pcm_u16be
);
243 PCM_CODEC(CODEC_ID_PCM_S8
, pcm_s8
);
244 PCM_CODEC(CODEC_ID_PCM_U8
, pcm_u8
);
245 PCM_CODEC(CODEC_ID_PCM_ALAW
, pcm_alaw
);
246 PCM_CODEC(CODEC_ID_PCM_MULAW
, pcm_mulaw
);
250 /* dummy raw video codec */
251 extern AVCodec rawvideo_codec
;
253 /* the following codecs use external GPL libs */
254 extern AVCodec ac3_decoder
;
258 struct ReSampleContext
;
260 typedef struct ReSampleContext ReSampleContext
;
262 ReSampleContext
*audio_resample_init(int output_channels
, int input_channels
,
263 int output_rate
, int input_rate
);
264 int audio_resample(ReSampleContext
*s
, short *output
, short *input
, int nb_samples
);
265 void audio_resample_close(ReSampleContext
*s
);
267 /* YUV420 format is assumed ! */
269 struct ImgReSampleContext
;
271 typedef struct ImgReSampleContext ImgReSampleContext
;
273 ImgReSampleContext
*img_resample_init(int output_width
, int output_height
,
274 int input_width
, int input_height
);
275 void img_resample(ImgReSampleContext
*s
,
276 AVPicture
*output
, AVPicture
*input
);
278 void img_resample_close(ImgReSampleContext
*s
);
280 void avpicture_fill(AVPicture
*picture
, UINT8
*ptr
,
281 int pix_fmt
, int width
, int height
);
282 int avpicture_get_size(int pix_fmt
, int width
, int height
);
284 /* convert among pixel formats */
285 int img_convert(AVPicture
*dst
, int dst_pix_fmt
,
286 AVPicture
*src
, int pix_fmt
,
287 int width
, int height
);
289 /* deinterlace a picture */
290 int avpicture_deinterlace(AVPicture
*dst
, AVPicture
*src
,
291 int pix_fmt
, int width
, int height
);
293 /* external high level API */
295 extern AVCodec
*first_avcodec
;
297 void avcodec_init(void);
299 void register_avcodec(AVCodec
*format
);
300 AVCodec
*avcodec_find_encoder(enum CodecID id
);
301 AVCodec
*avcodec_find_encoder_by_name(const char *name
);
302 AVCodec
*avcodec_find_decoder(enum CodecID id
);
303 AVCodec
*avcodec_find_decoder_by_name(const char *name
);
304 void avcodec_string(char *buf
, int buf_size
, AVCodecContext
*enc
, int encode
);
306 int avcodec_open(AVCodecContext
*avctx
, AVCodec
*codec
);
307 int avcodec_decode_audio(AVCodecContext
*avctx
, INT16
*samples
,
309 UINT8
*buf
, int buf_size
);
310 int avcodec_decode_video(AVCodecContext
*avctx
, AVPicture
*picture
,
311 int *got_picture_ptr
,
312 UINT8
*buf
, int buf_size
);
313 int avcodec_encode_audio(AVCodecContext
*avctx
, UINT8
*buf
, int buf_size
,
314 const short *samples
);
315 int avcodec_encode_video(AVCodecContext
*avctx
, UINT8
*buf
, int buf_size
,
316 const AVPicture
*pict
);
318 int avcodec_close(AVCodecContext
*avctx
);
320 void avcodec_register_all(void);
322 #ifdef FF_POSTPROCESS
327 extern int quant_store
[MBR
+1][MBC
+1]; // [Review]
330 #endif /* AVCODEC_H */