Mercurial > libavformat.hg
annotate avformat.h @ 30:90fd30dd68b3 libavformat
grab device is in AVFormatParameter (at least better than global variable)
author | bellard |
---|---|
date | Thu, 23 Jan 2003 10:33:16 +0000 |
parents | 86a085c19c7f |
children | d20d414473a5 |
rev | line source |
---|---|
0 | 1 #ifndef AVFORMAT_H |
2 #define AVFORMAT_H | |
3 | |
4 #define LIBAVFORMAT_VERSION_INT 0x000406 | |
5 #define LIBAVFORMAT_VERSION "0.4.6" | |
17
e1200dd82537
added simple still image format support to simplify image and imagepipe video formats
bellard
parents:
5
diff
changeset
|
6 #define LIBAVFORMAT_BUILD 4603 |
0 | 7 |
8 #include "avcodec.h" | |
9 | |
10 #include "avio.h" | |
11 | |
12 /* packet functions */ | |
13 | |
14 #define AV_NOPTS_VALUE 0 | |
15 | |
16 typedef struct AVPacket { | |
17 INT64 pts; /* presentation time stamp in stream units (set av_set_pts_info) */ | |
18 UINT8 *data; | |
19 int size; | |
20 int stream_index; | |
21 int flags; | |
22 int duration; | |
23 #define PKT_FLAG_KEY 0x0001 | |
24 } AVPacket; | |
25 | |
26 int av_new_packet(AVPacket *pkt, int size); | |
27 void av_free_packet(AVPacket *pkt); | |
28 | |
29 /*************************************************/ | |
30 /* fractional numbers for exact pts handling */ | |
31 | |
32 /* the exact value of the fractional number is: 'val + num / den'. num | |
33 is assumed to be such as 0 <= num < den */ | |
34 typedef struct AVFrac { | |
35 INT64 val, num, den; | |
36 } AVFrac; | |
37 | |
38 void av_frac_init(AVFrac *f, INT64 val, INT64 num, INT64 den); | |
39 void av_frac_add(AVFrac *f, INT64 incr); | |
40 void av_frac_set(AVFrac *f, INT64 val); | |
41 | |
42 /*************************************************/ | |
43 /* input/output formats */ | |
44 | |
45 struct AVFormatContext; | |
46 | |
47 /* this structure contains the data a format has to probe a file */ | |
48 typedef struct AVProbeData { | |
49 char *filename; | |
50 unsigned char *buf; | |
51 int buf_size; | |
52 } AVProbeData; | |
53 | |
54 #define AVPROBE_SCORE_MAX 100 | |
55 | |
56 typedef struct AVFormatParameters { | |
57 int frame_rate; | |
58 int sample_rate; | |
59 int channels; | |
60 int width; | |
61 int height; | |
62 enum PixelFormat pix_fmt; | |
17
e1200dd82537
added simple still image format support to simplify image and imagepipe video formats
bellard
parents:
5
diff
changeset
|
63 struct AVImageFormat *image_format; |
30
90fd30dd68b3
grab device is in AVFormatParameter (at least better than global variable)
bellard
parents:
29
diff
changeset
|
64 int channel; /* used to select dv channel */ |
90fd30dd68b3
grab device is in AVFormatParameter (at least better than global variable)
bellard
parents:
29
diff
changeset
|
65 const char *device; /* video4linux, audio or DV device */ |
0 | 66 } AVFormatParameters; |
67 | |
68 #define AVFMT_NOFILE 0x0001 /* no file should be opened */ | |
69 #define AVFMT_NEEDNUMBER 0x0002 /* needs '%d' in filename */ | |
70 #define AVFMT_NOHEADER 0x0004 /* signal that no header is present | |
71 (streams are added dynamically) */ | |
72 #define AVFMT_SHOW_IDS 0x0008 /* show format stream IDs numbers */ | |
73 #define AVFMT_RAWPICTURE 0x0020 /* format wants AVPicture structure for | |
74 raw picture data */ | |
75 | |
76 typedef struct AVOutputFormat { | |
77 const char *name; | |
78 const char *long_name; | |
79 const char *mime_type; | |
80 const char *extensions; /* comma separated extensions */ | |
81 /* size of private data so that it can be allocated in the wrapper */ | |
82 int priv_data_size; | |
83 /* output support */ | |
84 enum CodecID audio_codec; /* default audio codec */ | |
85 enum CodecID video_codec; /* default video codec */ | |
86 int (*write_header)(struct AVFormatContext *); | |
87 /* XXX: change prototype for 64 bit pts */ | |
88 int (*write_packet)(struct AVFormatContext *, | |
89 int stream_index, | |
90 unsigned char *buf, int size, int force_pts); | |
91 int (*write_trailer)(struct AVFormatContext *); | |
92 /* can use flags: AVFMT_NOFILE, AVFMT_NEEDNUMBER */ | |
93 int flags; | |
17
e1200dd82537
added simple still image format support to simplify image and imagepipe video formats
bellard
parents:
5
diff
changeset
|
94 /* currently only used to set pixel format if not YUV420P */ |
e1200dd82537
added simple still image format support to simplify image and imagepipe video formats
bellard
parents:
5
diff
changeset
|
95 int (*set_parameters)(struct AVFormatContext *, AVFormatParameters *); |
0 | 96 /* private fields */ |
97 struct AVOutputFormat *next; | |
98 } AVOutputFormat; | |
99 | |
100 typedef struct AVInputFormat { | |
101 const char *name; | |
102 const char *long_name; | |
103 /* size of private data so that it can be allocated in the wrapper */ | |
104 int priv_data_size; | |
105 /* tell if a given file has a chance of being parsing by this format */ | |
106 int (*read_probe)(AVProbeData *); | |
107 /* read the format header and initialize the AVFormatContext | |
108 structure. Return 0 if OK. 'ap' if non NULL contains | |
109 additionnal paramters. Only used in raw format right | |
110 now. 'av_new_stream' should be called to create new streams. */ | |
111 int (*read_header)(struct AVFormatContext *, | |
112 AVFormatParameters *ap); | |
113 /* read one packet and put it in 'pkt'. pts and flags are also | |
114 set. 'av_new_stream' can be called only if the flag | |
115 AVFMT_NOHEADER is used. */ | |
116 int (*read_packet)(struct AVFormatContext *, AVPacket *pkt); | |
117 /* close the stream. The AVFormatContext and AVStreams are not | |
118 freed by this function */ | |
119 int (*read_close)(struct AVFormatContext *); | |
120 /* seek at or before a given pts (given in microsecond). The pts | |
121 origin is defined by the stream */ | |
122 int (*read_seek)(struct AVFormatContext *, INT64 pts); | |
123 /* can use flags: AVFMT_NOFILE, AVFMT_NEEDNUMBER, AVFMT_NOHEADER */ | |
124 int flags; | |
125 /* if extensions are defined, then no probe is done. You should | |
126 usually not use extension format guessing because it is not | |
127 reliable enough */ | |
128 const char *extensions; | |
129 /* general purpose read only value that the format can use */ | |
130 int value; | |
131 /* private fields */ | |
132 struct AVInputFormat *next; | |
133 } AVInputFormat; | |
134 | |
135 typedef struct AVStream { | |
136 int index; /* stream index in AVFormatContext */ | |
137 int id; /* format specific stream id */ | |
138 AVCodecContext codec; /* codec context */ | |
139 int r_frame_rate; /* real frame rate of the stream */ | |
140 uint64_t time_length; /* real length of the stream in miliseconds */ | |
141 void *priv_data; | |
142 /* internal data used in av_find_stream_info() */ | |
143 int codec_info_state; | |
144 int codec_info_nb_repeat_frames; | |
145 int codec_info_nb_real_frames; | |
146 /* PTS generation when outputing stream */ | |
147 AVFrac pts; | |
148 /* ffmpeg.c private use */ | |
149 int stream_copy; /* if TRUE, just copy stream */ | |
5 | 150 /* quality, as it has been removed from AVCodecContext and put in AVVideoFrame |
151 * MN:dunno if thats the right place, for it */ | |
152 float quality; | |
0 | 153 } AVStream; |
154 | |
155 #define MAX_STREAMS 20 | |
156 | |
157 /* format I/O context */ | |
158 typedef struct AVFormatContext { | |
159 /* can only be iformat or oformat, not both at the same time */ | |
160 struct AVInputFormat *iformat; | |
161 struct AVOutputFormat *oformat; | |
162 void *priv_data; | |
163 ByteIOContext pb; | |
164 int nb_streams; | |
165 AVStream *streams[MAX_STREAMS]; | |
166 char filename[1024]; /* input or output filename */ | |
167 /* stream info */ | |
168 char title[512]; | |
169 char author[512]; | |
170 char copyright[512]; | |
171 char comment[512]; | |
172 int flags; /* format specific flags */ | |
173 /* private data for pts handling (do not modify directly) */ | |
174 int pts_wrap_bits; /* number of bits in pts (used for wrapping control) */ | |
175 int pts_num, pts_den; /* value to convert to seconds */ | |
176 /* This buffer is only needed when packets were already buffered but | |
177 not decoded, for example to get the codec parameters in mpeg | |
178 streams */ | |
179 struct AVPacketList *packet_buffer; | |
180 } AVFormatContext; | |
181 | |
182 typedef struct AVPacketList { | |
183 AVPacket pkt; | |
184 struct AVPacketList *next; | |
185 } AVPacketList; | |
186 | |
187 extern AVInputFormat *first_iformat; | |
188 extern AVOutputFormat *first_oformat; | |
189 | |
17
e1200dd82537
added simple still image format support to simplify image and imagepipe video formats
bellard
parents:
5
diff
changeset
|
190 /* still image support */ |
e1200dd82537
added simple still image format support to simplify image and imagepipe video formats
bellard
parents:
5
diff
changeset
|
191 struct AVInputImageContext; |
e1200dd82537
added simple still image format support to simplify image and imagepipe video formats
bellard
parents:
5
diff
changeset
|
192 typedef struct AVInputImageContext AVInputImageContext; |
e1200dd82537
added simple still image format support to simplify image and imagepipe video formats
bellard
parents:
5
diff
changeset
|
193 |
e1200dd82537
added simple still image format support to simplify image and imagepipe video formats
bellard
parents:
5
diff
changeset
|
194 typedef struct AVImageInfo { |
e1200dd82537
added simple still image format support to simplify image and imagepipe video formats
bellard
parents:
5
diff
changeset
|
195 enum PixelFormat pix_fmt; /* requested pixel format */ |
e1200dd82537
added simple still image format support to simplify image and imagepipe video formats
bellard
parents:
5
diff
changeset
|
196 int width; /* requested width */ |
e1200dd82537
added simple still image format support to simplify image and imagepipe video formats
bellard
parents:
5
diff
changeset
|
197 int height; /* requested height */ |
e1200dd82537
added simple still image format support to simplify image and imagepipe video formats
bellard
parents:
5
diff
changeset
|
198 AVPicture pict; /* returned allocated image */ |
e1200dd82537
added simple still image format support to simplify image and imagepipe video formats
bellard
parents:
5
diff
changeset
|
199 } AVImageInfo; |
e1200dd82537
added simple still image format support to simplify image and imagepipe video formats
bellard
parents:
5
diff
changeset
|
200 |
e1200dd82537
added simple still image format support to simplify image and imagepipe video formats
bellard
parents:
5
diff
changeset
|
201 typedef struct AVImageFormat { |
e1200dd82537
added simple still image format support to simplify image and imagepipe video formats
bellard
parents:
5
diff
changeset
|
202 const char *name; |
e1200dd82537
added simple still image format support to simplify image and imagepipe video formats
bellard
parents:
5
diff
changeset
|
203 const char *extensions; |
e1200dd82537
added simple still image format support to simplify image and imagepipe video formats
bellard
parents:
5
diff
changeset
|
204 /* tell if a given file has a chance of being parsing by this format */ |
e1200dd82537
added simple still image format support to simplify image and imagepipe video formats
bellard
parents:
5
diff
changeset
|
205 int (*img_probe)(AVProbeData *); |
e1200dd82537
added simple still image format support to simplify image and imagepipe video formats
bellard
parents:
5
diff
changeset
|
206 /* read a whole image. 'alloc_cb' is called when the image size is |
e1200dd82537
added simple still image format support to simplify image and imagepipe video formats
bellard
parents:
5
diff
changeset
|
207 known so that the caller can allocate the image. If 'allo_cb' |
e1200dd82537
added simple still image format support to simplify image and imagepipe video formats
bellard
parents:
5
diff
changeset
|
208 returns non zero, then the parsing is aborted. Return '0' if |
e1200dd82537
added simple still image format support to simplify image and imagepipe video formats
bellard
parents:
5
diff
changeset
|
209 OK. */ |
e1200dd82537
added simple still image format support to simplify image and imagepipe video formats
bellard
parents:
5
diff
changeset
|
210 int (*img_read)(ByteIOContext *, |
e1200dd82537
added simple still image format support to simplify image and imagepipe video formats
bellard
parents:
5
diff
changeset
|
211 int (*alloc_cb)(void *, AVImageInfo *info), void *); |
e1200dd82537
added simple still image format support to simplify image and imagepipe video formats
bellard
parents:
5
diff
changeset
|
212 /* write the image */ |
e1200dd82537
added simple still image format support to simplify image and imagepipe video formats
bellard
parents:
5
diff
changeset
|
213 int supported_pixel_formats; /* mask of supported formats for output */ |
e1200dd82537
added simple still image format support to simplify image and imagepipe video formats
bellard
parents:
5
diff
changeset
|
214 int (*img_write)(ByteIOContext *, AVImageInfo *); |
e1200dd82537
added simple still image format support to simplify image and imagepipe video formats
bellard
parents:
5
diff
changeset
|
215 struct AVImageFormat *next; |
e1200dd82537
added simple still image format support to simplify image and imagepipe video formats
bellard
parents:
5
diff
changeset
|
216 } AVImageFormat; |
e1200dd82537
added simple still image format support to simplify image and imagepipe video formats
bellard
parents:
5
diff
changeset
|
217 |
e1200dd82537
added simple still image format support to simplify image and imagepipe video formats
bellard
parents:
5
diff
changeset
|
218 void av_register_image_format(AVImageFormat *img_fmt); |
e1200dd82537
added simple still image format support to simplify image and imagepipe video formats
bellard
parents:
5
diff
changeset
|
219 AVImageFormat *av_probe_image_format(AVProbeData *pd); |
e1200dd82537
added simple still image format support to simplify image and imagepipe video formats
bellard
parents:
5
diff
changeset
|
220 AVImageFormat *guess_image_format(const char *filename); |
e1200dd82537
added simple still image format support to simplify image and imagepipe video formats
bellard
parents:
5
diff
changeset
|
221 int av_read_image(ByteIOContext *pb, const char *filename, |
e1200dd82537
added simple still image format support to simplify image and imagepipe video formats
bellard
parents:
5
diff
changeset
|
222 AVImageFormat *fmt, |
e1200dd82537
added simple still image format support to simplify image and imagepipe video formats
bellard
parents:
5
diff
changeset
|
223 int (*alloc_cb)(void *, AVImageInfo *info), void *opaque); |
e1200dd82537
added simple still image format support to simplify image and imagepipe video formats
bellard
parents:
5
diff
changeset
|
224 int av_write_image(ByteIOContext *pb, AVImageFormat *fmt, AVImageInfo *img); |
e1200dd82537
added simple still image format support to simplify image and imagepipe video formats
bellard
parents:
5
diff
changeset
|
225 |
e1200dd82537
added simple still image format support to simplify image and imagepipe video formats
bellard
parents:
5
diff
changeset
|
226 extern AVImageFormat *first_image_format; |
e1200dd82537
added simple still image format support to simplify image and imagepipe video formats
bellard
parents:
5
diff
changeset
|
227 |
e1200dd82537
added simple still image format support to simplify image and imagepipe video formats
bellard
parents:
5
diff
changeset
|
228 extern AVImageFormat pnm_image_format; |
e1200dd82537
added simple still image format support to simplify image and imagepipe video formats
bellard
parents:
5
diff
changeset
|
229 extern AVImageFormat pbm_image_format; |
e1200dd82537
added simple still image format support to simplify image and imagepipe video formats
bellard
parents:
5
diff
changeset
|
230 extern AVImageFormat pgm_image_format; |
e1200dd82537
added simple still image format support to simplify image and imagepipe video formats
bellard
parents:
5
diff
changeset
|
231 extern AVImageFormat ppm_image_format; |
e1200dd82537
added simple still image format support to simplify image and imagepipe video formats
bellard
parents:
5
diff
changeset
|
232 extern AVImageFormat pgmyuv_image_format; |
e1200dd82537
added simple still image format support to simplify image and imagepipe video formats
bellard
parents:
5
diff
changeset
|
233 extern AVImageFormat yuv_image_format; |
e1200dd82537
added simple still image format support to simplify image and imagepipe video formats
bellard
parents:
5
diff
changeset
|
234 |
0 | 235 /* XXX: use automatic init with either ELF sections or C file parser */ |
236 /* modules */ | |
237 | |
238 /* mpeg.c */ | |
239 int mpegps_init(void); | |
240 | |
241 /* mpegts.c */ | |
242 extern AVInputFormat mpegts_demux; | |
243 int mpegts_init(void); | |
244 | |
245 /* rm.c */ | |
246 int rm_init(void); | |
247 | |
248 /* crc.c */ | |
249 int crc_init(void); | |
250 | |
251 /* img.c */ | |
252 int img_init(void); | |
253 | |
254 /* asf.c */ | |
255 int asf_init(void); | |
256 | |
257 /* avienc.c */ | |
258 int avienc_init(void); | |
259 | |
260 /* avidec.c */ | |
261 int avidec_init(void); | |
262 | |
263 /* swf.c */ | |
264 int swf_init(void); | |
265 | |
266 /* mov.c */ | |
267 int mov_init(void); | |
268 | |
269 /* jpeg.c */ | |
270 int jpeg_init(void); | |
271 | |
272 /* gif.c */ | |
273 int gif_init(void); | |
274 | |
275 /* au.c */ | |
276 int au_init(void); | |
277 | |
278 /* wav.c */ | |
279 int wav_init(void); | |
280 | |
281 /* raw.c */ | |
282 int raw_init(void); | |
283 | |
284 /* ogg.c */ | |
285 int ogg_init(void); | |
286 | |
287 /* dv.c */ | |
288 int dv_init(void); | |
289 | |
290 /* ffm.c */ | |
291 int ffm_init(void); | |
292 | |
293 /* rtsp.c */ | |
294 extern AVInputFormat redir_demux; | |
295 int redir_open(AVFormatContext **ic_ptr, ByteIOContext *f); | |
296 | |
297 #include "rtp.h" | |
298 | |
299 #include "rtsp.h" | |
300 | |
17
e1200dd82537
added simple still image format support to simplify image and imagepipe video formats
bellard
parents:
5
diff
changeset
|
301 /* yuv4mpeg.c */ |
e1200dd82537
added simple still image format support to simplify image and imagepipe video formats
bellard
parents:
5
diff
changeset
|
302 extern AVOutputFormat yuv4mpegpipe_oformat; |
e1200dd82537
added simple still image format support to simplify image and imagepipe video formats
bellard
parents:
5
diff
changeset
|
303 |
0 | 304 /* utils.c */ |
305 #define MKTAG(a,b,c,d) (a | (b << 8) | (c << 16) | (d << 24)) | |
306 #define MKBETAG(a,b,c,d) (d | (c << 8) | (b << 16) | (a << 24)) | |
307 | |
308 void av_register_input_format(AVInputFormat *format); | |
309 void av_register_output_format(AVOutputFormat *format); | |
310 AVOutputFormat *guess_stream_format(const char *short_name, | |
311 const char *filename, const char *mime_type); | |
312 AVOutputFormat *guess_format(const char *short_name, | |
313 const char *filename, const char *mime_type); | |
314 | |
315 void av_hex_dump(UINT8 *buf, int size); | |
316 | |
317 void av_register_all(void); | |
318 | |
319 typedef struct FifoBuffer { | |
320 UINT8 *buffer; | |
321 UINT8 *rptr, *wptr, *end; | |
322 } FifoBuffer; | |
323 | |
324 int fifo_init(FifoBuffer *f, int size); | |
325 void fifo_free(FifoBuffer *f); | |
326 int fifo_size(FifoBuffer *f, UINT8 *rptr); | |
327 int fifo_read(FifoBuffer *f, UINT8 *buf, int buf_size, UINT8 **rptr_ptr); | |
328 void fifo_write(FifoBuffer *f, UINT8 *buf, int size, UINT8 **wptr_ptr); | |
329 | |
330 /* media file input */ | |
331 AVInputFormat *av_find_input_format(const char *short_name); | |
332 AVInputFormat *av_probe_input_format(AVProbeData *pd, int is_opened); | |
333 int av_open_input_file(AVFormatContext **ic_ptr, const char *filename, | |
334 AVInputFormat *fmt, | |
335 int buf_size, | |
336 AVFormatParameters *ap); | |
337 | |
338 #define AVERROR_UNKNOWN (-1) /* unknown error */ | |
339 #define AVERROR_IO (-2) /* i/o error */ | |
340 #define AVERROR_NUMEXPECTED (-3) /* number syntax expected in filename */ | |
341 #define AVERROR_INVALIDDATA (-4) /* invalid data found */ | |
342 #define AVERROR_NOMEM (-5) /* not enough memory */ | |
343 #define AVERROR_NOFMT (-6) /* unknown format */ | |
344 | |
345 int av_find_stream_info(AVFormatContext *ic); | |
346 int av_read_packet(AVFormatContext *s, AVPacket *pkt); | |
347 void av_close_input_file(AVFormatContext *s); | |
348 AVStream *av_new_stream(AVFormatContext *s, int id); | |
349 void av_set_pts_info(AVFormatContext *s, int pts_wrap_bits, | |
350 int pts_num, int pts_den); | |
351 | |
352 /* media file output */ | |
17
e1200dd82537
added simple still image format support to simplify image and imagepipe video formats
bellard
parents:
5
diff
changeset
|
353 int av_set_parameters(AVFormatContext *s, AVFormatParameters *ap); |
0 | 354 int av_write_header(AVFormatContext *s); |
355 int av_write_frame(AVFormatContext *s, int stream_index, const uint8_t *buf, | |
356 int size); | |
357 int av_write_trailer(AVFormatContext *s); | |
358 | |
359 void dump_format(AVFormatContext *ic, | |
360 int index, | |
361 const char *url, | |
362 int is_output); | |
363 int parse_image_size(int *width_ptr, int *height_ptr, const char *str); | |
364 INT64 parse_date(const char *datestr, int duration); | |
365 | |
366 INT64 av_gettime(void); | |
367 | |
368 /* ffm specific for ffserver */ | |
369 #define FFM_PACKET_SIZE 4096 | |
370 offset_t ffm_read_write_index(int fd); | |
371 void ffm_write_write_index(int fd, offset_t pos); | |
372 void ffm_set_write_index(AVFormatContext *s, offset_t pos, offset_t file_size); | |
373 | |
374 int find_info_tag(char *arg, int arg_size, const char *tag1, const char *info); | |
375 | |
376 int get_frame_filename(char *buf, int buf_size, | |
377 const char *path, int number); | |
378 int filename_number_test(const char *filename); | |
379 | |
380 /* grab specific */ | |
381 int video_grab_init(void); | |
382 int audio_init(void); | |
383 | |
29 | 384 /* DV1394 */ |
385 int dv1394_init(void); | |
0 | 386 |
387 #ifdef HAVE_AV_CONFIG_H | |
388 int strstart(const char *str, const char *val, const char **ptr); | |
389 int stristart(const char *str, const char *val, const char **ptr); | |
390 void pstrcpy(char *buf, int buf_size, const char *str); | |
391 char *pstrcat(char *buf, int buf_size, const char *s); | |
392 | |
393 struct in_addr; | |
394 int resolve_host(struct in_addr *sin_addr, const char *hostname); | |
395 | |
396 void url_split(char *proto, int proto_size, | |
397 char *hostname, int hostname_size, | |
398 int *port_ptr, | |
399 char *path, int path_size, | |
400 const char *url); | |
401 | |
402 int match_ext(const char *filename, const char *extensions); | |
403 | |
404 #endif /* HAVE_AV_CONFIG_H */ | |
405 | |
406 #endif /* AVFORMAT_H */ |