8 typedef struct AVPacket {
14 #define PKT_FLAG_KEY 0x0001
15 #define PKT_FLAG_DROPPED_FRAME 0x0002
18 int av_new_packet(AVPacket *pkt, int size);
19 void av_free_packet(AVPacket *pkt);
21 /*************************************************/
24 struct AVFormatContext;
25 struct AVFormatInputContext;
27 typedef struct AVFormatParameters {
33 enum PixelFormat pix_fmt;
36 typedef struct AVFormat {
38 const char *long_name;
39 const char *mime_type;
40 const char *extensions; /* comma separated extensions */
43 enum CodecID audio_codec; /* default audio codec */
44 enum CodecID video_codec; /* default video codec */
45 int (*write_header)(struct AVFormatContext *);
46 int (*write_packet)(struct AVFormatContext *,
48 unsigned char *buf, int size, int force_pts);
49 int (*write_trailer)(struct AVFormatContext *);
51 /* optional input support */
52 /* read the format header and initialize the AVFormatInputContext
53 structure. Return 0 if OK. 'ap' if non NULL contains
54 additionnal paramters. Only used in raw format right now */
55 int (*read_header)(struct AVFormatContext *,
56 AVFormatParameters *ap);
57 /* read one packet and put it in 'pkt'. pts and flags are also set */
58 int (*read_packet)(struct AVFormatContext *, AVPacket *pkt);
59 /* close the stream. The AVFormatContext and AVStreams are not
60 freed by this function */
61 int (*read_close)(struct AVFormatContext *);
62 /* seek at or before a given pts (given in microsecond). The pts
63 origin is defined by the stream */
64 int (*read_seek)(struct AVFormatContext *, INT64 pts);
66 #define AVFMT_NOFILE 0x0001 /* no file should be opened */
67 #define AVFMT_NEEDNUMBER 0x0002 /* needs '%d' in filename */
68 struct AVFormat *next;
71 typedef struct AVStream {
72 int id; /* internal stream id */
73 AVCodecContext codec; /* codec context */
77 #define MAX_STREAMS 20
79 /* format I/O context */
80 typedef struct AVFormatContext {
81 struct AVFormat *format;
85 AVStream *streams[MAX_STREAMS];
86 char filename[1024]; /* input or output filename */
92 /* This buffer is only needed when packets were already buffered but
93 not decoded, for example to get the codec parameters in mpeg
95 struct AVPacketList *packet_buffer;
98 typedef struct AVPacketList {
100 struct AVPacketList *next;
103 extern AVFormat *first_format;
106 extern AVFormat rm_format;
109 extern AVFormat mpeg_mux_format;
112 extern AVFormat asf_format;
115 extern AVFormat avi_format;
118 extern AVFormat mov_format;
119 extern AVFormat mp4_format;
122 extern AVFormat mpjpeg_format;
123 extern AVFormat jpeg_format;
124 extern AVFormat single_jpeg_format;
127 extern AVFormat swf_format;
130 extern AVFormat gif_format;
132 extern AVFormat au_format;
135 extern AVFormat wav_format;
138 extern AVFormat pgm_format;
139 extern AVFormat ppm_format;
140 extern AVFormat pgmyuv_format;
141 extern AVFormat imgyuv_format;
143 extern AVFormat pgmpipe_format;
144 extern AVFormat pgmyuvpipe_format;
145 extern AVFormat ppmpipe_format;
148 extern AVFormat mp2_format;
149 extern AVFormat ac3_format;
150 extern AVFormat h263_format;
151 extern AVFormat mpeg1video_format;
152 extern AVFormat mjpeg_format;
153 extern AVFormat pcm_s16le_format;
154 extern AVFormat pcm_s16be_format;
155 extern AVFormat pcm_u16le_format;
156 extern AVFormat pcm_u16be_format;
157 extern AVFormat pcm_s8_format;
158 extern AVFormat pcm_u8_format;
159 extern AVFormat pcm_mulaw_format;
160 extern AVFormat pcm_alaw_format;
161 extern AVFormat rawvideo_format;
164 extern AVFormat ffm_format;
168 #define MKTAG(a,b,c,d) (a | (b << 8) | (c << 16) | (d << 24))
169 #define MKBETAG(a,b,c,d) (d | (c << 8) | (b << 16) | (a << 24))
171 void register_avformat(AVFormat *format);
172 AVFormat *guess_format(const char *short_name, const char *filename, const char *mime_type);
174 int strstart(const char *str, const char *val, const char **ptr);
175 void nstrcpy(char *buf, int buf_size, const char *str);
176 int match_ext(const char *filename, const char *extensions);
178 void register_all(void);
182 typedef struct FifoBuffer {
184 UINT8 *rptr, *wptr, *end;
187 int fifo_init(FifoBuffer *f, int size);
188 void fifo_free(FifoBuffer *f);
189 int fifo_size(FifoBuffer *f, UINT8 *rptr);
190 int fifo_read(FifoBuffer *f, UINT8 *buf, int buf_size, UINT8 **rptr_ptr);
191 void fifo_write(FifoBuffer *f, UINT8 *buf, int size, UINT8 **wptr_ptr);
193 AVFormatContext *av_open_input_file(const char *filename,
194 const char *format_name,
196 AVFormatParameters *ap);
197 int av_read_packet(AVFormatContext *s, AVPacket *pkt);
198 void av_close_input_file(AVFormatContext *s);
200 int av_write_packet(AVFormatContext *s, AVPacket *pkt, int force_pts);
202 void dump_format(AVFormatContext *ic,
206 int parse_image_size(int *width_ptr, int *height_ptr, const char *str);
208 INT64 parse_date(const char *datestr, int duration);
210 /* ffm specific for ffserver */
211 #define FFM_PACKET_SIZE 4096
212 offset_t ffm_read_write_index(int fd);
213 void ffm_write_write_index(int fd, offset_t pos);
214 void ffm_set_write_index(AVFormatContext *s, offset_t pos, offset_t file_size);
216 int find_info_tag(char *arg, int arg_size, const char *tag1, const char *info);
218 int get_frame_filename(char *buf, int buf_size,
219 const char *path, int number);
221 /* grab/output specific */
222 extern AVFormat video_grab_device_format;
223 extern AVFormat audio_device_format;
225 extern const char *v4l_device;
226 extern const char *audio_device;