8 #define LIBAVFORMAT_VERSION_INT 0x000406
9 #define LIBAVFORMAT_VERSION "0.4.6"
10 #define LIBAVFORMAT_BUILD 4605
16 /* packet functions */
18 #define AV_NOPTS_VALUE 0
20 typedef struct AVPacket
{
21 int64_t pts
; /* presentation time stamp in stream units (set av_set_pts_info) */
27 void (*destruct
)(struct AVPacket
*);
30 #define PKT_FLAG_KEY 0x0001
32 static inline void av_init_packet(AVPacket
*pkt
)
34 pkt
->pts
= AV_NOPTS_VALUE
;
36 pkt
->stream_index
= 0;
39 int av_new_packet(AVPacket
*pkt
, int size
);
44 * @param pkt packet to free
46 static inline void av_free_packet(AVPacket
*pkt
)
51 /*************************************************/
52 /* fractional numbers for exact pts handling */
54 /* the exact value of the fractional number is: 'val + num / den'. num
55 is assumed to be such as 0 <= num < den */
56 typedef struct AVFrac
{
57 int64_t val
, num
, den
;
60 void av_frac_init(AVFrac
*f
, int64_t val
, int64_t num
, int64_t den
);
61 void av_frac_add(AVFrac
*f
, int64_t incr
);
62 void av_frac_set(AVFrac
*f
, int64_t val
);
64 /*************************************************/
65 /* input/output formats */
67 struct AVFormatContext
;
69 /* this structure contains the data a format has to probe a file */
70 typedef struct AVProbeData
{
76 #define AVPROBE_SCORE_MAX 100
78 typedef struct AVFormatParameters
{
85 enum PixelFormat pix_fmt
;
86 struct AVImageFormat
*image_format
;
87 int channel
; /* used to select dv channel */
88 const char *device
; /* video4linux, audio or DV device */
91 #define AVFMT_NOFILE 0x0001 /* no file should be opened */
92 #define AVFMT_NEEDNUMBER 0x0002 /* needs '%d' in filename */
93 #define AVFMT_NOHEADER 0x0004 /* signal that no header is present
94 (streams are added dynamically) */
95 #define AVFMT_SHOW_IDS 0x0008 /* show format stream IDs numbers */
96 #define AVFMT_RAWPICTURE 0x0020 /* format wants AVPicture structure for
99 typedef struct AVOutputFormat
{
101 const char *long_name
;
102 const char *mime_type
;
103 const char *extensions
; /* comma separated extensions */
104 /* size of private data so that it can be allocated in the wrapper */
107 enum CodecID audio_codec
; /* default audio codec */
108 enum CodecID video_codec
; /* default video codec */
109 int (*write_header
)(struct AVFormatContext
*);
110 /* XXX: change prototype for 64 bit pts */
111 int (*write_packet
)(struct AVFormatContext
*,
113 unsigned char *buf
, int size
, int force_pts
);
114 int (*write_trailer
)(struct AVFormatContext
*);
115 /* can use flags: AVFMT_NOFILE, AVFMT_NEEDNUMBER */
117 /* currently only used to set pixel format if not YUV420P */
118 int (*set_parameters
)(struct AVFormatContext
*, AVFormatParameters
*);
120 struct AVOutputFormat
*next
;
123 typedef struct AVInputFormat
{
125 const char *long_name
;
126 /* size of private data so that it can be allocated in the wrapper */
128 /* tell if a given file has a chance of being parsing by this format */
129 int (*read_probe
)(AVProbeData
*);
130 /* read the format header and initialize the AVFormatContext
131 structure. Return 0 if OK. 'ap' if non NULL contains
132 additionnal paramters. Only used in raw format right
133 now. 'av_new_stream' should be called to create new streams. */
134 int (*read_header
)(struct AVFormatContext
*,
135 AVFormatParameters
*ap
);
136 /* read one packet and put it in 'pkt'. pts and flags are also
137 set. 'av_new_stream' can be called only if the flag
138 AVFMT_NOHEADER is used. */
139 int (*read_packet
)(struct AVFormatContext
*, AVPacket
*pkt
);
140 /* close the stream. The AVFormatContext and AVStreams are not
141 freed by this function */
142 int (*read_close
)(struct AVFormatContext
*);
143 /* seek at or before a given pts (given in microsecond). The pts
144 origin is defined by the stream */
145 int (*read_seek
)(struct AVFormatContext
*, int64_t pts
);
146 /* can use flags: AVFMT_NOFILE, AVFMT_NEEDNUMBER, AVFMT_NOHEADER */
148 /* if extensions are defined, then no probe is done. You should
149 usually not use extension format guessing because it is not
151 const char *extensions
;
152 /* general purpose read only value that the format can use */
155 struct AVInputFormat
*next
;
158 typedef struct AVStream
{
159 int index
; /* stream index in AVFormatContext */
160 int id
; /* format specific stream id */
161 AVCodecContext codec
; /* codec context */
162 int r_frame_rate
; /* real frame rate of the stream */
163 int r_frame_rate_base
;/* real frame rate base of the stream */
164 uint64_t time_length
; /* real length of the stream in miliseconds */
166 /* internal data used in av_find_stream_info() */
167 int codec_info_state
;
168 int codec_info_nb_repeat_frames
;
169 int codec_info_nb_real_frames
;
170 /* PTS generation when outputing stream */
172 /* ffmpeg.c private use */
173 int stream_copy
; /* if TRUE, just copy stream */
174 /* quality, as it has been removed from AVCodecContext and put in AVVideoFrame
175 * MN:dunno if thats the right place, for it */
179 #define MAX_STREAMS 20
181 /* format I/O context */
182 typedef struct AVFormatContext
{
183 /* can only be iformat or oformat, not both at the same time */
184 struct AVInputFormat
*iformat
;
185 struct AVOutputFormat
*oformat
;
189 AVStream
*streams
[MAX_STREAMS
];
190 char filename
[1024]; /* input or output filename */
196 int flags
; /* format specific flags */
197 /* private data for pts handling (do not modify directly) */
198 int pts_wrap_bits
; /* number of bits in pts (used for wrapping control) */
199 int pts_num
, pts_den
; /* value to convert to seconds */
200 /* This buffer is only needed when packets were already buffered but
201 not decoded, for example to get the codec parameters in mpeg
203 struct AVPacketList
*packet_buffer
;
206 typedef struct AVPacketList
{
208 struct AVPacketList
*next
;
211 extern AVInputFormat
*first_iformat
;
212 extern AVOutputFormat
*first_oformat
;
214 /* still image support */
215 struct AVInputImageContext
;
216 typedef struct AVInputImageContext AVInputImageContext
;
218 typedef struct AVImageInfo
{
219 enum PixelFormat pix_fmt
; /* requested pixel format */
220 int width
; /* requested width */
221 int height
; /* requested height */
222 int interleaved
; /* image is interleaved (e.g. interleaved GIF) */
223 AVPicture pict
; /* returned allocated image */
226 /* AVImageFormat.flags field constants */
227 #define AVIMAGE_INTERLEAVED 0x0001 /* image format support interleaved output */
229 typedef struct AVImageFormat
{
231 const char *extensions
;
232 /* tell if a given file has a chance of being parsing by this format */
233 int (*img_probe
)(AVProbeData
*);
234 /* read a whole image. 'alloc_cb' is called when the image size is
235 known so that the caller can allocate the image. If 'allo_cb'
236 returns non zero, then the parsing is aborted. Return '0' if
238 int (*img_read
)(ByteIOContext
*,
239 int (*alloc_cb
)(void *, AVImageInfo
*info
), void *);
240 /* write the image */
241 int supported_pixel_formats
; /* mask of supported formats for output */
242 int (*img_write
)(ByteIOContext
*, AVImageInfo
*);
244 struct AVImageFormat
*next
;
247 void av_register_image_format(AVImageFormat
*img_fmt
);
248 AVImageFormat
*av_probe_image_format(AVProbeData
*pd
);
249 AVImageFormat
*guess_image_format(const char *filename
);
250 int av_read_image(ByteIOContext
*pb
, const char *filename
,
252 int (*alloc_cb
)(void *, AVImageInfo
*info
), void *opaque
);
253 int av_write_image(ByteIOContext
*pb
, AVImageFormat
*fmt
, AVImageInfo
*img
);
255 extern AVImageFormat
*first_image_format
;
257 extern AVImageFormat pnm_image_format
;
258 extern AVImageFormat pbm_image_format
;
259 extern AVImageFormat pgm_image_format
;
260 extern AVImageFormat ppm_image_format
;
261 extern AVImageFormat pam_image_format
;
262 extern AVImageFormat pgmyuv_image_format
;
263 extern AVImageFormat yuv_image_format
;
265 extern AVImageFormat png_image_format
;
267 extern AVImageFormat jpeg_image_format
;
268 extern AVImageFormat gif_image_format
;
270 /* XXX: use automatic init with either ELF sections or C file parser */
274 int mpegps_init(void);
277 extern AVInputFormat mpegts_demux
;
278 int mpegts_init(void);
293 int avienc_init(void);
296 int avidec_init(void);
332 extern AVInputFormat redir_demux
;
333 int redir_open(AVFormatContext
**ic_ptr
, ByteIOContext
*f
);
336 int fourxm_init(void);
343 extern AVOutputFormat yuv4mpegpipe_oformat
;
346 void av_register_input_format(AVInputFormat
*format
);
347 void av_register_output_format(AVOutputFormat
*format
);
348 AVOutputFormat
*guess_stream_format(const char *short_name
,
349 const char *filename
, const char *mime_type
);
350 AVOutputFormat
*guess_format(const char *short_name
,
351 const char *filename
, const char *mime_type
);
353 void av_hex_dump(uint8_t *buf
, int size
);
355 void av_register_all(void);
357 typedef struct FifoBuffer
{
359 uint8_t *rptr
, *wptr
, *end
;
362 int fifo_init(FifoBuffer
*f
, int size
);
363 void fifo_free(FifoBuffer
*f
);
364 int fifo_size(FifoBuffer
*f
, uint8_t *rptr
);
365 int fifo_read(FifoBuffer
*f
, uint8_t *buf
, int buf_size
, uint8_t **rptr_ptr
);
366 void fifo_write(FifoBuffer
*f
, uint8_t *buf
, int size
, uint8_t **wptr_ptr
);
368 /* media file input */
369 AVInputFormat
*av_find_input_format(const char *short_name
);
370 AVInputFormat
*av_probe_input_format(AVProbeData
*pd
, int is_opened
);
371 int av_open_input_file(AVFormatContext
**ic_ptr
, const char *filename
,
374 AVFormatParameters
*ap
);
376 #define AVERROR_UNKNOWN (-1) /* unknown error */
377 #define AVERROR_IO (-2) /* i/o error */
378 #define AVERROR_NUMEXPECTED (-3) /* number syntax expected in filename */
379 #define AVERROR_INVALIDDATA (-4) /* invalid data found */
380 #define AVERROR_NOMEM (-5) /* not enough memory */
381 #define AVERROR_NOFMT (-6) /* unknown format */
383 int av_find_stream_info(AVFormatContext
*ic
);
384 int av_read_packet(AVFormatContext
*s
, AVPacket
*pkt
);
385 void av_close_input_file(AVFormatContext
*s
);
386 AVStream
*av_new_stream(AVFormatContext
*s
, int id
);
387 void av_set_pts_info(AVFormatContext
*s
, int pts_wrap_bits
,
388 int pts_num
, int pts_den
);
390 /* media file output */
391 int av_set_parameters(AVFormatContext
*s
, AVFormatParameters
*ap
);
392 int av_write_header(AVFormatContext
*s
);
393 int av_write_frame(AVFormatContext
*s
, int stream_index
, const uint8_t *buf
,
395 int av_write_trailer(AVFormatContext
*s
);
397 void dump_format(AVFormatContext
*ic
,
401 int parse_image_size(int *width_ptr
, int *height_ptr
, const char *str
);
402 int64_t parse_date(const char *datestr
, int duration
);
404 int64_t av_gettime(void);
406 /* ffm specific for ffserver */
407 #define FFM_PACKET_SIZE 4096
408 offset_t
ffm_read_write_index(int fd
);
409 void ffm_write_write_index(int fd
, offset_t pos
);
410 void ffm_set_write_index(AVFormatContext
*s
, offset_t pos
, offset_t file_size
);
412 int find_info_tag(char *arg
, int arg_size
, const char *tag1
, const char *info
);
414 int get_frame_filename(char *buf
, int buf_size
,
415 const char *path
, int number
);
416 int filename_number_test(const char *filename
);
419 int video_grab_init(void);
420 int audio_init(void);
423 int dv1394_init(void);
425 #ifdef HAVE_AV_CONFIG_H
426 int strstart(const char *str
, const char *val
, const char **ptr
);
427 int stristart(const char *str
, const char *val
, const char **ptr
);
428 void pstrcpy(char *buf
, int buf_size
, const char *str
);
429 char *pstrcat(char *buf
, int buf_size
, const char *s
);
432 int resolve_host(struct in_addr
*sin_addr
, const char *hostname
);
434 void url_split(char *proto
, int proto_size
,
435 char *hostname
, int hostname_size
,
437 char *path
, int path_size
,
440 int match_ext(const char *filename
, const char *extensions
);
442 #endif /* HAVE_AV_CONFIG_H */
448 #endif /* AVFORMAT_H */