Mercurial > libavcodec.hg
annotate avcodec.h @ 320:cda7d0857baf libavcodec
- ME setting moved to AVCodecContext/MpegEncContext, no longer a global.
- EPZS ME algo used by default.
- HQ flag activated for ffmpeg.
- Cosmetics ...
author | pulento |
---|---|
date | Sun, 14 Apr 2002 18:57:51 +0000 |
parents | 5afea0021fb8 |
children | 2b00e171b1d4 |
rev | line source |
---|---|
92 | 1 #ifndef AVCODEC_H |
2 #define AVCODEC_H | |
3 | |
0 | 4 #include "common.h" |
5 | |
6 enum CodecID { | |
7 CODEC_ID_NONE, | |
8 CODEC_ID_MPEG1VIDEO, | |
9 CODEC_ID_H263, | |
10 CODEC_ID_RV10, | |
11 CODEC_ID_MP2, | |
260
e1bacfb3f51f
- Added MP3 encoding through libmp3lame contributed by Lennert Buytenhek.
pulento
parents:
252
diff
changeset
|
12 CODEC_ID_MP3LAME, |
0 | 13 CODEC_ID_AC3, |
14 CODEC_ID_MJPEG, | |
67 | 15 CODEC_ID_MPEG4, |
0 | 16 CODEC_ID_RAWVIDEO, |
307 | 17 CODEC_ID_MSMPEG4V1, |
18 CODEC_ID_MSMPEG4V2, | |
19 CODEC_ID_MSMPEG4V3, | |
311 | 20 CODEC_ID_WMV1, |
0 | 21 CODEC_ID_H263P, |
22 CODEC_ID_H263I, | |
92 | 23 |
24 /* various pcm "codecs" */ | |
25 CODEC_ID_PCM_S16LE, | |
26 CODEC_ID_PCM_S16BE, | |
27 CODEC_ID_PCM_U16LE, | |
28 CODEC_ID_PCM_U16BE, | |
29 CODEC_ID_PCM_S8, | |
30 CODEC_ID_PCM_U8, | |
31 CODEC_ID_PCM_MULAW, | |
32 CODEC_ID_PCM_ALAW, | |
0 | 33 }; |
307 | 34 #define CODEC_ID_MSMPEG4 CODEC_ID_MSMPEG4V3 |
0 | 35 |
36 enum CodecType { | |
37 CODEC_TYPE_VIDEO, | |
38 CODEC_TYPE_AUDIO, | |
39 }; | |
40 | |
41 enum PixelFormat { | |
317
5afea0021fb8
- PIX_FMT_ANY = -1 to avoid breaking any stuff that could be using it.
pulento
parents:
316
diff
changeset
|
42 PIX_FMT_ANY = -1, |
0 | 43 PIX_FMT_YUV420P, |
44 PIX_FMT_YUV422, | |
45 PIX_FMT_RGB24, | |
46 PIX_FMT_BGR24, | |
27
b8723ec6c80f
added 422P and 444P formats (need to patch ffmpeg.c so that it is handled in all the program)
glantau
parents:
24
diff
changeset
|
47 PIX_FMT_YUV422P, |
b8723ec6c80f
added 422P and 444P formats (need to patch ffmpeg.c so that it is handled in all the program)
glantau
parents:
24
diff
changeset
|
48 PIX_FMT_YUV444P, |
0 | 49 }; |
50 | |
92 | 51 /* currently unused, may be used if 24/32 bits samples ever supported */ |
52 enum SampleFormat { | |
53 SAMPLE_FMT_S16 = 0, /* signed 16 bits */ | |
54 }; | |
55 | |
0 | 56 /* in bytes */ |
57 #define AVCODEC_MAX_AUDIO_FRAME_SIZE 18432 | |
58 | |
320
cda7d0857baf
- ME setting moved to AVCodecContext/MpegEncContext, no longer a global.
pulento
parents:
317
diff
changeset
|
59 /* motion estimation type, EPZS by default */ |
cda7d0857baf
- ME setting moved to AVCodecContext/MpegEncContext, no longer a global.
pulento
parents:
317
diff
changeset
|
60 enum Motion_Est_ID { |
cda7d0857baf
- ME setting moved to AVCodecContext/MpegEncContext, no longer a global.
pulento
parents:
317
diff
changeset
|
61 ME_ZERO = -4, |
cda7d0857baf
- ME setting moved to AVCodecContext/MpegEncContext, no longer a global.
pulento
parents:
317
diff
changeset
|
62 ME_FULL, |
cda7d0857baf
- ME setting moved to AVCodecContext/MpegEncContext, no longer a global.
pulento
parents:
317
diff
changeset
|
63 ME_LOG, |
cda7d0857baf
- ME setting moved to AVCodecContext/MpegEncContext, no longer a global.
pulento
parents:
317
diff
changeset
|
64 ME_PHODS, |
cda7d0857baf
- ME setting moved to AVCodecContext/MpegEncContext, no longer a global.
pulento
parents:
317
diff
changeset
|
65 ME_EPZS, |
cda7d0857baf
- ME setting moved to AVCodecContext/MpegEncContext, no longer a global.
pulento
parents:
317
diff
changeset
|
66 ME_X1 |
cda7d0857baf
- ME setting moved to AVCodecContext/MpegEncContext, no longer a global.
pulento
parents:
317
diff
changeset
|
67 }; |
cda7d0857baf
- ME setting moved to AVCodecContext/MpegEncContext, no longer a global.
pulento
parents:
317
diff
changeset
|
68 |
cda7d0857baf
- ME setting moved to AVCodecContext/MpegEncContext, no longer a global.
pulento
parents:
317
diff
changeset
|
69 /* ME algos sorted by quality */ |
cda7d0857baf
- ME setting moved to AVCodecContext/MpegEncContext, no longer a global.
pulento
parents:
317
diff
changeset
|
70 static const int Motion_Est_QTab[] = { -4, -1, -2, 1, 0, -3 }; |
0 | 71 |
72 /* encoding support */ | |
294 | 73 /* note not everything is supported yet */ |
0 | 74 |
75 #define CODEC_FLAG_HQ 0x0001 /* high quality (non real time) encoding */ | |
76 #define CODEC_FLAG_QSCALE 0x0002 /* use fixed qscale */ | |
294 | 77 #define CODEC_FLAG_4MV 0x0004 /* 4 MV per MB allowed */ |
78 #define CODEC_FLAG_B 0x0008 /* use B frames */ | |
79 #define CODEC_FLAG_QPEL 0x0010 /* use qpel MC */ | |
80 #define CODEC_FLAG_GMC 0x0020 /* use GMC */ | |
298
e20de99b6295
using Juanjo's way to pass forced type - especially as I_TYPE/P_TYPE defines aren't exported in the public interface, and the flagged method matches the way as qscale forcing work
arpi_esp
parents:
297
diff
changeset
|
81 #define CODEC_FLAG_TYPE 0x0040 /* fixed I/P frame type, from avctx->key_frame */ |
0 | 82 |
67 | 83 /* codec capabilities */ |
84 | |
85 /* decoder can use draw_horiz_band callback */ | |
86 #define CODEC_CAP_DRAW_HORIZ_BAND 0x0001 | |
87 | |
0 | 88 #define FRAME_RATE_BASE 10000 |
89 | |
90 typedef struct AVCodecContext { | |
91 int bit_rate; | |
268 | 92 int bit_rate_tolerance; /* amount of +- bits (>0)*/ |
0 | 93 int flags; |
94 int sub_id; /* some codecs needs additionnal format info. It is | |
95 stored there */ | |
320
cda7d0857baf
- ME setting moved to AVCodecContext/MpegEncContext, no longer a global.
pulento
parents:
317
diff
changeset
|
96 |
cda7d0857baf
- ME setting moved to AVCodecContext/MpegEncContext, no longer a global.
pulento
parents:
317
diff
changeset
|
97 int me_method; /* ME algorithm used for video coding */ |
cda7d0857baf
- ME setting moved to AVCodecContext/MpegEncContext, no longer a global.
pulento
parents:
317
diff
changeset
|
98 |
0 | 99 /* video only */ |
100 int frame_rate; /* frames per sec multiplied by FRAME_RATE_BASE */ | |
101 int width, height; | |
281
1fc96b02142e
mpeg4 aspect_ratio_info in AVCodecContext (requested by alex)
michaelni
parents:
277
diff
changeset
|
102 int aspect_ratio_info; |
282 | 103 #define FF_ASPECT_SQUARE 1 |
104 #define FF_ASPECT_4_3_625 2 | |
105 #define FF_ASPECT_4_3_525 3 | |
106 #define FF_ASPECT_16_9_625 4 | |
107 #define FF_ASPECT_16_9_525 5 | |
0 | 108 int gop_size; /* 0 = intra only */ |
315 | 109 enum PixelFormat pix_fmt; /* pixel format, see PIX_FMT_xxx */ |
67 | 110 |
111 /* if non NULL, 'draw_horiz_band' is called by the libavcodec | |
112 decoder to draw an horizontal band. It improve cache usage. Not | |
113 all codecs can do that. You must check the codec capabilities | |
114 before */ | |
115 void (*draw_horiz_band)(struct AVCodecContext *s, | |
116 UINT8 **src_ptr, int linesize, | |
117 int y, int width, int height); | |
118 | |
0 | 119 /* audio only */ |
120 int sample_rate; /* samples per sec */ | |
121 int channels; | |
92 | 122 int sample_fmt; /* sample format, currenly unused */ |
0 | 123 |
124 /* the following data should not be initialized */ | |
125 int frame_size; /* in samples, initialized when calling 'init' */ | |
126 int frame_number; /* audio or video frame number */ | |
127 int key_frame; /* true if the previous compressed frame was | |
128 a key frame (intra, or seekable) */ | |
129 int quality; /* quality of the previous encoded frame | |
130 (between 1 (good) and 31 (bad)) */ | |
268 | 131 float qcompress; /* amount of qscale change between easy & hard scenes (0.0-1.0)*/ |
132 float qblur; /* amount of qscale smoothing over time (0.0-1.0) */ | |
133 int qmin; /* min qscale */ | |
134 int qmax; /* max qscale */ | |
135 int max_qdiff; /* max qscale difference between frames */ | |
297 | 136 |
0 | 137 struct AVCodec *codec; |
138 void *priv_data; | |
139 | |
162 | 140 /* The following data is for RTP friendly coding */ |
141 /* By now only H.263/H.263+ coder honours this */ | |
142 int rtp_mode; /* 1 for activate RTP friendly-mode */ | |
143 /* highers numbers represent more error-prone */ | |
144 /* enviroments, by now just "1" exist */ | |
145 | |
146 int rtp_payload_size; /* The size of the RTP payload, the coder will */ | |
147 /* do it's best to deliver a chunk with size */ | |
148 /* below rtp_payload_size, the chunk will start */ | |
149 /* with a start code on some codecs like H.263 */ | |
150 /* This doesn't take account of any particular */ | |
151 /* headers inside the transmited RTP payload */ | |
231 | 152 |
153 | |
154 /* The RTP callcack: This function is called */ | |
155 /* every time the encoder as a packet to send */ | |
156 /* Depends on the encoder if the data starts */ | |
157 /* with a Start Code (it should) H.263 does */ | |
158 void (*rtp_callback)(void *data, int size, int packet_number); | |
159 | |
252
ddb1a0e94cf4
- Added PSNR feature to libavcodec and ffmpeg. By now just Y PSNR until I'm
pulento
parents:
231
diff
changeset
|
160 /* These are for PSNR calculation, if you set get_psnr to 1 */ |
ddb1a0e94cf4
- Added PSNR feature to libavcodec and ffmpeg. By now just Y PSNR until I'm
pulento
parents:
231
diff
changeset
|
161 /* after encoding you will have the PSNR on psnr_y/cb/cr */ |
ddb1a0e94cf4
- Added PSNR feature to libavcodec and ffmpeg. By now just Y PSNR until I'm
pulento
parents:
231
diff
changeset
|
162 int get_psnr; |
ddb1a0e94cf4
- Added PSNR feature to libavcodec and ffmpeg. By now just Y PSNR until I'm
pulento
parents:
231
diff
changeset
|
163 float psnr_y; |
ddb1a0e94cf4
- Added PSNR feature to libavcodec and ffmpeg. By now just Y PSNR until I'm
pulento
parents:
231
diff
changeset
|
164 float psnr_cb; |
ddb1a0e94cf4
- Added PSNR feature to libavcodec and ffmpeg. By now just Y PSNR until I'm
pulento
parents:
231
diff
changeset
|
165 float psnr_cr; |
286 | 166 |
167 /* statistics, used for 2-pass encoding */ | |
168 int mv_bits; | |
169 int header_bits; | |
170 int i_tex_bits; | |
171 int p_tex_bits; | |
172 int i_count; | |
173 int p_count; | |
174 int skip_count; | |
175 int misc_bits; // cbp, mb_type | |
176 int frame_bits; | |
162 | 177 |
0 | 178 /* the following fields are ignored */ |
67 | 179 void *opaque; /* can be used to carry app specific stuff */ |
0 | 180 char codec_name[32]; |
181 int codec_type; /* see CODEC_TYPE_xxx */ | |
182 int codec_id; /* see CODEC_ID_xxx */ | |
183 unsigned int codec_tag; /* codec tag, only used if unknown codec */ | |
184 } AVCodecContext; | |
185 | |
186 typedef struct AVCodec { | |
187 char *name; | |
188 int type; | |
189 int id; | |
190 int priv_data_size; | |
191 int (*init)(AVCodecContext *); | |
192 int (*encode)(AVCodecContext *, UINT8 *buf, int buf_size, void *data); | |
193 int (*close)(AVCodecContext *); | |
194 int (*decode)(AVCodecContext *, void *outdata, int *outdata_size, | |
195 UINT8 *buf, int buf_size); | |
67 | 196 int capabilities; |
0 | 197 struct AVCodec *next; |
198 } AVCodec; | |
199 | |
200 /* three components are given, that's all */ | |
201 typedef struct AVPicture { | |
202 UINT8 *data[3]; | |
203 int linesize[3]; | |
204 } AVPicture; | |
205 | |
206 extern AVCodec ac3_encoder; | |
207 extern AVCodec mp2_encoder; | |
260
e1bacfb3f51f
- Added MP3 encoding through libmp3lame contributed by Lennert Buytenhek.
pulento
parents:
252
diff
changeset
|
208 extern AVCodec mp3lame_encoder; |
0 | 209 extern AVCodec mpeg1video_encoder; |
210 extern AVCodec h263_encoder; | |
211 extern AVCodec h263p_encoder; | |
212 extern AVCodec rv10_encoder; | |
213 extern AVCodec mjpeg_encoder; | |
67 | 214 extern AVCodec mpeg4_encoder; |
307 | 215 extern AVCodec msmpeg4v1_encoder; |
216 extern AVCodec msmpeg4v2_encoder; | |
217 extern AVCodec msmpeg4v3_encoder; | |
0 | 218 |
219 extern AVCodec h263_decoder; | |
67 | 220 extern AVCodec mpeg4_decoder; |
307 | 221 extern AVCodec msmpeg4v1_decoder; |
222 extern AVCodec msmpeg4v2_decoder; | |
223 extern AVCodec msmpeg4v3_decoder; | |
311 | 224 extern AVCodec wmv1_decoder; |
0 | 225 extern AVCodec mpeg_decoder; |
226 extern AVCodec h263i_decoder; | |
227 extern AVCodec rv10_decoder; | |
24 | 228 extern AVCodec mjpeg_decoder; |
92 | 229 extern AVCodec mp3_decoder; |
0 | 230 |
92 | 231 /* pcm codecs */ |
232 #define PCM_CODEC(id, name) \ | |
233 extern AVCodec name ## _decoder; \ | |
234 extern AVCodec name ## _encoder; | |
235 | |
236 PCM_CODEC(CODEC_ID_PCM_S16LE, pcm_s16le); | |
237 PCM_CODEC(CODEC_ID_PCM_S16BE, pcm_s16be); | |
238 PCM_CODEC(CODEC_ID_PCM_U16LE, pcm_u16le); | |
239 PCM_CODEC(CODEC_ID_PCM_U16BE, pcm_u16be); | |
240 PCM_CODEC(CODEC_ID_PCM_S8, pcm_s8); | |
241 PCM_CODEC(CODEC_ID_PCM_U8, pcm_u8); | |
242 PCM_CODEC(CODEC_ID_PCM_ALAW, pcm_alaw); | |
243 PCM_CODEC(CODEC_ID_PCM_MULAW, pcm_mulaw); | |
244 | |
245 #undef PCM_CODEC | |
246 | |
247 /* dummy raw video codec */ | |
0 | 248 extern AVCodec rawvideo_codec; |
249 | |
250 /* the following codecs use external GPL libs */ | |
251 extern AVCodec ac3_decoder; | |
252 | |
253 /* resample.c */ | |
254 | |
255 struct ReSampleContext; | |
256 | |
257 typedef struct ReSampleContext ReSampleContext; | |
258 | |
259 ReSampleContext *audio_resample_init(int output_channels, int input_channels, | |
260 int output_rate, int input_rate); | |
261 int audio_resample(ReSampleContext *s, short *output, short *input, int nb_samples); | |
262 void audio_resample_close(ReSampleContext *s); | |
263 | |
264 /* YUV420 format is assumed ! */ | |
265 | |
266 struct ImgReSampleContext; | |
267 | |
268 typedef struct ImgReSampleContext ImgReSampleContext; | |
269 | |
270 ImgReSampleContext *img_resample_init(int output_width, int output_height, | |
271 int input_width, int input_height); | |
272 void img_resample(ImgReSampleContext *s, | |
273 AVPicture *output, AVPicture *input); | |
274 | |
275 void img_resample_close(ImgReSampleContext *s); | |
276 | |
49 | 277 void avpicture_fill(AVPicture *picture, UINT8 *ptr, |
278 int pix_fmt, int width, int height); | |
279 int avpicture_get_size(int pix_fmt, int width, int height); | |
280 | |
281 /* convert among pixel formats */ | |
282 int img_convert(AVPicture *dst, int dst_pix_fmt, | |
283 AVPicture *src, int pix_fmt, | |
284 int width, int height); | |
285 | |
286 /* deinterlace a picture */ | |
287 int avpicture_deinterlace(AVPicture *dst, AVPicture *src, | |
0 | 288 int pix_fmt, int width, int height); |
289 | |
290 /* external high level API */ | |
291 | |
292 extern AVCodec *first_avcodec; | |
293 | |
294 void avcodec_init(void); | |
295 | |
296 void register_avcodec(AVCodec *format); | |
297 AVCodec *avcodec_find_encoder(enum CodecID id); | |
177 | 298 AVCodec *avcodec_find_encoder_by_name(const char *name); |
0 | 299 AVCodec *avcodec_find_decoder(enum CodecID id); |
300 AVCodec *avcodec_find_decoder_by_name(const char *name); | |
301 void avcodec_string(char *buf, int buf_size, AVCodecContext *enc, int encode); | |
302 | |
303 int avcodec_open(AVCodecContext *avctx, AVCodec *codec); | |
304 int avcodec_decode_audio(AVCodecContext *avctx, INT16 *samples, | |
305 int *frame_size_ptr, | |
306 UINT8 *buf, int buf_size); | |
307 int avcodec_decode_video(AVCodecContext *avctx, AVPicture *picture, | |
308 int *got_picture_ptr, | |
309 UINT8 *buf, int buf_size); | |
310 int avcodec_encode_audio(AVCodecContext *avctx, UINT8 *buf, int buf_size, | |
311 const short *samples); | |
312 int avcodec_encode_video(AVCodecContext *avctx, UINT8 *buf, int buf_size, | |
313 const AVPicture *pict); | |
314 | |
315 int avcodec_close(AVCodecContext *avctx); | |
316 | |
317 void avcodec_register_all(void); | |
92 | 318 |
108
1e4a4af694d1
exporting qscale data for postprocessing (for MPlayer)
arpi_esp
parents:
92
diff
changeset
|
319 #ifdef FF_POSTPROCESS |
1e4a4af694d1
exporting qscale data for postprocessing (for MPlayer)
arpi_esp
parents:
92
diff
changeset
|
320 #ifndef MBC |
162 | 321 #define MBC 48 |
322 #define MBR 36 | |
108
1e4a4af694d1
exporting qscale data for postprocessing (for MPlayer)
arpi_esp
parents:
92
diff
changeset
|
323 #endif |
1e4a4af694d1
exporting qscale data for postprocessing (for MPlayer)
arpi_esp
parents:
92
diff
changeset
|
324 extern int quant_store[MBR+1][MBC+1]; // [Review] |
1e4a4af694d1
exporting qscale data for postprocessing (for MPlayer)
arpi_esp
parents:
92
diff
changeset
|
325 #endif |
1e4a4af694d1
exporting qscale data for postprocessing (for MPlayer)
arpi_esp
parents:
92
diff
changeset
|
326 |
92 | 327 #endif /* AVCODEC_H */ |