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 55
00026 #define LIBAVFORMAT_VERSION_MICRO 0
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
00123 typedef struct {
00124 char *key;
00125 char *value;
00126 }AVMetadataTag;
00127
00128 typedef struct AVMetadata AVMetadata;
00129 typedef struct AVMetadataConv AVMetadataConv;
00130
00137 AVMetadataTag *
00138 av_metadata_get(AVMetadata *m, const char *key, const AVMetadataTag *prev, int flags);
00139
00140 #if LIBAVFORMAT_VERSION_MAJOR == 52
00141
00147 int av_metadata_set(AVMetadata **pm, const char *key, const char *value);
00148 #endif
00149
00156 int av_metadata_set2(AVMetadata **pm, const char *key, const char *value, int flags);
00157
00165 void av_metadata_conv(struct AVFormatContext *ctx,const AVMetadataConv *d_conv,
00166 const AVMetadataConv *s_conv);
00167
00171 void av_metadata_free(AVMetadata **m);
00172
00173
00174
00175
00176
00185 int av_get_packet(ByteIOContext *s, AVPacket *pkt, int size);
00186
00187
00188
00189
00190
00195 typedef struct AVFrac {
00196 int64_t val, num, den;
00197 } AVFrac;
00198
00199
00200
00201
00202 struct AVCodecTag;
00203
00205 typedef struct AVProbeData {
00206 const char *filename;
00207 unsigned char *buf;
00208 int buf_size;
00209 } AVProbeData;
00210
00211 #define AVPROBE_SCORE_MAX 100
00212 #define AVPROBE_PADDING_SIZE 32
00213
00214 typedef struct AVFormatParameters {
00215 AVRational time_base;
00216 int sample_rate;
00217 int channels;
00218 int width;
00219 int height;
00220 enum PixelFormat pix_fmt;
00221 int channel;
00222 const char *standard;
00223 unsigned int mpeg2ts_raw:1;
00224 unsigned int mpeg2ts_compute_pcr:1;
00227 unsigned int initial_pause:1;
00229 unsigned int prealloced_context:1;
00230 #if LIBAVFORMAT_VERSION_INT < (53<<16)
00231 enum CodecID video_codec_id;
00232 enum CodecID audio_codec_id;
00233 #endif
00234 } AVFormatParameters;
00235
00237 #define AVFMT_NOFILE 0x0001
00238 #define AVFMT_NEEDNUMBER 0x0002
00239 #define AVFMT_SHOW_IDS 0x0008
00240 #define AVFMT_RAWPICTURE 0x0020
00242 #define AVFMT_GLOBALHEADER 0x0040
00243 #define AVFMT_NOTIMESTAMPS 0x0080
00244 #define AVFMT_GENERIC_INDEX 0x0100
00245 #define AVFMT_TS_DISCONT 0x0200
00246 #define AVFMT_VARIABLE_FPS 0x0400
00247 #define AVFMT_NODIMENSIONS 0x0800
00249 typedef struct AVOutputFormat {
00250 const char *name;
00256 const char *long_name;
00257 const char *mime_type;
00258 const char *extensions;
00260 int priv_data_size;
00261
00262 enum CodecID audio_codec;
00263 enum CodecID video_codec;
00264 int (*write_header)(struct AVFormatContext *);
00265 int (*write_packet)(struct AVFormatContext *, AVPacket *pkt);
00266 int (*write_trailer)(struct AVFormatContext *);
00268 int flags;
00270 int (*set_parameters)(struct AVFormatContext *, AVFormatParameters *);
00271 int (*interleave_packet)(struct AVFormatContext *, AVPacket *out,
00272 AVPacket *in, int flush);
00273
00278 const struct AVCodecTag * const *codec_tag;
00279
00280 enum CodecID subtitle_codec;
00282 const AVMetadataConv *metadata_conv;
00283
00284
00285 struct AVOutputFormat *next;
00286 } AVOutputFormat;
00287
00288 typedef struct AVInputFormat {
00289 const char *name;
00295 const char *long_name;
00297 int priv_data_size;
00303 int (*read_probe)(AVProbeData *);
00308 int (*read_header)(struct AVFormatContext *,
00309 AVFormatParameters *ap);
00316 int (*read_packet)(struct AVFormatContext *, AVPacket *pkt);
00319 int (*read_close)(struct AVFormatContext *);
00320
00321 #if LIBAVFORMAT_VERSION_MAJOR < 53
00322
00330 int (*read_seek)(struct AVFormatContext *,
00331 int stream_index, int64_t timestamp, int flags);
00332 #endif
00333
00337 int64_t (*read_timestamp)(struct AVFormatContext *s, int stream_index,
00338 int64_t *pos, int64_t pos_limit);
00340 int flags;
00344 const char *extensions;
00346 int value;
00347
00350 int (*read_play)(struct AVFormatContext *);
00351
00354 int (*read_pause)(struct AVFormatContext *);
00355
00356 const struct AVCodecTag * const *codec_tag;
00357
00364 int (*read_seek2)(struct AVFormatContext *s, int stream_index, int64_t min_ts, int64_t ts, int64_t max_ts, int flags);
00365
00366 const AVMetadataConv *metadata_conv;
00367
00368
00369 struct AVInputFormat *next;
00370 } AVInputFormat;
00371
00372 enum AVStreamParseType {
00373 AVSTREAM_PARSE_NONE,
00374 AVSTREAM_PARSE_FULL,
00375 AVSTREAM_PARSE_HEADERS,
00376 AVSTREAM_PARSE_TIMESTAMPS,
00377 };
00378
00379 typedef struct AVIndexEntry {
00380 int64_t pos;
00381 int64_t timestamp;
00382 #define AVINDEX_KEYFRAME 0x0001
00383 int flags:2;
00384 int size:30;
00385 int min_distance;
00386 } AVIndexEntry;
00387
00388 #define AV_DISPOSITION_DEFAULT 0x0001
00389 #define AV_DISPOSITION_DUB 0x0002
00390 #define AV_DISPOSITION_ORIGINAL 0x0004
00391 #define AV_DISPOSITION_COMMENT 0x0008
00392 #define AV_DISPOSITION_LYRICS 0x0010
00393 #define AV_DISPOSITION_KARAOKE 0x0020
00394
00402 typedef struct AVStream {
00403 int index;
00404 int id;
00405 AVCodecContext *codec;
00414 AVRational r_frame_rate;
00415 void *priv_data;
00416
00417
00418 int64_t first_dts;
00420 struct AVFrac pts;
00421
00427 AVRational time_base;
00428 int pts_wrap_bits;
00429
00430 int stream_copy;
00431 enum AVDiscard discard;
00432
00435 float quality;
00444 int64_t start_time;
00450 int64_t duration;
00451
00452 #if LIBAVFORMAT_VERSION_INT < (53<<16)
00453 char language[4];
00454 #endif
00455
00456
00457 enum AVStreamParseType need_parsing;
00458 struct AVCodecParserContext *parser;
00459
00460 int64_t cur_dts;
00461 int last_IP_duration;
00462 int64_t last_IP_pts;
00463
00464 AVIndexEntry *index_entries;
00466 int nb_index_entries;
00467 unsigned int index_entries_allocated_size;
00468
00469 int64_t nb_frames;
00470
00471 #if LIBAVFORMAT_VERSION_INT < (53<<16)
00472 int64_t unused[4+1];
00473
00474 char *filename;
00475 #endif
00476
00477 int disposition;
00479 AVProbeData probe_data;
00480 #define MAX_REORDER_DELAY 16
00481 int64_t pts_buffer[MAX_REORDER_DELAY+1];
00482
00488 AVRational sample_aspect_ratio;
00489
00490 AVMetadata *metadata;
00491
00492
00493 const uint8_t *cur_ptr;
00494 int cur_len;
00495 AVPacket cur_pkt;
00496
00497
00505 int64_t reference_dts;
00506
00511 #define MAX_PROBE_PACKETS 2500
00512 int probe_packets;
00513
00518 struct AVPacketList *last_in_packet_buffer;
00519
00523 AVRational avg_frame_rate;
00524
00528 int codec_info_nb_frames;
00529 } AVStream;
00530
00531 #define AV_PROGRAM_RUNNING 1
00532
00539 typedef struct AVProgram {
00540 int id;
00541 #if LIBAVFORMAT_VERSION_INT < (53<<16)
00542 char *provider_name;
00543 char *name;
00544 #endif
00545 int flags;
00546 enum AVDiscard discard;
00547 unsigned int *stream_index;
00548 unsigned int nb_stream_indexes;
00549 AVMetadata *metadata;
00550 } AVProgram;
00551
00552 #define AVFMTCTX_NOHEADER 0x0001
00555 typedef struct AVChapter {
00556 int id;
00557 AVRational time_base;
00558 int64_t start, end;
00559 #if LIBAVFORMAT_VERSION_INT < (53<<16)
00560 char *title;
00561 #endif
00562 AVMetadata *metadata;
00563 } AVChapter;
00564
00565 #if LIBAVFORMAT_VERSION_MAJOR < 53
00566 #define MAX_STREAMS 20
00567 #else
00568 #define MAX_STREAMS 100
00569 #endif
00570
00578 typedef struct AVFormatContext {
00579 const AVClass *av_class;
00580
00581 struct AVInputFormat *iformat;
00582 struct AVOutputFormat *oformat;
00583 void *priv_data;
00584 ByteIOContext *pb;
00585 unsigned int nb_streams;
00586 AVStream *streams[MAX_STREAMS];
00587 char filename[1024];
00588
00589 int64_t timestamp;
00590 #if LIBAVFORMAT_VERSION_INT < (53<<16)
00591 char title[512];
00592 char author[512];
00593 char copyright[512];
00594 char comment[512];
00595 char album[512];
00596 int year;
00597 int track;
00598 char genre[32];
00599 #endif
00600
00601 int ctx_flags;
00602
00606 struct AVPacketList *packet_buffer;
00607
00611 int64_t start_time;
00615 int64_t duration;
00617 int64_t file_size;
00621 int bit_rate;
00622
00623
00624 AVStream *cur_st;
00625 #if LIBAVFORMAT_VERSION_INT < (53<<16)
00626 const uint8_t *cur_ptr_deprecated;
00627 int cur_len_deprecated;
00628 AVPacket cur_pkt_deprecated;
00629 #endif
00630
00631
00632 int64_t data_offset;
00633 int index_built;
00634
00635 int mux_rate;
00636 unsigned int packet_size;
00637 int preload;
00638 int max_delay;
00639
00640 #define AVFMT_NOOUTPUTLOOP -1
00641 #define AVFMT_INFINITEOUTPUTLOOP 0
00642
00643 int loop_output;
00644
00645 int flags;
00646 #define AVFMT_FLAG_GENPTS 0x0001
00647 #define AVFMT_FLAG_IGNIDX 0x0002
00648 #define AVFMT_FLAG_NONBLOCK 0x0004
00649 #define AVFMT_FLAG_IGNDTS 0x0008
00650
00651 int loop_input;
00653 unsigned int probesize;
00654
00659 int max_analyze_duration;
00660
00661 const uint8_t *key;
00662 int keylen;
00663
00664 unsigned int nb_programs;
00665 AVProgram **programs;
00666
00671 enum CodecID video_codec_id;
00676 enum CodecID audio_codec_id;
00681 enum CodecID subtitle_codec_id;
00682
00693 unsigned int max_index_size;
00694
00699 unsigned int max_picture_buffer;
00700
00701 unsigned int nb_chapters;
00702 AVChapter **chapters;
00703
00707 int debug;
00708 #define FF_FDEBUG_TS 0x0001
00709
00716 struct AVPacketList *raw_packet_buffer;
00717 struct AVPacketList *raw_packet_buffer_end;
00718
00719 struct AVPacketList *packet_buffer_end;
00720
00721 AVMetadata *metadata;
00722
00727 #define RAW_PACKET_BUFFER_SIZE 2500000
00728 int raw_packet_buffer_remaining_size;
00729 } AVFormatContext;
00730
00731 typedef struct AVPacketList {
00732 AVPacket pkt;
00733 struct AVPacketList *next;
00734 } AVPacketList;
00735
00736 #if LIBAVFORMAT_VERSION_INT < (53<<16)
00737 extern AVInputFormat *first_iformat;
00738 extern AVOutputFormat *first_oformat;
00739 #endif
00740
00746 AVInputFormat *av_iformat_next(AVInputFormat *f);
00747
00753 AVOutputFormat *av_oformat_next(AVOutputFormat *f);
00754
00755 enum CodecID av_guess_image2_codec(const char *filename);
00756
00757
00758
00759
00760
00761 void av_register_input_format(AVInputFormat *format);
00762 void av_register_output_format(AVOutputFormat *format);
00763 #if LIBAVFORMAT_VERSION_MAJOR < 53
00764 attribute_deprecated AVOutputFormat *guess_stream_format(const char *short_name,
00765 const char *filename,
00766 const char *mime_type);
00767
00771 attribute_deprecated AVOutputFormat *guess_format(const char *short_name,
00772 const char *filename,
00773 const char *mime_type);
00774 #endif
00775
00788 AVOutputFormat *av_guess_format(const char *short_name,
00789 const char *filename,
00790 const char *mime_type);
00791
00795 enum CodecID av_guess_codec(AVOutputFormat *fmt, const char *short_name,
00796 const char *filename, const char *mime_type,
00797 enum CodecType type);
00798
00808 void av_hex_dump(FILE *f, uint8_t *buf, int size);
00809
00822 void av_hex_dump_log(void *avcl, int level, uint8_t *buf, int size);
00823
00831 void av_pkt_dump(FILE *f, AVPacket *pkt, int dump_payload);
00832
00843 void av_pkt_dump_log(void *avcl, int level, AVPacket *pkt, int dump_payload);
00844
00854 void av_register_all(void);
00855
00857 enum CodecID av_codec_get_id(const struct AVCodecTag * const *tags, unsigned int tag);
00858 unsigned int av_codec_get_tag(const struct AVCodecTag * const *tags, enum CodecID id);
00859
00860
00861
00865 AVInputFormat *av_find_input_format(const char *short_name);
00866
00873 AVInputFormat *av_probe_input_format(AVProbeData *pd, int is_opened);
00874
00879 int av_open_input_stream(AVFormatContext **ic_ptr,
00880 ByteIOContext *pb, const char *filename,
00881 AVInputFormat *fmt, AVFormatParameters *ap);
00882
00895 int av_open_input_file(AVFormatContext **ic_ptr, const char *filename,
00896 AVInputFormat *fmt,
00897 int buf_size,
00898 AVFormatParameters *ap);
00899
00900 #if LIBAVFORMAT_VERSION_MAJOR < 53
00901
00904 attribute_deprecated AVFormatContext *av_alloc_format_context(void);
00905 #endif
00906
00912 AVFormatContext *avformat_alloc_context(void);
00913
00927 int av_find_stream_info(AVFormatContext *ic);
00928
00939 int av_read_packet(AVFormatContext *s, AVPacket *pkt);
00940
00960 int av_read_frame(AVFormatContext *s, AVPacket *pkt);
00961
00973 int av_seek_frame(AVFormatContext *s, int stream_index, int64_t timestamp,
00974 int flags);
00975
01002 int avformat_seek_file(AVFormatContext *s, int stream_index, int64_t min_ts, int64_t ts, int64_t max_ts, int flags);
01003
01008 int av_read_play(AVFormatContext *s);
01009
01015 int av_read_pause(AVFormatContext *s);
01016
01021 void av_close_input_stream(AVFormatContext *s);
01022
01028 void av_close_input_file(AVFormatContext *s);
01029
01040 AVStream *av_new_stream(AVFormatContext *s, int id);
01041 AVProgram *av_new_program(AVFormatContext *s, int id);
01042
01056 AVChapter *ff_new_chapter(AVFormatContext *s, int id, AVRational time_base,
01057 int64_t start, int64_t end, const char *title);
01058
01068 void av_set_pts_info(AVStream *s, int pts_wrap_bits,
01069 unsigned int pts_num, unsigned int pts_den);
01070
01071 #define AVSEEK_FLAG_BACKWARD 1
01072 #define AVSEEK_FLAG_BYTE 2
01073 #define AVSEEK_FLAG_ANY 4
01074 #define AVSEEK_FLAG_FRAME 8
01075
01076 int av_find_default_stream_index(AVFormatContext *s);
01077
01086 int av_index_search_timestamp(AVStream *st, int64_t timestamp, int flags);
01087
01095 void ff_reduce_index(AVFormatContext *s, int stream_index);
01096
01103 int av_add_index_entry(AVStream *st, int64_t pos, int64_t timestamp,
01104 int size, int distance, int flags);
01105
01114 int av_seek_frame_binary(AVFormatContext *s, int stream_index,
01115 int64_t target_ts, int flags);
01116
01125 void av_update_cur_dts(AVFormatContext *s, AVStream *ref_st, int64_t timestamp);
01126
01134 int64_t av_gen_search(AVFormatContext *s, int stream_index,
01135 int64_t target_ts, int64_t pos_min,
01136 int64_t pos_max, int64_t pos_limit,
01137 int64_t ts_min, int64_t ts_max,
01138 int flags, int64_t *ts_ret,
01139 int64_t (*read_timestamp)(struct AVFormatContext *, int , int64_t *, int64_t ));
01140
01142 int av_set_parameters(AVFormatContext *s, AVFormatParameters *ap);
01143
01151 int av_write_header(AVFormatContext *s);
01152
01165 int av_write_frame(AVFormatContext *s, AVPacket *pkt);
01166
01182 int av_interleaved_write_frame(AVFormatContext *s, AVPacket *pkt);
01183
01199 int av_interleave_packet_per_dts(AVFormatContext *s, AVPacket *out,
01200 AVPacket *pkt, int flush);
01201
01211 int av_write_trailer(AVFormatContext *s);
01212
01213 void dump_format(AVFormatContext *ic,
01214 int index,
01215 const char *url,
01216 int is_output);
01217
01218 #if LIBAVFORMAT_VERSION_MAJOR < 53
01219
01223 attribute_deprecated int parse_image_size(int *width_ptr, int *height_ptr,
01224 const char *str);
01225
01230 attribute_deprecated int parse_frame_rate(int *frame_rate, int *frame_rate_base,
01231 const char *arg);
01232 #endif
01233
01260 int64_t parse_date(const char *datestr, int duration);
01261
01263 int64_t av_gettime(void);
01264
01265
01266 #define FFM_PACKET_SIZE 4096
01267 int64_t ffm_read_write_index(int fd);
01268 int ffm_write_write_index(int fd, int64_t pos);
01269 void ffm_set_write_index(AVFormatContext *s, int64_t pos, int64_t file_size);
01270
01277 int find_info_tag(char *arg, int arg_size, const char *tag1, const char *info);
01278
01291 int av_get_frame_filename(char *buf, int buf_size,
01292 const char *path, int number);
01293
01300 int av_filename_number_test(const char *filename);
01301
01316 int avf_sdp_create(AVFormatContext *ac[], int n_files, char *buff, int size);
01317
01318 #ifdef HAVE_AV_CONFIG_H
01319
01320 void ff_dynarray_add(intptr_t **tab_ptr, int *nb_ptr, intptr_t elem);
01321
01322 #ifdef __GNUC__
01323 #define dynarray_add(tab, nb_ptr, elem)\
01324 do {\
01325 __typeof__(tab) _tab = (tab);\
01326 __typeof__(elem) _elem = (elem);\
01327 (void)sizeof(**_tab == _elem); \
01328 ff_dynarray_add((intptr_t **)_tab, nb_ptr, (intptr_t)_elem);\
01329 } while(0)
01330 #else
01331 #define dynarray_add(tab, nb_ptr, elem)\
01332 do {\
01333 ff_dynarray_add((intptr_t **)(tab), nb_ptr, (intptr_t)(elem));\
01334 } while(0)
01335 #endif
01336
01337 time_t mktimegm(struct tm *tm);
01338 struct tm *brktimegm(time_t secs, struct tm *tm);
01339 const char *small_strptime(const char *p, const char *fmt,
01340 struct tm *dt);
01341
01348 int av_match_ext(const char *filename, const char *extensions);
01349
01350 #endif
01351
01352 #endif