wmv format is asf format
[libav.git] / libavcodec / avcodec.h
CommitLineData
de6d9b64
FB
1#include "common.h"
2
3enum CodecID {
4 CODEC_ID_NONE,
5 CODEC_ID_MPEG1VIDEO,
6 CODEC_ID_H263,
7 CODEC_ID_RV10,
8 CODEC_ID_MP2,
9 CODEC_ID_AC3,
10 CODEC_ID_MJPEG,
bf89e6b1 11 CODEC_ID_MPEG4,
de6d9b64
FB
12 CODEC_ID_PCM,
13 CODEC_ID_RAWVIDEO,
14 CODEC_ID_MSMPEG4,
15 CODEC_ID_H263P,
16 CODEC_ID_H263I,
17};
18
19enum CodecType {
20 CODEC_TYPE_VIDEO,
21 CODEC_TYPE_AUDIO,
22};
23
24enum PixelFormat {
25 PIX_FMT_YUV420P,
26 PIX_FMT_YUV422,
27 PIX_FMT_RGB24,
28 PIX_FMT_BGR24,
d9fea0b5
FB
29 PIX_FMT_YUV422P,
30 PIX_FMT_YUV444P,
de6d9b64
FB
31};
32
33/* in bytes */
34#define AVCODEC_MAX_AUDIO_FRAME_SIZE 18432
35
36/* motion estimation type */
37extern int motion_estimation_method;
38#define ME_ZERO 0
39#define ME_FULL 1
40#define ME_LOG 2
41#define ME_PHODS 3
42
43/* encoding support */
44
45#define CODEC_FLAG_HQ 0x0001 /* high quality (non real time) encoding */
46#define CODEC_FLAG_QSCALE 0x0002 /* use fixed qscale */
47
bf89e6b1
FB
48/* codec capabilities */
49
50/* decoder can use draw_horiz_band callback */
51#define CODEC_CAP_DRAW_HORIZ_BAND 0x0001
52
de6d9b64
FB
53#define FRAME_RATE_BASE 10000
54
55typedef struct AVCodecContext {
56 int bit_rate;
57 int flags;
58 int sub_id; /* some codecs needs additionnal format info. It is
59 stored there */
60 /* video only */
61 int frame_rate; /* frames per sec multiplied by FRAME_RATE_BASE */
62 int width, height;
63 int gop_size; /* 0 = intra only */
64 int pix_fmt; /* pixel format, see PIX_FMT_xxx */
bf89e6b1
FB
65
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
69 before */
70 void (*draw_horiz_band)(struct AVCodecContext *s,
71 UINT8 **src_ptr, int linesize,
72 int y, int width, int height);
73
de6d9b64
FB
74 /* audio only */
75 int sample_rate; /* samples per sec */
76 int channels;
77
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;
86 void *priv_data;
87
88 /* the following fields are ignored */
bf89e6b1 89 void *opaque; /* can be used to carry app specific stuff */
de6d9b64
FB
90 char codec_name[32];
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 */
94} AVCodecContext;
95
96typedef struct AVCodec {
97 char *name;
98 int type;
99 int id;
100 int priv_data_size;
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);
bf89e6b1 106 int capabilities;
de6d9b64
FB
107 struct AVCodec *next;
108} AVCodec;
109
110/* three components are given, that's all */
111typedef struct AVPicture {
112 UINT8 *data[3];
113 int linesize[3];
114} AVPicture;
115
116extern AVCodec ac3_encoder;
117extern AVCodec mp2_encoder;
118extern AVCodec mpeg1video_encoder;
119extern AVCodec h263_encoder;
120extern AVCodec h263p_encoder;
121extern AVCodec rv10_encoder;
122extern AVCodec mjpeg_encoder;
bf89e6b1 123extern AVCodec mpeg4_encoder;
de6d9b64
FB
124extern AVCodec msmpeg4_encoder;
125
126extern AVCodec h263_decoder;
bf89e6b1 127extern AVCodec mpeg4_decoder;
de6d9b64
FB
128extern AVCodec msmpeg4_decoder;
129extern AVCodec mpeg_decoder;
130extern AVCodec h263i_decoder;
131extern AVCodec rv10_decoder;
4e66ab3b 132extern AVCodec mjpeg_decoder;
de6d9b64
FB
133
134/* dummy raw codecs */
135extern AVCodec pcm_codec;
136extern AVCodec rawvideo_codec;
137
138/* the following codecs use external GPL libs */
139extern AVCodec mp3_decoder;
140extern AVCodec ac3_decoder;
141
142/* resample.c */
143
144struct ReSampleContext;
145
146typedef struct ReSampleContext ReSampleContext;
147
148ReSampleContext *audio_resample_init(int output_channels, int input_channels,
149 int output_rate, int input_rate);
150int audio_resample(ReSampleContext *s, short *output, short *input, int nb_samples);
151void audio_resample_close(ReSampleContext *s);
152
153/* YUV420 format is assumed ! */
154
155struct ImgReSampleContext;
156
157typedef struct ImgReSampleContext ImgReSampleContext;
158
159ImgReSampleContext *img_resample_init(int output_width, int output_height,
160 int input_width, int input_height);
161void img_resample(ImgReSampleContext *s,
162 AVPicture *output, AVPicture *input);
163
164void img_resample_close(ImgReSampleContext *s);
165
219b06c6
FB
166void avpicture_fill(AVPicture *picture, UINT8 *ptr,
167 int pix_fmt, int width, int height);
168int avpicture_get_size(int pix_fmt, int width, int height);
169
170/* convert among pixel formats */
171int img_convert(AVPicture *dst, int dst_pix_fmt,
172 AVPicture *src, int pix_fmt,
173 int width, int height);
174
175/* deinterlace a picture */
176int avpicture_deinterlace(AVPicture *dst, AVPicture *src,
de6d9b64
FB
177 int pix_fmt, int width, int height);
178
179/* external high level API */
180
181extern AVCodec *first_avcodec;
182
183void avcodec_init(void);
184
185void register_avcodec(AVCodec *format);
186AVCodec *avcodec_find_encoder(enum CodecID id);
187AVCodec *avcodec_find_decoder(enum CodecID id);
188AVCodec *avcodec_find_decoder_by_name(const char *name);
189void avcodec_string(char *buf, int buf_size, AVCodecContext *enc, int encode);
190
191int avcodec_open(AVCodecContext *avctx, AVCodec *codec);
192int avcodec_decode_audio(AVCodecContext *avctx, INT16 *samples,
193 int *frame_size_ptr,
194 UINT8 *buf, int buf_size);
195int avcodec_decode_video(AVCodecContext *avctx, AVPicture *picture,
196 int *got_picture_ptr,
197 UINT8 *buf, int buf_size);
198int avcodec_encode_audio(AVCodecContext *avctx, UINT8 *buf, int buf_size,
199 const short *samples);
200int avcodec_encode_video(AVCodecContext *avctx, UINT8 *buf, int buf_size,
201 const AVPicture *pict);
202
203int avcodec_close(AVCodecContext *avctx);
204
205void avcodec_register_all(void);