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 #define FRAME_RATE_BASE 10000
50 typedef struct AVCodecContext {
53 int sub_id; /* some codecs needs additionnal format info. It is
56 int frame_rate; /* frames per sec multiplied by FRAME_RATE_BASE */
58 int gop_size; /* 0 = intra only */
59 int pix_fmt; /* pixel format, see PIX_FMT_xxx */
61 int sample_rate; /* samples per sec */
64 /* the following data should not be initialized */
65 int frame_size; /* in samples, initialized when calling 'init' */
66 int frame_number; /* audio or video frame number */
67 int key_frame; /* true if the previous compressed frame was
68 a key frame (intra, or seekable) */
69 int quality; /* quality of the previous encoded frame
70 (between 1 (good) and 31 (bad)) */
71 struct AVCodec *codec;
74 /* the following fields are ignored */
76 int codec_type; /* see CODEC_TYPE_xxx */
77 int codec_id; /* see CODEC_ID_xxx */
78 unsigned int codec_tag; /* codec tag, only used if unknown codec */
81 typedef struct AVCodec {
86 int (*init)(AVCodecContext *);
87 int (*encode)(AVCodecContext *, UINT8 *buf, int buf_size, void *data);
88 int (*close)(AVCodecContext *);
89 int (*decode)(AVCodecContext *, void *outdata, int *outdata_size,
90 UINT8 *buf, int buf_size);
94 /* three components are given, that's all */
95 typedef struct AVPicture {
100 extern AVCodec ac3_encoder;
101 extern AVCodec mp2_encoder;
102 extern AVCodec mpeg1video_encoder;
103 extern AVCodec h263_encoder;
104 extern AVCodec h263p_encoder;
105 extern AVCodec rv10_encoder;
106 extern AVCodec mjpeg_encoder;
107 extern AVCodec opendivx_encoder;
108 extern AVCodec msmpeg4_encoder;
110 extern AVCodec h263_decoder;
111 extern AVCodec opendivx_decoder;
112 extern AVCodec msmpeg4_decoder;
113 extern AVCodec mpeg_decoder;
114 extern AVCodec h263i_decoder;
115 extern AVCodec rv10_decoder;
116 extern AVCodec mjpeg_decoder;
118 /* dummy raw codecs */
119 extern AVCodec pcm_codec;
120 extern AVCodec rawvideo_codec;
122 /* the following codecs use external GPL libs */
123 extern AVCodec mp3_decoder;
124 extern AVCodec ac3_decoder;
128 struct ReSampleContext;
130 typedef struct ReSampleContext ReSampleContext;
132 ReSampleContext *audio_resample_init(int output_channels, int input_channels,
133 int output_rate, int input_rate);
134 int audio_resample(ReSampleContext *s, short *output, short *input, int nb_samples);
135 void audio_resample_close(ReSampleContext *s);
137 /* YUV420 format is assumed ! */
139 struct ImgReSampleContext;
141 typedef struct ImgReSampleContext ImgReSampleContext;
143 ImgReSampleContext *img_resample_init(int output_width, int output_height,
144 int input_width, int input_height);
145 void img_resample(ImgReSampleContext *s,
146 AVPicture *output, AVPicture *input);
148 void img_resample_close(ImgReSampleContext *s);
150 int img_convert_to_yuv420(UINT8 *img_out, UINT8 *img,
151 int pix_fmt, int width, int height);
153 /* external high level API */
155 extern AVCodec *first_avcodec;
157 void avcodec_init(void);
159 void register_avcodec(AVCodec *format);
160 AVCodec *avcodec_find_encoder(enum CodecID id);
161 AVCodec *avcodec_find_decoder(enum CodecID id);
162 AVCodec *avcodec_find_decoder_by_name(const char *name);
163 void avcodec_string(char *buf, int buf_size, AVCodecContext *enc, int encode);
165 int avcodec_open(AVCodecContext *avctx, AVCodec *codec);
166 int avcodec_decode_audio(AVCodecContext *avctx, INT16 *samples,
168 UINT8 *buf, int buf_size);
169 int avcodec_decode_video(AVCodecContext *avctx, AVPicture *picture,
170 int *got_picture_ptr,
171 UINT8 *buf, int buf_size);
172 int avcodec_encode_audio(AVCodecContext *avctx, UINT8 *buf, int buf_size,
173 const short *samples);
174 int avcodec_encode_video(AVCodecContext *avctx, UINT8 *buf, int buf_size,
175 const AVPicture *pict);
177 int avcodec_close(AVCodecContext *avctx);
179 void avcodec_register_all(void);