34 #define AVCODEC_MAX_AUDIO_FRAME_SIZE 18432
36 /* motion estimation type */
37 extern int motion_estimation_method;
43 /* encoding support */
45 #define CODEC_FLAG_HQ 0x0001 /* high quality (non real time) encoding */
46 #define CODEC_FLAG_QSCALE 0x0002 /* use fixed qscale */
48 /* codec capabilities */
50 /* decoder can use draw_horiz_band callback */
51 #define CODEC_CAP_DRAW_HORIZ_BAND 0x0001
53 #define FRAME_RATE_BASE 10000
55 typedef struct AVCodecContext {
58 int sub_id; /* some codecs needs additionnal format info. It is
61 int frame_rate; /* frames per sec multiplied by FRAME_RATE_BASE */
63 int gop_size; /* 0 = intra only */
64 int pix_fmt; /* pixel format, see PIX_FMT_xxx */
66 /* if non NULL, 'draw_horiz_band' is called by the libavcodec
67 decoder to draw an horizontal band. It improve cache usage. Not
68 all codecs can do that. You must check the codec capabilities
70 void (*draw_horiz_band)(struct AVCodecContext *s,
71 UINT8 **src_ptr, int linesize,
72 int y, int width, int height);
75 int sample_rate; /* samples per sec */
78 /* the following data should not be initialized */
79 int frame_size; /* in samples, initialized when calling 'init' */
80 int frame_number; /* audio or video frame number */
81 int key_frame; /* true if the previous compressed frame was
82 a key frame (intra, or seekable) */
83 int quality; /* quality of the previous encoded frame
84 (between 1 (good) and 31 (bad)) */
85 struct AVCodec *codec;
88 /* the following fields are ignored */
89 void *opaque; /* can be used to carry app specific stuff */
91 int codec_type; /* see CODEC_TYPE_xxx */
92 int codec_id; /* see CODEC_ID_xxx */
93 unsigned int codec_tag; /* codec tag, only used if unknown codec */
96 typedef struct AVCodec {
101 int (*init)(AVCodecContext *);
102 int (*encode)(AVCodecContext *, UINT8 *buf, int buf_size, void *data);
103 int (*close)(AVCodecContext *);
104 int (*decode)(AVCodecContext *, void *outdata, int *outdata_size,
105 UINT8 *buf, int buf_size);
107 struct AVCodec *next;
110 /* three components are given, that's all */
111 typedef struct AVPicture {
116 extern AVCodec ac3_encoder;
117 extern AVCodec mp2_encoder;
118 extern AVCodec mpeg1video_encoder;
119 extern AVCodec h263_encoder;
120 extern AVCodec h263p_encoder;
121 extern AVCodec rv10_encoder;
122 extern AVCodec mjpeg_encoder;
123 extern AVCodec mpeg4_encoder;
124 extern AVCodec msmpeg4_encoder;
126 extern AVCodec h263_decoder;
127 extern AVCodec mpeg4_decoder;
128 extern AVCodec msmpeg4_decoder;
129 extern AVCodec mpeg_decoder;
130 extern AVCodec h263i_decoder;
131 extern AVCodec rv10_decoder;
132 extern AVCodec mjpeg_decoder;
134 /* dummy raw codecs */
135 extern AVCodec pcm_codec;
136 extern AVCodec rawvideo_codec;
138 /* the following codecs use external GPL libs */
139 extern AVCodec mp3_decoder;
140 extern AVCodec ac3_decoder;
144 struct ReSampleContext;
146 typedef struct ReSampleContext ReSampleContext;
148 ReSampleContext *audio_resample_init(int output_channels, int input_channels,
149 int output_rate, int input_rate);
150 int audio_resample(ReSampleContext *s, short *output, short *input, int nb_samples);
151 void audio_resample_close(ReSampleContext *s);
153 /* YUV420 format is assumed ! */
155 struct ImgReSampleContext;
157 typedef struct ImgReSampleContext ImgReSampleContext;
159 ImgReSampleContext *img_resample_init(int output_width, int output_height,
160 int input_width, int input_height);
161 void img_resample(ImgReSampleContext *s,
162 AVPicture *output, AVPicture *input);
164 void img_resample_close(ImgReSampleContext *s);
166 void avpicture_fill(AVPicture *picture, UINT8 *ptr,
167 int pix_fmt, int width, int height);
168 int avpicture_get_size(int pix_fmt, int width, int height);
170 /* convert among pixel formats */
171 int img_convert(AVPicture *dst, int dst_pix_fmt,
172 AVPicture *src, int pix_fmt,
173 int width, int height);
175 /* deinterlace a picture */
176 int avpicture_deinterlace(AVPicture *dst, AVPicture *src,
177 int pix_fmt, int width, int height);
179 /* external high level API */
181 extern AVCodec *first_avcodec;
183 void avcodec_init(void);
185 void register_avcodec(AVCodec *format);
186 AVCodec *avcodec_find_encoder(enum CodecID id);
187 AVCodec *avcodec_find_decoder(enum CodecID id);
188 AVCodec *avcodec_find_decoder_by_name(const char *name);
189 void avcodec_string(char *buf, int buf_size, AVCodecContext *enc, int encode);
191 int avcodec_open(AVCodecContext *avctx, AVCodec *codec);
192 int avcodec_decode_audio(AVCodecContext *avctx, INT16 *samples,
194 UINT8 *buf, int buf_size);
195 int avcodec_decode_video(AVCodecContext *avctx, AVPicture *picture,
196 int *got_picture_ptr,
197 UINT8 *buf, int buf_size);
198 int avcodec_encode_audio(AVCodecContext *avctx, UINT8 *buf, int buf_size,
199 const short *samples);
200 int avcodec_encode_video(AVCodecContext *avctx, UINT8 *buf, int buf_size,
201 const AVPicture *pict);
203 int avcodec_close(AVCodecContext *avctx);
205 void avcodec_register_all(void);