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 */
120 /* The RTP callcack: This function is called */
121 /* every time the encoder as a packet to send */
122 /* Depends on the encoder if the data starts */
123 /* with a Start Code (it should) H.263 does */
124 void (*rtp_callback)(void *data, int size, int packet_number);
126 /* These are for PSNR calculation, if you set get_psnr to 1 */
127 /* after encoding you will have the PSNR on psnr_y/cb/cr */
133 /* the following fields are ignored */
134 void *opaque; /* can be used to carry app specific stuff */
136 int codec_type; /* see CODEC_TYPE_xxx */
137 int codec_id; /* see CODEC_ID_xxx */
138 unsigned int codec_tag; /* codec tag, only used if unknown codec */
141 typedef struct AVCodec {
146 int (*init)(AVCodecContext *);
147 int (*encode)(AVCodecContext *, UINT8 *buf, int buf_size, void *data);
148 int (*close)(AVCodecContext *);
149 int (*decode)(AVCodecContext *, void *outdata, int *outdata_size,
150 UINT8 *buf, int buf_size);
152 struct AVCodec *next;
155 /* three components are given, that's all */
156 typedef struct AVPicture {
161 extern AVCodec ac3_encoder;
162 extern AVCodec mp2_encoder;
163 extern AVCodec mpeg1video_encoder;
164 extern AVCodec h263_encoder;
165 extern AVCodec h263p_encoder;
166 extern AVCodec rv10_encoder;
167 extern AVCodec mjpeg_encoder;
168 extern AVCodec mpeg4_encoder;
169 extern AVCodec msmpeg4_encoder;
171 extern AVCodec h263_decoder;
172 extern AVCodec mpeg4_decoder;
173 extern AVCodec msmpeg4_decoder;
174 extern AVCodec mpeg_decoder;
175 extern AVCodec h263i_decoder;
176 extern AVCodec rv10_decoder;
177 extern AVCodec mjpeg_decoder;
178 extern AVCodec mp3_decoder;
181 #define PCM_CODEC(id, name) \
182 extern AVCodec name ## _decoder; \
183 extern AVCodec name ## _encoder;
185 PCM_CODEC(CODEC_ID_PCM_S16LE, pcm_s16le);
186 PCM_CODEC(CODEC_ID_PCM_S16BE, pcm_s16be);
187 PCM_CODEC(CODEC_ID_PCM_U16LE, pcm_u16le);
188 PCM_CODEC(CODEC_ID_PCM_U16BE, pcm_u16be);
189 PCM_CODEC(CODEC_ID_PCM_S8, pcm_s8);
190 PCM_CODEC(CODEC_ID_PCM_U8, pcm_u8);
191 PCM_CODEC(CODEC_ID_PCM_ALAW, pcm_alaw);
192 PCM_CODEC(CODEC_ID_PCM_MULAW, pcm_mulaw);
196 /* dummy raw video codec */
197 extern AVCodec rawvideo_codec;
199 /* the following codecs use external GPL libs */
200 extern AVCodec ac3_decoder;
204 struct ReSampleContext;
206 typedef struct ReSampleContext ReSampleContext;
208 ReSampleContext *audio_resample_init(int output_channels, int input_channels,
209 int output_rate, int input_rate);
210 int audio_resample(ReSampleContext *s, short *output, short *input, int nb_samples);
211 void audio_resample_close(ReSampleContext *s);
213 /* YUV420 format is assumed ! */
215 struct ImgReSampleContext;
217 typedef struct ImgReSampleContext ImgReSampleContext;
219 ImgReSampleContext *img_resample_init(int output_width, int output_height,
220 int input_width, int input_height);
221 void img_resample(ImgReSampleContext *s,
222 AVPicture *output, AVPicture *input);
224 void img_resample_close(ImgReSampleContext *s);
226 void avpicture_fill(AVPicture *picture, UINT8 *ptr,
227 int pix_fmt, int width, int height);
228 int avpicture_get_size(int pix_fmt, int width, int height);
230 /* convert among pixel formats */
231 int img_convert(AVPicture *dst, int dst_pix_fmt,
232 AVPicture *src, int pix_fmt,
233 int width, int height);
235 /* deinterlace a picture */
236 int avpicture_deinterlace(AVPicture *dst, AVPicture *src,
237 int pix_fmt, int width, int height);
239 /* external high level API */
241 extern AVCodec *first_avcodec;
243 void avcodec_init(void);
245 void register_avcodec(AVCodec *format);
246 AVCodec *avcodec_find_encoder(enum CodecID id);
247 AVCodec *avcodec_find_encoder_by_name(const char *name);
248 AVCodec *avcodec_find_decoder(enum CodecID id);
249 AVCodec *avcodec_find_decoder_by_name(const char *name);
250 void avcodec_string(char *buf, int buf_size, AVCodecContext *enc, int encode);
252 int avcodec_open(AVCodecContext *avctx, AVCodec *codec);
253 int avcodec_decode_audio(AVCodecContext *avctx, INT16 *samples,
255 UINT8 *buf, int buf_size);
256 int avcodec_decode_video(AVCodecContext *avctx, AVPicture *picture,
257 int *got_picture_ptr,
258 UINT8 *buf, int buf_size);
259 int avcodec_encode_audio(AVCodecContext *avctx, UINT8 *buf, int buf_size,
260 const short *samples);
261 int avcodec_encode_video(AVCodecContext *avctx, UINT8 *buf, int buf_size,
262 const AVPicture *pict);
264 int avcodec_close(AVCodecContext *avctx);
266 void avcodec_register_all(void);
268 #ifdef FF_POSTPROCESS
273 extern int quant_store[MBR+1][MBC+1]; // [Review]
276 #endif /* AVCODEC_H */