]> git.sesse.net Git - ffmpeg/blob - libavcodec/avcodec.h
added draw_horiz_band test
[ffmpeg] / libavcodec / avcodec.h
1 #include "common.h"
2
3 enum 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_MPEG4,
12     CODEC_ID_PCM,
13     CODEC_ID_RAWVIDEO,
14     CODEC_ID_MSMPEG4,
15     CODEC_ID_H263P,
16     CODEC_ID_H263I,
17 };
18
19 enum CodecType {
20     CODEC_TYPE_VIDEO,
21     CODEC_TYPE_AUDIO,
22 };
23
24 enum PixelFormat {
25     PIX_FMT_YUV420P,
26     PIX_FMT_YUV422,
27     PIX_FMT_RGB24,
28     PIX_FMT_BGR24,
29     PIX_FMT_YUV422P,
30     PIX_FMT_YUV444P,
31 };
32
33 /* in bytes */
34 #define AVCODEC_MAX_AUDIO_FRAME_SIZE 18432
35
36 /* motion estimation type */
37 extern 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
48 /* codec capabilities */
49
50 /* decoder can use draw_horiz_band callback */
51 #define CODEC_CAP_DRAW_HORIZ_BAND 0x0001
52
53 #define FRAME_RATE_BASE 10000
54
55 typedef 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 */
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
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 */
89     void *opaque;   /* can be used to carry app specific stuff */
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
96 typedef 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);
106     int capabilities;
107     struct AVCodec *next;
108 } AVCodec;
109
110 /* three components are given, that's all */
111 typedef struct AVPicture {
112     UINT8 *data[3];
113     int linesize[3];
114 } AVPicture;
115
116 extern AVCodec ac3_encoder;
117 extern AVCodec mp2_encoder;
118 extern AVCodec mpeg1video_encoder;
119 extern AVCodec h263_encoder;
120 extern AVCodec h263p_encoder;
121 extern AVCodec rv10_encoder;
122 extern AVCodec mjpeg_encoder;
123 extern AVCodec mpeg4_encoder;
124 extern AVCodec msmpeg4_encoder;
125
126 extern AVCodec h263_decoder;
127 extern AVCodec mpeg4_decoder;
128 extern AVCodec msmpeg4_decoder;
129 extern AVCodec mpeg_decoder;
130 extern AVCodec h263i_decoder;
131 extern AVCodec rv10_decoder;
132 extern AVCodec mjpeg_decoder;
133
134 /* dummy raw codecs */
135 extern AVCodec pcm_codec;
136 extern AVCodec rawvideo_codec;
137
138 /* the following codecs use external GPL libs */
139 extern AVCodec mp3_decoder;
140 extern AVCodec ac3_decoder;
141
142 /* resample.c */
143
144 struct ReSampleContext;
145
146 typedef struct ReSampleContext ReSampleContext;
147
148 ReSampleContext *audio_resample_init(int output_channels, int input_channels, 
149                                      int output_rate, int input_rate);
150 int audio_resample(ReSampleContext *s, short *output, short *input, int nb_samples);
151 void audio_resample_close(ReSampleContext *s);
152
153 /* YUV420 format is assumed ! */
154
155 struct ImgReSampleContext;
156
157 typedef struct ImgReSampleContext ImgReSampleContext;
158
159 ImgReSampleContext *img_resample_init(int output_width, int output_height,
160                                       int input_width, int input_height);
161 void img_resample(ImgReSampleContext *s, 
162                   AVPicture *output, AVPicture *input);
163
164 void img_resample_close(ImgReSampleContext *s);
165
166 void avpicture_fill(AVPicture *picture, UINT8 *ptr,
167                     int pix_fmt, int width, int height);
168 int avpicture_get_size(int pix_fmt, int width, int height);
169
170 /* convert among pixel formats */
171 int img_convert(AVPicture *dst, int dst_pix_fmt,
172                 AVPicture *src, int pix_fmt, 
173                 int width, int height);
174
175 /* deinterlace a picture */
176 int avpicture_deinterlace(AVPicture *dst, AVPicture *src,
177                           int pix_fmt, int width, int height);
178
179 /* external high level API */
180
181 extern AVCodec *first_avcodec;
182
183 void avcodec_init(void);
184
185 void register_avcodec(AVCodec *format);
186 AVCodec *avcodec_find_encoder(enum CodecID id);
187 AVCodec *avcodec_find_decoder(enum CodecID id);
188 AVCodec *avcodec_find_decoder_by_name(const char *name);
189 void avcodec_string(char *buf, int buf_size, AVCodecContext *enc, int encode);
190
191 int avcodec_open(AVCodecContext *avctx, AVCodec *codec);
192 int avcodec_decode_audio(AVCodecContext *avctx, INT16 *samples, 
193                          int *frame_size_ptr,
194                          UINT8 *buf, int buf_size);
195 int avcodec_decode_video(AVCodecContext *avctx, AVPicture *picture, 
196                          int *got_picture_ptr,
197                          UINT8 *buf, int buf_size);
198 int avcodec_encode_audio(AVCodecContext *avctx, UINT8 *buf, int buf_size, 
199                          const short *samples);
200 int avcodec_encode_video(AVCodecContext *avctx, UINT8 *buf, int buf_size, 
201                          const AVPicture *pict);
202
203 int avcodec_close(AVCodecContext *avctx);
204
205 void avcodec_register_all(void);