Libav
avformat.h
Go to the documentation of this file.
1 /*
2  * copyright (c) 2001 Fabrice Bellard
3  *
4  * This file is part of Libav.
5  *
6  * Libav is free software; you can redistribute it and/or
7  * modify it under the terms of the GNU Lesser General Public
8  * License as published by the Free Software Foundation; either
9  * version 2.1 of the License, or (at your option) any later version.
10  *
11  * Libav is distributed in the hope that it will be useful,
12  * but WITHOUT ANY WARRANTY; without even the implied warranty of
13  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
14  * Lesser General Public License for more details.
15  *
16  * You should have received a copy of the GNU Lesser General Public
17  * License along with Libav; if not, write to the Free Software
18  * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
19  */
20 
21 #ifndef AVFORMAT_AVFORMAT_H
22 #define AVFORMAT_AVFORMAT_H
23 
253 #include <time.h>
254 #include <stdio.h> /* FILE */
255 #include "libavcodec/avcodec.h"
256 #include "libavutil/dict.h"
257 #include "libavutil/log.h"
258 
259 #include "avio.h"
260 #include "libavformat/version.h"
261 
262 struct AVFormatContext;
263 
264 
338 /* packet functions */
339 
340 
350 int av_get_packet(AVIOContext *s, AVPacket *pkt, int size);
351 
352 
367 int av_append_packet(AVIOContext *s, AVPacket *pkt, int size);
368 
369 /*************************************************/
370 /* fractional numbers for exact pts handling */
371 
376 typedef struct AVFrac {
377  int64_t val, num, den;
378 } AVFrac;
379 
380 /*************************************************/
381 /* input/output formats */
382 
383 struct AVCodecTag;
384 
388 typedef struct AVProbeData {
389  const char *filename;
390  unsigned char *buf;
391  int buf_size;
392 } AVProbeData;
393 
394 #define AVPROBE_SCORE_EXTENSION 50
395 #define AVPROBE_SCORE_MAX 100
396 
397 #define AVPROBE_PADDING_SIZE 32
398 
399 #define AVFMT_NOFILE 0x0001
401 #define AVFMT_NEEDNUMBER 0x0002
402 #define AVFMT_SHOW_IDS 0x0008
403 #define AVFMT_RAWPICTURE 0x0020
405 #define AVFMT_GLOBALHEADER 0x0040
406 #define AVFMT_NOTIMESTAMPS 0x0080
407 #define AVFMT_GENERIC_INDEX 0x0100
408 #define AVFMT_TS_DISCONT 0x0200
409 #define AVFMT_VARIABLE_FPS 0x0400
410 #define AVFMT_NODIMENSIONS 0x0800
411 #define AVFMT_NOSTREAMS 0x1000
412 #define AVFMT_NOBINSEARCH 0x2000
413 #define AVFMT_NOGENSEARCH 0x4000
414 #define AVFMT_NO_BYTE_SEEK 0x8000
415 #define AVFMT_ALLOW_FLUSH 0x10000
416 #define AVFMT_TS_NONSTRICT 0x20000
419 #define AVFMT_TS_NEGATIVE 0x40000
429 typedef struct AVOutputFormat {
430  const char *name;
436  const char *long_name;
437  const char *mime_type;
438  const char *extensions;
439  /* output support */
440  enum AVCodecID audio_codec;
441  enum AVCodecID video_codec;
442  enum AVCodecID subtitle_codec;
449  int flags;
450 
455  const struct AVCodecTag * const *codec_tag;
457 
458  const AVClass *priv_class;
459 
460  /*****************************************************************
461  * No fields below this line are part of the public API. They
462  * may not be used outside of libavformat and can be changed and
463  * removed at will.
464  * New public fields should be added right above.
465  *****************************************************************
466  */
467  struct AVOutputFormat *next;
471  int priv_data_size;
472 
473  int (*write_header)(struct AVFormatContext *);
481  int (*write_packet)(struct AVFormatContext *, AVPacket *pkt);
482  int (*write_trailer)(struct AVFormatContext *);
486  int (*interleave_packet)(struct AVFormatContext *, AVPacket *out,
487  AVPacket *in, int flush);
494  int (*query_codec)(enum AVCodecID id, int std_compliance);
504 typedef struct AVInputFormat {
509  const char *name;
510 
516  const char *long_name;
517 
523  int flags;
524 
530  const char *extensions;
531 
532  const struct AVCodecTag * const *codec_tag;
533 
534  const AVClass *priv_class;
535 
536  /*****************************************************************
537  * No fields below this line are part of the public API. They
538  * may not be used outside of libavformat and can be changed and
539  * removed at will.
540  * New public fields should be added right above.
541  *****************************************************************
542  */
543  struct AVInputFormat *next;
544 
548  int raw_codec_id;
549 
553  int priv_data_size;
554 
561 
567  int (*read_header)(struct AVFormatContext *);
568 
578  int (*read_packet)(struct AVFormatContext *, AVPacket *pkt);
579 
584  int (*read_close)(struct AVFormatContext *);
594  int (*read_seek)(struct AVFormatContext *,
595  int stream_index, int64_t timestamp, int flags);
596 
601  int64_t (*read_timestamp)(struct AVFormatContext *s, int stream_index,
602  int64_t *pos, int64_t pos_limit);
603 
608  int (*read_play)(struct AVFormatContext *);
609 
614  int (*read_pause)(struct AVFormatContext *);
622  int (*read_seek2)(struct AVFormatContext *s, int stream_index, int64_t min_ts, int64_t ts, int64_t max_ts, int flags);
623 } AVInputFormat;
628 enum AVStreamParseType {
634 };
636 typedef struct AVIndexEntry {
637  int64_t pos;
638  int64_t timestamp;
639 #define AVINDEX_KEYFRAME 0x0001
640  int flags:2;
641  int size:30; //Yeah, trying to keep the size of this small to reduce memory requirements (it is 24 vs. 32 bytes due to possible 8-byte alignment).
642  int min_distance;
645 #define AV_DISPOSITION_DEFAULT 0x0001
646 #define AV_DISPOSITION_DUB 0x0002
647 #define AV_DISPOSITION_ORIGINAL 0x0004
648 #define AV_DISPOSITION_COMMENT 0x0008
649 #define AV_DISPOSITION_LYRICS 0x0010
650 #define AV_DISPOSITION_KARAOKE 0x0020
651 
657 #define AV_DISPOSITION_FORCED 0x0040
658 #define AV_DISPOSITION_HEARING_IMPAIRED 0x0080
659 #define AV_DISPOSITION_VISUAL_IMPAIRED 0x0100
660 #define AV_DISPOSITION_CLEAN_EFFECTS 0x0200
667 #define AV_DISPOSITION_ATTACHED_PIC 0x0400
668 
676 typedef struct AVStream {
677  int index;
683  int id;
696  void *priv_data;
697 
701  struct AVFrac pts;
713 
720  int64_t start_time;
721 
727  int64_t duration;
728 
729  int64_t nb_frames;
730 
731  int disposition;
733  enum AVDiscard discard;
741 
743 
748 
757 
758  /*****************************************************************
759  * All fields below this line are not part of the public API. They
760  * may not be used outside of libavformat and can be changed and
761  * removed at will.
762  * New public fields should be added right above.
763  *****************************************************************
764  */
765 
769 #define MAX_STD_TIMEBASES (60*12+5)
770  struct {
771  int nb_decoded_frames;
772  int found_decoder;
773 
777  int64_t fps_first_dts;
779  int64_t fps_last_dts;
780  int fps_last_dts_idx;
781 
782  } *info;
783 
786 #if FF_API_REFERENCE_DTS
787  /* a hack to keep ABI compatibility for avconv, which accesses parser even
788  * though it should not */
789  int64_t do_not_use;
790 #endif
791  // Timestamp generation support:
792  int64_t first_dts;
793  int64_t cur_dts;
794  int64_t last_IP_pts;
795  int last_IP_duration;
796 
800 #define MAX_PROBE_PACKETS 2500
808  /* av_read_frame() support */
811 
817 #define MAX_REORDER_DELAY 16
818  int64_t pts_buffer[MAX_REORDER_DELAY+1];
819 
826 #define AV_PROGRAM_RUNNING 1
834 typedef struct AVProgram {
835  int id;
836  int flags;
837  enum AVDiscard discard;
838  unsigned int *stream_index;
839  unsigned int nb_stream_indexes;
843 #define AVFMTCTX_NOHEADER 0x0001
846 typedef struct AVChapter {
847  int id;
848  AVRational time_base;
849  int64_t start, end;
850  AVDictionary *metadata;
851 } AVChapter;
852 
853 typedef struct AVFormatInternal AVFormatInternal;
863 typedef struct AVFormatContext {
868  const AVClass *av_class;
869 
875  struct AVInputFormat *iformat;
882  struct AVOutputFormat *oformat;
891  void *priv_data;
892 
905  AVIOContext *pb;
906 
907  /* stream info */
908  int ctx_flags;
915  unsigned int nb_streams;
927  AVStream **streams;
928 
935  char filename[1024];
936 
944  int64_t start_time;
945 
954  int64_t duration;
955 
961  int bit_rate;
963  unsigned int packet_size;
964  int max_delay;
965 
966  int flags;
967 #define AVFMT_FLAG_GENPTS 0x0001
968 #define AVFMT_FLAG_IGNIDX 0x0002
969 #define AVFMT_FLAG_NONBLOCK 0x0004
970 #define AVFMT_FLAG_IGNDTS 0x0008
971 #define AVFMT_FLAG_NOFILLIN 0x0010
972 #define AVFMT_FLAG_NOPARSE 0x0020
973 #define AVFMT_FLAG_NOBUFFER 0x0040
974 #define AVFMT_FLAG_CUSTOM_IO 0x0080
975 #define AVFMT_FLAG_DISCARD_CORRUPT 0x0100
976 #define AVFMT_FLAG_FLUSH_PACKETS 0x0200
983  unsigned int probesize;
992  const uint8_t *key;
993  int keylen;
994 
995  unsigned int nb_programs;
997 
1009 
1015 
1026  unsigned int max_index_size;
1027 
1032  unsigned int max_picture_buffer;
1033 
1045  unsigned int nb_chapters;
1046  AVChapter **chapters;
1047 
1057 
1065 
1071  int fps_probe_size;
1078  int error_recognition;
1090 
1094  int debug;
1095 #define FF_FDEBUG_TS 0x0001
1096 
1113  int64_t max_interleave_delta;
1114 
1115  /*****************************************************************
1116  * All fields below this line are not part of the public API. They
1117  * may not be used outside of libavformat and can be changed and
1118  * removed at will.
1119  * New public fields should be added right above.
1120  *****************************************************************
1121  */
1122 
1128  struct AVPacketList *packet_buffer;
1130 
1131  /* av_seek_frame() support */
1132  int64_t data_offset;
1145  struct AVPacketList *parse_queue;
1146  struct AVPacketList *parse_queue_end;
1150 #define RAW_PACKET_BUFFER_SIZE 2500000
1152 
1157  int64_t offset;
1163 
1168  AVFormatInternal *internal;
1169 } AVFormatContext;
1171 typedef struct AVPacketList {
1172  AVPacket pkt;
1173  struct AVPacketList *next;
1174 } AVPacketList;
1175 
1189 unsigned avformat_version(void);
1190 
1194 const char *avformat_configuration(void);
1195 
1199 const char *avformat_license(void);
1200 
1210 void av_register_all(void);
1211 
1214 
1223 int avformat_network_init(void);
1224 
1228 int avformat_network_deinit(void);
1229 
1236 
1243 
1250 
1256 
1263 const AVClass *avformat_get_class(void);
1264 
1282 
1284 
1298 AVInputFormat *av_find_input_format(const char *short_name);
1299 
1307 AVInputFormat *av_probe_input_format(AVProbeData *pd, int is_opened);
1308 
1321 AVInputFormat *av_probe_input_format2(AVProbeData *pd, int is_opened, int *score_max);
1322 
1339  const char *filename, void *logctx,
1340  unsigned int offset, unsigned int max_probe_size);
1341 
1361 int avformat_open_input(AVFormatContext **ps, const char *filename, AVInputFormat *fmt, AVDictionary **options);
1362 
1385 
1411  enum AVMediaType type,
1412  int wanted_stream_nb,
1413  int related_stream,
1414  AVCodec **decoder_ret,
1415  int flags);
1416 
1442 
1456 int av_seek_frame(AVFormatContext *s, int stream_index, int64_t timestamp,
1457  int flags);
1458 
1486 int avformat_seek_file(AVFormatContext *s, int stream_index, int64_t min_ts, int64_t ts, int64_t max_ts, int flags);
1487 
1493 
1500 
1510 #define AVSEEK_FLAG_BACKWARD 1
1511 #define AVSEEK_FLAG_BYTE 2
1512 #define AVSEEK_FLAG_ANY 4
1513 #define AVSEEK_FLAG_FRAME 8
1514 
1515 
1535 
1567 
1602 
1613 
1626 AVOutputFormat *av_guess_format(const char *short_name,
1627  const char *filename,
1628  const char *mime_type);
1629 
1633 enum AVCodecID av_guess_codec(AVOutputFormat *fmt, const char *short_name,
1634  const char *filename, const char *mime_type,
1635  enum AVMediaType type);
1636 
1660 void av_hex_dump(FILE *f, const uint8_t *buf, int size);
1661 
1674 void av_hex_dump_log(void *avcl, int level, const uint8_t *buf, int size);
1675 
1684 void av_pkt_dump2(FILE *f, AVPacket *pkt, int dump_payload, AVStream *st);
1685 
1686 
1698 void av_pkt_dump_log2(void *avcl, int level, AVPacket *pkt, int dump_payload,
1699  AVStream *st);
1700 
1709 enum AVCodecID av_codec_get_id(const struct AVCodecTag * const *tags, unsigned int tag);
1710 
1719 unsigned int av_codec_get_tag(const struct AVCodecTag * const *tags, enum AVCodecID id);
1720 
1722 
1734 int av_index_search_timestamp(AVStream *st, int64_t timestamp, int flags);
1735 
1742 int av_add_index_entry(AVStream *st, int64_t pos, int64_t timestamp,
1743  int size, int distance, int flags);
1744 
1745 
1765 void av_url_split(char *proto, int proto_size,
1766  char *authorization, int authorization_size,
1767  char *hostname, int hostname_size,
1768  int *port_ptr,
1769  char *path, int path_size,
1770  const char *url);
1771 
1772 
1774  int index,
1775  const char *url,
1776  int is_output);
1777 
1790 int av_get_frame_filename(char *buf, int buf_size,
1791  const char *path, int number);
1792 
1799 int av_filename_number_test(const char *filename);
1800 
1818 int av_sdp_create(AVFormatContext *ac[], int n_files, char *buf, int size);
1819 
1827 int av_match_ext(const char *filename, const char *extensions);
1828 
1839 int avformat_query_codec(AVOutputFormat *ofmt, enum AVCodecID codec_id, int std_compliance);
1840 
1856 const struct AVCodecTag *avformat_get_riff_video_tags(void);
1860 const struct AVCodecTag *avformat_get_riff_audio_tags(void);
1869 #endif /* AVFORMAT_AVFORMAT_H */
unsigned int nb_chapters
Number of chapters in AVChapter array.
Definition: avformat.h:1053
unsigned int max_index_size
Maximum amount of memory in bytes to use for the index of each stream.
Definition: avformat.h:1034
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.
Definition: utils.c:3092
unsigned int packet_size
Definition: avformat.h:971
int64_t first_dts
Definition: avformat.h:799
full parsing and interpolation of timestamps for frames not starting on a packet boundary ...
Definition: avformat.h:639
Bytestream IO Context.
Definition: avio.h:68
AVProbeData probe_data
Definition: avformat.h:823
Buffered I/O operations.
int64_t start_time_realtime
Start time of the stream in real world time, in microseconds since the Unix epoch (00:00 1st January ...
Definition: avformat.h:1072
int size
int64_t(* read_timestamp)(struct AVFormatContext *s, int stream_index, int64_t *pos, int64_t pos_limit)
Get the next timestamp in stream[stream_index].time_base units.
Definition: avformat.h:608
int av_interleaved_write_frame(AVFormatContext *s, AVPacket *pkt)
Write a packet to an output media file ensuring correct interleaving.
Definition: mux.c:628
AVIOInterruptCB interrupt_callback
Custom interrupt callbacks for the I/O layer.
Definition: avformat.h:1097
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.
Definition: utils.c:1312
enum AVCodecID id
Definition: mxfenc.c:84
int avformat_write_header(AVFormatContext *s, AVDictionary **options)
Allocate the stream private data and write the stream header to an output media file.
Definition: mux.c:302
int av_write_frame(AVFormatContext *s, AVPacket *pkt)
Write a packet to an output media file.
Definition: mux.c:454
const char * filename
Definition: avformat.h:389
int avformat_open_input(AVFormatContext **ps, const char *filename, AVInputFormat *fmt, AVDictionary **options)
Open an input stream and read the header.
Definition: utils.c:381
int avformat_query_codec(AVOutputFormat *ofmt, enum AVCodecID codec_id, int std_compliance)
Test if the given container can store a codec.
Definition: utils.c:3313
int64_t pts_buffer[MAX_REORDER_DELAY+1]
Definition: avformat.h:825
unsigned int max_picture_buffer
Maximum amount of memory in bytes to use for buffering frames obtained from realtime capture devices...
Definition: avformat.h:1040
int64_t pos
Definition: avformat.h:644
int probe_packets
Definition: avformat.h:808
static int write_packet(AVFormatContext *s, AVPacket *pkt)
Definition: assenc.c:58
AVRational sample_aspect_ratio
sample aspect ratio (0 if unknown)
Definition: avformat.h:747
int index
stream index in AVFormatContext
Definition: avformat.h:684
AVIndexEntry * index_entries
Only used if the format does not support seeking natively.
Definition: avformat.h:827
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.
Definition: utils.c:3081
void * priv_data
Definition: avformat.h:703
int64_t data_offset
offset of the first packet
Definition: avformat.h:1140
int priv_data_size
Size of private data so that it can be allocated in the wrapper.
Definition: avformat.h:560
int ctx_flags
Format-specific flags, see AVFMTCTX_xx.
Definition: avformat.h:916
int id
Definition: avformat.h:842
enum AVCodecID subtitle_codec_id
Forced subtitle codec_id.
Definition: avformat.h:1022
AVCodec.
Definition: avcodec.h:2755
struct AVPacketList * packet_buffer
This buffer is only needed when packets were already buffered but not decoded, for example to get the...
Definition: avformat.h:1136
Format I/O context.
Definition: avformat.h:871
unsigned int nb_stream_indexes
Definition: avformat.h:846
int64_t cur_dts
Definition: avformat.h:800
Public dictionary API.
int flags
Definition: avformat.h:843
int(* read_close)(struct AVFormatContext *)
Close the stream.
Definition: avformat.h:591
uint8_t
const struct AVCodecTag * avformat_get_riff_video_tags(void)
Definition: riff.c:398
int flags
Can use flags: AVFMT_NOFILE, AVFMT_NEEDNUMBER, AVFMT_SHOW_IDS, AVFMT_GENERIC_INDEX, AVFMT_TS_DISCONT, AVFMT_NOBINSEARCH, AVFMT_NOGENSEARCH, AVFMT_NO_BYTE_SEEK.
Definition: avformat.h:530
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.
Definition: utils.c:59
const char * avformat_license(void)
Return the libavformat license.
Definition: utils.c:69
AVPacket pkt
Definition: avformat.h:1180
int priv_data_size
size of private data so that it can be allocated in the wrapper
Definition: avformat.h:478
enum AVStreamParseType need_parsing
Definition: avformat.h:816
int id
Format-specific stream ID.
Definition: avformat.h:690
const char * name
uint8_t pi<< 24) CONV_FUNC_GROUP(AV_SAMPLE_FMT_FLT, float, AV_SAMPLE_FMT_U8, uint8_t,(*(constuint8_t *) pi-0x80)*(1.0f/(1<< 7))) CONV_FUNC_GROUP(AV_SAMPLE_FMT_DBL, double, AV_SAMPLE_FMT_U8, uint8_t,(*(constuint8_t *) pi-0x80)*(1.0/(1<< 7))) CONV_FUNC_GROUP(AV_SAMPLE_FMT_U8, uint8_t, AV_SAMPLE_FMT_S16, int16_t,(*(constint16_t *) pi >>8)+0x80) CONV_FUNC_GROUP(AV_SAMPLE_FMT_FLT, float, AV_SAMPLE_FMT_S16, int16_t,*(constint16_t *) pi *(1.0f/(1<< 15))) CONV_FUNC_GROUP(AV_SAMPLE_FMT_DBL, double, AV_SAMPLE_FMT_S16, int16_t,*(constint16_t *) pi *(1.0/(1<< 15))) CONV_FUNC_GROUP(AV_SAMPLE_FMT_U8, uint8_t, AV_SAMPLE_FMT_S32, int32_t,(*(constint32_t *) pi >>24)+0x80) CONV_FUNC_GROUP(AV_SAMPLE_FMT_FLT, float, AV_SAMPLE_FMT_S32, int32_t,*(constint32_t *) pi *(1.0f/(1U<< 31))) CONV_FUNC_GROUP(AV_SAMPLE_FMT_DBL, double, AV_SAMPLE_FMT_S32, int32_t,*(constint32_t *) pi *(1.0/(1U<< 31))) CONV_FUNC_GROUP(AV_SAMPLE_FMT_U8, uint8_t, AV_SAMPLE_FMT_FLT, float, av_clip_uint8(lrintf(*(constfloat *) pi *(1<< 7))+0x80)) CONV_FUNC_GROUP(AV_SAMPLE_FMT_S16, int16_t, AV_SAMPLE_FMT_FLT, float, av_clip_int16(lrintf(*(constfloat *) pi *(1<< 15)))) CONV_FUNC_GROUP(AV_SAMPLE_FMT_S32, int32_t, AV_SAMPLE_FMT_FLT, float, av_clipl_int32(llrintf(*(constfloat *) pi *(1U<< 31)))) CONV_FUNC_GROUP(AV_SAMPLE_FMT_U8, uint8_t, AV_SAMPLE_FMT_DBL, double, av_clip_uint8(lrint(*(constdouble *) pi *(1<< 7))+0x80)) CONV_FUNC_GROUP(AV_SAMPLE_FMT_S16, int16_t, AV_SAMPLE_FMT_DBL, double, av_clip_int16(lrint(*(constdouble *) pi *(1<< 15)))) CONV_FUNC_GROUP(AV_SAMPLE_FMT_S32, int32_t, AV_SAMPLE_FMT_DBL, double, av_clipl_int32(llrint(*(constdouble *) pi *(1U<< 31))))#defineSET_CONV_FUNC_GROUP(ofmt, ifmt) staticvoidset_generic_function(AudioConvert *ac){}voidff_audio_convert_free(AudioConvert **ac){if(!*ac) return;ff_dither_free(&(*ac) ->dc);av_freep(ac);}AudioConvert *ff_audio_convert_alloc(AVAudioResampleContext *avr, enumAVSampleFormatout_fmt, enumAVSampleFormatin_fmt, intchannels, intsample_rate, intapply_map){AudioConvert *ac;intin_planar, out_planar;ac=av_mallocz(sizeof(*ac));if(!ac) returnNULL;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);returnNULL;}returnac;}in_planar=av_sample_fmt_is_planar(in_fmt);out_planar=av_sample_fmt_is_planar(out_fmt);if(in_planar==out_planar){ac->func_type=CONV_FUNC_TYPE_FLAT;ac->planes=in_planar?ac->channels:1;}elseif(in_planar) ac->func_type=CONV_FUNC_TYPE_INTERLEAVE;elseac->func_type=CONV_FUNC_TYPE_DEINTERLEAVE;set_generic_function(ac);if(ARCH_ARM) ff_audio_convert_init_arm(ac);if(ARCH_X86) ff_audio_convert_init_x86(ac);returnac;}intff_audio_convert(AudioConvert *ac, AudioData *out, AudioData *in){intuse_generic=1;intlen=in->nb_samples;intp;if(ac->dc){av_dlog(ac->avr,"%dsamples-audio_convert:%sto%s(dithered)\n", len, av_get_sample_fmt_name(ac->in_fmt), av_get_sample_fmt_name(ac->out_fmt));returnff_convert_dither(ac-> out
AVStream ** streams
A list of all streams in the file.
Definition: avformat.h:935
AVFormatContext * avformat_alloc_context(void)
Allocate an AVFormatContext.
Definition: options.c:98
const char * avformat_configuration(void)
Return the libavformat build-time configuration.
Definition: utils.c:64
#define MAX_REORDER_DELAY
Definition: avformat.h:824
const AVClass * priv_class
AVClass for the private context.
Definition: avformat.h:541
AVProgram * av_new_program(AVFormatContext *s, int id)
Definition: utils.c:2711
int(* read_header)(struct AVFormatContext *)
Read the format header and initialize the AVFormatContext structure.
Definition: avformat.h:574
int64_t max_interleave_delta
Maximum buffering duration for interleaving.
Definition: avformat.h:1121
static int flags
Definition: log.c:44
uint32_t tag
Definition: movenc.c:822
int avformat_network_init(void)
Do global initialization of network components.
Definition: utils.c:3329
const struct AVCodecTag * avformat_get_riff_audio_tags(void)
Definition: riff.c:403
int fps_probe_size
The number of frames used for determining the framerate in avformat_find_stream_info().
Definition: avformat.h:1079
int av_sdp_create(AVFormatContext *ac[], int n_files, char *buf, int size)
Generate an SDP for an RTP session.
Definition: sdp.c:689
int av_get_packet(AVIOContext *s, AVPacket *pkt, int size)
Allocate and read the payload of a packet and initialize its fields with default values.
Definition: utils.c:118
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.
Definition: format.c:73
const AVClass * avformat_get_class(void)
Get the AVClass for AVFormatContext.
Definition: options.c:114
enum AVDiscard discard
selects which program to discard and which to feed to the caller
Definition: avformat.h:844
static int interleave_packet(AVFormatContext *s, AVPacket *out, AVPacket *in, int flush)
Interleave an AVPacket correctly so it can be muxed.
Definition: mux.c:617
struct AVStream::@91 * info
unsigned int * stream_index
Definition: avformat.h:845
int64_t offset
Offset to remap timestamps to be non-negative.
Definition: avformat.h:1165
enum AVCodecID video_codec_id
Forced video codec_id.
Definition: avformat.h:1010
static int write_trailer(AVFormatContext *s)
Definition: assenc.c:64
int av_append_packet(AVIOContext *s, AVPacket *pkt, int size)
Read data and append it to the current content of the AVPacket.
Definition: utils.c:128
struct AVOutputFormat * oformat
The output container format.
Definition: avformat.h:890
struct AVPacketList * raw_packet_buffer
Raw packets from the demuxer, prior to parsing and decoding.
Definition: avformat.h:1148
void av_dump_format(AVFormatContext *ic, int index, const char *url, int is_output)
Definition: utils.c:2875
Callback for checking whether to abort blocking functions.
Definition: avio.h:51
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.
Definition: utils.c:2523
AVCodecID
Identify the syntax and semantics of the bitstream.
Definition: avcodec.h:105
AVDictionary * metadata
Metadata that applies to the whole file.
Definition: avformat.h:1064
int nb_decoded_frames
Definition: avformat.h:778
int av_index_search_timestamp(AVStream *st, int64_t timestamp, int flags)
Get the index for a specific timestamp.
Definition: utils.c:1353
int(* read_probe)(AVProbeData *)
Tell if a given file has a chance of being parsed as this format.
Definition: avformat.h:567
AVRational offset_timebase
Timebase for the timestamp offset.
Definition: avformat.h:1170
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.
Definition: utils.c:3047
int64_t timestamp
Definition: avformat.h:645
uint8_t pi<< 24) CONV_FUNC_GROUP(AV_SAMPLE_FMT_FLT, float, AV_SAMPLE_FMT_U8, uint8_t,(*(constuint8_t *) pi-0x80)*(1.0f/(1<< 7))) CONV_FUNC_GROUP(AV_SAMPLE_FMT_DBL, double, AV_SAMPLE_FMT_U8, uint8_t,(*(constuint8_t *) pi-0x80)*(1.0/(1<< 7))) CONV_FUNC_GROUP(AV_SAMPLE_FMT_U8, uint8_t, AV_SAMPLE_FMT_S16, int16_t,(*(constint16_t *) pi >>8)+0x80) CONV_FUNC_GROUP(AV_SAMPLE_FMT_FLT, float, AV_SAMPLE_FMT_S16, int16_t,*(constint16_t *) pi *(1.0f/(1<< 15))) CONV_FUNC_GROUP(AV_SAMPLE_FMT_DBL, double, AV_SAMPLE_FMT_S16, int16_t,*(constint16_t *) pi *(1.0/(1<< 15))) CONV_FUNC_GROUP(AV_SAMPLE_FMT_U8, uint8_t, AV_SAMPLE_FMT_S32, int32_t,(*(constint32_t *) pi >>24)+0x80) CONV_FUNC_GROUP(AV_SAMPLE_FMT_FLT, float, AV_SAMPLE_FMT_S32, int32_t,*(constint32_t *) pi *(1.0f/(1U<< 31))) CONV_FUNC_GROUP(AV_SAMPLE_FMT_DBL, double, AV_SAMPLE_FMT_S32, int32_t,*(constint32_t *) pi *(1.0/(1U<< 31))) CONV_FUNC_GROUP(AV_SAMPLE_FMT_U8, uint8_t, AV_SAMPLE_FMT_FLT, float, av_clip_uint8(lrintf(*(constfloat *) pi *(1<< 7))+0x80)) CONV_FUNC_GROUP(AV_SAMPLE_FMT_S16, int16_t, AV_SAMPLE_FMT_FLT, float, av_clip_int16(lrintf(*(constfloat *) pi *(1<< 15)))) CONV_FUNC_GROUP(AV_SAMPLE_FMT_S32, int32_t, AV_SAMPLE_FMT_FLT, float, av_clipl_int32(llrintf(*(constfloat *) pi *(1U<< 31)))) CONV_FUNC_GROUP(AV_SAMPLE_FMT_U8, uint8_t, AV_SAMPLE_FMT_DBL, double, av_clip_uint8(lrint(*(constdouble *) pi *(1<< 7))+0x80)) CONV_FUNC_GROUP(AV_SAMPLE_FMT_S16, int16_t, AV_SAMPLE_FMT_DBL, double, av_clip_int16(lrint(*(constdouble *) pi *(1<< 15)))) CONV_FUNC_GROUP(AV_SAMPLE_FMT_S32, int32_t, AV_SAMPLE_FMT_DBL, double, av_clipl_int32(llrint(*(constdouble *) pi *(1U<< 31))))#defineSET_CONV_FUNC_GROUP(ofmt, ifmt) staticvoidset_generic_function(AudioConvert *ac){}voidff_audio_convert_free(AudioConvert **ac){if(!*ac) return;ff_dither_free(&(*ac) ->dc);av_freep(ac);}AudioConvert *ff_audio_convert_alloc(AVAudioResampleContext *avr, enumAVSampleFormatout_fmt, enumAVSampleFormatin_fmt, intchannels, intsample_rate, intapply_map){AudioConvert *ac;intin_planar, out_planar;ac=av_mallocz(sizeof(*ac));if(!ac) returnNULL;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);returnNULL;}returnac;}in_planar=av_sample_fmt_is_planar(in_fmt);out_planar=av_sample_fmt_is_planar(out_fmt);if(in_planar==out_planar){ac->func_type=CONV_FUNC_TYPE_FLAT;ac->planes=in_planar?ac->channels:1;}elseif(in_planar) ac->func_type=CONV_FUNC_TYPE_INTERLEAVE;elseac->func_type=CONV_FUNC_TYPE_DEINTERLEAVE;set_generic_function(ac);if(ARCH_ARM) ff_audio_convert_init_arm(ac);if(ARCH_X86) ff_audio_convert_init_x86(ac);returnac;}intff_audio_convert(AudioConvert *ac, AudioData *out, AudioData *in){intuse_generic=1;intlen=in->nb_samples;intp;if(ac->dc){av_dlog(ac->avr,"%dsamples-audio_convert:%sto%s(dithered)\n", len, av_get_sample_fmt_name(ac->in_fmt), av_get_sample_fmt_name(ac->out_fmt));returnff_convert_dither(ac-> in
unsigned int nb_programs
Definition: avformat.h:1003
int last_IP_duration
Definition: avformat.h:802
int av_read_play(AVFormatContext *s)
Start playing a network-based stream (e.g.
Definition: utils.c:2577
AVChapter ** chapters
Definition: avformat.h:1054
AVStream * avformat_new_stream(AVFormatContext *s, AVCodec *c)
Add a new stream to a media file.
Definition: utils.c:2662
enum AVCodecID codec_id
Definition: mov_chan.c:432
AVRational avg_frame_rate
Average framerate.
Definition: avformat.h:754
New fields can be added to the end with minor version bumps.
Definition: avformat.h:841
AVInputFormat * av_probe_input_format2(AVProbeData *pd, int is_opened, int *score_max)
Guess the file format.
Definition: utils.c:142
int min_distance
Minimum distance between this and the previous keyframe, used to avoid unneeded searching.
Definition: avformat.h:649
The exact value of the fractional number is: 'val + num / den'.
Definition: avformat.h:376
Only parse headers, do not repack.
Definition: avformat.h:638
AVCodecContext * codec
Codec context associated with this stream.
Definition: avformat.h:702
static float distance(float x, float y, int band)
int buf_size
Size of buf except extra allocated bytes.
Definition: avformat.h:391
unsigned char * buf
Buffer must have AVPROBE_PADDING_SIZE of extra allocated bytes filled with zero.
Definition: avformat.h:390
unsigned int nb_streams
Number of elements in AVFormatContext.streams.
Definition: avformat.h:923
int64_t fps_first_dts
Those are used for average framerate estimation.
Definition: avformat.h:784
int av_read_pause(AVFormatContext *s)
Pause a network-based stream (e.g.
Definition: utils.c:2586
AVInputFormat * av_find_input_format(const char *short_name)
Find AVInputFormat based on the short name of the input format.
Definition: format.c:176
char filename[1024]
input or output filename
Definition: avformat.h:943
enum AVCodecID audio_codec_id
Forced audio codec_id.
Definition: avformat.h:1016
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.
Definition: format.c:153
int av_find_default_stream_index(AVFormatContext *s)
Definition: utils.c:1187
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.
Definition: utils.c:247
AVDictionary * metadata
Definition: avformat.h:749
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...
Definition: format.c:118
void av_register_input_format(AVInputFormat *format)
Definition: format.c:51
Libavformat version macros.
int(* read_pause)(struct AVFormatContext *)
Pause playing - only meaningful if using a network-based format (RTSP).
Definition: avformat.h:621
unsigned int probesize
Maximum size of the data read from input for determining the input container format.
Definition: avformat.h:991
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.
Definition: utils.c:2959
AVOutputFormat * av_oformat_next(AVOutputFormat *f)
If f is NULL, returns the first registered output format, if f is non-NULL, returns the next register...
Definition: format.c:43
const char * long_name
Descriptive name for the format, meant to be more human-readable than name.
Definition: avformat.h:523
int raw_packet_buffer_remaining_size
Definition: avformat.h:1159
Stream structure.
Definition: avformat.h:683
void av_register_output_format(AVOutputFormat *format)
Definition: format.c:62
int avformat_network_deinit(void)
Undo the initialization done by avformat_network_init.
Definition: utils.c:3341
Libavcodec external API header.
struct AVOutputFormat * next
Definition: avformat.h:474
int(* read_seek)(struct AVFormatContext *, int stream_index, int64_t timestamp, int flags)
Seek to a given timestamp relative to the frames in stream component stream_index.
Definition: avformat.h:601
int debug
Flags to enable debugging.
Definition: avformat.h:1102
AVIOContext * pb
I/O context.
Definition: avformat.h:913
main external API structure.
Definition: avcodec.h:1054
int av_filename_number_test(const char *filename)
Check whether filename actually is a numbered sequence generator.
Definition: utils.c:135
int(* read_packet)(struct AVFormatContext *, AVPacket *pkt)
Read one packet and put it in 'pkt'.
Definition: avformat.h:585
int nb_index_entries
Definition: avformat.h:829
Describe the class of an AVClass context structure.
Definition: log.h:33
int index
Definition: gxfenc.c:72
rational number numerator/denominator
Definition: rational.h:43
struct AVPacketList * packet_buffer_end
Definition: avformat.h:1137
const AVClass * av_class
A class for logging and AVOptions.
Definition: avformat.h:876
AVMediaType
Definition: avutil.h:185
int64_t fps_last_dts
Definition: avformat.h:786
int found_decoder
Definition: avformat.h:779
void avformat_free_context(AVFormatContext *s)
Free an AVFormatContext and all its streams.
Definition: utils.c:2595
This structure contains the data a format has to probe a file.
Definition: avformat.h:388
int av_read_frame(AVFormatContext *s, AVPacket *pkt)
Return the next frame of a stream.
Definition: utils.c:1120
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.
Definition: utils.c:1673
full parsing and repack of the first frame only, only implemented for H.264 currently ...
Definition: avformat.h:640
int raw_codec_id
Raw demuxers store their codec ID here.
Definition: avformat.h:555
struct AVPacketList * parse_queue_end
Definition: avformat.h:1154
AVDictionary * metadata
Definition: avformat.h:847
int fps_first_dts_idx
Definition: avformat.h:785
struct AVPacketList * parse_queue
Packets split by the parser get queued here.
Definition: avformat.h:1153
int64_t val
Definition: avformat.h:377
int64_t start_time
Position of the first frame of the component, in AV_TIME_BASE fractional seconds. ...
Definition: avformat.h:952
int64_t num
Definition: avformat.h:377
uint8_t level
Definition: svq3.c:143
int av_seek_frame(AVFormatContext *s, int stream_index, int64_t timestamp, int flags)
Seek to the keyframe at timestamp.
Definition: utils.c:1662
int64_t duration
Decoding: duration of the stream, in stream time base.
Definition: avformat.h:734
int64_t den
Definition: avformat.h:377
const OptionDef options[]
Definition: avserver.c:4624
const char * extensions
If extensions are defined, then no probe is done.
Definition: avformat.h:537
const uint8_t * key
Definition: avformat.h:1000
full parsing and repack
Definition: avformat.h:637
struct AVPacketList * next
Definition: avformat.h:1181
int(* read_play)(struct AVFormatContext *)
Start/resume playing - only meaningful if using a network-based format (RTSP).
Definition: avformat.h:615
int avformat_find_stream_info(AVFormatContext *ic, AVDictionary **options)
Read packets of a media file to get stream information.
Definition: utils.c:2201
static av_cold void flush(AVCodecContext *avctx)
Flush (reset) the frame ID after seeking.
Definition: alsdec.c:1792
int64_t start_time
Decoding: pts of the first frame of the stream, in stream time base.
Definition: avformat.h:727
int error_recognition
Error recognition; higher values will detect more errors but may misdetect some more or less valid pa...
Definition: avformat.h:1086
int disposition
AV_DISPOSITION_* bit field.
Definition: avformat.h:738
AVStreamParseType
Definition: avformat.h:635
int pts_wrap_bits
number of bits in pts (used for wrapping control)
Definition: avformat.h:791
int64_t nb_frames
number of frames in this stream if known or 0
Definition: avformat.h:736
int max_analyze_duration
Maximum duration (in AV_TIME_BASE units) of the data read from input in avformat_find_stream_info().
Definition: avformat.h:998
struct AVInputFormat * iformat
The input container format.
Definition: avformat.h:883
void avformat_close_input(AVFormatContext **s)
Close an opened input AVFormatContext.
Definition: utils.c:2640
AVInputFormat * av_iformat_next(AVInputFormat *f)
If f is NULL, returns the first registered input format, if f is non-NULL, returns the next registere...
Definition: format.c:35
unsigned int index_entries_allocated_size
Definition: avformat.h:830
struct AVFrac pts
encoding: pts generation when outputting stream
Definition: avformat.h:708
struct AVCodecParserContext * parser
Definition: avformat.h:817
void * priv_data
Format private data.
Definition: avformat.h:899
int codec_info_nb_frames
Number of frames that have been demuxed during av_find_stream_info()
Definition: avformat.h:813
static void write_header(FFV1Context *f)
Definition: ffv1enc.c:380
AVDiscard
Definition: avcodec.h:538
int av_write_trailer(AVFormatContext *s)
Write the stream trailer to an output media file and free the file private data.
Definition: mux.c:684
int bit_rate
Total stream bitrate in bit/s, 0 if not available.
Definition: avformat.h:969
int64_t duration
Duration of the stream, in AV_TIME_BASE fractional seconds.
Definition: avformat.h:962
int64_t last_IP_pts
Definition: avformat.h:801
int(* read_seek2)(struct AVFormatContext *s, int stream_index, int64_t min_ts, int64_t ts, int64_t max_ts, int flags)
Seek to timestamp ts.
Definition: avformat.h:629
const char * name
A comma separated list of short names for the format.
Definition: avformat.h:516
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.
Definition: utils.c:3086
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.
Definition: utils.c:3052
int fps_last_dts_idx
Definition: avformat.h:787
AVRational time_base
This is the fundamental unit of time (in seconds) in terms of which frame timestamps are represented...
Definition: avformat.h:719
struct AVInputFormat * next
Definition: avformat.h:550
unsigned int av_codec_get_tag(const struct AVCodecTag *const *tags, enum AVCodecID id)
Get the codec tag for the given codec id id.
enum AVDiscard discard
Selects which packets can be discarded at will and do not need to be demuxed.
Definition: avformat.h:740
AVInputFormat * av_probe_input_format(AVProbeData *pd, int is_opened)
Guess the file format.
Definition: utils.c:197
struct AVPacketList * raw_packet_buffer_end
Definition: avformat.h:1149
This structure stores compressed data.
Definition: avcodec.h:950
void av_register_all(void)
Initialize libavformat and register all the muxers, demuxers and protocols.
Definition: allformats.c:51
const struct AVCodecTag *const * codec_tag
Definition: avformat.h:539
AVPacket attached_pic
For streams with AV_DISPOSITION_ATTACHED_PIC disposition, this packet will contain the attached pictu...
Definition: avformat.h:763
struct AVPacketList * last_in_packet_buffer
last packet in packet_buffer for this stream when muxing.
Definition: avformat.h:822
AVProgram ** programs
Definition: avformat.h:1004