8 #define LIBAVFORMAT_VERSION_INT 0x000406
9 #define LIBAVFORMAT_VERSION "0.4.6"
10 #define LIBAVFORMAT_BUILD 4603
16 /* packet functions */
18 #define AV_NOPTS_VALUE 0
20 typedef struct AVPacket
{
21 INT64 pts
; /* presentation time stamp in stream units (set av_set_pts_info) */
27 #define PKT_FLAG_KEY 0x0001
30 int av_new_packet(AVPacket
*pkt
, int size
);
31 void av_free_packet(AVPacket
*pkt
);
33 /*************************************************/
34 /* fractional numbers for exact pts handling */
36 /* the exact value of the fractional number is: 'val + num / den'. num
37 is assumed to be such as 0 <= num < den */
38 typedef struct AVFrac
{
42 void av_frac_init(AVFrac
*f
, INT64 val
, INT64 num
, INT64 den
);
43 void av_frac_add(AVFrac
*f
, INT64 incr
);
44 void av_frac_set(AVFrac
*f
, INT64 val
);
46 /*************************************************/
47 /* input/output formats */
49 struct AVFormatContext
;
51 /* this structure contains the data a format has to probe a file */
52 typedef struct AVProbeData
{
58 #define AVPROBE_SCORE_MAX 100
60 typedef struct AVFormatParameters
{
66 enum PixelFormat pix_fmt
;
67 struct AVImageFormat
*image_format
;
68 int channel
; /* used to select dv channel */
69 const char *device
; /* video4linux, audio or DV device */
72 #define AVFMT_NOFILE 0x0001 /* no file should be opened */
73 #define AVFMT_NEEDNUMBER 0x0002 /* needs '%d' in filename */
74 #define AVFMT_NOHEADER 0x0004 /* signal that no header is present
75 (streams are added dynamically) */
76 #define AVFMT_SHOW_IDS 0x0008 /* show format stream IDs numbers */
77 #define AVFMT_RAWPICTURE 0x0020 /* format wants AVPicture structure for
80 typedef struct AVOutputFormat
{
82 const char *long_name
;
83 const char *mime_type
;
84 const char *extensions
; /* comma separated extensions */
85 /* size of private data so that it can be allocated in the wrapper */
88 enum CodecID audio_codec
; /* default audio codec */
89 enum CodecID video_codec
; /* default video codec */
90 int (*write_header
)(struct AVFormatContext
*);
91 /* XXX: change prototype for 64 bit pts */
92 int (*write_packet
)(struct AVFormatContext
*,
94 unsigned char *buf
, int size
, int force_pts
);
95 int (*write_trailer
)(struct AVFormatContext
*);
96 /* can use flags: AVFMT_NOFILE, AVFMT_NEEDNUMBER */
98 /* currently only used to set pixel format if not YUV420P */
99 int (*set_parameters
)(struct AVFormatContext
*, AVFormatParameters
*);
101 struct AVOutputFormat
*next
;
104 typedef struct AVInputFormat
{
106 const char *long_name
;
107 /* size of private data so that it can be allocated in the wrapper */
109 /* tell if a given file has a chance of being parsing by this format */
110 int (*read_probe
)(AVProbeData
*);
111 /* read the format header and initialize the AVFormatContext
112 structure. Return 0 if OK. 'ap' if non NULL contains
113 additionnal paramters. Only used in raw format right
114 now. 'av_new_stream' should be called to create new streams. */
115 int (*read_header
)(struct AVFormatContext
*,
116 AVFormatParameters
*ap
);
117 /* read one packet and put it in 'pkt'. pts and flags are also
118 set. 'av_new_stream' can be called only if the flag
119 AVFMT_NOHEADER is used. */
120 int (*read_packet
)(struct AVFormatContext
*, AVPacket
*pkt
);
121 /* close the stream. The AVFormatContext and AVStreams are not
122 freed by this function */
123 int (*read_close
)(struct AVFormatContext
*);
124 /* seek at or before a given pts (given in microsecond). The pts
125 origin is defined by the stream */
126 int (*read_seek
)(struct AVFormatContext
*, INT64 pts
);
127 /* can use flags: AVFMT_NOFILE, AVFMT_NEEDNUMBER, AVFMT_NOHEADER */
129 /* if extensions are defined, then no probe is done. You should
130 usually not use extension format guessing because it is not
132 const char *extensions
;
133 /* general purpose read only value that the format can use */
136 struct AVInputFormat
*next
;
139 typedef struct AVStream
{
140 int index
; /* stream index in AVFormatContext */
141 int id
; /* format specific stream id */
142 AVCodecContext codec
; /* codec context */
143 int r_frame_rate
; /* real frame rate of the stream */
144 uint64_t time_length
; /* real length of the stream in miliseconds */
146 /* internal data used in av_find_stream_info() */
147 int codec_info_state
;
148 int codec_info_nb_repeat_frames
;
149 int codec_info_nb_real_frames
;
150 /* PTS generation when outputing stream */
152 /* ffmpeg.c private use */
153 int stream_copy
; /* if TRUE, just copy stream */
154 /* quality, as it has been removed from AVCodecContext and put in AVVideoFrame
155 * MN:dunno if thats the right place, for it */
159 #define MAX_STREAMS 20
161 /* format I/O context */
162 typedef struct AVFormatContext
{
163 /* can only be iformat or oformat, not both at the same time */
164 struct AVInputFormat
*iformat
;
165 struct AVOutputFormat
*oformat
;
169 AVStream
*streams
[MAX_STREAMS
];
170 char filename
[1024]; /* input or output filename */
176 int flags
; /* format specific flags */
177 /* private data for pts handling (do not modify directly) */
178 int pts_wrap_bits
; /* number of bits in pts (used for wrapping control) */
179 int pts_num
, pts_den
; /* value to convert to seconds */
180 /* This buffer is only needed when packets were already buffered but
181 not decoded, for example to get the codec parameters in mpeg
183 struct AVPacketList
*packet_buffer
;
186 typedef struct AVPacketList
{
188 struct AVPacketList
*next
;
191 extern AVInputFormat
*first_iformat
;
192 extern AVOutputFormat
*first_oformat
;
194 /* still image support */
195 struct AVInputImageContext
;
196 typedef struct AVInputImageContext AVInputImageContext
;
198 typedef struct AVImageInfo
{
199 enum PixelFormat pix_fmt
; /* requested pixel format */
200 int width
; /* requested width */
201 int height
; /* requested height */
202 AVPicture pict
; /* returned allocated image */
205 typedef struct AVImageFormat
{
207 const char *extensions
;
208 /* tell if a given file has a chance of being parsing by this format */
209 int (*img_probe
)(AVProbeData
*);
210 /* read a whole image. 'alloc_cb' is called when the image size is
211 known so that the caller can allocate the image. If 'allo_cb'
212 returns non zero, then the parsing is aborted. Return '0' if
214 int (*img_read
)(ByteIOContext
*,
215 int (*alloc_cb
)(void *, AVImageInfo
*info
), void *);
216 /* write the image */
217 int supported_pixel_formats
; /* mask of supported formats for output */
218 int (*img_write
)(ByteIOContext
*, AVImageInfo
*);
219 struct AVImageFormat
*next
;
222 void av_register_image_format(AVImageFormat
*img_fmt
);
223 AVImageFormat
*av_probe_image_format(AVProbeData
*pd
);
224 AVImageFormat
*guess_image_format(const char *filename
);
225 int av_read_image(ByteIOContext
*pb
, const char *filename
,
227 int (*alloc_cb
)(void *, AVImageInfo
*info
), void *opaque
);
228 int av_write_image(ByteIOContext
*pb
, AVImageFormat
*fmt
, AVImageInfo
*img
);
230 extern AVImageFormat
*first_image_format
;
232 extern AVImageFormat pnm_image_format
;
233 extern AVImageFormat pbm_image_format
;
234 extern AVImageFormat pgm_image_format
;
235 extern AVImageFormat ppm_image_format
;
236 extern AVImageFormat pgmyuv_image_format
;
237 extern AVImageFormat yuv_image_format
;
238 extern AVImageFormat png_image_format
;
240 /* XXX: use automatic init with either ELF sections or C file parser */
244 int mpegps_init(void);
247 extern AVInputFormat mpegts_demux
;
248 int mpegts_init(void);
263 int avienc_init(void);
266 int avidec_init(void);
299 extern AVInputFormat redir_demux
;
300 int redir_open(AVFormatContext
**ic_ptr
, ByteIOContext
*f
);
307 extern AVOutputFormat yuv4mpegpipe_oformat
;
310 #define MKTAG(a,b,c,d) (a | (b << 8) | (c << 16) | (d << 24))
311 #define MKBETAG(a,b,c,d) (d | (c << 8) | (b << 16) | (a << 24))
313 void av_register_input_format(AVInputFormat
*format
);
314 void av_register_output_format(AVOutputFormat
*format
);
315 AVOutputFormat
*guess_stream_format(const char *short_name
,
316 const char *filename
, const char *mime_type
);
317 AVOutputFormat
*guess_format(const char *short_name
,
318 const char *filename
, const char *mime_type
);
320 void av_hex_dump(UINT8
*buf
, int size
);
322 void av_register_all(void);
324 typedef struct FifoBuffer
{
326 UINT8
*rptr
, *wptr
, *end
;
329 int fifo_init(FifoBuffer
*f
, int size
);
330 void fifo_free(FifoBuffer
*f
);
331 int fifo_size(FifoBuffer
*f
, UINT8
*rptr
);
332 int fifo_read(FifoBuffer
*f
, UINT8
*buf
, int buf_size
, UINT8
**rptr_ptr
);
333 void fifo_write(FifoBuffer
*f
, UINT8
*buf
, int size
, UINT8
**wptr_ptr
);
335 /* media file input */
336 AVInputFormat
*av_find_input_format(const char *short_name
);
337 AVInputFormat
*av_probe_input_format(AVProbeData
*pd
, int is_opened
);
338 int av_open_input_file(AVFormatContext
**ic_ptr
, const char *filename
,
341 AVFormatParameters
*ap
);
343 #define AVERROR_UNKNOWN (-1) /* unknown error */
344 #define AVERROR_IO (-2) /* i/o error */
345 #define AVERROR_NUMEXPECTED (-3) /* number syntax expected in filename */
346 #define AVERROR_INVALIDDATA (-4) /* invalid data found */
347 #define AVERROR_NOMEM (-5) /* not enough memory */
348 #define AVERROR_NOFMT (-6) /* unknown format */
350 int av_find_stream_info(AVFormatContext
*ic
);
351 int av_read_packet(AVFormatContext
*s
, AVPacket
*pkt
);
352 void av_close_input_file(AVFormatContext
*s
);
353 AVStream
*av_new_stream(AVFormatContext
*s
, int id
);
354 void av_set_pts_info(AVFormatContext
*s
, int pts_wrap_bits
,
355 int pts_num
, int pts_den
);
357 /* media file output */
358 int av_set_parameters(AVFormatContext
*s
, AVFormatParameters
*ap
);
359 int av_write_header(AVFormatContext
*s
);
360 int av_write_frame(AVFormatContext
*s
, int stream_index
, const uint8_t *buf
,
362 int av_write_trailer(AVFormatContext
*s
);
364 void dump_format(AVFormatContext
*ic
,
368 int parse_image_size(int *width_ptr
, int *height_ptr
, const char *str
);
369 INT64
parse_date(const char *datestr
, int duration
);
371 INT64
av_gettime(void);
373 /* ffm specific for ffserver */
374 #define FFM_PACKET_SIZE 4096
375 offset_t
ffm_read_write_index(int fd
);
376 void ffm_write_write_index(int fd
, offset_t pos
);
377 void ffm_set_write_index(AVFormatContext
*s
, offset_t pos
, offset_t file_size
);
379 int find_info_tag(char *arg
, int arg_size
, const char *tag1
, const char *info
);
381 int get_frame_filename(char *buf
, int buf_size
,
382 const char *path
, int number
);
383 int filename_number_test(const char *filename
);
386 int video_grab_init(void);
387 int audio_init(void);
390 int dv1394_init(void);
392 #ifdef HAVE_AV_CONFIG_H
393 int strstart(const char *str
, const char *val
, const char **ptr
);
394 int stristart(const char *str
, const char *val
, const char **ptr
);
395 void pstrcpy(char *buf
, int buf_size
, const char *str
);
396 char *pstrcat(char *buf
, int buf_size
, const char *s
);
399 int resolve_host(struct in_addr
*sin_addr
, const char *hostname
);
401 void url_split(char *proto
, int proto_size
,
402 char *hostname
, int hostname_size
,
404 char *path
, int path_size
,
407 int match_ext(const char *filename
, const char *extensions
);
409 #endif /* HAVE_AV_CONFIG_H */
415 #endif /* AVFORMAT_H */