8
#define LIBAVFORMAT_BUILD 4608
8
#define LIBAVFORMAT_BUILD 4616
10
10
#define LIBAVFORMAT_VERSION_INT FFMPEG_VERSION_INT
11
11
#define LIBAVFORMAT_VERSION FFMPEG_VERSION
12
12
#define LIBAVFORMAT_IDENT "FFmpeg" FFMPEG_VERSION "b" AV_STRINGIFY(LIBAVFORMAT_BUILD)
15
#include <stdio.h> /* FILE */
16
16
#include "avcodec.h"
27
27
#define MININT64 int64_t_C(0x8000000000000000)
30
#define AV_NOPTS_VALUE MININT64
31
#define AV_TIME_BASE 1000000
33
30
typedef struct AVPacket {
34
int64_t pts; /* presentation time stamp in stream units (set av_set_pts_info) */
31
int64_t pts; /* presentation time stamp in AV_TIME_BASE units (or
32
pts_den units in muxers or demuxers) */
33
int64_t dts; /* decompression time stamp in AV_TIME_BASE units (or
34
pts_den units in muxers or demuxers) */
39
int duration; /* presentation duration (0 if not available) */
40
40
void (*destruct)(struct AVPacket *);
43
43
#define PKT_FLAG_KEY 0x0001
45
/* initialize optional fields of a packet */
45
46
static inline void av_init_packet(AVPacket *pkt)
47
48
pkt->pts = AV_NOPTS_VALUE;
49
pkt->dts = AV_NOPTS_VALUE;
49
52
pkt->stream_index = 0;
52
55
int av_new_packet(AVPacket *pkt, int size);
56
int av_dup_packet(AVPacket *pkt);
102
106
int channel; /* used to select dv channel */
103
107
const char *device; /* video4linux, audio or DV device */
104
108
const char *standard; /* tv standard, NTSC, PAL, SECAM */
109
int mpeg2ts_raw:1; /* force raw MPEG2 transport stream output, if possible */
110
int mpeg2ts_compute_pcr:1; /* compute exact PCR for each transport
111
stream packet (only meaningful if
112
mpeg2ts_raw is TRUE */
113
int initial_pause:1; /* do not begin to play the stream
114
immediately (RTSP only) */
105
115
} AVFormatParameters;
107
117
#define AVFMT_NOFILE 0x0001 /* no file should be opened */
108
118
#define AVFMT_NEEDNUMBER 0x0002 /* needs '%d' in filename */
109
#define AVFMT_NOHEADER 0x0004 /* signal that no header is present
110
(streams are added dynamically) */
111
119
#define AVFMT_SHOW_IDS 0x0008 /* show format stream IDs numbers */
112
120
#define AVFMT_RAWPICTURE 0x0020 /* format wants AVPicture structure for
113
121
raw picture data */
123
131
enum CodecID audio_codec; /* default audio codec */
124
132
enum CodecID video_codec; /* default video codec */
125
133
int (*write_header)(struct AVFormatContext *);
126
int (*write_packet)(struct AVFormatContext *,
128
const uint8_t *buf, int size, int64_t pts);
134
int (*write_packet)(struct AVFormatContext *, AVPacket *pkt);
129
135
int (*write_trailer)(struct AVFormatContext *);
130
136
/* can use flags: AVFMT_NOFILE, AVFMT_NEEDNUMBER */
150
156
AVFormatParameters *ap);
151
157
/* read one packet and put it in 'pkt'. pts and flags are also
152
158
set. 'av_new_stream' can be called only if the flag
153
AVFMT_NOHEADER is used. */
159
AVFMTCTX_NOHEADER is used. */
154
160
int (*read_packet)(struct AVFormatContext *, AVPacket *pkt);
155
161
/* close the stream. The AVFormatContext and AVStreams are not
156
162
freed by this function */
157
163
int (*read_close)(struct AVFormatContext *);
158
/* seek at or before a given pts (given in microsecond). The pts
159
origin is defined by the stream */
160
int (*read_seek)(struct AVFormatContext *, int64_t pts);
161
/* can use flags: AVFMT_NOFILE, AVFMT_NEEDNUMBER, AVFMT_NOHEADER */
164
/* seek at or before a given timestamp (given in AV_TIME_BASE
165
units) relative to the frames in stream component stream_index */
166
int (*read_seek)(struct AVFormatContext *,
167
int stream_index, int64_t timestamp);
169
* gets the next timestamp in AV_TIME_BASE units.
171
int64_t (*read_timestamp)(struct AVFormatContext *s, int stream_index,
172
int64_t *pos, int64_t pos_limit);
173
/* can use flags: AVFMT_NOFILE, AVFMT_NEEDNUMBER */
163
175
/* if extensions are defined, then no probe is done. You should
164
176
usually not use extension format guessing because it is not
166
178
const char *extensions;
167
179
/* general purpose read only value that the format can use */
182
/* start/resume playing - only meaningful if using a network based format
184
int (*read_play)(struct AVFormatContext *);
186
/* pause playing - only meaningful if using a network based format
188
int (*read_pause)(struct AVFormatContext *);
169
190
/* private fields */
170
191
struct AVInputFormat *next;
194
typedef struct AVIndexEntry {
197
#define AVINDEX_KEYFRAME 0x0001
198
/* the following 2 flags indicate that the next/prev keyframe is known, and scaning for it isnt needed */
200
int min_distance; /* min distance between this and the previous keyframe, used to avoid unneeded searching */
173
203
typedef struct AVStream {
174
204
int index; /* stream index in AVFormatContext */
175
205
int id; /* format specific stream id */
178
208
int r_frame_rate_base;/* real frame rate base of the stream */
180
210
/* internal data used in av_find_stream_info() */
181
int codec_info_state;
182
int codec_info_nb_repeat_frames;
183
int codec_info_nb_real_frames;
184
/* PTS generation when outputing stream */
211
int64_t codec_info_duration;
212
int codec_info_nb_frames;
213
/* encoding: PTS generation when outputing stream */
215
AVRational time_base;
216
int pts_wrap_bits; /* number of bits in pts (used for wrapping control) */
186
217
/* ffmpeg.c private use */
187
218
int stream_copy; /* if TRUE, just copy stream */
188
219
/* quality, as it has been removed from AVCodecContext and put in AVVideoFrame
194
225
/* decoding: duration of the stream, in AV_TIME_BASE fractional
196
227
int64_t duration;
229
/* av_read_frame() support */
231
struct AVCodecParserContext *parser;
234
int last_IP_duration;
236
/* av_seek_frame() support */
237
AVIndexEntry *index_entries; /* only used if the format does not
238
support seeking natively */
239
int nb_index_entries;
240
int index_entries_allocated_size;
243
#define AVFMTCTX_NOHEADER 0x0001 /* signal that no header is present
244
(streams are added dynamically) */
199
246
#define MAX_STREAMS 20
201
248
/* format I/O context */
202
249
typedef struct AVFormatContext {
250
AVClass *av_class; /* set by av_alloc_format_context */
203
251
/* can only be iformat or oformat, not both at the same time */
204
252
struct AVInputFormat *iformat;
205
253
struct AVOutputFormat *oformat;
218
267
int track; /* track number, 0 if none */
219
268
char genre[32]; /* ID3 genre */
221
int flags; /* format specific flags */
270
int ctx_flags; /* format specific flags, see AVFMTCTX_xx */
222
271
/* private data for pts handling (do not modify directly) */
223
int pts_wrap_bits; /* number of bits in pts (used for wrapping control) */
224
int pts_num, pts_den; /* value to convert to seconds */
225
272
/* This buffer is only needed when packets were already buffered but
226
273
not decoded, for example to get the codec parameters in mpeg
241
288
available. Never set it directly if the file_size and the
242
289
duration are known as ffmpeg can compute it automatically. */
292
/* av_read_frame() support */
294
const uint8_t *cur_ptr;
298
/* av_seek_frame() support */
299
int64_t data_offset; /* offset of the first packet */
244
301
} AVFormatContext;
246
303
typedef struct AVPacketList {
421
499
AVOutputFormat *guess_format(const char *short_name,
422
500
const char *filename, const char *mime_type);
424
void av_hex_dump(uint8_t *buf, int size);
502
void av_hex_dump(FILE *f, uint8_t *buf, int size);
503
void av_pkt_dump(FILE *f, AVPacket *pkt, int dump_payload);
426
505
void av_register_all(void);
439
518
/* media file input */
440
519
AVInputFormat *av_find_input_format(const char *short_name);
441
520
AVInputFormat *av_probe_input_format(AVProbeData *pd, int is_opened);
521
int av_open_input_stream(AVFormatContext **ic_ptr,
522
ByteIOContext *pb, const char *filename,
523
AVInputFormat *fmt, AVFormatParameters *ap);
442
524
int av_open_input_file(AVFormatContext **ic_ptr, const char *filename,
443
525
AVInputFormat *fmt,
445
527
AVFormatParameters *ap);
528
/* no av_open for output, so applications will need this: */
529
AVFormatContext *av_alloc_format_context(void);
447
531
#define AVERROR_UNKNOWN (-1) /* unknown error */
448
532
#define AVERROR_IO (-2) /* i/o error */
450
534
#define AVERROR_INVALIDDATA (-4) /* invalid data found */
451
535
#define AVERROR_NOMEM (-5) /* not enough memory */
452
536
#define AVERROR_NOFMT (-6) /* unknown format */
537
#define AVERROR_NOTSUPP (-7) /* operation not supported */
454
539
int av_find_stream_info(AVFormatContext *ic);
455
540
int av_read_packet(AVFormatContext *s, AVPacket *pkt);
541
int av_read_frame(AVFormatContext *s, AVPacket *pkt);
542
int av_seek_frame(AVFormatContext *s, int stream_index, int64_t timestamp);
543
int av_read_play(AVFormatContext *s);
544
int av_read_pause(AVFormatContext *s);
456
545
void av_close_input_file(AVFormatContext *s);
457
546
AVStream *av_new_stream(AVFormatContext *s, int id);
458
void av_set_pts_info(AVFormatContext *s, int pts_wrap_bits,
547
void av_set_pts_info(AVStream *s, int pts_wrap_bits,
459
548
int pts_num, int pts_den);
550
int av_find_default_stream_index(AVFormatContext *s);
551
int av_index_search_timestamp(AVStream *st, int timestamp);
552
int av_add_index_entry(AVStream *st,
553
int64_t pos, int64_t timestamp, int distance, int flags);
554
int av_seek_frame_binary(AVFormatContext *s, int stream_index, int64_t target_ts);
461
556
/* media file output */
462
557
int av_set_parameters(AVFormatContext *s, AVFormatParameters *ap);
463
558
int av_write_header(AVFormatContext *s);
464
int av_write_frame(AVFormatContext *s, int stream_index, const uint8_t *buf,
559
int av_write_frame(AVFormatContext *s, AVPacket *pkt);
560
int av_interleaved_write_frame(AVFormatContext *s, AVPacket *pkt);
466
562
int av_write_trailer(AVFormatContext *s);
468
564
void dump_format(AVFormatContext *ic,