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 
256 #include <time.h>
257 #include <stdio.h> /* FILE */
258 #include "libavcodec/avcodec.h"
259 #include "libavutil/dict.h"
260 #include "libavutil/log.h"
261 
262 #include "avio.h"
263 #include "libavformat/version.h"
264 
265 struct AVFormatContext;
266 
267 
346 /* packet functions */
347 
348 
358 int av_get_packet(AVIOContext *s, AVPacket *pkt, int size);
359 
360 
375 int av_append_packet(AVIOContext *s, AVPacket *pkt, int size);
376 
377 #if FF_API_LAVF_FRAC
378 /*************************************************/
379 /* fractional numbers for exact pts handling */
380 
385 typedef struct AVFrac {
386  int64_t val, num, den;
387 } AVFrac;
388 #endif
389 
390 /*************************************************/
391 /* input/output formats */
392 
393 struct AVCodecTag;
394 
398 typedef struct AVProbeData {
399  const char *filename;
400  unsigned char *buf;
401  int buf_size;
402  const char *mime_type;
403 } AVProbeData;
404 
405 #define AVPROBE_SCORE_EXTENSION 50
406 #define AVPROBE_SCORE_MIME 75
407 #define AVPROBE_SCORE_MAX 100
408 
409 #define AVPROBE_PADDING_SIZE 32
410 
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
418 #endif
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 {
444  const char *name;
450  const char *long_name;
451  const char *mime_type;
452  const char *extensions;
453  /* output support */
454  enum AVCodecID audio_codec;
455  enum AVCodecID video_codec;
456  enum AVCodecID subtitle_codec;
463  int flags;
464 
469  const struct AVCodecTag * const *codec_tag;
470 
471 
472  const AVClass *priv_class;
473 
474  /*****************************************************************
475  * No fields below this line are part of the public API. They
476  * may not be used outside of libavformat and can be changed and
477  * removed at will.
478  * New public fields should be added right above.
479  *****************************************************************
480  */
481  struct AVOutputFormat *next;
485  int priv_data_size;
486 
487  int (*write_header)(struct AVFormatContext *);
495  int (*write_packet)(struct AVFormatContext *, AVPacket *pkt);
496  int (*write_trailer)(struct AVFormatContext *);
500  int (*interleave_packet)(struct AVFormatContext *, AVPacket *out,
501  AVPacket *in, int flush);
508  int (*query_codec)(enum AVCodecID id, int std_compliance);
518 typedef struct AVInputFormat {
523  const char *name;
530  const char *long_name;
531 
537  int flags;
538 
544  const char *extensions;
545 
546  const struct AVCodecTag * const *codec_tag;
547 
548  const AVClass *priv_class;
549 
555  const char *mime_type;
556 
557  /*****************************************************************
558  * No fields below this line are part of the public API. They
559  * may not be used outside of libavformat and can be changed and
560  * removed at will.
561  * New public fields should be added right above.
562  *****************************************************************
563  */
564  struct AVInputFormat *next;
565 
569  int raw_codec_id;
574  int priv_data_size;
581  int (*read_probe)(AVProbeData *);
582 
588  int (*read_header)(struct AVFormatContext *);
589 
599  int (*read_packet)(struct AVFormatContext *, AVPacket *pkt);
600 
605  int (*read_close)(struct AVFormatContext *);
606 
615  int (*read_seek)(struct AVFormatContext *,
616  int stream_index, int64_t timestamp, int flags);
617 
622  int64_t (*read_timestamp)(struct AVFormatContext *s, int stream_index,
623  int64_t *pos, int64_t pos_limit);
624 
629  int (*read_play)(struct AVFormatContext *);
630 
635  int (*read_pause)(struct AVFormatContext *);
636 
643  int (*read_seek2)(struct AVFormatContext *s, int stream_index, int64_t min_ts, int64_t ts, int64_t max_ts, int flags);
644 } AVInputFormat;
655 };
657 typedef struct AVIndexEntry {
658  int64_t pos;
659  int64_t timestamp;
660 #define AVINDEX_KEYFRAME 0x0001
661  int flags:2;
662  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).
663  int min_distance;
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
689 
690 typedef struct AVStreamInternal AVStreamInternal;
691 
699 typedef struct AVStream {
700  int index;
706  int id;
707 #if FF_API_LAVF_AVCTX
708 
713 #endif
714  void *priv_data;
715 
716 #if FF_API_LAVF_FRAC
717 
721  struct AVFrac pts;
722 #endif
723 
736  AVRational time_base;
737 
744  int64_t start_time;
745 
751  int64_t duration;
752 
753  int64_t nb_frames;
754 
755  int disposition;
757  enum AVDiscard discard;
758 
764  AVRational sample_aspect_ratio;
765 
766  AVDictionary *metadata;
767 
775  AVRational avg_frame_rate;
776 
784  AVPacket attached_pic;
785 
802  AVPacketSideData *side_data;
806  int nb_side_data;
807 
813  int event_flags;
814 #define AVSTREAM_EVENT_FLAG_METADATA_UPDATED 0x0001
815 
816  /*
817  * Codec parameters associated with this stream. Allocated and freed by
818  * libavformat in avformat_new_stream() and avformat_free_context()
819  * respectively.
820  *
821  * - demuxing: filled by libavformat on stream creation or in
822  * avformat_find_stream_info()
823  * - muxing: filled by the caller before avformat_write_header()
824  */
825  AVCodecParameters *codecpar;
826 
827  /*****************************************************************
828  * All fields below this line are not part of the public API. They
829  * may not be used outside of libavformat and can be changed and
830  * removed at will.
831  * New public fields should be added right above.
832  *****************************************************************
833  */
834 
838 #define MAX_STD_TIMEBASES (60*12+5)
839  struct {
840  int nb_decoded_frames;
841  int found_decoder;
842 
846  int64_t fps_first_dts;
847  int fps_first_dts_idx;
848  int64_t fps_last_dts;
849  int fps_last_dts_idx;
850 
851  } *info;
853  int pts_wrap_bits;
855  // Timestamp generation support:
856  int64_t first_dts;
857  int64_t cur_dts;
858  int64_t last_IP_pts;
859  int last_IP_duration;
860 
864 #define MAX_PROBE_PACKETS 2500
865  int probe_packets;
866 
870  int codec_info_nb_frames;
872  /* av_read_frame() support */
873  enum AVStreamParseType need_parsing;
875 
879  struct AVPacketList *last_in_packet_buffer;
880  AVProbeData probe_data;
881 #define MAX_REORDER_DELAY 16
882  int64_t pts_buffer[MAX_REORDER_DELAY+1];
883 
884  AVIndexEntry *index_entries;
886  int nb_index_entries;
887  unsigned int index_entries_allocated_size;
893  AVStreamInternal *internal;
894 } AVStream;
895 
896 #define AV_PROGRAM_RUNNING 1
897 
904 typedef struct AVProgram {
905  int id;
906  int flags;
907  enum AVDiscard discard;
908  unsigned int *stream_index;
909  unsigned int nb_stream_indexes;
910  AVDictionary *metadata;
913 #define AVFMTCTX_NOHEADER 0x0001
916 typedef struct AVChapter {
917  int id;
918  AVRational time_base;
919  int64_t start, end;
920  AVDictionary *metadata;
921 } AVChapter;
922 
933 typedef struct AVFormatContext {
938  const AVClass *av_class;
939 
946 
952  struct AVOutputFormat *oformat;
953 
961  void *priv_data;
962 
975  AVIOContext *pb;
976 
977  /* stream info */
982  int ctx_flags;
983 
989  unsigned int nb_streams;
1001  AVStream **streams;
1002 
1009  char filename[1024];
1010 
1018  int64_t start_time;
1019 
1028  int64_t duration;
1029 
1035  int bit_rate;
1036 
1037  unsigned int packet_size;
1038  int max_delay;
1039 
1044  int flags;
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
1062 
1068  unsigned int probesize;
1069 
1075  int max_analyze_duration;
1076 
1077  const uint8_t *key;
1078  int keylen;
1079 
1080  unsigned int nb_programs;
1081  AVProgram **programs;
1087  enum AVCodecID video_codec_id;
1093  enum AVCodecID audio_codec_id;
1099  enum AVCodecID subtitle_codec_id;
1111  unsigned int max_index_size;
1112 
1117  unsigned int max_picture_buffer;
1130  unsigned int nb_chapters;
1131  AVChapter **chapters;
1132 
1141  AVDictionary *metadata;
1142 
1149  int64_t start_time_realtime;
1150 
1156  int fps_probe_size;
1157 
1163  int error_recognition;
1164 
1174  AVIOInterruptCB interrupt_callback;
1175 
1179  int debug;
1180 #define FF_FDEBUG_TS 0x0001
1198  int64_t max_interleave_delta;
1199 
1204  int strict_std_compliance;
1211  int event_flags;
1212 #define AVFMT_EVENT_FLAG_METADATA_UPDATED 0x0001
1213 
1214 
1218  int max_ts_probe;
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
1231 
1232 
1236  AVFormatInternal *internal;
1241  void *opaque;
1242 
1263  int (*io_open)(struct AVFormatContext *s, AVIOContext **pb, const char *url,
1264  int flags, AVDictionary **options);
1265 
1269  void (*io_close)(struct AVFormatContext *s, AVIOContext *pb);
1278  char *protocol_blacklist;
1279 
1287  char *protocol_whitelist;
1288 } AVFormatContext;
1289 
1290 typedef struct AVPacketList {
1291  AVPacket pkt;
1292  struct AVPacketList *next;
1293 } AVPacketList;
1295 
1308 unsigned avformat_version(void);
1309 
1313 const char *avformat_configuration(void);
1314 
1318 const char *avformat_license(void);
1319 
1329 void av_register_all(void);
1330 
1333 
1342 int avformat_network_init(void);
1343 
1347 int avformat_network_deinit(void);
1348 
1355 
1362 
1369 
1375 
1382 const AVClass *avformat_get_class(void);
1383 
1401 
1411  enum AVPacketSideDataType type, int size);
1421  enum AVPacketSideDataType type, int *size);
1422 
1424 
1438 AVInputFormat *av_find_input_format(const char *short_name);
1439 
1447 AVInputFormat *av_probe_input_format(AVProbeData *pd, int is_opened);
1448 
1461 AVInputFormat *av_probe_input_format2(AVProbeData *pd, int is_opened, int *score_max);
1462 
1479  const char *filename, void *logctx,
1480  unsigned int offset, unsigned int max_probe_size);
1481 
1501 int avformat_open_input(AVFormatContext **ps, const char *filename, AVInputFormat *fmt, AVDictionary **options);
1502 
1525 
1551  enum AVMediaType type,
1552  int wanted_stream_nb,
1553  int related_stream,
1554  AVCodec **decoder_ret,
1555  int flags);
1556 
1582 
1596 int av_seek_frame(AVFormatContext *s, int stream_index, int64_t timestamp,
1597  int flags);
1598 
1626 int avformat_seek_file(AVFormatContext *s, int stream_index, int64_t min_ts, int64_t ts, int64_t max_ts, int flags);
1627 
1633 
1640 
1650 #define AVSEEK_FLAG_BACKWARD 1
1651 #define AVSEEK_FLAG_BYTE 2
1652 #define AVSEEK_FLAG_ANY 4
1653 #define AVSEEK_FLAG_FRAME 8
1654 
1655 
1675 
1714 
1759 
1770 
1783 AVOutputFormat *av_guess_format(const char *short_name,
1784  const char *filename,
1785  const char *mime_type);
1786 
1790 enum AVCodecID av_guess_codec(AVOutputFormat *fmt, const char *short_name,
1791  const char *filename, const char *mime_type,
1792  enum AVMediaType type);
1793 
1817 void av_hex_dump(FILE *f, const uint8_t *buf, int size);
1818 
1831 void av_hex_dump_log(void *avcl, int level, const uint8_t *buf, int size);
1832 
1841 void av_pkt_dump2(FILE *f, AVPacket *pkt, int dump_payload, AVStream *st);
1842 
1843 
1855 void av_pkt_dump_log2(void *avcl, int level, AVPacket *pkt, int dump_payload,
1856  AVStream *st);
1857 
1866 enum AVCodecID av_codec_get_id(const struct AVCodecTag * const *tags, unsigned int tag);
1867 
1876 unsigned int av_codec_get_tag(const struct AVCodecTag * const *tags, enum AVCodecID id);
1877 
1879 
1891 int av_index_search_timestamp(AVStream *st, int64_t timestamp, int flags);
1892 
1899 int av_add_index_entry(AVStream *st, int64_t pos, int64_t timestamp,
1900  int size, int distance, int flags);
1901 
1902 
1922 void av_url_split(char *proto, int proto_size,
1923  char *authorization, int authorization_size,
1924  char *hostname, int hostname_size,
1925  int *port_ptr,
1926  char *path, int path_size,
1927  const char *url);
1928 
1929 
1941  int index,
1942  const char *url,
1943  int is_output);
1944 
1957 int av_get_frame_filename(char *buf, int buf_size,
1958  const char *path, int number);
1959 
1966 int av_filename_number_test(const char *filename);
1967 
1985 int av_sdp_create(AVFormatContext *ac[], int n_files, char *buf, int size);
1986 
1994 int av_match_ext(const char *filename, const char *extensions);
1995 
2007  int std_compliance);
2008 
2024 const struct AVCodecTag *avformat_get_riff_video_tags(void);
2028 const struct AVCodecTag *avformat_get_riff_audio_tags(void);
2037 #endif /* AVFORMAT_AVFORMAT_H */
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:2870
full parsing and interpolation of timestamps for frames not starting on a packet boundary ...
Definition: avformat.h:659
Bytestream IO Context.
Definition: avio.h:104
Buffered I/O operations.
AVPacketSideDataType
Definition: avcodec.h:1191
int size
int av_interleaved_write_frame(AVFormatContext *s, AVPacket *pkt)
Write a packet to an output media file ensuring correct interleaving.
Definition: mux.c:662
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:1214
enum AVCodecID id
Definition: mxfenc.c:85
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:252
int av_write_frame(AVFormatContext *s, AVPacket *pkt)
Write a packet to an output media file.
Definition: mux.c:470
const char * filename
Definition: avformat.h:399
int avformat_open_input(AVFormatContext **ps, const char *filename, AVInputFormat *fmt, AVDictionary **options)
Open an input stream and read the header.
Definition: utils.c:284
static int read_seek(AVFormatContext *ctx, int stream_index, int64_t timestamp, int flags)
Definition: libcdio.c:153
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: dump.c:103
uint8_t * av_stream_get_side_data(AVStream *stream, enum AVPacketSideDataType type, int *size)
Get side information from stream.
Definition: utils.c:3265
int priv_data_size
Size of private data so that it can be allocated in the wrapper.
Definition: avformat.h:580
AVCodec.
Definition: avcodec.h:3120
This struct describes the properties of an encoded stream.
Definition: avcodec.h:3475
Format I/O context.
Definition: avformat.h:940
Public dictionary API.
uint8_t
const struct AVCodecTag * avformat_get_riff_video_tags(void)
Definition: riff.c:459
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:58
const char * avformat_license(void)
Return the libavformat license.
Definition: utils.c:68
AVPacket pkt
Definition: avformat.h:1298
int priv_data_size
size of private data so that it can be allocated in the wrapper
Definition: avformat.h:491
AVStream * avformat_new_stream(AVFormatContext *s, const AVCodec *c)
Add a new stream to a media file.
Definition: utils.c:2648
int64_t duration
Definition: movenc.c:63
AVFormatContext * avformat_alloc_context(void)
Allocate an AVFormatContext.
Definition: options.c:136
const char * avformat_configuration(void)
Return the libavformat build-time configuration.
Definition: utils.c:63
#define MAX_REORDER_DELAY
Definition: avformat.h:887
AVProgram * av_new_program(AVFormatContext *s, int id)
Definition: utils.c:2735
char * protocol_whitelist
A comma-separated list of protocol names that can be used internally by libavformat.
Definition: avformat.h:1294
static int flags
Definition: log.c:50
uint32_t tag
Definition: movenc.c:854
int avformat_network_init(void)
Do global initialization of network components.
Definition: utils.c:3100
const struct AVCodecTag * avformat_get_riff_audio_tags(void)
Definition: riff.c:464
static av_cold int read_close(AVFormatContext *ctx)
Definition: libcdio.c:145
int av_sdp_create(AVFormatContext *ac[], int n_files, char *buf, int size)
Generate an SDP for an RTP session.
Definition: sdp.c:805
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:117
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:77
const AVClass * avformat_get_class(void)
Get the AVClass for AVFormatContext.
Definition: options.c:153
static int interleave_packet(AVFormatContext *s, AVPacket *out, AVPacket *in, int flush)
Interleave an AVPacket correctly so it can be muxed.
Definition: mux.c:651
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:127
const OptionDef options[]
Definition: avconv_opt.c:2447
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.
Definition: dump.c:453
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:2482
static int64_t start_time
Definition: avplay.c:245
AVCodecID
Identify the syntax and semantics of the bitstream.
Definition: avcodec.h:193
int av_index_search_timestamp(AVStream *st, int64_t timestamp, int flags)
Get the index for a specific timestamp.
Definition: utils.c:1255
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: dump.c:69
struct AVCodecParser * parser
Definition: avcodec.h:4364
int av_read_play(AVFormatContext *s)
Start playing a network-based stream (e.g.
Definition: utils.c:2536
New fields can be added to the end with minor version bumps.
Definition: avformat.h:910
AVInputFormat * av_probe_input_format2(AVProbeData *pd, int is_opened, int *score_max)
Guess the file format.
Definition: format.c:171
Only parse headers, do not repack.
Definition: avformat.h:658
int avformat_query_codec(const AVOutputFormat *ofmt, enum AVCodecID codec_id, int std_compliance)
Test if the given container can store a codec.
Definition: utils.c:3084
static float distance(float x, float y, int band)
const char * mime_type
mime_type, when known.
Definition: avformat.h:402
int buf_size
Size of buf except extra allocated bytes.
Definition: avformat.h:401
unsigned char * buf
Buffer must have AVPROBE_PADDING_SIZE of extra allocated bytes filled with zero.
Definition: avformat.h:400
int av_read_pause(AVFormatContext *s)
Pause a network-based stream (e.g.
Definition: utils.c:2545
AVInputFormat * av_find_input_format(const char *short_name)
Find AVInputFormat based on the short name of the input format.
Definition: format.c:162
const char * name
Definition: qsvenc.c:44
static int read_probe(AVProbeData *pd)
Definition: jvdec.c:55
enum AVCodecID codec_id
Definition: avconv_vaapi.c:149
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:139
int av_find_default_stream_index(AVFormatContext *s)
Definition: utils.c:1089
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: format.c:238
uint8_t * av_stream_new_side_data(AVStream *stream, enum AVPacketSideDataType type, int size)
Allocate new information from stream.
Definition: utils.c:3280
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:104
void av_register_input_format(AVInputFormat *format)
Definition: format.c:55
Libavformat version macros.
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...
Definition: format.c:47
int av_get_frame_filename(char *buf, int buf_size, const char *path, int number)
Return in &#39;buf&#39; the path with &#39;d&#39; replaced by a number.
Definition: utils.c:2817
static int read_header(FFV1Context *f)
Definition: ffv1dec.c:546
Stream structure.
Definition: avformat.h:705
void av_register_output_format(AVOutputFormat *format)
Definition: format.c:66
int avformat_network_deinit(void)
Undo the initialization done by avformat_network_init.
Definition: utils.c:3112
Libavcodec external API header.
struct AVOutputFormat * next
Definition: avformat.h:487
AVIOContext * pb
I/O context.
Definition: avformat.h:982
main external API structure.
Definition: avcodec.h:1409
static void write_packet(OutputFile *of, AVPacket *pkt, OutputStream *ost)
Definition: avconv.c:278
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.
Definition: utils.c:134
void(* io_close)(struct AVFormatContext *s, AVIOContext *pb)
A callback for closing the streams opened with AVFormatContext.io_open().
Definition: avformat.h:1276
static int read_packet(AVFormatContext *ctx, AVPacket *pkt)
Definition: libcdio.c:114
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
const char * format
Definition: movenc.c:47
Describe the class of an AVClass context structure.
Definition: log.h:34
int index
Definition: gxfenc.c:72
rational number numerator/denominator
Definition: rational.h:43
AVMediaType
Definition: avutil.h:192
void avformat_free_context(AVFormatContext *s)
Free an AVFormatContext and all its streams.
Definition: utils.c:2594
This structure contains the data a format has to probe a file.
Definition: avformat.h:398
int av_read_frame(AVFormatContext *s, AVPacket *pkt)
Return the next frame of a stream.
Definition: utils.c:1021
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:1575
full parsing and repack of the first frame only, only implemented for H.264 currently ...
Definition: avformat.h:660
int raw_codec_id
Raw demuxers store their codec ID here.
Definition: avformat.h:575
static int64_t pts
Global timestamp for the audio frames.
uint8_t level
Definition: svq3.c:204
#define attribute_deprecated
Definition: attributes.h:80
int av_seek_frame(AVFormatContext *s, int stream_index, int64_t timestamp, int flags)
Seek to the keyframe at timestamp.
Definition: utils.c:1564
full parsing and repack
Definition: avformat.h:657
struct AVPacketList * next
Definition: avformat.h:1299
static AVInputFormat * iformat
Definition: avprobe.c:68
int avformat_find_stream_info(AVFormatContext *ic, AVDictionary **options)
Read packets of a media file to get stream information.
Definition: utils.c:2092
static av_cold void flush(AVCodecContext *avctx)
Flush (reset) the frame ID after seeking.
Definition: alsdec.c:1797
AVStreamParseType
Definition: avformat.h:655
void avformat_close_input(AVFormatContext **s)
Close an opened input AVFormatContext.
Definition: utils.c:2626
static void write_header(FFV1Context *f)
Definition: ffv1enc.c:373
AVDiscard
Definition: avcodec.h:681
int av_write_trailer(AVFormatContext *s)
Write the stream trailer to an output media file and free the file private data.
Definition: mux.c:714
char * protocol_blacklist
A comma-separated list of protocol names that will not be used internally by libavformat.
Definition: avformat.h:1285
FILE * out
Definition: movenc.c:54
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: dump.c:108
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: dump.c:74
struct AVInputFormat * next
Definition: avformat.h:570
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.
Definition: format.c:228
This structure stores compressed data.
Definition: avcodec.h:1323
void av_register_all(void)
Initialize libavformat and register all the muxers, demuxers and protocols.
Definition: allformats.c:44
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...
Definition: format.c:39
static int read_seek2(AVFormatContext *s, int stream_index, int64_t min_ts, int64_t ts, int64_t max_ts, int flags)
Definition: assdec.c:175