fixing msmpeg4 decoding if fps < 16 (i thought it was a indicator for the ext header...
[libav.git] / libavcodec / avcodec.h
CommitLineData
a96b68b7
FB
1#ifndef AVCODEC_H
2#define AVCODEC_H
3
de6d9b64
FB
4#include "common.h"
5
6enum CodecID {
7 CODEC_ID_NONE,
8 CODEC_ID_MPEG1VIDEO,
9 CODEC_ID_H263,
10 CODEC_ID_RV10,
11 CODEC_ID_MP2,
12 CODEC_ID_AC3,
13 CODEC_ID_MJPEG,
bf89e6b1 14 CODEC_ID_MPEG4,
de6d9b64
FB
15 CODEC_ID_RAWVIDEO,
16 CODEC_ID_MSMPEG4,
17 CODEC_ID_H263P,
18 CODEC_ID_H263I,
a96b68b7
FB
19
20 /* various pcm "codecs" */
21 CODEC_ID_PCM_S16LE,
22 CODEC_ID_PCM_S16BE,
23 CODEC_ID_PCM_U16LE,
24 CODEC_ID_PCM_U16BE,
25 CODEC_ID_PCM_S8,
26 CODEC_ID_PCM_U8,
27 CODEC_ID_PCM_MULAW,
28 CODEC_ID_PCM_ALAW,
de6d9b64
FB
29};
30
31enum CodecType {
32 CODEC_TYPE_VIDEO,
33 CODEC_TYPE_AUDIO,
34};
35
36enum PixelFormat {
37 PIX_FMT_YUV420P,
38 PIX_FMT_YUV422,
39 PIX_FMT_RGB24,
40 PIX_FMT_BGR24,
d9fea0b5
FB
41 PIX_FMT_YUV422P,
42 PIX_FMT_YUV444P,
de6d9b64
FB
43};
44
a96b68b7
FB
45/* currently unused, may be used if 24/32 bits samples ever supported */
46enum SampleFormat {
47 SAMPLE_FMT_S16 = 0, /* signed 16 bits */
48};
49
de6d9b64
FB
50/* in bytes */
51#define AVCODEC_MAX_AUDIO_FRAME_SIZE 18432
52
53/* motion estimation type */
54extern int motion_estimation_method;
55#define ME_ZERO 0
56#define ME_FULL 1
57#define ME_LOG 2
58#define ME_PHODS 3
59
60/* encoding support */
61
62#define CODEC_FLAG_HQ 0x0001 /* high quality (non real time) encoding */
63#define CODEC_FLAG_QSCALE 0x0002 /* use fixed qscale */
64
bf89e6b1
FB
65/* codec capabilities */
66
67/* decoder can use draw_horiz_band callback */
68#define CODEC_CAP_DRAW_HORIZ_BAND 0x0001
69
de6d9b64
FB
70#define FRAME_RATE_BASE 10000
71
72typedef struct AVCodecContext {
73 int bit_rate;
74 int flags;
75 int sub_id; /* some codecs needs additionnal format info. It is
76 stored there */
77 /* video only */
78 int frame_rate; /* frames per sec multiplied by FRAME_RATE_BASE */
79 int width, height;
80 int gop_size; /* 0 = intra only */
81 int pix_fmt; /* pixel format, see PIX_FMT_xxx */
bf89e6b1
FB
82
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
86 before */
87 void (*draw_horiz_band)(struct AVCodecContext *s,
88 UINT8 **src_ptr, int linesize,
89 int y, int width, int height);
90
de6d9b64
FB
91 /* audio only */
92 int sample_rate; /* samples per sec */
93 int channels;
a96b68b7 94 int sample_fmt; /* sample format, currenly unused */
de6d9b64
FB
95
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;
104 void *priv_data;
105
644d98a4
J
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 */
111
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 */
81401c1f
J
118
119
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);
125
644d98a4 126
de6d9b64 127 /* the following fields are ignored */
bf89e6b1 128 void *opaque; /* can be used to carry app specific stuff */
de6d9b64
FB
129 char codec_name[32];
130 int codec_type; /* see CODEC_TYPE_xxx */
131 int codec_id; /* see CODEC_ID_xxx */
132 unsigned int codec_tag; /* codec tag, only used if unknown codec */
133} AVCodecContext;
134
135typedef struct AVCodec {
136 char *name;
137 int type;
138 int id;
139 int priv_data_size;
140 int (*init)(AVCodecContext *);
141 int (*encode)(AVCodecContext *, UINT8 *buf, int buf_size, void *data);
142 int (*close)(AVCodecContext *);
143 int (*decode)(AVCodecContext *, void *outdata, int *outdata_size,
144 UINT8 *buf, int buf_size);
bf89e6b1 145 int capabilities;
de6d9b64
FB
146 struct AVCodec *next;
147} AVCodec;
148
149/* three components are given, that's all */
150typedef struct AVPicture {
151 UINT8 *data[3];
152 int linesize[3];
153} AVPicture;
154
155extern AVCodec ac3_encoder;
156extern AVCodec mp2_encoder;
157extern AVCodec mpeg1video_encoder;
158extern AVCodec h263_encoder;
159extern AVCodec h263p_encoder;
160extern AVCodec rv10_encoder;
161extern AVCodec mjpeg_encoder;
bf89e6b1 162extern AVCodec mpeg4_encoder;
de6d9b64
FB
163extern AVCodec msmpeg4_encoder;
164
165extern AVCodec h263_decoder;
bf89e6b1 166extern AVCodec mpeg4_decoder;
de6d9b64
FB
167extern AVCodec msmpeg4_decoder;
168extern AVCodec mpeg_decoder;
169extern AVCodec h263i_decoder;
170extern AVCodec rv10_decoder;
4e66ab3b 171extern AVCodec mjpeg_decoder;
a96b68b7 172extern AVCodec mp3_decoder;
de6d9b64 173
a96b68b7
FB
174/* pcm codecs */
175#define PCM_CODEC(id, name) \
176extern AVCodec name ## _decoder; \
177extern AVCodec name ## _encoder;
178
179PCM_CODEC(CODEC_ID_PCM_S16LE, pcm_s16le);
180PCM_CODEC(CODEC_ID_PCM_S16BE, pcm_s16be);
181PCM_CODEC(CODEC_ID_PCM_U16LE, pcm_u16le);
182PCM_CODEC(CODEC_ID_PCM_U16BE, pcm_u16be);
183PCM_CODEC(CODEC_ID_PCM_S8, pcm_s8);
184PCM_CODEC(CODEC_ID_PCM_U8, pcm_u8);
185PCM_CODEC(CODEC_ID_PCM_ALAW, pcm_alaw);
186PCM_CODEC(CODEC_ID_PCM_MULAW, pcm_mulaw);
187
188#undef PCM_CODEC
189
190/* dummy raw video codec */
de6d9b64
FB
191extern AVCodec rawvideo_codec;
192
193/* the following codecs use external GPL libs */
de6d9b64
FB
194extern AVCodec ac3_decoder;
195
196/* resample.c */
197
198struct ReSampleContext;
199
200typedef struct ReSampleContext ReSampleContext;
201
202ReSampleContext *audio_resample_init(int output_channels, int input_channels,
203 int output_rate, int input_rate);
204int audio_resample(ReSampleContext *s, short *output, short *input, int nb_samples);
205void audio_resample_close(ReSampleContext *s);
206
207/* YUV420 format is assumed ! */
208
209struct ImgReSampleContext;
210
211typedef struct ImgReSampleContext ImgReSampleContext;
212
213ImgReSampleContext *img_resample_init(int output_width, int output_height,
214 int input_width, int input_height);
215void img_resample(ImgReSampleContext *s,
216 AVPicture *output, AVPicture *input);
217
218void img_resample_close(ImgReSampleContext *s);
219
219b06c6
FB
220void avpicture_fill(AVPicture *picture, UINT8 *ptr,
221 int pix_fmt, int width, int height);
222int avpicture_get_size(int pix_fmt, int width, int height);
223
224/* convert among pixel formats */
225int img_convert(AVPicture *dst, int dst_pix_fmt,
226 AVPicture *src, int pix_fmt,
227 int width, int height);
228
229/* deinterlace a picture */
230int avpicture_deinterlace(AVPicture *dst, AVPicture *src,
de6d9b64
FB
231 int pix_fmt, int width, int height);
232
233/* external high level API */
234
235extern AVCodec *first_avcodec;
236
237void avcodec_init(void);
238
239void register_avcodec(AVCodec *format);
240AVCodec *avcodec_find_encoder(enum CodecID id);
98f3b098 241AVCodec *avcodec_find_encoder_by_name(const char *name);
de6d9b64
FB
242AVCodec *avcodec_find_decoder(enum CodecID id);
243AVCodec *avcodec_find_decoder_by_name(const char *name);
244void avcodec_string(char *buf, int buf_size, AVCodecContext *enc, int encode);
245
246int avcodec_open(AVCodecContext *avctx, AVCodec *codec);
247int avcodec_decode_audio(AVCodecContext *avctx, INT16 *samples,
248 int *frame_size_ptr,
249 UINT8 *buf, int buf_size);
250int avcodec_decode_video(AVCodecContext *avctx, AVPicture *picture,
251 int *got_picture_ptr,
252 UINT8 *buf, int buf_size);
253int avcodec_encode_audio(AVCodecContext *avctx, UINT8 *buf, int buf_size,
254 const short *samples);
255int avcodec_encode_video(AVCodecContext *avctx, UINT8 *buf, int buf_size,
256 const AVPicture *pict);
257
258int avcodec_close(AVCodecContext *avctx);
259
260void avcodec_register_all(void);
a96b68b7 261
79e7b305
A
262#ifdef FF_POSTPROCESS
263#ifndef MBC
644d98a4
J
264#define MBC 48
265#define MBR 36
79e7b305
A
266#endif
267extern int quant_store[MBR+1][MBC+1]; // [Review]
268#endif
269
a96b68b7 270#endif /* AVCODEC_H */