20 /* various pcm "codecs" */
45 /* currently unused, may be used if 24/32 bits samples ever supported */
47 SAMPLE_FMT_S16 = 0, /* signed 16 bits */
51 #define AVCODEC_MAX_AUDIO_FRAME_SIZE 18432
53 /* motion estimation type */
54 extern int motion_estimation_method;
60 /* encoding support */
62 #define CODEC_FLAG_HQ 0x0001 /* high quality (non real time) encoding */
63 #define CODEC_FLAG_QSCALE 0x0002 /* use fixed qscale */
65 /* codec capabilities */
67 /* decoder can use draw_horiz_band callback */
68 #define CODEC_CAP_DRAW_HORIZ_BAND 0x0001
70 #define FRAME_RATE_BASE 10000
72 typedef struct AVCodecContext {
75 int sub_id; /* some codecs needs additionnal format info. It is
78 int frame_rate; /* frames per sec multiplied by FRAME_RATE_BASE */
80 int gop_size; /* 0 = intra only */
81 int pix_fmt; /* pixel format, see PIX_FMT_xxx */
83 /* if non NULL, 'draw_horiz_band' is called by the libavcodec
84 decoder to draw an horizontal band. It improve cache usage. Not
85 all codecs can do that. You must check the codec capabilities
87 void (*draw_horiz_band)(struct AVCodecContext *s,
88 UINT8 **src_ptr, int linesize,
89 int y, int width, int height);
92 int sample_rate; /* samples per sec */
94 int sample_fmt; /* sample format, currenly unused */
96 /* the following data should not be initialized */
97 int frame_size; /* in samples, initialized when calling 'init' */
98 int frame_number; /* audio or video frame number */
99 int key_frame; /* true if the previous compressed frame was
100 a key frame (intra, or seekable) */
101 int quality; /* quality of the previous encoded frame
102 (between 1 (good) and 31 (bad)) */
103 struct AVCodec *codec;
106 /* The following data is for RTP friendly coding */
107 /* By now only H.263/H.263+ coder honours this */
108 int rtp_mode; /* 1 for activate RTP friendly-mode */
109 /* highers numbers represent more error-prone */
110 /* enviroments, by now just "1" exist */
112 int rtp_payload_size; /* The size of the RTP payload, the coder will */
113 /* do it's best to deliver a chunk with size */
114 /* below rtp_payload_size, the chunk will start */
115 /* with a start code on some codecs like H.263 */
116 /* This doesn't take account of any particular */
117 /* headers inside the transmited RTP payload */
119 /* the following fields are ignored */
120 void *opaque; /* can be used to carry app specific stuff */
122 int codec_type; /* see CODEC_TYPE_xxx */
123 int codec_id; /* see CODEC_ID_xxx */
124 unsigned int codec_tag; /* codec tag, only used if unknown codec */
127 typedef struct AVCodec {
132 int (*init)(AVCodecContext *);
133 int (*encode)(AVCodecContext *, UINT8 *buf, int buf_size, void *data);
134 int (*close)(AVCodecContext *);
135 int (*decode)(AVCodecContext *, void *outdata, int *outdata_size,
136 UINT8 *buf, int buf_size);
138 struct AVCodec *next;
141 /* three components are given, that's all */
142 typedef struct AVPicture {
147 extern AVCodec ac3_encoder;
148 extern AVCodec mp2_encoder;
149 extern AVCodec mpeg1video_encoder;
150 extern AVCodec h263_encoder;
151 extern AVCodec h263p_encoder;
152 extern AVCodec rv10_encoder;
153 extern AVCodec mjpeg_encoder;
154 extern AVCodec mpeg4_encoder;
155 extern AVCodec msmpeg4_encoder;
157 extern AVCodec h263_decoder;
158 extern AVCodec mpeg4_decoder;
159 extern AVCodec msmpeg4_decoder;
160 extern AVCodec mpeg_decoder;
161 extern AVCodec h263i_decoder;
162 extern AVCodec rv10_decoder;
163 extern AVCodec mjpeg_decoder;
164 extern AVCodec mp3_decoder;
167 #define PCM_CODEC(id, name) \
168 extern AVCodec name ## _decoder; \
169 extern AVCodec name ## _encoder;
171 PCM_CODEC(CODEC_ID_PCM_S16LE, pcm_s16le);
172 PCM_CODEC(CODEC_ID_PCM_S16BE, pcm_s16be);
173 PCM_CODEC(CODEC_ID_PCM_U16LE, pcm_u16le);
174 PCM_CODEC(CODEC_ID_PCM_U16BE, pcm_u16be);
175 PCM_CODEC(CODEC_ID_PCM_S8, pcm_s8);
176 PCM_CODEC(CODEC_ID_PCM_U8, pcm_u8);
177 PCM_CODEC(CODEC_ID_PCM_ALAW, pcm_alaw);
178 PCM_CODEC(CODEC_ID_PCM_MULAW, pcm_mulaw);
182 /* dummy raw video codec */
183 extern AVCodec rawvideo_codec;
185 /* the following codecs use external GPL libs */
186 extern AVCodec ac3_decoder;
190 struct ReSampleContext;
192 typedef struct ReSampleContext ReSampleContext;
194 ReSampleContext *audio_resample_init(int output_channels, int input_channels,
195 int output_rate, int input_rate);
196 int audio_resample(ReSampleContext *s, short *output, short *input, int nb_samples);
197 void audio_resample_close(ReSampleContext *s);
199 /* YUV420 format is assumed ! */
201 struct ImgReSampleContext;
203 typedef struct ImgReSampleContext ImgReSampleContext;
205 ImgReSampleContext *img_resample_init(int output_width, int output_height,
206 int input_width, int input_height);
207 void img_resample(ImgReSampleContext *s,
208 AVPicture *output, AVPicture *input);
210 void img_resample_close(ImgReSampleContext *s);
212 void avpicture_fill(AVPicture *picture, UINT8 *ptr,
213 int pix_fmt, int width, int height);
214 int avpicture_get_size(int pix_fmt, int width, int height);
216 /* convert among pixel formats */
217 int img_convert(AVPicture *dst, int dst_pix_fmt,
218 AVPicture *src, int pix_fmt,
219 int width, int height);
221 /* deinterlace a picture */
222 int avpicture_deinterlace(AVPicture *dst, AVPicture *src,
223 int pix_fmt, int width, int height);
225 /* external high level API */
227 extern AVCodec *first_avcodec;
229 void avcodec_init(void);
231 void register_avcodec(AVCodec *format);
232 AVCodec *avcodec_find_encoder(enum CodecID id);
233 AVCodec *avcodec_find_encoder_by_name(const char *name);
234 AVCodec *avcodec_find_decoder(enum CodecID id);
235 AVCodec *avcodec_find_decoder_by_name(const char *name);
236 void avcodec_string(char *buf, int buf_size, AVCodecContext *enc, int encode);
238 int avcodec_open(AVCodecContext *avctx, AVCodec *codec);
239 int avcodec_decode_audio(AVCodecContext *avctx, INT16 *samples,
241 UINT8 *buf, int buf_size);
242 int avcodec_decode_video(AVCodecContext *avctx, AVPicture *picture,
243 int *got_picture_ptr,
244 UINT8 *buf, int buf_size);
245 int avcodec_encode_audio(AVCodecContext *avctx, UINT8 *buf, int buf_size,
246 const short *samples);
247 int avcodec_encode_video(AVCodecContext *avctx, UINT8 *buf, int buf_size,
248 const AVPicture *pict);
250 int avcodec_close(AVCodecContext *avctx);
252 void avcodec_register_all(void);
254 #ifdef FF_POSTPROCESS
259 extern int quant_store[MBR+1][MBC+1]; // [Review]
262 #endif /* AVCODEC_H */