4 #define LIBAVFORMAT_VERSION_INT 0x000406
5 #define LIBAVFORMAT_VERSION "0.4.6"
6 #define LIBAVFORMAT_BUILD 4603
12 /* packet functions */
14 #define AV_NOPTS_VALUE 0
16 typedef struct AVPacket
{
17 INT64 pts
; /* presentation time stamp in stream units (set av_set_pts_info) */
23 #define PKT_FLAG_KEY 0x0001
26 int av_new_packet(AVPacket
*pkt
, int size
);
27 void av_free_packet(AVPacket
*pkt
);
29 /*************************************************/
30 /* fractional numbers for exact pts handling */
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
{
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
);
42 /*************************************************/
43 /* input/output formats */
45 struct AVFormatContext
;
47 /* this structure contains the data a format has to probe a file */
48 typedef struct AVProbeData
{
54 #define AVPROBE_SCORE_MAX 100
56 typedef struct AVFormatParameters
{
62 enum PixelFormat pix_fmt
;
63 struct AVImageFormat
*image_format
;
66 #define AVFMT_NOFILE 0x0001 /* no file should be opened */
67 #define AVFMT_NEEDNUMBER 0x0002 /* needs '%d' in filename */
68 #define AVFMT_NOHEADER 0x0004 /* signal that no header is present
69 (streams are added dynamically) */
70 #define AVFMT_SHOW_IDS 0x0008 /* show format stream IDs numbers */
71 #define AVFMT_RAWPICTURE 0x0020 /* format wants AVPicture structure for
74 typedef struct AVOutputFormat
{
76 const char *long_name
;
77 const char *mime_type
;
78 const char *extensions
; /* comma separated extensions */
79 /* size of private data so that it can be allocated in the wrapper */
82 enum CodecID audio_codec
; /* default audio codec */
83 enum CodecID video_codec
; /* default video codec */
84 int (*write_header
)(struct AVFormatContext
*);
85 /* XXX: change prototype for 64 bit pts */
86 int (*write_packet
)(struct AVFormatContext
*,
88 unsigned char *buf
, int size
, int force_pts
);
89 int (*write_trailer
)(struct AVFormatContext
*);
90 /* can use flags: AVFMT_NOFILE, AVFMT_NEEDNUMBER */
92 /* currently only used to set pixel format if not YUV420P */
93 int (*set_parameters
)(struct AVFormatContext
*, AVFormatParameters
*);
95 struct AVOutputFormat
*next
;
98 typedef struct AVInputFormat
{
100 const char *long_name
;
101 /* size of private data so that it can be allocated in the wrapper */
103 /* tell if a given file has a chance of being parsing by this format */
104 int (*read_probe
)(AVProbeData
*);
105 /* read the format header and initialize the AVFormatContext
106 structure. Return 0 if OK. 'ap' if non NULL contains
107 additionnal paramters. Only used in raw format right
108 now. 'av_new_stream' should be called to create new streams. */
109 int (*read_header
)(struct AVFormatContext
*,
110 AVFormatParameters
*ap
);
111 /* read one packet and put it in 'pkt'. pts and flags are also
112 set. 'av_new_stream' can be called only if the flag
113 AVFMT_NOHEADER is used. */
114 int (*read_packet
)(struct AVFormatContext
*, AVPacket
*pkt
);
115 /* close the stream. The AVFormatContext and AVStreams are not
116 freed by this function */
117 int (*read_close
)(struct AVFormatContext
*);
118 /* seek at or before a given pts (given in microsecond). The pts
119 origin is defined by the stream */
120 int (*read_seek
)(struct AVFormatContext
*, INT64 pts
);
121 /* can use flags: AVFMT_NOFILE, AVFMT_NEEDNUMBER, AVFMT_NOHEADER */
123 /* if extensions are defined, then no probe is done. You should
124 usually not use extension format guessing because it is not
126 const char *extensions
;
127 /* general purpose read only value that the format can use */
130 struct AVInputFormat
*next
;
133 typedef struct AVStream
{
134 int index
; /* stream index in AVFormatContext */
135 int id
; /* format specific stream id */
136 AVCodecContext codec
; /* codec context */
137 int r_frame_rate
; /* real frame rate of the stream */
138 uint64_t time_length
; /* real length of the stream in miliseconds */
140 /* internal data used in av_find_stream_info() */
141 int codec_info_state
;
142 int codec_info_nb_repeat_frames
;
143 int codec_info_nb_real_frames
;
144 /* PTS generation when outputing stream */
146 /* ffmpeg.c private use */
147 int stream_copy
; /* if TRUE, just copy stream */
148 /* quality, as it has been removed from AVCodecContext and put in AVVideoFrame
149 * MN:dunno if thats the right place, for it */
153 #define MAX_STREAMS 20
155 /* format I/O context */
156 typedef struct AVFormatContext
{
157 /* can only be iformat or oformat, not both at the same time */
158 struct AVInputFormat
*iformat
;
159 struct AVOutputFormat
*oformat
;
163 AVStream
*streams
[MAX_STREAMS
];
164 char filename
[1024]; /* input or output filename */
170 int flags
; /* format specific flags */
171 /* private data for pts handling (do not modify directly) */
172 int pts_wrap_bits
; /* number of bits in pts (used for wrapping control) */
173 int pts_num
, pts_den
; /* value to convert to seconds */
174 /* This buffer is only needed when packets were already buffered but
175 not decoded, for example to get the codec parameters in mpeg
177 struct AVPacketList
*packet_buffer
;
180 typedef struct AVPacketList
{
182 struct AVPacketList
*next
;
185 extern AVInputFormat
*first_iformat
;
186 extern AVOutputFormat
*first_oformat
;
188 /* still image support */
189 struct AVInputImageContext
;
190 typedef struct AVInputImageContext AVInputImageContext
;
192 typedef struct AVImageInfo
{
193 enum PixelFormat pix_fmt
; /* requested pixel format */
194 int width
; /* requested width */
195 int height
; /* requested height */
196 AVPicture pict
; /* returned allocated image */
199 typedef struct AVImageFormat
{
201 const char *extensions
;
202 /* tell if a given file has a chance of being parsing by this format */
203 int (*img_probe
)(AVProbeData
*);
204 /* read a whole image. 'alloc_cb' is called when the image size is
205 known so that the caller can allocate the image. If 'allo_cb'
206 returns non zero, then the parsing is aborted. Return '0' if
208 int (*img_read
)(ByteIOContext
*,
209 int (*alloc_cb
)(void *, AVImageInfo
*info
), void *);
210 /* write the image */
211 int supported_pixel_formats
; /* mask of supported formats for output */
212 int (*img_write
)(ByteIOContext
*, AVImageInfo
*);
213 struct AVImageFormat
*next
;
216 void av_register_image_format(AVImageFormat
*img_fmt
);
217 AVImageFormat
*av_probe_image_format(AVProbeData
*pd
);
218 AVImageFormat
*guess_image_format(const char *filename
);
219 int av_read_image(ByteIOContext
*pb
, const char *filename
,
221 int (*alloc_cb
)(void *, AVImageInfo
*info
), void *opaque
);
222 int av_write_image(ByteIOContext
*pb
, AVImageFormat
*fmt
, AVImageInfo
*img
);
224 extern AVImageFormat
*first_image_format
;
226 extern AVImageFormat pnm_image_format
;
227 extern AVImageFormat pbm_image_format
;
228 extern AVImageFormat pgm_image_format
;
229 extern AVImageFormat ppm_image_format
;
230 extern AVImageFormat pgmyuv_image_format
;
231 extern AVImageFormat yuv_image_format
;
233 /* XXX: use automatic init with either ELF sections or C file parser */
237 int mpegps_init(void);
240 extern AVInputFormat mpegts_demux
;
241 int mpegts_init(void);
256 int avienc_init(void);
259 int avidec_init(void);
292 extern AVInputFormat redir_demux
;
293 int redir_open(AVFormatContext
**ic_ptr
, ByteIOContext
*f
);
300 extern AVOutputFormat yuv4mpegpipe_oformat
;
303 #define MKTAG(a,b,c,d) (a | (b << 8) | (c << 16) | (d << 24))
304 #define MKBETAG(a,b,c,d) (d | (c << 8) | (b << 16) | (a << 24))
306 void av_register_input_format(AVInputFormat
*format
);
307 void av_register_output_format(AVOutputFormat
*format
);
308 AVOutputFormat
*guess_stream_format(const char *short_name
,
309 const char *filename
, const char *mime_type
);
310 AVOutputFormat
*guess_format(const char *short_name
,
311 const char *filename
, const char *mime_type
);
313 void av_hex_dump(UINT8
*buf
, int size
);
315 void av_register_all(void);
317 typedef struct FifoBuffer
{
319 UINT8
*rptr
, *wptr
, *end
;
322 int fifo_init(FifoBuffer
*f
, int size
);
323 void fifo_free(FifoBuffer
*f
);
324 int fifo_size(FifoBuffer
*f
, UINT8
*rptr
);
325 int fifo_read(FifoBuffer
*f
, UINT8
*buf
, int buf_size
, UINT8
**rptr_ptr
);
326 void fifo_write(FifoBuffer
*f
, UINT8
*buf
, int size
, UINT8
**wptr_ptr
);
328 /* media file input */
329 AVInputFormat
*av_find_input_format(const char *short_name
);
330 AVInputFormat
*av_probe_input_format(AVProbeData
*pd
, int is_opened
);
331 int av_open_input_file(AVFormatContext
**ic_ptr
, const char *filename
,
334 AVFormatParameters
*ap
);
336 #define AVERROR_UNKNOWN (-1) /* unknown error */
337 #define AVERROR_IO (-2) /* i/o error */
338 #define AVERROR_NUMEXPECTED (-3) /* number syntax expected in filename */
339 #define AVERROR_INVALIDDATA (-4) /* invalid data found */
340 #define AVERROR_NOMEM (-5) /* not enough memory */
341 #define AVERROR_NOFMT (-6) /* unknown format */
343 int av_find_stream_info(AVFormatContext
*ic
);
344 int av_read_packet(AVFormatContext
*s
, AVPacket
*pkt
);
345 void av_close_input_file(AVFormatContext
*s
);
346 AVStream
*av_new_stream(AVFormatContext
*s
, int id
);
347 void av_set_pts_info(AVFormatContext
*s
, int pts_wrap_bits
,
348 int pts_num
, int pts_den
);
350 /* media file output */
351 int av_set_parameters(AVFormatContext
*s
, AVFormatParameters
*ap
);
352 int av_write_header(AVFormatContext
*s
);
353 int av_write_frame(AVFormatContext
*s
, int stream_index
, const uint8_t *buf
,
355 int av_write_trailer(AVFormatContext
*s
);
357 void dump_format(AVFormatContext
*ic
,
361 int parse_image_size(int *width_ptr
, int *height_ptr
, const char *str
);
362 INT64
parse_date(const char *datestr
, int duration
);
364 INT64
av_gettime(void);
366 /* ffm specific for ffserver */
367 #define FFM_PACKET_SIZE 4096
368 offset_t
ffm_read_write_index(int fd
);
369 void ffm_write_write_index(int fd
, offset_t pos
);
370 void ffm_set_write_index(AVFormatContext
*s
, offset_t pos
, offset_t file_size
);
372 int find_info_tag(char *arg
, int arg_size
, const char *tag1
, const char *info
);
374 int get_frame_filename(char *buf
, int buf_size
,
375 const char *path
, int number
);
376 int filename_number_test(const char *filename
);
379 int video_grab_init(void);
380 int audio_init(void);
382 extern const char *v4l_device
;
383 extern const char *audio_device
;
385 #ifdef HAVE_AV_CONFIG_H
386 int strstart(const char *str
, const char *val
, const char **ptr
);
387 int stristart(const char *str
, const char *val
, const char **ptr
);
388 void pstrcpy(char *buf
, int buf_size
, const char *str
);
389 char *pstrcat(char *buf
, int buf_size
, const char *s
);
392 int resolve_host(struct in_addr
*sin_addr
, const char *hostname
);
394 void url_split(char *proto
, int proto_size
,
395 char *hostname
, int hostname_size
,
397 char *path
, int path_size
,
400 int match_ext(const char *filename
, const char *extensions
);
402 #endif /* HAVE_AV_CONFIG_H */
404 #endif /* AVFORMAT_H */