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