21 #ifndef AVFORMAT_AVFORMAT_H 22 #define AVFORMAT_AVFORMAT_H 385 typedef struct AVFrac {
386 int64_t val, num, den;
405 #define AVPROBE_SCORE_EXTENSION 50 406 #define AVPROBE_SCORE_MIME 75 407 #define AVPROBE_SCORE_MAX 100 409 #define AVPROBE_PADDING_SIZE 32 411 #define AVFMT_NOFILE 0x0001 413 #define AVFMT_NEEDNUMBER 0x0002 414 #define AVFMT_SHOW_IDS 0x0008 415 #if FF_API_LAVF_FMT_RAWPICTURE 416 #define AVFMT_RAWPICTURE 0x0020 419 #define AVFMT_GLOBALHEADER 0x0040 420 #define AVFMT_NOTIMESTAMPS 0x0080 421 #define AVFMT_GENERIC_INDEX 0x0100 422 #define AVFMT_TS_DISCONT 0x0200 423 #define AVFMT_VARIABLE_FPS 0x0400 424 #define AVFMT_NODIMENSIONS 0x0800 425 #define AVFMT_NOSTREAMS 0x1000 426 #define AVFMT_NOBINSEARCH 0x2000 427 #define AVFMT_NOGENSEARCH 0x4000 428 #define AVFMT_NO_BYTE_SEEK 0x8000 429 #define AVFMT_ALLOW_FLUSH 0x10000 430 #define AVFMT_TS_NONSTRICT 0x20000 433 #define AVFMT_TS_NEGATIVE 0x40000 443 typedef struct AVOutputFormat { 450 const char *long_name;
451 const char *mime_type;
452 const char *extensions;
508 int (*query_codec)(
enum AVCodecID id,
int std_compliance);
530 const char *long_name;
544 const char *extensions;
555 const char *mime_type;
616 int stream_index, int64_t timestamp,
int flags);
623 int64_t *pos, int64_t pos_limit);
660 #define AVINDEX_KEYFRAME 0x0001 666 #define AV_DISPOSITION_DEFAULT 0x0001 667 #define AV_DISPOSITION_DUB 0x0002 668 #define AV_DISPOSITION_ORIGINAL 0x0004 669 #define AV_DISPOSITION_COMMENT 0x0008 670 #define AV_DISPOSITION_LYRICS 0x0010 671 #define AV_DISPOSITION_KARAOKE 0x0020 678 #define AV_DISPOSITION_FORCED 0x0040 679 #define AV_DISPOSITION_HEARING_IMPAIRED 0x0080 680 #define AV_DISPOSITION_VISUAL_IMPAIRED 0x0100 681 #define AV_DISPOSITION_CLEAN_EFFECTS 0x0200 688 #define AV_DISPOSITION_ATTACHED_PIC 0x0400 707 #if FF_API_LAVF_AVCTX 814 #define AVSTREAM_EVENT_FLAG_METADATA_UPDATED 0x0001 838 #define MAX_STD_TIMEBASES (60*12+5) 840 int nb_decoded_frames;
846 int64_t fps_first_dts;
847 int fps_first_dts_idx;
848 int64_t fps_last_dts;
849 int fps_last_dts_idx;
859 int last_IP_duration;
864 #define MAX_PROBE_PACKETS 2500 870 int codec_info_nb_frames;
881 #define MAX_REORDER_DELAY 16 886 int nb_index_entries;
887 unsigned int index_entries_allocated_size;
896 #define AV_PROGRAM_RUNNING 1 908 unsigned int *stream_index;
909 unsigned int nb_stream_indexes;
913 #define AVFMTCTX_NOHEADER 0x0001 916 typedef struct AVChapter { 989 unsigned int nb_streams;
1009 char filename[1024];
1037 unsigned int packet_size;
1045 #define AVFMT_FLAG_GENPTS 0x0001 1046 #define AVFMT_FLAG_IGNIDX 0x0002 1047 #define AVFMT_FLAG_NONBLOCK 0x0004 1048 #define AVFMT_FLAG_IGNDTS 0x0008 1049 #define AVFMT_FLAG_NOFILLIN 0x0010 1050 #define AVFMT_FLAG_NOPARSE 0x0020 1051 #define AVFMT_FLAG_NOBUFFER 0x0040 1052 #define AVFMT_FLAG_CUSTOM_IO 0x0080 1053 #define AVFMT_FLAG_DISCARD_CORRUPT 0x0100 1054 #define AVFMT_FLAG_FLUSH_PACKETS 0x0200 1061 #define AVFMT_FLAG_BITEXACT 0x0400 1068 unsigned int probesize;
1075 int max_analyze_duration;
1080 unsigned int nb_programs;
1111 unsigned int max_index_size;
1117 unsigned int max_picture_buffer;
1130 unsigned int nb_chapters;
1149 int64_t start_time_realtime;
1163 int error_recognition;
1180 #define FF_FDEBUG_TS 0x0001 1198 int64_t max_interleave_delta;
1204 int strict_std_compliance;
1212 #define AVFMT_EVENT_FLAG_METADATA_UPDATED 0x0001 1227 int avoid_negative_ts;
1228 #define AVFMT_AVOID_NEG_TS_AUTO -1 1229 #define AVFMT_AVOID_NEG_TS_MAKE_NON_NEGATIVE 1 1230 #define AVFMT_AVOID_NEG_TS_MAKE_ZERO 2 1479 const char *filename,
void *logctx,
1480 unsigned int offset,
unsigned int max_probe_size);
1552 int wanted_stream_nb,
1650 #define AVSEEK_FLAG_BACKWARD 1 1651 #define AVSEEK_FLAG_BYTE 2 1652 #define AVSEEK_FLAG_ANY 4 1653 #define AVSEEK_FLAG_FRAME 8 1784 const char *filename,
1785 const char *mime_type);
1791 const char *filename,
const char *mime_type,
1923 char *authorization,
int authorization_size,
1924 char *hostname,
int hostname_size,
1926 char *path,
int path_size,
1958 const char *path,
int number);
1994 int av_match_ext(
const char *filename,
const char *extensions);
2007 int std_compliance);
void av_url_split(char *proto, int proto_size, char *authorization, int authorization_size, char *hostname, int hostname_size, int *port_ptr, char *path, int path_size, const char *url)
Split a URL string into components.
int av_interleaved_write_frame(AVFormatContext *s, AVPacket *pkt)
Write a packet to an output media file ensuring correct interleaving.
int av_add_index_entry(AVStream *st, int64_t pos, int64_t timestamp, int size, int distance, int flags)
Add an index entry into a sorted list.
int avformat_write_header(AVFormatContext *s, AVDictionary **options)
Allocate the stream private data and write the stream header to an output media file.
int av_write_frame(AVFormatContext *s, AVPacket *pkt)
Write a packet to an output media file.
int avformat_open_input(AVFormatContext **ps, const char *filename, AVInputFormat *fmt, AVDictionary **options)
Open an input stream and read the header.
static int read_seek(AVFormatContext *ctx, int stream_index, int64_t timestamp, int flags)
void av_pkt_dump2(FILE *f, AVPacket *pkt, int dump_payload, AVStream *st)
Send a nice dump of a packet to the specified file stream.
uint8_t * av_stream_get_side_data(AVStream *stream, enum AVPacketSideDataType type, int *size)
Get side information from stream.
This struct describes the properties of an encoded stream.
const struct AVCodecTag * avformat_get_riff_video_tags(void)
enum AVCodecID av_codec_get_id(const struct AVCodecTag *const *tags, unsigned int tag)
Get the AVCodecID for the given codec tag tag.
unsigned avformat_version(void)
Return the LIBAVFORMAT_VERSION_INT constant.
const char * avformat_license(void)
Return the libavformat license.
AVStream * avformat_new_stream(AVFormatContext *s, const AVCodec *c)
Add a new stream to a media file.
AVFormatContext * avformat_alloc_context(void)
Allocate an AVFormatContext.
const char * avformat_configuration(void)
Return the libavformat build-time configuration.
AVProgram * av_new_program(AVFormatContext *s, int id)
char * protocol_whitelist
A comma-separated list of protocol names that can be used internally by libavformat.
int avformat_network_init(void)
Do global initialization of network components.
const struct AVCodecTag * avformat_get_riff_audio_tags(void)
static av_cold int read_close(AVFormatContext *ctx)
int av_sdp_create(AVFormatContext *ac[], int n_files, char *buf, int size)
Generate an SDP for an RTP session.
int av_match_ext(const char *filename, const char *extensions)
Return a positive value if the given filename has one of the given extensions, 0 otherwise.
const AVClass * avformat_get_class(void)
Get the AVClass for AVFormatContext.
static int interleave_packet(AVFormatContext *s, AVPacket *out, AVPacket *in, int flush)
Interleave an AVPacket correctly so it can be muxed.
const OptionDef options[]
void av_dump_format(AVFormatContext *ic, int index, const char *url, int is_output)
Print detailed information about the input or output format, such as duration, bitrate, streams, container, programs, metadata, side data, codec and time base.
Callback for checking whether to abort blocking functions.
int av_find_best_stream(AVFormatContext *ic, enum AVMediaType type, int wanted_stream_nb, int related_stream, AVCodec **decoder_ret, int flags)
Find the "best" stream in the file.
static int64_t start_time
AVCodecID
Identify the syntax and semantics of the bitstream.
int av_index_search_timestamp(AVStream *st, int64_t timestamp, int flags)
Get the index for a specific timestamp.
void av_hex_dump(FILE *f, const uint8_t *buf, int size)
Send a nice hexadecimal dump of a buffer to the specified file stream.
struct AVCodecParser * parser
int av_read_play(AVFormatContext *s)
Start playing a network-based stream (e.g.
New fields can be added to the end with minor version bumps.
AVInputFormat * av_probe_input_format2(AVProbeData *pd, int is_opened, int *score_max)
Guess the file format.
int avformat_query_codec(const AVOutputFormat *ofmt, enum AVCodecID codec_id, int std_compliance)
Test if the given container can store a codec.
static float distance(float x, float y, int band)
const char * mime_type
mime_type, when known.
int buf_size
Size of buf except extra allocated bytes.
unsigned char * buf
Buffer must have AVPROBE_PADDING_SIZE of extra allocated bytes filled with zero.
int av_read_pause(AVFormatContext *s)
Pause a network-based stream (e.g.
AVInputFormat * av_find_input_format(const char *short_name)
Find AVInputFormat based on the short name of the input format.
enum AVCodecID av_guess_codec(AVOutputFormat *fmt, const char *short_name, const char *filename, const char *mime_type, enum AVMediaType type)
Guess the codec ID based upon muxer and filename.
int av_find_default_stream_index(AVFormatContext *s)
int av_probe_input_buffer(AVIOContext *pb, AVInputFormat **fmt, const char *filename, void *logctx, unsigned int offset, unsigned int max_probe_size)
Probe a bytestream to determine the input format.
uint8_t * av_stream_new_side_data(AVStream *stream, enum AVPacketSideDataType type, int size)
Allocate new information from stream.
AVOutputFormat * av_guess_format(const char *short_name, const char *filename, const char *mime_type)
Return the output format in the list of registered output formats which best matches the provided par...
void av_register_input_format(AVInputFormat *format)
AVOutputFormat * av_oformat_next(const AVOutputFormat *f)
If f is NULL, returns the first registered output format, if f is non-NULL, returns the next register...
int av_get_frame_filename(char *buf, int buf_size, const char *path, int number)
Return in 'buf' the path with 'd' replaced by a number.
static int read_header(FFV1Context *f)
void av_register_output_format(AVOutputFormat *format)
int avformat_network_deinit(void)
Undo the initialization done by avformat_network_init.
Libavcodec external API header.
AVIOContext * pb
I/O context.
main external API structure.
static void write_packet(OutputFile *of, AVPacket *pkt, OutputStream *ost)
static void(WINAPI *cond_broadcast)(pthread_cond_t *cond)
int av_filename_number_test(const char *filename)
Check whether filename actually is a numbered sequence generator.
void(* io_close)(struct AVFormatContext *s, AVIOContext *pb)
A callback for closing the streams opened with AVFormatContext.io_open().
static int read_packet(AVFormatContext *ctx, AVPacket *pkt)
uint8_t pi<< 24) CONV_FUNC_GROUP(AV_SAMPLE_FMT_FLT, float, AV_SAMPLE_FMT_U8, uint8_t,(*(const uint8_t *) pi - 0x80) *(1.0f/(1<< 7))) CONV_FUNC_GROUP(AV_SAMPLE_FMT_DBL, double, AV_SAMPLE_FMT_U8, uint8_t,(*(const uint8_t *) pi - 0x80) *(1.0/(1<< 7))) CONV_FUNC_GROUP(AV_SAMPLE_FMT_U8, uint8_t, AV_SAMPLE_FMT_S16, int16_t,(*(const int16_t *) pi >> 8)+0x80) CONV_FUNC_GROUP(AV_SAMPLE_FMT_FLT, float, AV_SAMPLE_FMT_S16, int16_t, *(const int16_t *) pi *(1.0f/(1<< 15))) CONV_FUNC_GROUP(AV_SAMPLE_FMT_DBL, double, AV_SAMPLE_FMT_S16, int16_t, *(const int16_t *) pi *(1.0/(1<< 15))) CONV_FUNC_GROUP(AV_SAMPLE_FMT_U8, uint8_t, AV_SAMPLE_FMT_S32, int32_t,(*(const int32_t *) pi >> 24)+0x80) CONV_FUNC_GROUP(AV_SAMPLE_FMT_FLT, float, AV_SAMPLE_FMT_S32, int32_t, *(const int32_t *) pi *(1.0f/(1U<< 31))) CONV_FUNC_GROUP(AV_SAMPLE_FMT_DBL, double, AV_SAMPLE_FMT_S32, int32_t, *(const int32_t *) pi *(1.0/(1U<< 31))) CONV_FUNC_GROUP(AV_SAMPLE_FMT_U8, uint8_t, AV_SAMPLE_FMT_FLT, float, av_clip_uint8(lrintf(*(const float *) pi *(1<< 7))+0x80)) CONV_FUNC_GROUP(AV_SAMPLE_FMT_S16, int16_t, AV_SAMPLE_FMT_FLT, float, av_clip_int16(lrintf(*(const float *) pi *(1<< 15)))) CONV_FUNC_GROUP(AV_SAMPLE_FMT_S32, int32_t, AV_SAMPLE_FMT_FLT, float, av_clipl_int32(llrintf(*(const float *) pi *(1U<< 31)))) CONV_FUNC_GROUP(AV_SAMPLE_FMT_U8, uint8_t, AV_SAMPLE_FMT_DBL, double, av_clip_uint8(lrint(*(const double *) pi *(1<< 7))+0x80)) CONV_FUNC_GROUP(AV_SAMPLE_FMT_S16, int16_t, AV_SAMPLE_FMT_DBL, double, av_clip_int16(lrint(*(const double *) pi *(1<< 15)))) CONV_FUNC_GROUP(AV_SAMPLE_FMT_S32, int32_t, AV_SAMPLE_FMT_DBL, double, av_clipl_int32(llrint(*(const double *) pi *(1U<< 31)))) #define SET_CONV_FUNC_GROUP(ofmt, ifmt) static void set_generic_function(AudioConvert *ac) { } void ff_audio_convert_free(AudioConvert **ac) { if(! *ac) return;ff_dither_free(&(*ac) ->dc);av_freep(ac);} AudioConvert *ff_audio_convert_alloc(AVAudioResampleContext *avr, enum AVSampleFormat out_fmt, enum AVSampleFormat in_fmt, int channels, int sample_rate, int apply_map) { AudioConvert *ac;int in_planar, out_planar;ac=av_mallocz(sizeof(*ac));if(!ac) return NULL;ac->avr=avr;ac->out_fmt=out_fmt;ac->in_fmt=in_fmt;ac->channels=channels;ac->apply_map=apply_map;if(avr->dither_method !=AV_RESAMPLE_DITHER_NONE &&av_get_packed_sample_fmt(out_fmt)==AV_SAMPLE_FMT_S16 &&av_get_bytes_per_sample(in_fmt) > 2) { ac->dc=ff_dither_alloc(avr, out_fmt, in_fmt, channels, sample_rate, apply_map);if(!ac->dc) { av_free(ac);return NULL;} return ac;} in_planar=ff_sample_fmt_is_planar(in_fmt, channels);out_planar=ff_sample_fmt_is_planar(out_fmt, channels);if(in_planar==out_planar) { ac->func_type=CONV_FUNC_TYPE_FLAT;ac->planes=in_planar ? ac->channels :1;} else if(in_planar) ac->func_type=CONV_FUNC_TYPE_INTERLEAVE;else ac->func_type=CONV_FUNC_TYPE_DEINTERLEAVE;set_generic_function(ac);if(ARCH_AARCH64) ff_audio_convert_init_aarch64(ac);if(ARCH_ARM) ff_audio_convert_init_arm(ac);if(ARCH_X86) ff_audio_convert_init_x86(ac);return ac;} int ff_audio_convert(AudioConvert *ac, AudioData *out, AudioData *in) { int use_generic=1;int len=in->nb_samples;int p;if(ac->dc) { av_log(ac->avr, AV_LOG_TRACE, "%d samples - audio_convert: %s to %s (dithered)\", len, av_get_sample_fmt_name(ac->in_fmt), av_get_sample_fmt_name(ac->out_fmt));return ff_convert_dither(ac-> in
Describe the class of an AVClass context structure.
rational number numerator/denominator
void avformat_free_context(AVFormatContext *s)
Free an AVFormatContext and all its streams.
This structure contains the data a format has to probe a file.
int av_read_frame(AVFormatContext *s, AVPacket *pkt)
Return the next frame of a stream.
int avformat_seek_file(AVFormatContext *s, int stream_index, int64_t min_ts, int64_t ts, int64_t max_ts, int flags)
Seek to timestamp ts.
static int64_t pts
Global timestamp for the audio frames.
#define attribute_deprecated
int av_seek_frame(AVFormatContext *s, int stream_index, int64_t timestamp, int flags)
Seek to the keyframe at timestamp.
struct AVPacketList * next
static AVInputFormat * iformat
int avformat_find_stream_info(AVFormatContext *ic, AVDictionary **options)
Read packets of a media file to get stream information.
static av_cold void flush(AVCodecContext *avctx)
Flush (reset) the frame ID after seeking.
void avformat_close_input(AVFormatContext **s)
Close an opened input AVFormatContext.
static void write_header(FFV1Context *f)
int av_write_trailer(AVFormatContext *s)
Write the stream trailer to an output media file and free the file private data.
char * protocol_blacklist
A comma-separated list of protocol names that will not be used internally by libavformat.
void av_pkt_dump_log2(void *avcl, int level, AVPacket *pkt, int dump_payload, AVStream *st)
Send a nice dump of a packet to the log.
void av_hex_dump_log(void *avcl, int level, const uint8_t *buf, int size)
Send a nice hexadecimal dump of a buffer to the log.
unsigned int av_codec_get_tag(const struct AVCodecTag *const *tags, enum AVCodecID id)
Get the codec tag for the given codec id id.
AVInputFormat * av_probe_input_format(AVProbeData *pd, int is_opened)
Guess the file format.
This structure stores compressed data.
void av_register_all(void)
Initialize libavformat and register all the muxers, demuxers and protocols.
AVInputFormat * av_iformat_next(const AVInputFormat *f)
If f is NULL, returns the first registered input format, if f is non-NULL, returns the next registere...