added correct component id handling
[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,
11 CODEC_ID_OPENDIVX,
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,
29};
30
31/* in bytes */
32#define AVCODEC_MAX_AUDIO_FRAME_SIZE 18432
33
34/* motion estimation type */
35extern int motion_estimation_method;
36#define ME_ZERO 0
37#define ME_FULL 1
38#define ME_LOG 2
39#define ME_PHODS 3
40
41/* encoding support */
42
43#define CODEC_FLAG_HQ 0x0001 /* high quality (non real time) encoding */
44#define CODEC_FLAG_QSCALE 0x0002 /* use fixed qscale */
45
46#define FRAME_RATE_BASE 10000
47
48typedef struct AVCodecContext {
49 int bit_rate;
50 int flags;
51 int sub_id; /* some codecs needs additionnal format info. It is
52 stored there */
53 /* video only */
54 int frame_rate; /* frames per sec multiplied by FRAME_RATE_BASE */
55 int width, height;
56 int gop_size; /* 0 = intra only */
57 int pix_fmt; /* pixel format, see PIX_FMT_xxx */
58 /* audio only */
59 int sample_rate; /* samples per sec */
60 int channels;
61
62 /* the following data should not be initialized */
63 int frame_size; /* in samples, initialized when calling 'init' */
64 int frame_number; /* audio or video frame number */
65 int key_frame; /* true if the previous compressed frame was
66 a key frame (intra, or seekable) */
67 int quality; /* quality of the previous encoded frame
68 (between 1 (good) and 31 (bad)) */
69 struct AVCodec *codec;
70 void *priv_data;
71
72 /* the following fields are ignored */
73 char codec_name[32];
74 int codec_type; /* see CODEC_TYPE_xxx */
75 int codec_id; /* see CODEC_ID_xxx */
76 unsigned int codec_tag; /* codec tag, only used if unknown codec */
77} AVCodecContext;
78
79typedef struct AVCodec {
80 char *name;
81 int type;
82 int id;
83 int priv_data_size;
84 int (*init)(AVCodecContext *);
85 int (*encode)(AVCodecContext *, UINT8 *buf, int buf_size, void *data);
86 int (*close)(AVCodecContext *);
87 int (*decode)(AVCodecContext *, void *outdata, int *outdata_size,
88 UINT8 *buf, int buf_size);
89 struct AVCodec *next;
90} AVCodec;
91
92/* three components are given, that's all */
93typedef struct AVPicture {
94 UINT8 *data[3];
95 int linesize[3];
96} AVPicture;
97
98extern AVCodec ac3_encoder;
99extern AVCodec mp2_encoder;
100extern AVCodec mpeg1video_encoder;
101extern AVCodec h263_encoder;
102extern AVCodec h263p_encoder;
103extern AVCodec rv10_encoder;
104extern AVCodec mjpeg_encoder;
105extern AVCodec opendivx_encoder;
106extern AVCodec msmpeg4_encoder;
107
108extern AVCodec h263_decoder;
109extern AVCodec opendivx_decoder;
110extern AVCodec msmpeg4_decoder;
111extern AVCodec mpeg_decoder;
112extern AVCodec h263i_decoder;
113extern AVCodec rv10_decoder;
4e66ab3b 114extern AVCodec mjpeg_decoder;
de6d9b64
FB
115
116/* dummy raw codecs */
117extern AVCodec pcm_codec;
118extern AVCodec rawvideo_codec;
119
120/* the following codecs use external GPL libs */
121extern AVCodec mp3_decoder;
122extern AVCodec ac3_decoder;
123
124/* resample.c */
125
126struct ReSampleContext;
127
128typedef struct ReSampleContext ReSampleContext;
129
130ReSampleContext *audio_resample_init(int output_channels, int input_channels,
131 int output_rate, int input_rate);
132int audio_resample(ReSampleContext *s, short *output, short *input, int nb_samples);
133void audio_resample_close(ReSampleContext *s);
134
135/* YUV420 format is assumed ! */
136
137struct ImgReSampleContext;
138
139typedef struct ImgReSampleContext ImgReSampleContext;
140
141ImgReSampleContext *img_resample_init(int output_width, int output_height,
142 int input_width, int input_height);
143void img_resample(ImgReSampleContext *s,
144 AVPicture *output, AVPicture *input);
145
146void img_resample_close(ImgReSampleContext *s);
147
148int img_convert_to_yuv420(UINT8 *img_out, UINT8 *img,
149 int pix_fmt, int width, int height);
150
151/* external high level API */
152
153extern AVCodec *first_avcodec;
154
155void avcodec_init(void);
156
157void register_avcodec(AVCodec *format);
158AVCodec *avcodec_find_encoder(enum CodecID id);
159AVCodec *avcodec_find_decoder(enum CodecID id);
160AVCodec *avcodec_find_decoder_by_name(const char *name);
161void avcodec_string(char *buf, int buf_size, AVCodecContext *enc, int encode);
162
163int avcodec_open(AVCodecContext *avctx, AVCodec *codec);
164int avcodec_decode_audio(AVCodecContext *avctx, INT16 *samples,
165 int *frame_size_ptr,
166 UINT8 *buf, int buf_size);
167int avcodec_decode_video(AVCodecContext *avctx, AVPicture *picture,
168 int *got_picture_ptr,
169 UINT8 *buf, int buf_size);
170int avcodec_encode_audio(AVCodecContext *avctx, UINT8 *buf, int buf_size,
171 const short *samples);
172int avcodec_encode_video(AVCodecContext *avctx, UINT8 *buf, int buf_size,
173 const AVPicture *pict);
174
175int avcodec_close(AVCodecContext *avctx);
176
177void avcodec_register_all(void);