2 #define LIBAV_VERSION_INT 0x000406
3 #define LIBAV_VERSION "0.4.6"
4 #define LIBAV_BUILD 4601
10 /* packet functions */
12 typedef struct AVPacket
{
19 #define PKT_FLAG_KEY 0x0001
20 #define PKT_FLAG_DROPPED_FRAME 0x0002
23 int av_new_packet(AVPacket
*pkt
, int size
);
24 void av_free_packet(AVPacket
*pkt
);
26 /*************************************************/
27 /* input/output formats */
29 struct AVFormatContext
;
31 /* this structure contains the data a format has to probe a file */
32 typedef struct AVProbeData
{
38 #define AVPROBE_SCORE_MAX 100
40 typedef struct AVFormatParameters
{
46 enum PixelFormat pix_fmt
;
49 #define AVFMT_NOFILE 0x0001 /* no file should be opened */
50 #define AVFMT_NEEDNUMBER 0x0002 /* needs '%d' in filename */
51 #define AVFMT_NOHEADER 0x0004 /* signal that no header is present
52 (streams are added dynamically) */
53 #define AVFMT_SHOW_IDS 0x0008 /* show format stream IDs numbers */
54 #define AVFMT_RGB24 0x0010 /* force RGB24 output for ppm (hack
57 typedef struct AVOutputFormat
{
59 const char *long_name
;
60 const char *mime_type
;
61 const char *extensions
; /* comma separated extensions */
62 /* size of private data so that it can be allocated in the wrapper */
65 enum CodecID audio_codec
; /* default audio codec */
66 enum CodecID video_codec
; /* default video codec */
67 int (*write_header
)(struct AVFormatContext
*);
68 int (*write_packet
)(struct AVFormatContext
*,
70 unsigned char *buf
, int size
, int force_pts
);
71 int (*write_trailer
)(struct AVFormatContext
*);
72 /* can use flags: AVFMT_NOFILE, AVFMT_NEEDNUMBER */
75 struct AVOutputFormat
*next
;
78 typedef struct AVInputFormat
{
80 const char *long_name
;
81 /* size of private data so that it can be allocated in the wrapper */
83 /* tell if a given file has a chance of being parsing by this format */
84 int (*read_probe
)(AVProbeData
*);
85 /* read the format header and initialize the AVFormatContext
86 structure. Return 0 if OK. 'ap' if non NULL contains
87 additionnal paramters. Only used in raw format right
88 now. 'av_new_stream' should be called to create new streams. */
89 int (*read_header
)(struct AVFormatContext
*,
90 AVFormatParameters
*ap
);
91 /* read one packet and put it in 'pkt'. pts and flags are also
92 set. 'av_new_stream' can be called only if the flag
93 AVFMT_NOHEADER is used. */
94 int (*read_packet
)(struct AVFormatContext
*, AVPacket
*pkt
);
95 /* close the stream. The AVFormatContext and AVStreams are not
96 freed by this function */
97 int (*read_close
)(struct AVFormatContext
*);
98 /* seek at or before a given pts (given in microsecond). The pts
99 origin is defined by the stream */
100 int (*read_seek
)(struct AVFormatContext
*, INT64 pts
);
101 /* can use flags: AVFMT_NOFILE, AVFMT_NEEDNUMBER, AVFMT_NOHEADER */
103 /* if extensions are defined, then no probe is done. You should
104 usually not use extension format guessing because it is not
106 const char *extensions
;
107 /* general purpose read only value that the format can use */
110 struct AVInputFormat
*next
;
113 typedef struct AVStream
{
114 int index
; /* stream index in AVFormatContext */
115 int id
; /* format specific stream id */
116 AVCodecContext codec
; /* codec context */
117 int r_frame_rate
; /* real frame rate of the stream */
119 /* internal data used in av_find_stream_info() */
120 int codec_info_state
;
121 int codec_info_nb_repeat_frames
;
122 int codec_info_nb_real_frames
;
125 #define MAX_STREAMS 20
127 /* format I/O context */
128 typedef struct AVFormatContext
{
129 /* can only be iformat or oformat, not both at the same time */
130 struct AVInputFormat
*iformat
;
131 struct AVOutputFormat
*oformat
;
135 AVStream
*streams
[MAX_STREAMS
];
136 char filename
[1024]; /* input or output filename */
142 int flags
; /* format specific flags */
143 /* This buffer is only needed when packets were already buffered but
144 not decoded, for example to get the codec parameters in mpeg
146 struct AVPacketList
*packet_buffer
;
149 typedef struct AVPacketList
{
151 struct AVPacketList
*next
;
154 extern AVInputFormat
*first_iformat
;
155 extern AVOutputFormat
*first_oformat
;
157 /* XXX: use automatic init with either ELF sections or C file parser */
161 #define AVF_FLAG_VCD 0x00000001 /* VCD compatible MPEG-PS */
162 int mpegps_init(void);
165 extern AVInputFormat mpegts_demux
;
166 int mpegts_init(void);
181 int avienc_init(void);
184 int avidec_init(void);
211 #define MKTAG(a,b,c,d) (a | (b << 8) | (c << 16) | (d << 24))
212 #define MKBETAG(a,b,c,d) (d | (c << 8) | (b << 16) | (a << 24))
214 void av_register_input_format(AVInputFormat
*format
);
215 void av_register_output_format(AVOutputFormat
*format
);
216 AVOutputFormat
*guess_format(const char *short_name
,
217 const char *filename
, const char *mime_type
);
219 int strstart(const char *str
, const char *val
, const char **ptr
);
220 void pstrcpy(char *buf
, int buf_size
, const char *str
);
222 int match_ext(const char *filename
, const char *extensions
);
223 void av_hex_dump(UINT8
*buf
, int size
);
225 void register_all(void);
229 typedef struct FifoBuffer
{
231 UINT8
*rptr
, *wptr
, *end
;
234 int fifo_init(FifoBuffer
*f
, int size
);
235 void fifo_free(FifoBuffer
*f
);
236 int fifo_size(FifoBuffer
*f
, UINT8
*rptr
);
237 int fifo_read(FifoBuffer
*f
, UINT8
*buf
, int buf_size
, UINT8
**rptr_ptr
);
238 void fifo_write(FifoBuffer
*f
, UINT8
*buf
, int size
, UINT8
**wptr_ptr
);
240 /* media file input */
241 AVInputFormat
*av_find_input_format(const char *short_name
);
242 int av_open_input_file(AVFormatContext
**ic_ptr
, const char *filename
,
245 AVFormatParameters
*ap
);
247 #define AVERROR_UNKNOWN (-1) /* unknown error */
248 #define AVERROR_IO (-2) /* i/o error */
249 #define AVERROR_NUMEXPECTED (-3) /* number syntax expected in filename */
250 #define AVERROR_INVALIDDATA (-4) /* invalid data found */
251 #define AVERROR_NOMEM (-5) /* not enough memory */
252 #define AVERROR_NOFMT (-6) /* unknown format */
254 int av_find_stream_info(AVFormatContext
*ic
);
255 int av_read_packet(AVFormatContext
*s
, AVPacket
*pkt
);
256 void av_close_input_file(AVFormatContext
*s
);
257 AVStream
*av_new_stream(AVFormatContext
*s
, int id
);
259 /* media file output */
260 int av_write_header(AVFormatContext
*s
);
261 int av_write_packet(AVFormatContext
*s
, AVPacket
*pkt
, int force_pts
);
262 int av_write_trailer(AVFormatContext
*s
);
264 void dump_format(AVFormatContext
*ic
,
268 int parse_image_size(int *width_ptr
, int *height_ptr
, const char *str
);
269 INT64
parse_date(const char *datestr
, int duration
);
271 /* ffm specific for ffserver */
272 #define FFM_PACKET_SIZE 4096
273 offset_t
ffm_read_write_index(int fd
);
274 void ffm_write_write_index(int fd
, offset_t pos
);
275 void ffm_set_write_index(AVFormatContext
*s
, offset_t pos
, offset_t file_size
);
277 int find_info_tag(char *arg
, int arg_size
, const char *tag1
, const char *info
);
279 int get_frame_filename(char *buf
, int buf_size
,
280 const char *path
, int number
);
281 int filename_number_test(const char *filename
);
284 int video_grab_init(void);
285 int audio_init(void);
287 extern const char *v4l_device
;
288 extern const char *audio_device
;