00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013
00014
00015
00016
00017
00018
00019
00020
00021 #ifndef AVFORMAT_AVFORMAT_H
00022 #define AVFORMAT_AVFORMAT_H
00023
00024 #define LIBAVFORMAT_VERSION_MAJOR 52
00025 #define LIBAVFORMAT_VERSION_MINOR 64
00026 #define LIBAVFORMAT_VERSION_MICRO 2
00027
00028 #define LIBAVFORMAT_VERSION_INT AV_VERSION_INT(LIBAVFORMAT_VERSION_MAJOR, \
00029 LIBAVFORMAT_VERSION_MINOR, \
00030 LIBAVFORMAT_VERSION_MICRO)
00031 #define LIBAVFORMAT_VERSION AV_VERSION(LIBAVFORMAT_VERSION_MAJOR, \
00032 LIBAVFORMAT_VERSION_MINOR, \
00033 LIBAVFORMAT_VERSION_MICRO)
00034 #define LIBAVFORMAT_BUILD LIBAVFORMAT_VERSION_INT
00035
00036 #define LIBAVFORMAT_IDENT "Lavf" AV_STRINGIFY(LIBAVFORMAT_VERSION)
00037
00042 unsigned avformat_version(void);
00043
00047 const char *avformat_configuration(void);
00048
00052 const char *avformat_license(void);
00053
00054 #include <time.h>
00055 #include <stdio.h>
00056 #include "libavcodec/avcodec.h"
00057
00058 #include "avio.h"
00059
00060 struct AVFormatContext;
00061
00062
00063
00064
00065
00066
00067
00068
00069
00070
00071
00072
00073
00074
00075
00076
00077
00078
00079
00080
00081
00082
00083
00084
00085
00086
00087
00088
00089
00090
00091
00092
00093
00094
00095
00096
00097
00098
00099
00100
00101
00102
00103
00104
00105
00106
00107
00108
00109
00110
00111
00112
00113
00114
00115
00116
00117
00118 #define AV_METADATA_MATCH_CASE 1
00119 #define AV_METADATA_IGNORE_SUFFIX 2
00120 #define AV_METADATA_DONT_STRDUP_KEY 4
00121 #define AV_METADATA_DONT_STRDUP_VAL 8
00122 #define AV_METADATA_DONT_OVERWRITE 16
00123
00124 typedef struct {
00125 char *key;
00126 char *value;
00127 }AVMetadataTag;
00128
00129 typedef struct AVMetadata AVMetadata;
00130 typedef struct AVMetadataConv AVMetadataConv;
00131
00139 AVMetadataTag *
00140 av_metadata_get(AVMetadata *m, const char *key, const AVMetadataTag *prev, int flags);
00141
00142 #if LIBAVFORMAT_VERSION_MAJOR == 52
00143
00150 attribute_deprecated int av_metadata_set(AVMetadata **pm, const char *key, const char *value);
00151 #endif
00152
00159 int av_metadata_set2(AVMetadata **pm, const char *key, const char *value, int flags);
00160
00168 void av_metadata_conv(struct AVFormatContext *ctx,const AVMetadataConv *d_conv,
00169 const AVMetadataConv *s_conv);
00170
00174 void av_metadata_free(AVMetadata **m);
00175
00176
00177
00178
00179
00188 int av_get_packet(ByteIOContext *s, AVPacket *pkt, int size);
00189
00190
00191
00192
00193
00198 typedef struct AVFrac {
00199 int64_t val, num, den;
00200 } AVFrac;
00201
00202
00203
00204
00205 struct AVCodecTag;
00206
00208 typedef struct AVProbeData {
00209 const char *filename;
00210 unsigned char *buf;
00211 int buf_size;
00212 } AVProbeData;
00213
00214 #define AVPROBE_SCORE_MAX 100
00215 #define AVPROBE_PADDING_SIZE 32
00216
00217 typedef struct AVFormatParameters {
00218 AVRational time_base;
00219 int sample_rate;
00220 int channels;
00221 int width;
00222 int height;
00223 enum PixelFormat pix_fmt;
00224 int channel;
00225 const char *standard;
00226 unsigned int mpeg2ts_raw:1;
00227 unsigned int mpeg2ts_compute_pcr:1;
00230 unsigned int initial_pause:1;
00232 unsigned int prealloced_context:1;
00233 #if LIBAVFORMAT_VERSION_INT < (53<<16)
00234 enum CodecID video_codec_id;
00235 enum CodecID audio_codec_id;
00236 #endif
00237 } AVFormatParameters;
00238
00240 #define AVFMT_NOFILE 0x0001
00241 #define AVFMT_NEEDNUMBER 0x0002
00242 #define AVFMT_SHOW_IDS 0x0008
00243 #define AVFMT_RAWPICTURE 0x0020
00245 #define AVFMT_GLOBALHEADER 0x0040
00246 #define AVFMT_NOTIMESTAMPS 0x0080
00247 #define AVFMT_GENERIC_INDEX 0x0100
00248 #define AVFMT_TS_DISCONT 0x0200
00249 #define AVFMT_VARIABLE_FPS 0x0400
00250 #define AVFMT_NODIMENSIONS 0x0800
00252 typedef struct AVOutputFormat {
00253 const char *name;
00259 const char *long_name;
00260 const char *mime_type;
00261 const char *extensions;
00263 int priv_data_size;
00264
00265 enum CodecID audio_codec;
00266 enum CodecID video_codec;
00267 int (*write_header)(struct AVFormatContext *);
00268 int (*write_packet)(struct AVFormatContext *, AVPacket *pkt);
00269 int (*write_trailer)(struct AVFormatContext *);
00271 int flags;
00273 int (*set_parameters)(struct AVFormatContext *, AVFormatParameters *);
00274 int (*interleave_packet)(struct AVFormatContext *, AVPacket *out,
00275 AVPacket *in, int flush);
00276
00281 const struct AVCodecTag * const *codec_tag;
00282
00283 enum CodecID subtitle_codec;
00285 const AVMetadataConv *metadata_conv;
00286
00287
00288 struct AVOutputFormat *next;
00289 } AVOutputFormat;
00290
00291 typedef struct AVInputFormat {
00292 const char *name;
00298 const char *long_name;
00300 int priv_data_size;
00306 int (*read_probe)(AVProbeData *);
00311 int (*read_header)(struct AVFormatContext *,
00312 AVFormatParameters *ap);
00319 int (*read_packet)(struct AVFormatContext *, AVPacket *pkt);
00322 int (*read_close)(struct AVFormatContext *);
00323
00324 #if LIBAVFORMAT_VERSION_MAJOR < 53
00325
00333 int (*read_seek)(struct AVFormatContext *,
00334 int stream_index, int64_t timestamp, int flags);
00335 #endif
00336
00340 int64_t (*read_timestamp)(struct AVFormatContext *s, int stream_index,
00341 int64_t *pos, int64_t pos_limit);
00343 int flags;
00347 const char *extensions;
00349 int value;
00350
00353 int (*read_play)(struct AVFormatContext *);
00354
00357 int (*read_pause)(struct AVFormatContext *);
00358
00359 const struct AVCodecTag * const *codec_tag;
00360
00367 int (*read_seek2)(struct AVFormatContext *s, int stream_index, int64_t min_ts, int64_t ts, int64_t max_ts, int flags);
00368
00369 const AVMetadataConv *metadata_conv;
00370
00371
00372 struct AVInputFormat *next;
00373 } AVInputFormat;
00374
00375 enum AVStreamParseType {
00376 AVSTREAM_PARSE_NONE,
00377 AVSTREAM_PARSE_FULL,
00378 AVSTREAM_PARSE_HEADERS,
00379 AVSTREAM_PARSE_TIMESTAMPS,
00380 };
00381
00382 typedef struct AVIndexEntry {
00383 int64_t pos;
00384 int64_t timestamp;
00385 #define AVINDEX_KEYFRAME 0x0001
00386 int flags:2;
00387 int size:30;
00388 int min_distance;
00389 } AVIndexEntry;
00390
00391 #define AV_DISPOSITION_DEFAULT 0x0001
00392 #define AV_DISPOSITION_DUB 0x0002
00393 #define AV_DISPOSITION_ORIGINAL 0x0004
00394 #define AV_DISPOSITION_COMMENT 0x0008
00395 #define AV_DISPOSITION_LYRICS 0x0010
00396 #define AV_DISPOSITION_KARAOKE 0x0020
00397
00405 typedef struct AVStream {
00406 int index;
00407 int id;
00408 AVCodecContext *codec;
00417 AVRational r_frame_rate;
00418 void *priv_data;
00419
00420
00421 int64_t first_dts;
00423 struct AVFrac pts;
00424
00430 AVRational time_base;
00431 int pts_wrap_bits;
00432
00433 int stream_copy;
00434 enum AVDiscard discard;
00435
00438 float quality;
00447 int64_t start_time;
00453 int64_t duration;
00454
00455 #if LIBAVFORMAT_VERSION_INT < (53<<16)
00456 char language[4];
00457 #endif
00458
00459
00460 enum AVStreamParseType need_parsing;
00461 struct AVCodecParserContext *parser;
00462
00463 int64_t cur_dts;
00464 int last_IP_duration;
00465 int64_t last_IP_pts;
00466
00467 AVIndexEntry *index_entries;
00469 int nb_index_entries;
00470 unsigned int index_entries_allocated_size;
00471
00472 int64_t nb_frames;
00473
00474 #if LIBAVFORMAT_VERSION_INT < (53<<16)
00475 int64_t unused[4+1];
00476
00477 char *filename;
00478 #endif
00479
00480 int disposition;
00482 AVProbeData probe_data;
00483 #define MAX_REORDER_DELAY 16
00484 int64_t pts_buffer[MAX_REORDER_DELAY+1];
00485
00491 AVRational sample_aspect_ratio;
00492
00493 AVMetadata *metadata;
00494
00495
00496 const uint8_t *cur_ptr;
00497 int cur_len;
00498 AVPacket cur_pkt;
00499
00500
00508 int64_t reference_dts;
00509
00514 #define MAX_PROBE_PACKETS 2500
00515 int probe_packets;
00516
00521 struct AVPacketList *last_in_packet_buffer;
00522
00526 AVRational avg_frame_rate;
00527
00531 int codec_info_nb_frames;
00532 } AVStream;
00533
00534 #define AV_PROGRAM_RUNNING 1
00535
00542 typedef struct AVProgram {
00543 int id;
00544 #if LIBAVFORMAT_VERSION_INT < (53<<16)
00545 char *provider_name;
00546 char *name;
00547 #endif
00548 int flags;
00549 enum AVDiscard discard;
00550 unsigned int *stream_index;
00551 unsigned int nb_stream_indexes;
00552 AVMetadata *metadata;
00553 } AVProgram;
00554
00555 #define AVFMTCTX_NOHEADER 0x0001
00558 typedef struct AVChapter {
00559 int id;
00560 AVRational time_base;
00561 int64_t start, end;
00562 #if LIBAVFORMAT_VERSION_INT < (53<<16)
00563 char *title;
00564 #endif
00565 AVMetadata *metadata;
00566 } AVChapter;
00567
00568 #if LIBAVFORMAT_VERSION_MAJOR < 53
00569 #define MAX_STREAMS 20
00570 #else
00571 #define MAX_STREAMS 100
00572 #endif
00573
00581 typedef struct AVFormatContext {
00582 const AVClass *av_class;
00583
00584 struct AVInputFormat *iformat;
00585 struct AVOutputFormat *oformat;
00586 void *priv_data;
00587 ByteIOContext *pb;
00588 unsigned int nb_streams;
00589 AVStream *streams[MAX_STREAMS];
00590 char filename[1024];
00591
00592 int64_t timestamp;
00593 #if LIBAVFORMAT_VERSION_INT < (53<<16)
00594 char title[512];
00595 char author[512];
00596 char copyright[512];
00597 char comment[512];
00598 char album[512];
00599 int year;
00600 int track;
00601 char genre[32];
00602 #endif
00603
00604 int ctx_flags;
00605
00609 struct AVPacketList *packet_buffer;
00610
00614 int64_t start_time;
00619 int64_t duration;
00621 int64_t file_size;
00625 int bit_rate;
00626
00627
00628 AVStream *cur_st;
00629 #if LIBAVFORMAT_VERSION_INT < (53<<16)
00630 const uint8_t *cur_ptr_deprecated;
00631 int cur_len_deprecated;
00632 AVPacket cur_pkt_deprecated;
00633 #endif
00634
00635
00636 int64_t data_offset;
00637 int index_built;
00638
00639 int mux_rate;
00640 unsigned int packet_size;
00641 int preload;
00642 int max_delay;
00643
00644 #define AVFMT_NOOUTPUTLOOP -1
00645 #define AVFMT_INFINITEOUTPUTLOOP 0
00646
00647 int loop_output;
00648
00649 int flags;
00650 #define AVFMT_FLAG_GENPTS 0x0001
00651 #define AVFMT_FLAG_IGNIDX 0x0002
00652 #define AVFMT_FLAG_NONBLOCK 0x0004
00653 #define AVFMT_FLAG_IGNDTS 0x0008
00654 #define AVFMT_FLAG_NOFILLIN 0x0010
00655 #define AVFMT_FLAG_NOPARSE 0x0020
00656 #define AVFMT_FLAG_RTP_HINT 0x0040
00657
00658 int loop_input;
00660 unsigned int probesize;
00661
00666 int max_analyze_duration;
00667
00668 const uint8_t *key;
00669 int keylen;
00670
00671 unsigned int nb_programs;
00672 AVProgram **programs;
00673
00678 enum CodecID video_codec_id;
00683 enum CodecID audio_codec_id;
00688 enum CodecID subtitle_codec_id;
00689
00700 unsigned int max_index_size;
00701
00706 unsigned int max_picture_buffer;
00707
00708 unsigned int nb_chapters;
00709 AVChapter **chapters;
00710
00714 int debug;
00715 #define FF_FDEBUG_TS 0x0001
00716
00723 struct AVPacketList *raw_packet_buffer;
00724 struct AVPacketList *raw_packet_buffer_end;
00725
00726 struct AVPacketList *packet_buffer_end;
00727
00728 AVMetadata *metadata;
00729
00734 #define RAW_PACKET_BUFFER_SIZE 2500000
00735 int raw_packet_buffer_remaining_size;
00736
00744 int64_t start_time_realtime;
00745 } AVFormatContext;
00746
00747 typedef struct AVPacketList {
00748 AVPacket pkt;
00749 struct AVPacketList *next;
00750 } AVPacketList;
00751
00752 #if LIBAVFORMAT_VERSION_INT < (53<<16)
00753 extern AVInputFormat *first_iformat;
00754 extern AVOutputFormat *first_oformat;
00755 #endif
00756
00762 AVInputFormat *av_iformat_next(AVInputFormat *f);
00763
00769 AVOutputFormat *av_oformat_next(AVOutputFormat *f);
00770
00771 enum CodecID av_guess_image2_codec(const char *filename);
00772
00773
00774
00775
00776
00777 void av_register_input_format(AVInputFormat *format);
00778 void av_register_output_format(AVOutputFormat *format);
00779 #if LIBAVFORMAT_VERSION_MAJOR < 53
00780 attribute_deprecated AVOutputFormat *guess_stream_format(const char *short_name,
00781 const char *filename,
00782 const char *mime_type);
00783
00787 attribute_deprecated AVOutputFormat *guess_format(const char *short_name,
00788 const char *filename,
00789 const char *mime_type);
00790 #endif
00791
00804 AVOutputFormat *av_guess_format(const char *short_name,
00805 const char *filename,
00806 const char *mime_type);
00807
00811 enum CodecID av_guess_codec(AVOutputFormat *fmt, const char *short_name,
00812 const char *filename, const char *mime_type,
00813 enum AVMediaType type);
00814
00824 void av_hex_dump(FILE *f, uint8_t *buf, int size);
00825
00838 void av_hex_dump_log(void *avcl, int level, uint8_t *buf, int size);
00839
00847 void av_pkt_dump(FILE *f, AVPacket *pkt, int dump_payload);
00848
00859 void av_pkt_dump_log(void *avcl, int level, AVPacket *pkt, int dump_payload);
00860
00870 void av_register_all(void);
00871
00879 enum CodecID av_codec_get_id(const struct AVCodecTag * const *tags, unsigned int tag);
00880
00888 unsigned int av_codec_get_tag(const struct AVCodecTag * const *tags, enum CodecID id);
00889
00890
00891
00895 AVInputFormat *av_find_input_format(const char *short_name);
00896
00903 AVInputFormat *av_probe_input_format(AVProbeData *pd, int is_opened);
00904
00916 AVInputFormat *av_probe_input_format2(AVProbeData *pd, int is_opened, int *score_max);
00917
00922 int av_open_input_stream(AVFormatContext **ic_ptr,
00923 ByteIOContext *pb, const char *filename,
00924 AVInputFormat *fmt, AVFormatParameters *ap);
00925
00938 int av_open_input_file(AVFormatContext **ic_ptr, const char *filename,
00939 AVInputFormat *fmt,
00940 int buf_size,
00941 AVFormatParameters *ap);
00942
00943 #if LIBAVFORMAT_VERSION_MAJOR < 53
00944
00947 attribute_deprecated AVFormatContext *av_alloc_format_context(void);
00948 #endif
00949
00955 AVFormatContext *avformat_alloc_context(void);
00956
00970 int av_find_stream_info(AVFormatContext *ic);
00971
00982 int av_read_packet(AVFormatContext *s, AVPacket *pkt);
00983
01003 int av_read_frame(AVFormatContext *s, AVPacket *pkt);
01004
01016 int av_seek_frame(AVFormatContext *s, int stream_index, int64_t timestamp,
01017 int flags);
01018
01045 int avformat_seek_file(AVFormatContext *s, int stream_index, int64_t min_ts, int64_t ts, int64_t max_ts, int flags);
01046
01051 int av_read_play(AVFormatContext *s);
01052
01058 int av_read_pause(AVFormatContext *s);
01059
01064 void av_close_input_stream(AVFormatContext *s);
01065
01071 void av_close_input_file(AVFormatContext *s);
01072
01083 AVStream *av_new_stream(AVFormatContext *s, int id);
01084 AVProgram *av_new_program(AVFormatContext *s, int id);
01085
01099 AVChapter *ff_new_chapter(AVFormatContext *s, int id, AVRational time_base,
01100 int64_t start, int64_t end, const char *title);
01101
01111 void av_set_pts_info(AVStream *s, int pts_wrap_bits,
01112 unsigned int pts_num, unsigned int pts_den);
01113
01114 #define AVSEEK_FLAG_BACKWARD 1
01115 #define AVSEEK_FLAG_BYTE 2
01116 #define AVSEEK_FLAG_ANY 4
01117 #define AVSEEK_FLAG_FRAME 8
01118
01119 int av_find_default_stream_index(AVFormatContext *s);
01120
01129 int av_index_search_timestamp(AVStream *st, int64_t timestamp, int flags);
01130
01138 void ff_reduce_index(AVFormatContext *s, int stream_index);
01139
01146 int av_add_index_entry(AVStream *st, int64_t pos, int64_t timestamp,
01147 int size, int distance, int flags);
01148
01157 int av_seek_frame_binary(AVFormatContext *s, int stream_index,
01158 int64_t target_ts, int flags);
01159
01168 void av_update_cur_dts(AVFormatContext *s, AVStream *ref_st, int64_t timestamp);
01169
01177 int64_t av_gen_search(AVFormatContext *s, int stream_index,
01178 int64_t target_ts, int64_t pos_min,
01179 int64_t pos_max, int64_t pos_limit,
01180 int64_t ts_min, int64_t ts_max,
01181 int flags, int64_t *ts_ret,
01182 int64_t (*read_timestamp)(struct AVFormatContext *, int , int64_t *, int64_t ));
01183
01185 int av_set_parameters(AVFormatContext *s, AVFormatParameters *ap);
01186
01194 int av_write_header(AVFormatContext *s);
01195
01208 int av_write_frame(AVFormatContext *s, AVPacket *pkt);
01209
01225 int av_interleaved_write_frame(AVFormatContext *s, AVPacket *pkt);
01226
01242 int av_interleave_packet_per_dts(AVFormatContext *s, AVPacket *out,
01243 AVPacket *pkt, int flush);
01244
01254 int av_write_trailer(AVFormatContext *s);
01255
01256 void dump_format(AVFormatContext *ic,
01257 int index,
01258 const char *url,
01259 int is_output);
01260
01261 #if LIBAVFORMAT_VERSION_MAJOR < 53
01262
01266 attribute_deprecated int parse_image_size(int *width_ptr, int *height_ptr,
01267 const char *str);
01268
01273 attribute_deprecated int parse_frame_rate(int *frame_rate, int *frame_rate_base,
01274 const char *arg);
01275 #endif
01276
01303 int64_t parse_date(const char *datestr, int duration);
01304
01306 int64_t av_gettime(void);
01307
01308
01309 #define FFM_PACKET_SIZE 4096
01310 int64_t ffm_read_write_index(int fd);
01311 int ffm_write_write_index(int fd, int64_t pos);
01312 void ffm_set_write_index(AVFormatContext *s, int64_t pos, int64_t file_size);
01313
01320 int find_info_tag(char *arg, int arg_size, const char *tag1, const char *info);
01321
01334 int av_get_frame_filename(char *buf, int buf_size,
01335 const char *path, int number);
01336
01343 int av_filename_number_test(const char *filename);
01344
01359 int avf_sdp_create(AVFormatContext *ac[], int n_files, char *buff, int size);
01360
01367 int av_match_ext(const char *filename, const char *extensions);
01368
01369 #endif