Mercurial > libavformat.hg
comparison avformat.h @ 303:2833c2311b66 libavformat
initial av_read_frame() and av_seek_frame() support
author | bellard |
---|---|
date | Mon, 10 Nov 2003 18:37:55 +0000 |
parents | 62cec412a186 |
children | 8756dec3281f |
comparison
equal
deleted
inserted
replaced
302:6949df67922d | 303:2833c2311b66 |
---|---|
3 | 3 |
4 #ifdef __cplusplus | 4 #ifdef __cplusplus |
5 extern "C" { | 5 extern "C" { |
6 #endif | 6 #endif |
7 | 7 |
8 #define LIBAVFORMAT_BUILD 4609 | 8 #define LIBAVFORMAT_BUILD 4610 |
9 | 9 |
10 #define LIBAVFORMAT_VERSION_INT FFMPEG_VERSION_INT | 10 #define LIBAVFORMAT_VERSION_INT FFMPEG_VERSION_INT |
11 #define LIBAVFORMAT_VERSION FFMPEG_VERSION | 11 #define LIBAVFORMAT_VERSION FFMPEG_VERSION |
12 #define LIBAVFORMAT_IDENT "FFmpeg" FFMPEG_VERSION "b" AV_STRINGIFY(LIBAVFORMAT_BUILD) | 12 #define LIBAVFORMAT_IDENT "FFmpeg" FFMPEG_VERSION "b" AV_STRINGIFY(LIBAVFORMAT_BUILD) |
13 | 13 |
29 | 29 |
30 #define AV_NOPTS_VALUE MININT64 | 30 #define AV_NOPTS_VALUE MININT64 |
31 #define AV_TIME_BASE 1000000 | 31 #define AV_TIME_BASE 1000000 |
32 | 32 |
33 typedef struct AVPacket { | 33 typedef struct AVPacket { |
34 int64_t pts; /* presentation time stamp in stream units (set av_set_pts_info) */ | 34 int64_t pts; /* presentation time stamp in AV_TIME_BASE units (or |
35 pts_den units in muxers or demuxers) */ | |
36 int64_t dts; /* decompression time stamp in AV_TIME_BASE units (or | |
37 pts_den units in muxers or demuxers) */ | |
35 uint8_t *data; | 38 uint8_t *data; |
36 int size; | 39 int size; |
37 int stream_index; | 40 int stream_index; |
38 int flags; | 41 int flags; |
39 int duration; | 42 int duration; /* presentation duration (0 if not available) */ |
40 void (*destruct)(struct AVPacket *); | 43 void (*destruct)(struct AVPacket *); |
41 void *priv; | 44 void *priv; |
42 } AVPacket; | 45 } AVPacket; |
43 #define PKT_FLAG_KEY 0x0001 | 46 #define PKT_FLAG_KEY 0x0001 |
44 | 47 |
45 /* initialize optional fields of a packet */ | 48 /* initialize optional fields of a packet */ |
46 static inline void av_init_packet(AVPacket *pkt) | 49 static inline void av_init_packet(AVPacket *pkt) |
47 { | 50 { |
48 pkt->pts = AV_NOPTS_VALUE; | 51 pkt->pts = AV_NOPTS_VALUE; |
52 pkt->dts = AV_NOPTS_VALUE; | |
53 pkt->duration = 0; | |
49 pkt->flags = 0; | 54 pkt->flags = 0; |
50 pkt->stream_index = 0; | 55 pkt->stream_index = 0; |
51 } | 56 } |
52 | 57 |
53 int av_new_packet(AVPacket *pkt, int size); | 58 int av_new_packet(AVPacket *pkt, int size); |
59 int av_dup_packet(AVPacket *pkt); | |
54 | 60 |
55 /** | 61 /** |
56 * Free a packet | 62 * Free a packet |
57 * | 63 * |
58 * @param pkt packet to free | 64 * @param pkt packet to free |
105 const char *standard; /* tv standard, NTSC, PAL, SECAM */ | 111 const char *standard; /* tv standard, NTSC, PAL, SECAM */ |
106 int mpeg2ts_raw:1; /* force raw MPEG2 transport stream output, if possible */ | 112 int mpeg2ts_raw:1; /* force raw MPEG2 transport stream output, if possible */ |
107 int mpeg2ts_compute_pcr:1; /* compute exact PCR for each transport | 113 int mpeg2ts_compute_pcr:1; /* compute exact PCR for each transport |
108 stream packet (only meaningful if | 114 stream packet (only meaningful if |
109 mpeg2ts_raw is TRUE */ | 115 mpeg2ts_raw is TRUE */ |
116 int initial_pause:1; /* do not begin to play the stream | |
117 immediately (RTSP only) */ | |
110 } AVFormatParameters; | 118 } AVFormatParameters; |
111 | 119 |
112 #define AVFMT_NOFILE 0x0001 /* no file should be opened */ | 120 #define AVFMT_NOFILE 0x0001 /* no file should be opened */ |
113 #define AVFMT_NEEDNUMBER 0x0002 /* needs '%d' in filename */ | 121 #define AVFMT_NEEDNUMBER 0x0002 /* needs '%d' in filename */ |
114 #define AVFMT_SHOW_IDS 0x0008 /* show format stream IDs numbers */ | 122 #define AVFMT_SHOW_IDS 0x0008 /* show format stream IDs numbers */ |
156 AVFMTCTX_NOHEADER is used. */ | 164 AVFMTCTX_NOHEADER is used. */ |
157 int (*read_packet)(struct AVFormatContext *, AVPacket *pkt); | 165 int (*read_packet)(struct AVFormatContext *, AVPacket *pkt); |
158 /* close the stream. The AVFormatContext and AVStreams are not | 166 /* close the stream. The AVFormatContext and AVStreams are not |
159 freed by this function */ | 167 freed by this function */ |
160 int (*read_close)(struct AVFormatContext *); | 168 int (*read_close)(struct AVFormatContext *); |
161 /* seek at or before a given pts (given in microsecond). The pts | 169 /* seek at or before a given timestamp (given in AV_TIME_BASE |
162 origin is defined by the stream */ | 170 units) relative to the frames in stream component stream_index */ |
163 int (*read_seek)(struct AVFormatContext *, int64_t pts); | 171 int (*read_seek)(struct AVFormatContext *, |
172 int stream_index, int64_t timestamp); | |
164 /* can use flags: AVFMT_NOFILE, AVFMT_NEEDNUMBER */ | 173 /* can use flags: AVFMT_NOFILE, AVFMT_NEEDNUMBER */ |
165 int flags; | 174 int flags; |
166 /* if extensions are defined, then no probe is done. You should | 175 /* if extensions are defined, then no probe is done. You should |
167 usually not use extension format guessing because it is not | 176 usually not use extension format guessing because it is not |
168 reliable enough */ | 177 reliable enough */ |
169 const char *extensions; | 178 const char *extensions; |
170 /* general purpose read only value that the format can use */ | 179 /* general purpose read only value that the format can use */ |
171 int value; | 180 int value; |
181 | |
182 /* start/resume playing - only meaningful if using a network based format | |
183 (RTSP) */ | |
184 int (*read_play)(struct AVFormatContext *); | |
185 | |
186 /* pause playing - only meaningful if using a network based format | |
187 (RTSP) */ | |
188 int (*read_pause)(struct AVFormatContext *); | |
189 | |
172 /* private fields */ | 190 /* private fields */ |
173 struct AVInputFormat *next; | 191 struct AVInputFormat *next; |
174 } AVInputFormat; | 192 } AVInputFormat; |
193 | |
194 typedef struct AVIndexEntry { | |
195 int64_t pos; | |
196 int64_t timestamp; | |
197 #define AVINDEX_KEYFRAME 0x0001 | |
198 int flags; | |
199 } AVIndexEntry; | |
175 | 200 |
176 typedef struct AVStream { | 201 typedef struct AVStream { |
177 int index; /* stream index in AVFormatContext */ | 202 int index; /* stream index in AVFormatContext */ |
178 int id; /* format specific stream id */ | 203 int id; /* format specific stream id */ |
179 AVCodecContext codec; /* codec context */ | 204 AVCodecContext codec; /* codec context */ |
180 int r_frame_rate; /* real frame rate of the stream */ | 205 int r_frame_rate; /* real frame rate of the stream */ |
181 int r_frame_rate_base;/* real frame rate base of the stream */ | 206 int r_frame_rate_base;/* real frame rate base of the stream */ |
182 void *priv_data; | 207 void *priv_data; |
183 /* internal data used in av_find_stream_info() */ | 208 /* internal data used in av_find_stream_info() */ |
184 int codec_info_state; | 209 int64_t codec_info_duration; |
185 int codec_info_nb_repeat_frames; | 210 int codec_info_nb_frames; |
186 int codec_info_nb_real_frames; | |
187 /* encoding: PTS generation when outputing stream */ | 211 /* encoding: PTS generation when outputing stream */ |
188 AVFrac pts; | 212 AVFrac pts; |
189 /* ffmpeg.c private use */ | 213 /* ffmpeg.c private use */ |
190 int stream_copy; /* if TRUE, just copy stream */ | 214 int stream_copy; /* if TRUE, just copy stream */ |
191 /* quality, as it has been removed from AVCodecContext and put in AVVideoFrame | 215 /* quality, as it has been removed from AVCodecContext and put in AVVideoFrame |
195 AV_TIME_BASE fractional seconds. */ | 219 AV_TIME_BASE fractional seconds. */ |
196 int64_t start_time; | 220 int64_t start_time; |
197 /* decoding: duration of the stream, in AV_TIME_BASE fractional | 221 /* decoding: duration of the stream, in AV_TIME_BASE fractional |
198 seconds. */ | 222 seconds. */ |
199 int64_t duration; | 223 int64_t duration; |
224 | |
225 /* av_read_frame() support */ | |
226 int need_parsing; | |
227 struct AVCodecParserContext *parser; | |
228 int got_frame; | |
229 int64_t cur_frame_pts; | |
230 int64_t cur_frame_dts; | |
231 int64_t cur_dts; | |
232 int last_IP_duration; | |
233 /* av_seek_frame() support */ | |
234 AVIndexEntry *index_entries; /* only used if the format does not | |
235 support seeking natively */ | |
236 int nb_index_entries; | |
237 int index_entries_allocated_size; | |
200 } AVStream; | 238 } AVStream; |
201 | 239 |
202 #define AVFMTCTX_NOHEADER 0x0001 /* signal that no header is present | 240 #define AVFMTCTX_NOHEADER 0x0001 /* signal that no header is present |
203 (streams are added dynamically) */ | 241 (streams are added dynamically) */ |
204 | 242 |
245 int64_t file_size; | 283 int64_t file_size; |
246 /* decoding: total stream bitrate in bit/s, 0 if not | 284 /* decoding: total stream bitrate in bit/s, 0 if not |
247 available. Never set it directly if the file_size and the | 285 available. Never set it directly if the file_size and the |
248 duration are known as ffmpeg can compute it automatically. */ | 286 duration are known as ffmpeg can compute it automatically. */ |
249 int bit_rate; | 287 int bit_rate; |
288 | |
289 /* av_read_frame() support */ | |
290 AVStream *cur_st; | |
291 const uint8_t *cur_ptr; | |
292 int cur_len; | |
293 AVPacket cur_pkt; | |
294 | |
295 /* the following are used for pts/dts unit conversion */ | |
296 int64_t last_pkt_stream_pts; | |
297 int64_t last_pkt_stream_dts; | |
298 int64_t last_pkt_pts; | |
299 int64_t last_pkt_dts; | |
300 int last_pkt_pts_frac; | |
301 int last_pkt_dts_frac; | |
302 | |
303 /* av_seek_frame() support */ | |
304 int64_t data_offset; /* offset of the first packet */ | |
305 int index_built; | |
250 } AVFormatContext; | 306 } AVFormatContext; |
251 | 307 |
252 typedef struct AVPacketList { | 308 typedef struct AVPacketList { |
253 AVPacket pkt; | 309 AVPacket pkt; |
254 struct AVPacketList *next; | 310 struct AVPacketList *next; |
371 | 427 |
372 /* wav.c */ | 428 /* wav.c */ |
373 int wav_init(void); | 429 int wav_init(void); |
374 | 430 |
375 /* raw.c */ | 431 /* raw.c */ |
432 int pcm_read_seek(AVFormatContext *s, | |
433 int stream_index, int64_t timestamp); | |
376 int raw_init(void); | 434 int raw_init(void); |
377 | 435 |
378 /* mp3.c */ | 436 /* mp3.c */ |
379 int mp3_init(void); | 437 int mp3_init(void); |
380 | 438 |
434 AVOutputFormat *guess_stream_format(const char *short_name, | 492 AVOutputFormat *guess_stream_format(const char *short_name, |
435 const char *filename, const char *mime_type); | 493 const char *filename, const char *mime_type); |
436 AVOutputFormat *guess_format(const char *short_name, | 494 AVOutputFormat *guess_format(const char *short_name, |
437 const char *filename, const char *mime_type); | 495 const char *filename, const char *mime_type); |
438 | 496 |
439 void av_hex_dump(uint8_t *buf, int size); | 497 void av_hex_dump(FILE *f, uint8_t *buf, int size); |
498 void av_pkt_dump(FILE *f, AVPacket *pkt, int dump_payload); | |
440 | 499 |
441 void av_register_all(void); | 500 void av_register_all(void); |
442 | 501 |
443 typedef struct FifoBuffer { | 502 typedef struct FifoBuffer { |
444 uint8_t *buffer; | 503 uint8_t *buffer; |
466 #define AVERROR_IO (-2) /* i/o error */ | 525 #define AVERROR_IO (-2) /* i/o error */ |
467 #define AVERROR_NUMEXPECTED (-3) /* number syntax expected in filename */ | 526 #define AVERROR_NUMEXPECTED (-3) /* number syntax expected in filename */ |
468 #define AVERROR_INVALIDDATA (-4) /* invalid data found */ | 527 #define AVERROR_INVALIDDATA (-4) /* invalid data found */ |
469 #define AVERROR_NOMEM (-5) /* not enough memory */ | 528 #define AVERROR_NOMEM (-5) /* not enough memory */ |
470 #define AVERROR_NOFMT (-6) /* unknown format */ | 529 #define AVERROR_NOFMT (-6) /* unknown format */ |
471 | 530 #define AVERROR_NOTSUPP (-7) /* operation not supported */ |
531 | |
472 int av_find_stream_info(AVFormatContext *ic); | 532 int av_find_stream_info(AVFormatContext *ic); |
473 int av_read_packet(AVFormatContext *s, AVPacket *pkt); | 533 int av_read_packet(AVFormatContext *s, AVPacket *pkt); |
534 int av_read_frame(AVFormatContext *s, AVPacket *pkt); | |
535 int av_seek_frame(AVFormatContext *s, int stream_index, int64_t timestamp); | |
536 int av_read_play(AVFormatContext *s); | |
537 int av_read_pause(AVFormatContext *s); | |
474 void av_close_input_file(AVFormatContext *s); | 538 void av_close_input_file(AVFormatContext *s); |
475 AVStream *av_new_stream(AVFormatContext *s, int id); | 539 AVStream *av_new_stream(AVFormatContext *s, int id); |
476 void av_set_pts_info(AVFormatContext *s, int pts_wrap_bits, | 540 void av_set_pts_info(AVFormatContext *s, int pts_wrap_bits, |
477 int pts_num, int pts_den); | 541 int pts_num, int pts_den); |
478 | 542 |