Commit | Line | Data |
---|---|---|
de6d9b64 FB |
1 | |
2 | #include "avcodec.h" | |
3 | ||
4 | #define FFMPEG_VERSION "0.4.5" | |
5 | ||
6 | #include "avio.h" | |
7 | ||
8 | /* packet functions */ | |
9 | ||
10 | typedef struct AVPacket { | |
11 | INT64 pts; | |
12 | UINT8 *data; | |
13 | int size; | |
14 | int stream_index; | |
15 | int flags; | |
16 | #define PKT_FLAG_KEY 0x0001 | |
17 | } AVPacket; | |
18 | ||
19 | int av_new_packet(AVPacket *pkt, int size); | |
20 | void av_free_packet(AVPacket *pkt); | |
21 | ||
22 | /*************************************************/ | |
23 | /* output formats */ | |
24 | ||
25 | struct AVFormatContext; | |
26 | struct AVFormatInputContext; | |
27 | ||
28 | typedef struct AVFormatParameters { | |
29 | int frame_rate; | |
30 | int sample_rate; | |
31 | int channels; | |
32 | int width; | |
33 | int height; | |
34 | int pix_fmt; | |
35 | } AVFormatParameters; | |
36 | ||
37 | typedef struct AVFormat { | |
38 | const char *name; | |
39 | const char *long_name; | |
40 | const char *mime_type; | |
41 | const char *extensions; /* comma separated extensions */ | |
42 | ||
43 | /* output support */ | |
44 | enum CodecID audio_codec; /* default audio codec */ | |
45 | enum CodecID video_codec; /* default video codec */ | |
46 | int (*write_header)(struct AVFormatContext *); | |
47 | int (*write_packet)(struct AVFormatContext *, | |
48 | int stream_index, | |
49 | unsigned char *buf, int size); | |
50 | int (*write_trailer)(struct AVFormatContext *); | |
51 | ||
52 | /* optional input support */ | |
53 | /* read the format header and initialize the AVFormatInputContext | |
54 | structure. Return 0 if OK. 'ap' if non NULL contains | |
55 | additionnal paramters. Only used in raw format right now */ | |
56 | int (*read_header)(struct AVFormatContext *, | |
57 | AVFormatParameters *ap); | |
58 | /* read one packet and put it in 'pkt'. pts and flags are also set */ | |
59 | int (*read_packet)(struct AVFormatContext *, AVPacket *pkt); | |
60 | /* close the stream. The AVFormatContext and AVStreams are not | |
61 | freed by this function */ | |
62 | int (*read_close)(struct AVFormatContext *); | |
63 | /* seek at or before a given pts (given in microsecond). The pts | |
64 | origin is defined by the stream */ | |
65 | int (*read_seek)(struct AVFormatContext *, INT64 pts); | |
66 | int flags; | |
67 | #define AVFMT_NOFILE 0x0001 /* no file should be opened */ | |
68 | struct AVFormat *next; | |
69 | } AVFormat; | |
70 | ||
71 | typedef struct AVStream { | |
72 | int id; /* internal stream id */ | |
73 | AVCodecContext codec; /* codec context */ | |
74 | void *priv_data; | |
75 | } AVStream; | |
76 | ||
77 | #define MAX_STREAMS 20 | |
78 | ||
79 | /* format I/O context */ | |
80 | typedef struct AVFormatContext { | |
81 | struct AVFormat *format; | |
82 | void *priv_data; | |
83 | ByteIOContext pb; | |
84 | int nb_streams; | |
85 | AVStream *streams[MAX_STREAMS]; | |
86 | char filename[1024]; /* input or output filename */ | |
87 | /* stream info */ | |
88 | char title[512]; | |
89 | char author[512]; | |
90 | char copyright[512]; | |
91 | char comment[512]; | |
92 | /* This buffer is only needed when packets were already buffered but | |
93 | not decoded, for example to get the codec parameters in mpeg | |
94 | streams */ | |
95 | struct AVPacketList *packet_buffer; | |
96 | } AVFormatContext; | |
97 | ||
98 | typedef struct AVPacketList { | |
99 | AVPacket pkt; | |
100 | struct AVPacketList *next; | |
101 | } AVPacketList; | |
102 | ||
103 | extern AVFormat *first_format; | |
104 | ||
105 | /* rv10enc.c */ | |
106 | extern AVFormat rm_format; | |
107 | ||
108 | /* mpegmux.c */ | |
109 | extern AVFormat mpeg_mux_format; | |
110 | ||
111 | /* asfenc.c */ | |
112 | extern AVFormat asf_format; | |
113 | ||
114 | /* avienc.c */ | |
115 | extern AVFormat avi_format; | |
116 | ||
117 | /* jpegenc.c */ | |
118 | extern AVFormat mpjpeg_format; | |
119 | extern AVFormat jpeg_format; | |
120 | ||
121 | /* swfenc.c */ | |
122 | extern AVFormat swf_format; | |
123 | ||
124 | /* wav.c */ | |
125 | extern AVFormat wav_format; | |
126 | ||
127 | /* img.c */ | |
128 | extern AVFormat pgm_format; | |
129 | extern AVFormat pgmyuv_format; | |
130 | extern AVFormat imgyuv_format; | |
131 | extern AVFormat pgmpipe_format; | |
132 | ||
133 | /* raw.c */ | |
134 | extern AVFormat mp2_format; | |
135 | extern AVFormat ac3_format; | |
136 | extern AVFormat h263_format; | |
137 | extern AVFormat mpeg1video_format; | |
138 | extern AVFormat pcm_format; | |
139 | extern AVFormat rawvideo_format; | |
140 | ||
141 | /* ffm.c */ | |
142 | extern AVFormat ffm_format; | |
143 | ||
144 | /* formats.c */ | |
145 | ||
146 | #define MKTAG(a,b,c,d) (a | (b << 8) | (c << 16) | (d << 24)) | |
147 | #define MKBETAG(a,b,c,d) (d | (c << 8) | (b << 16) | (a << 24)) | |
148 | ||
149 | void register_avformat(AVFormat *format); | |
150 | AVFormat *guess_format(const char *short_name, const char *filename, const char *mime_type); | |
151 | ||
152 | int strstart(const char *str, const char *val, const char **ptr); | |
153 | void nstrcpy(char *buf, int buf_size, const char *str); | |
154 | int match_ext(const char *filename, const char *extensions); | |
155 | ||
156 | void register_all(void); | |
157 | ||
158 | INT64 gettime(void); | |
159 | ||
160 | typedef struct FifoBuffer { | |
161 | UINT8 *buffer; | |
162 | UINT8 *rptr, *wptr, *end; | |
163 | } FifoBuffer; | |
164 | ||
165 | int fifo_init(FifoBuffer *f, int size); | |
166 | void fifo_free(FifoBuffer *f); | |
167 | int fifo_size(FifoBuffer *f, UINT8 *rptr); | |
168 | int fifo_read(FifoBuffer *f, UINT8 *buf, int buf_size, UINT8 **rptr_ptr); | |
169 | void fifo_write(FifoBuffer *f, UINT8 *buf, int size, UINT8 **wptr_ptr); | |
170 | ||
171 | AVFormatContext *av_open_input_file(const char *filename, int buf_size); | |
172 | int av_read_packet(AVFormatContext *s, AVPacket *pkt); | |
173 | void av_close_input_file(AVFormatContext *s); | |
174 | ||
175 | int av_write_packet(AVFormatContext *s, AVPacket *pkt); | |
176 | ||
177 | void dump_format(AVFormatContext *ic, | |
178 | int index, | |
179 | const char *url, | |
180 | int is_output); | |
181 | int parse_image_size(int *width_ptr, int *height_ptr, const char *str); | |
182 | INT64 gettime(void); | |
183 | INT64 parse_date(const char *datestr, int duration); | |
184 | ||
185 | /* ffm specific for ffserver */ | |
186 | #define FFM_PACKET_SIZE 4096 | |
187 | offset_t ffm_read_write_index(int fd); | |
188 | void ffm_write_write_index(int fd, offset_t pos); | |
189 | void ffm_set_write_index(AVFormatContext *s, offset_t pos, offset_t file_size); | |
190 | ||
191 | int find_info_tag(char *arg, int arg_size, const char *tag1, const char *info); | |
192 |