68 #define LICENSE_PREFIX "libavformat license: "
115 }
else if (num >= den) {
129 if(f)
return f->
next;
135 if(f)
return f->
next;
165 ext = strrchr(filename,
'.');
171 while (*p !=
'\0' && *p !=
',' && q-ext1<
sizeof(ext1)-1)
192 namelen = strlen(name);
193 while ((p = strchr(names,
','))) {
194 len =
FFMAX(p - names, namelen);
203 const char *mime_type)
206 int score_max, score;
209 #if CONFIG_IMAGE2_MUXER
210 if (!short_name && filename &&
221 if (fmt->
name && short_name && !strcmp(fmt->
name, short_name))
229 if (score > score_max) {
238 const char *filename,
const char *mime_type,
enum AVMediaType type){
242 #if CONFIG_IMAGE2_MUXER
243 if(!strcmp(fmt->
name,
"image2") || !strcmp(fmt->
name,
"image2pipe")){
293 old_size = pkt->
size;
336 if (score > *score_max) {
339 }
else if (score == *score_max)
354 if (fmt->extensions &&
av_match_ext(
"mp3", fmt->extensions)) {
370 static const struct {
389 for (i = 0; fmt_id_type[i].name; i++) {
390 if (!strcmp(fmt->
name, fmt_id_type[i].name)) {
403 #if FF_API_FORMAT_PARAMETERS
412 if (ap->time_base.num) {
413 snprintf(buf,
sizeof(buf),
"%d/%d", ap->time_base.den, ap->time_base.num);
416 if (ap->sample_rate) {
417 snprintf(buf,
sizeof(buf),
"%d", ap->sample_rate);
421 snprintf(buf,
sizeof(buf),
"%d", ap->channels);
424 if (ap->width || ap->height) {
425 snprintf(buf,
sizeof(buf),
"%dx%d", ap->width, ap->height);
432 snprintf(buf,
sizeof(buf),
"%d", ap->channel);
438 if (ap->mpeg2ts_compute_pcr) {
441 if (ap->initial_pause) {
461 memset(ap, 0,
sizeof(default_ap));
463 opts = convert_format_parameters(ap);
465 if(!ap->prealloced_context)
475 "will be ignored with AVFMT_NOFILE format.\n");
481 ic->
pb = ic->
pb ? ic->
pb : pb;
491 #define PROBE_BUF_MIN 2048
492 #define PROBE_BUF_MAX (1<<20)
495 const char *filename,
void *logctx,
496 unsigned int offset,
unsigned int max_probe_size)
499 unsigned char *buf =
NULL;
500 int ret = 0, probe_size;
502 if (!max_probe_size) {
510 if (offset >= max_probe_size) {
514 for(probe_size=
PROBE_BUF_MIN; probe_size<=max_probe_size && !*fmt;
515 probe_size =
FFMIN(probe_size<<1,
FFMAX(max_probe_size, probe_size+1))) {
518 if (probe_size < offset) {
534 pd.
buf = &buf[offset];
542 av_log(logctx,
AV_LOG_WARNING,
"Format detected only with low score of %d, misdetection possible!\n", score);
544 av_log(logctx,
AV_LOG_DEBUG,
"Probed with size=%d and score=%d\n", probe_size, score);
560 #if FF_API_FORMAT_PARAMETERS
569 if (!ap || !ap->prealloced_context)
624 if ((ret =
init_input(s, filename, &tmp)) < 0)
690 (*plast_pktl)->next = pktl;
692 *packet_buffer = pktl;
726 if (!pktl || ret ==
AVERROR(EAGAIN))
736 "Dropped corrupted packet (stream = %d)\n",
801 if (bits_per_sample) {
804 frame_size = (size << 3) / (bits_per_sample * enc->
channels);
854 if (frame_size <= 0 || st->codec->sample_rate <= 0)
890 int64_t dts, int64_t pts)
901 for(; pktl; pktl= pktl->
next){
925 for(; pktl; pktl= pktl->
next){
937 for(; pktl; pktl= pktl->
next){
957 int num, den, presentation_delayed, delay, i;
972 presentation_delayed = 0;
978 presentation_delayed = 1;
1035 presentation_delayed = 1;
1041 if (presentation_delayed) {
1064 if(old_diff < new_diff && old_diff < (pkt->
duration>>3)){
1208 av_log(s,
AV_LOG_WARNING,
"Invalid timestamps stream=%d, pts=%"PRId64
", dts=%"PRId64
", size=%d\n",
1218 av_log(s,
AV_LOG_DEBUG,
"av_read_packet stream=%d, pts=%"PRId64
", dts=%"PRId64
", size=%d, duration=%d, flags=%d\n",
1243 av_log(s,
AV_LOG_DEBUG,
"read_frame_internal stream=%d, pts=%"PRId64
", dts=%"PRId64
", size=%d, duration=%d, flags=%d\n",
1301 if (pktl && ret !=
AVERROR(EAGAIN)) {
1343 int first_audio_index = -1;
1355 first_audio_index = i;
1357 return first_audio_index >= 0 ? first_audio_index : 0;
1395 #if FF_API_SEEK_PUBLIC
1429 int *nb_index_entries,
1430 unsigned int *index_entries_allocated_size,
1436 if((
unsigned)*nb_index_entries + 1 >= UINT_MAX /
sizeof(
AVIndexEntry))
1440 index_entries_allocated_size,
1441 (*nb_index_entries + 1) *
1446 *index_entries= entries;
1451 index= (*nb_index_entries)++;
1452 ie= &entries[
index];
1453 assert(index==0 || ie[-1].timestamp < timestamp);
1455 ie= &entries[
index];
1459 memmove(entries + index + 1, entries + index,
sizeof(
AVIndexEntry)*(*nb_index_entries - index));
1460 (*nb_index_entries)++;
1461 }
else if(ie->
pos == pos && distance < ie->min_distance)
1479 timestamp, size, distance, flags);
1483 int64_t wanted_timestamp,
int flags)
1492 if(b && entries[b-1].timestamp < wanted_timestamp)
1498 if(timestamp >= wanted_timestamp)
1500 if(timestamp <= wanted_timestamp)
1520 wanted_timestamp, flags);
1523 #if FF_API_SEEK_PUBLIC
1533 int64_t ts_min, ts_max, ts;
1538 if (stream_index < 0)
1541 av_dlog(s,
"read_seek: %d %"PRId64
"\n", stream_index, target_ts);
1552 index=
FFMAX(index, 0);
1558 av_dlog(s,
"using cached pos_min=0x%"PRIx64
" dts_min=%"PRId64
"\n",
1565 assert(index < st->nb_index_entries);
1572 av_dlog(s,
"using cached pos_max=0x%"PRIx64
" pos_limit=0x%"PRIx64
" dts_max=%"PRId64
"\n",
1573 pos_max,pos_limit, ts_max);
1577 pos=
ff_gen_search(s, stream_index, target_ts, pos_min, pos_max, pos_limit, ts_min, ts_max, flags, &ts, avif->
read_timestamp);
1590 #if FF_API_SEEK_PUBLIC
1591 int64_t av_gen_search(
AVFormatContext *s,
int stream_index, int64_t target_ts,
1592 int64_t pos_min, int64_t pos_max, int64_t pos_limit,
1593 int64_t ts_min, int64_t ts_max,
int flags, int64_t *ts_ret,
1594 int64_t (*read_timestamp)(
struct AVFormatContext *,
int , int64_t *, int64_t ))
1596 return ff_gen_search(s, stream_index, target_ts, pos_min, pos_max,
1597 pos_limit, ts_min, ts_max, flags, ts_ret,
1603 int64_t pos_min, int64_t pos_max, int64_t pos_limit,
1604 int64_t ts_min, int64_t ts_max,
int flags, int64_t *ts_ret,
1605 int64_t (*read_timestamp)(
struct AVFormatContext *,
int , int64_t *, int64_t ))
1608 int64_t start_pos, filesize;
1611 av_dlog(s,
"gen_seek: %d %"PRId64
"\n", stream_index, target_ts);
1615 ts_min = read_timestamp(s, stream_index, &pos_min,
INT64_MAX);
1623 pos_max = filesize - 1;
1626 ts_max = read_timestamp(s, stream_index, &pos_max, pos_max + step);
1633 int64_t tmp_pos= pos_max + 1;
1634 int64_t tmp_ts= read_timestamp(s, stream_index, &tmp_pos,
INT64_MAX);
1639 if(tmp_pos >= filesize)
1645 if(ts_min > ts_max){
1647 }
else if(ts_min == ts_max){
1652 while (pos_min < pos_limit) {
1653 av_dlog(s,
"pos_min=0x%"PRIx64
" pos_max=0x%"PRIx64
" dts_min=%"PRId64
" dts_max=%"PRId64
"\n",
1654 pos_min, pos_max, ts_min, ts_max);
1655 assert(pos_limit <= pos_max);
1658 int64_t approximate_keyframe_distance= pos_max - pos_limit;
1660 pos =
av_rescale(target_ts - ts_min, pos_max - pos_min, ts_max - ts_min)
1661 + pos_min - approximate_keyframe_distance;
1662 }
else if(no_change==1){
1664 pos = (pos_min + pos_limit)>>1;
1672 else if(pos > pos_limit)
1676 ts = read_timestamp(s, stream_index, &pos,
INT64_MAX);
1681 av_dlog(s,
"%"PRId64
" %"PRId64
" %"PRId64
" / %"PRId64
" %"PRId64
" %"PRId64
" target:%"PRId64
" limit:%"PRId64
" start:%"PRId64
" noc:%d\n",
1682 pos_min, pos, pos_max, ts_min, ts, ts_max, target_ts,
1683 pos_limit, start_pos, no_change);
1689 if (target_ts <= ts) {
1690 pos_limit = start_pos - 1;
1694 if (target_ts >= ts) {
1703 ts_min = read_timestamp(s, stream_index, &pos_min,
INT64_MAX);
1705 ts_max = read_timestamp(s, stream_index, &pos_min,
INT64_MAX);
1706 av_dlog(s,
"pos=0x%"PRIx64
" %"PRId64
"<=%"PRId64
"<=%"PRId64
"\n",
1707 pos, ts_min, target_ts, ts_max);
1713 int64_t pos_min, pos_max;
1717 if (stream_index < 0)
1726 if (pos < pos_min) pos= pos_min;
1727 else if(pos > pos_max) pos= pos_max;
1732 av_update_cur_dts(s, st, ts);
1738 int stream_index, int64_t timestamp,
int flags)
1745 st = s->
streams[stream_index];
1749 if(index < 0 && st->nb_index_entries && timestamp < st->index_entries[0].timestamp)
1752 if(index < 0 || index==st->nb_index_entries-1){
1769 }
while (read_status ==
AVERROR(EAGAIN));
1770 if (read_status < 0)
1808 if(stream_index < 0){
1810 if(stream_index < 0)
1841 if(min_ts > ts || max_ts < ts)
1888 int64_t
start_time, start_time1, end_time, end_time1;
1889 int64_t
duration, duration1, filesize;
1900 start_time =
FFMIN(start_time, start_time1);
1902 end_time1 = start_time1
1904 end_time =
FFMAX(end_time, end_time1);
1909 duration =
FFMAX(duration, duration1);
1915 duration =
FFMAX(duration, end_time - start_time);
1981 #define DURATION_MAX_READ_SIZE 250000
1982 #define DURATION_MAX_RETRY 3
1989 int read_size, i, ret;
1991 int64_t filesize, offset,
duration;
2028 }
while(ret ==
AVERROR(EAGAIN));
2031 read_size += pkt->
size;
2036 duration = end_time = pkt->
pts;
2074 file_size =
FFMAX(0, file_size);
2098 av_dlog(ic,
"%d: start_time: %0.3f duration: %0.3f\n", i,
2102 av_dlog(ic,
"stream: start_time: %0.3f duration: %0.3f bitrate=%d kb/s\n",
2144 int got_picture = 1, ret = 0;
2159 av_dict_set(options ? options : &thread_opt,
"threads",
"1", 0);
2167 while ((pkt.
size > 0 || (!pkt.
data && got_picture)) &&
2177 &got_picture, &pkt);
2210 if(tag == tags[i].tag)
2223 for(i=0; tags && tags[i]; i++){
2233 for(i=0; tags && tags[i]; i++){
2254 if (j != i && next_start > ch->
start && next_start < end)
2262 if(i<60*12)
return i*1001;
2263 else return ((
const int[]){24,30,60,12,15})[i-60*12]*1000*12;
2286 #if FF_API_FORMAT_PARAMETERS
2295 int i, count, ret, read_size, j;
2325 av_dict_set(options ? &options[i] : &thread_opt,
"threads",
"1", 0);
2358 int fps_analyze_framecount = 20;
2367 fps_analyze_framecount *= 2;
2417 (options && i < orig_nb_streams) ?
2418 &options[i] :
NULL);
2423 "decoding for stream %d failed\n", st->
index);
2428 "Could not find codec parameters (%s)\n", buf);
2438 goto find_stream_info_err;
2440 read_size += pkt->
size;
2463 int ticks=
lrintf(dur*framerate/(1001*12));
2464 double error = dur - (double)ticks*1001*12 / framerate;
2531 if(error < best_error){
2582 if(ppkt1->stream_index != i)
2584 if(ppkt1->pkt->dts < 0)
2599 find_stream_info_err:
2621 int wanted_stream_nb,
2628 unsigned *program =
NULL;
2631 if (related_stream >= 0 && wanted_stream_nb < 0) {
2638 for (i = 0; i < nb_streams; i++) {
2639 int real_stream_index = program ? program[i] : i;
2644 if (wanted_stream_nb >= 0 && real_stream_index != wanted_stream_nb)
2659 ret = real_stream_index;
2661 if (program && i == nb_streams - 1 && ret < 0) {
2668 *decoder_ret = best_decoder;
2692 #if FF_API_FORMAT_PARAMETERS
2745 #if FF_API_CLOSE_INPUT_FILE
2766 #if FF_API_NEW_STREAM
2782 if (s->
nb_streams >= INT_MAX/
sizeof(*streams))
2831 av_dlog(ac,
"new_program: id=0x%04x\n",
id);
2867 chapter->
start = start;
2876 #if FF_API_FORMAT_PARAMETERS
2906 unsigned int tag = 0;
2934 #if FF_API_FORMAT_PARAMETERS
3002 "Tag %s/0x%08x incompatible with output codec id '%d'\n",
3013 av_log(s,
AV_LOG_WARNING,
"Codec for stream %d does not use global headers but container format requires global headers\n", i);
3078 int num, den, frame_size, i;
3080 av_dlog(s,
"compute_pkt_fields2: pts:%"PRId64
" dts:%"PRId64
" cur_dts:%"PRId64
" b:%d size:%d st:%d\n",
3117 "Application provided invalid, non monotonically increasing dts to muxer in stream %d: %"PRId64
" >= %"PRId64
"\n",
3171 this_pktl->
pkt= *pkt;
3182 while(!compare(s, &(*next_point)->pkt, pkt)){
3183 next_point= &(*next_point)->
next;
3190 assert(!*next_point);
3195 this_pktl->
next= *next_point;
3198 *next_point= this_pktl;
3225 if(stream_count && (s->
nb_streams == stream_count || flush)){
3270 av_dlog(s,
"av_interleaved_write_frame size:%d dts:%"PRId64
" pts:%"PRId64
"\n",
3373 if(strcmp(
"language", tag->
key))
3406 display_aspect_ratio.
num, display_aspect_ratio.
den);
3442 #if FF_API_DUMP_FORMAT
3463 is_output ?
"Output" :
"Input",
3466 is_output ?
"to" :
"from", url);
3471 int hours, mins, secs, us;
3508 int j, k, total = 0;
3513 name ? name->
value :
"");
3521 if (total < ic->nb_streams)
3534 gettimeofday(&tv,
NULL);
3535 return (int64_t)tv.tv_sec * 1000000 + tv.tv_usec;
3543 #if FF_API_PARSE_DATE
3546 int64_t parse_date(
const char *timestr,
int duration)
3554 #if FF_API_FIND_INFO_TAG
3557 int find_info_tag(
char *arg,
int arg_size,
const char *tag1,
const char *info)
3564 const char *path,
int number)
3567 char *q, buf1[20], c;
3568 int nd,
len, percentd_found;
3580 while (isdigit(*p)) {
3581 nd = nd * 10 + *p++ -
'0';
3584 }
while (isdigit(c));
3593 snprintf(buf1,
sizeof(buf1),
"%0*d", nd, number);
3595 if ((q - buf + len) > buf_size - 1)
3597 memcpy(q, buf1, len);
3605 if ((q - buf) < buf_size - 1)
3609 if (!percentd_found)
3622 #define PRINT(...) do { if (!f) av_log(avcl, level, __VA_ARGS__); else fprintf(f, __VA_ARGS__); } while(0)
3624 for(i=0;i<
size;i+=16) {
3631 PRINT(
" %02x", buf[i+j]);
3636 for(j=0;j<
len;j++) {
3638 if (c < ' ' || c >
'~')
3660 #define PRINT(...) do { if (!f) av_log(avcl, level, __VA_ARGS__); else fprintf(f, __VA_ARGS__); } while(0)
3684 void av_pkt_dump(FILE *
f,
AVPacket *pkt,
int dump_payload)
3697 void av_pkt_dump_log(
void *avcl,
int level,
AVPacket *pkt,
int dump_payload)
3711 char *authorization,
int authorization_size,
3712 char *hostname,
int hostname_size,
3714 char *path,
int path_size,
3717 const char *p, *ls, *at, *col, *brk;
3719 if (port_ptr) *port_ptr = -1;
3720 if (proto_size > 0) proto[0] = 0;
3721 if (authorization_size > 0) authorization[0] = 0;
3722 if (hostname_size > 0) hostname[0] = 0;
3723 if (path_size > 0) path[0] = 0;
3726 if ((p = strchr(url,
':'))) {
3738 ls = strchr(p,
'/');
3740 ls = strchr(p,
'?');
3749 if ((at = strchr(p,
'@')) && at < ls) {
3751 FFMIN(authorization_size, at + 1 - p));
3755 if (*p ==
'[' && (brk = strchr(p,
']')) && brk < ls) {
3758 FFMIN(hostname_size, brk - p));
3759 if (brk[1] ==
':' && port_ptr)
3760 *port_ptr = atoi(brk + 2);
3761 }
else if ((col = strchr(p,
':')) && col < ls) {
3763 FFMIN(col + 1 - p, hostname_size));
3764 if (port_ptr) *port_ptr = atoi(col + 1);
3767 FFMIN(ls + 1 - p, hostname_size));
3774 static const char hex_table_uc[16] = {
'0',
'1',
'2',
'3',
3777 'C',
'D',
'E',
'F' };
3778 static const char hex_table_lc[16] = {
'0',
'1',
'2',
'3',
3781 'c',
'd',
'e',
'f' };
3782 const char *hex_table = lowercase ? hex_table_lc : hex_table_uc;
3784 for(i = 0; i < s; i++) {
3785 buff[i * 2] = hex_table[src[i] >> 4];
3786 buff[i * 2 + 1] = hex_table[src[i] & 0xF];
3802 c = toupper((
unsigned char) *p++);
3803 if (c >=
'0' && c <=
'9')
3805 else if (c >=
'A' && c <=
'F')
3820 #if FF_API_SET_PTS_INFO
3821 void av_set_pts_info(
AVStream *s,
int pts_wrap_bits,
3822 unsigned int pts_num,
unsigned int pts_den)
3829 unsigned int pts_num,
unsigned int pts_den)
3833 if(new_tb.
num != pts_num)
3838 if(new_tb.
num <= 0 || new_tb.
den <= 0) {
3847 const char *authorization,
const char *hostname,
3848 int port,
const char *fmt, ...)
3857 if (authorization && authorization[0])
3859 #if CONFIG_NETWORK && defined(AF_INET6)
3862 memset(&hints, 0,
sizeof(hints));
3882 int len = strlen(str);
3885 vsnprintf(str + len, size > len ? size - len : 0, fmt, vl);
3912 const char *ptr = str;
3917 char *dest =
NULL, *dest_end;
3918 int key_len, dest_len = 0;
3921 while (*ptr && (isspace(*ptr) || *ptr ==
','))
3928 if (!(ptr = strchr(key,
'=')))
3931 key_len = ptr - key;
3933 callback_get_buf(context, key, key_len, &dest, &dest_len);
3934 dest_end = dest + dest_len - 1;
3938 while (*ptr && *ptr !=
'\"') {
3942 if (dest && dest < dest_end)
3946 if (dest && dest < dest_end)
3954 for (; *ptr && !(isspace(*ptr) || *ptr ==
','); ptr++)
3955 if (dest && dest < dest_end)
3978 if (base && strstr(base,
"://") && rel[0] ==
'/') {
3981 sep = strstr(buf,
"://");
3984 sep = strchr(sep,
'/');
3992 if (!base || strstr(rel,
"://") || rel[0] ==
'/') {
3999 sep = strrchr(buf,
'/');
4007 sep = strrchr(buf,
'/');
4009 if (!strcmp(sep ? &sep[1] : buf,
"..")) {
4027 struct tm time1 = {0}, time2 = {0};
4029 ret1 = strptime(datestr,
"%Y - %m - %d %T", &time1);
4030 ret2 = strptime(datestr,
"%Y - %m - %dT%T", &time2);
4037 "the date string.\n");
4046 return ofmt->
query_codec(codec_id, std_compliance);
4078 uint64_t channel_layout, int32_t sample_rate,
4090 if (channel_layout) {
4098 if (width || height) {
4105 bytestream_put_le32(&data, flags);
4107 bytestream_put_le32(&data, channels);
4109 bytestream_put_le64(&data, channel_layout);
4111 bytestream_put_le32(&data, sample_rate);
4112 if (width || height) {
4113 bytestream_put_le32(&data, width);
4114 bytestream_put_le32(&data, height);
time_t av_timegm(struct tm *tm)
Convert the decomposed UTC time in tm to a time_t value.
unsigned int max_index_size
Maximum amount of memory in bytes to use for the index of each stream.
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.
void * av_mallocz(size_t size)
Allocate a block of size bytes with alignment suitable for all memory accesses (including vectors if ...
enum PixelFormat pix_fmt
Pixel format, see PIX_FMT_xxx.
int av_interleave_packet_per_dts(AVFormatContext *s, AVPacket *out, AVPacket *pkt, int flush)
Interleave a packet per dts in an output media file.
#define AVERROR_INVALIDDATA
Invalid data found when processing input.
int64_t avio_size(AVIOContext *s)
Get the filesize.
int av_interleaved_write_frame(AVFormatContext *s, AVPacket *pkt)
Write a packet to an output media file ensuring correct interleaving.
AVIOInterruptCB interrupt_callback
Custom interrupt callbacks for the I/O layer.
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.
int64_t av_rescale_rnd(int64_t a, int64_t b, int64_t c, enum AVRounding rnd)
Rescale a 64-bit integer with specified rounding.
enum CodecID 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.
int64_t pos
byte position in stream, -1 if unknown
int avformat_open_input(AVFormatContext **ps, const char *filename, AVInputFormat *fmt, AVDictionary **options)
Open an input stream and read the header.
int64_t pts_buffer[MAX_REORDER_DELAY+1]
int av_parse_time(int64_t *timeval, const char *timestr, int duration)
Parse timestr and return in *time a corresponding number of microseconds.
int av_new_packet(AVPacket *pkt, int size)
Allocate the payload of a packet and initialize its fields with default values.
int max_b_frames
maximum number of B-frames between non-B-frames Note: The output will be delayed by max_b_frames+1 re...
#define AV_LOG_WARNING
Something somehow does not look correct.
AVCodecParserContext * av_parser_init(int codec_id)
void av_opt_set_defaults(void *s)
Set the values of all AVOption fields to their default values.
AVRational sample_aspect_ratio
sample aspect ratio (0 if unknown)
int index
stream index in AVFormatContext
int avcodec_is_open(AVCodecContext *s)
#define ID3v2_DEFAULT_MAGIC
Default magic bytes for ID3v2 header: "ID3".
int64_t avio_seek(AVIOContext *s, int64_t offset, int whence)
fseek() equivalent for AVIOContext.
#define AVIO_FLAG_READ
read-only
AVIndexEntry * index_entries
Only used if the format does not support seeking natively.
AVRational sample_aspect_ratio
sample aspect ratio (0 if unknown) That is the width of a pixel divided by the height of the pixel...
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.
int av_strncasecmp(const char *a, const char *b, size_t n)
Locale-independent case-insensitive compare.
void ff_network_close(void)
static int av_cmp_q(AVRational a, AVRational b)
Compare two rationals.
void * av_realloc(void *ptr, size_t size)
Allocate or reallocate a block of memory.
#define FF_ARRAY_ELEMS(a)
#define AV_PKT_FLAG_KEY
The packet contains a keyframe.
int64_t data_offset
offset of the first packet
int ctx_flags
Format-specific flags, see AVFMTCTX_xx.
int dts_ref_dts_delta
Offset of the current timestamp against last timestamp sync point in units of AVCodecContext.time_base.
AVDictionaryEntry * av_dict_get(AVDictionary *m, const char *key, const AVDictionaryEntry *prev, int flags)
Get a dictionary entry with matching key.
enum CodecID video_codec_id
Forced video codec_id.
int block_align
number of bytes per packet if constant and known or 0 Used by some WAV based audio codecs...
struct AVPacketList * packet_buffer
This buffer is only needed when packets were already buffered but not decoded, for example to get the...
AVRational time_base
This is the fundamental unit of time (in seconds) in terms of which frame timestamps are represented...
void av_freep(void *arg)
Free a memory block which has been allocated with av_malloc(z)() or av_realloc() and set the pointer ...
void av_shrink_packet(AVPacket *pkt, int size)
Reduce packet size, correctly zeroing padding.
enum AVAudioServiceType audio_service_type
Type of service that the audio stream conveys.
void * av_fast_realloc(void *ptr, unsigned int *size, size_t min_size)
Reallocate the given block if it is not large enough, otherwise do nothing.
unsigned int nb_stream_indexes
void av_init_packet(AVPacket *pkt)
Initialize optional fields of a packet with default values.
int ff_network_inited_globally
#define av_assert0(cond)
assert() equivalent, that is always enabled.
void av_parser_close(AVCodecParserContext *s)
enum AVSampleFormat sample_fmt
audio sample format
const struct AVCodecTag * avformat_get_riff_video_tags(void)
int ff_network_init(void)
unsigned avformat_version(void)
Return the LIBAVFORMAT_VERSION_INT constant.
const char * avformat_license(void)
Return the libavformat license.
int id
unique ID to identify the chapter
int id
format-specific stream ID
enum AVStreamParseType need_parsing
double duration_error[MAX_STD_TIMEBASES]
uint8_t * extradata
some codecs need / can use extradata like Huffman tables.
AVFormatContext * avformat_alloc_context(void)
Allocate an AVFormatContext.
const char * avformat_configuration(void)
Return the libavformat build-time configuration.
static double av_q2d(AVRational a)
Convert rational to double.
AVProgram * av_new_program(AVFormatContext *ac, int id)
void ff_id3v2_read(AVFormatContext *s, const char *magic)
Read an ID3v2 tag (text tags only)
int avformat_network_init(void)
Do global initialization of network components.
const struct AVCodecTag * avformat_get_riff_audio_tags(void)
void av_free_packet(AVPacket *pkt)
Free a packet.
int fps_probe_size
decoding: number of frames used to probe fps
AVCodecContext * avcodec_alloc_context3(AVCodec *codec)
Allocate an AVCodecContext and set its fields to default values.
#define AVERROR_EOF
End of file.
int av_find_info_tag(char *arg, int arg_size, const char *tag1, const char *info)
Attempt to find a specific tag in a URL.
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.
static av_always_inline int64_t avio_tell(AVIOContext *s)
ftell() equivalent for AVIOContext.
int bits_per_coded_sample
bits per sample/pixel from the demuxer (needed for huffyuv).
enum AVDiscard discard
selects which program to discard and which to feed to the caller
int duration
Duration of this packet in AVStream->time_base units, 0 if unknown.
unsigned int * stream_index
void av_hex_dump_log(void *avcl, int level, uint8_t *buf, int size)
Send a nice hexadecimal dump of a buffer to the log.
int avio_read(AVIOContext *s, unsigned char *buf, int size)
Read size bytes from AVIOContext into buf.
struct AVOutputFormat * oformat
int avformat_query_codec(AVOutputFormat *ofmt, enum CodecID codec_id, int std_compliance)
Test if the given container can store a codec.
void avcodec_string(char *buf, int buf_size, AVCodecContext *enc, int encode)
preferred ID for MPEG-1/2 video decoding
void(* destruct)(struct AVPacket *)
#define CODEC_CAP_CHANNEL_CONF
Codec should fill in channel configuration and samplerate instead of container.
struct AVPacketList * raw_packet_buffer
Raw packets from the demuxer, prior to parsing and decoding.
int64_t av_rescale_q(int64_t a, AVRational bq, AVRational cq)
Rescale a 64-bit integer by 2 rational numbers.
void av_dump_format(AVFormatContext *ic, int index, const char *url, int is_output)
void av_dict_copy(AVDictionary **dst, AVDictionary *src, int flags)
Copy entries from one AVDictionary struct into another.
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
int has_b_frames
Size of the frame reordering buffer in the decoder.
void av_free(void *ptr)
Free a memory block which has been allocated with av_malloc(z)() or av_realloc(). ...
int64_t pos
Byte position of currently parsed frame in stream.
int av_index_search_timestamp(AVStream *st, int64_t wanted_timestamp, int flags)
Get the index for a specific timestamp.
struct AVCodecParser * parser
unsigned int avpriv_toupper4(unsigned int x)
int avio_close(AVIOContext *s)
Close the resource accessed by the AVIOContext s and free it.
int64_t convergence_duration
Time difference in AVStream->time_base units from the pts of this packet to the point at which the ou...
int capabilities
Codec capabilities.
int attribute_align_arg avcodec_decode_video2(AVCodecContext *avctx, AVFrame *picture, int *got_picture_ptr, AVPacket *avpkt)
Decode the video frame of size avpkt->size from avpkt->data into picture.
int av_read_play(AVFormatContext *s)
Start playing a network-based stream (e.g.
void av_dict_free(AVDictionary **pm)
Free all the memory allocated for an AVDictionary struct and all keys and values. ...
simple assert() macros that are a bit more flexible than ISO C assert().
int64_t av_gcd(int64_t a, int64_t b)
Return the greatest common divisor of a and b.
void av_log(void *avcl, int level, const char *fmt,...)
AVStream * avformat_new_stream(AVFormatContext *s, AVCodec *c)
Add a new stream to a media file.
AVCodec * avcodec_find_decoder(enum CodecID id)
Find a registered decoder with a matching codec ID.
int attribute_align_arg avcodec_open2(AVCodecContext *avctx, AVCodec *codec, AVDictionary **options)
Initialize the AVCodecContext to use the given AVCodec.
AVRational avg_frame_rate
Average framerate.
const AVCodecTag ff_codec_wav_tags[]
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 min_distance
Minimum distance between this and the previous keyframe, used to avoid unneeded searching.
size_t av_strlcpy(char *dst, const char *src, size_t size)
Copy the string src to dst, but no more than size - 1 bytes, and null-terminate dst.
The exact value of the fractional number is: 'val + num / den'.
int flags
A combination of AV_PKT_FLAG values.
int av_compare_ts(int64_t ts_a, AVRational tb_a, int64_t ts_b, AVRational tb_b)
Compare 2 timestamps each in its own timebases.
AVCodecContext * codec
codec context
static float distance(float x, float y, int band)
int av_reduce(int *dst_num, int *dst_den, int64_t num, int64_t den, int64_t max)
Reduce a fraction.
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.
#define FF_MAX_EXTRADATA_SIZE
Maximum size in bytes of extradata.
unsigned int nb_streams
A list of all streams in the file.
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.
int seekable
A combination of AVIO_SEEKABLE_ flags or 0 when the stream is not seekable.
int bit_rate
the average bitrate
char filename[1024]
input or output filename
int64_t av_rescale(int64_t a, int64_t b, int64_t c)
Rescale a 64-bit integer with rounding to nearest.
#define AV_TIME_BASE
Internal time base represented as integer.
const AVCodecTag ff_codec_bmp_tags[]
struct AVStream::@65 * info
int av_strcasecmp(const char *a, const char *b)
static const chunk_decoder decoder[8]
int width
picture width / height.
uint8_t * av_packet_new_side_data(AVPacket *pkt, enum AVPacketSideDataType type, int size)
Allocate new information of a packet.
int64_t offset
byte offset from starting packet start
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.
enum CodecID ff_guess_image2_codec(const char *filename)
int64_t convergence_duration
Time difference in stream time base units from the pts of this packet to the point at which the outpu...
internal header for RIFF based (de)muxers do NOT include this in end user applications ...
const char * av_get_pix_fmt_name(enum PixelFormat pix_fmt)
Return the short name for a pixel format, NULL in case pix_fmt is unknown.
static av_always_inline av_const long int lrintf(float x)
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...
int ticks_per_frame
For some codecs, the time base is closer to the field rate than the frame rate.
int ffio_rewind_with_probe_data(AVIOContext *s, unsigned char *buf, int buf_size)
Rewind the AVIOContext using the specified buffer containing the first buf_size bytes of the file...
void av_register_input_format(AVInputFormat *format)
int av_get_bits_per_sample(enum CodecID codec_id)
Return codec bits per sample.
#define AVERROR_EXIT
Immediate exit was requested; the called function should not be restarted.
unsigned int probesize
decoding: size of data to probe; encoding: unused.
#define av_dlog(pctx,...)
av_dlog macros Useful to print debug messages that shouldn't get compiled in normally.
int thread_count
thread count is used to decide how many independent tasks should be passed to execute() ...
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.
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...
int raw_packet_buffer_remaining_size
#define AVERROR_PATCHWELCOME
Not yet implemented in Libav, patches welcome.
codec_id is not known (like CODEC_ID_NONE) but lavf should attempt to identify it ...
int64_t end
chapter start/end time in time_base units
void av_register_output_format(AVOutputFormat *format)
int avformat_network_deinit(void)
Undo the initialization done by avformat_network_init.
int frame_size
Samples per packet, initialized when calling 'init'.
int pts_dts_delta
Presentation delay of current frame in units of AVCodecContext.time_base.
enum CodecID audio_codec_id
Forced audio codec_id.
enum AVMediaType codec_type
int ff_check_interrupt(AVIOInterruptCB *cb)
Check if the user has requested to interrup a blocking function associated with cb.
int debug
Flags to enable debugging.
void avcodec_get_frame_defaults(AVFrame *pic)
Set the fields of the given AVFrame to default values.
#define AV_TIME_BASE_Q
Internal time base represented as fractional value.
int av_dup_packet(AVPacket *pkt)
int av_opt_set_dict(void *obj, AVDictionary **options)
int sample_rate
samples per second
int64_t reference_dts
Timestamp corresponding to the last dts sync point.
static const OptionDef options[]
main external API structure.
int av_filename_number_test(const char *filename)
Check whether filename actually is a numbered sequence generator.
#define AV_LOG_ERROR
Something went wrong and cannot losslessly be recovered.
unsigned int codec_tag
fourcc (LSB first, so "ABCD" -> ('D'<<24) + ('C'<<16) + ('B'<<8) + 'A').
int av_grow_packet(AVPacket *pkt, int grow_by)
Increase packet size, correctly zeroing padding.
int av_dict_set(AVDictionary **pm, const char *key, const char *value, int flags)
Set the given entry in *pm, overwriting an existing entry.
void * av_malloc(size_t size)
Allocate a block of size bytes with alignment suitable for all memory accesses (including vectors if ...
Describe the class of an AVClass context structure.
#define CODEC_FLAG_GLOBAL_HEADER
Place global headers in extradata instead of every keyframe.
#define FF_COMPLIANCE_NORMAL
rational number numerator/denominator
enum CodecID subtitle_codec_id
Forced subtitle codec_id.
struct AVPacketList * packet_buffer_end
#define AV_PKT_FLAG_CORRUPT
The packet content is corrupted.
size_t av_strlcatf(char *dst, size_t size, const char *fmt,...)
int avio_open2(AVIOContext **s, const char *url, int flags, const AVIOInterruptCB *int_cb, AVDictionary **options)
Create and initialize a AVIOContext for accessing the resource indicated by url.
#define FF_INPUT_BUFFER_PADDING_SIZE
Required number of additionally allocated bytes at the end of the input bitstream for decoding...
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.
size_t av_strlcat(char *dst, const char *src, size_t size)
Append the string src to the string dst, but to a total length of no more than size - 1 bytes...
int avio_pause(AVIOContext *h, int pause)
Pause and resume playing - only meaningful if using a network streaming protocol (e.g.
av_cold int avcodec_close(AVCodecContext *avctx)
Close a given AVCodecContext and free all the data associated with it (but not the AVCodecContext its...
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.
int64_t codec_info_duration
int attribute_align_arg avcodec_decode_audio4(AVCodecContext *avctx, AVFrame *frame, int *got_frame_ptr, AVPacket *avpkt)
Decode the audio frame of size avpkt->size from avpkt->data into frame.
int64_t start_time
Decoding: position of the first frame of the component, in AV_TIME_BASE fractional seconds...
int av_seek_frame(AVFormatContext *s, int stream_index, int64_t timestamp, int flags)
Seek to the keyframe at timestamp.
int64_t duration
Decoding: duration of the stream, in stream time base.
int av_strstart(const char *str, const char *pfx, const char **ptr)
Return non-zero if pfx is a prefix of str.
void av_hex_dump(FILE *f, uint8_t *buf, int size)
Send a nice hexadecimal dump of a buffer to the specified file stream.
int(* split)(AVCodecContext *avctx, const uint8_t *buf, int buf_size)
void av_opt_free(void *obj)
Free all string and binary options in obj.
common internal api header.
#define AV_LOG_DEBUG
Stuff which is only useful for libav* developers.
struct AVPacketList * next
int ff_id3v2_match(const uint8_t *buf, const char *magic)
Detect ID3v2 Header.
static av_cold void flush(AVCodecContext *avctx)
Flush (reset) the frame ID after seeking.
int avformat_find_stream_info(AVFormatContext *ic, AVDictionary **options)
Read packets of a media file to get stream information.
int64_t start_time
Decoding: pts of the first frame of the stream, in stream time base.
int disposition
AV_DISPOSITION_* bit field.
int pts_wrap_bits
number of bits in pts (used for wrapping control)
AVRational time_base
time base in which the start/end timestamps are specified
#define PARSER_FLAG_COMPLETE_FRAMES
int64_t nb_frames
number of frames in this stream if known or 0
int max_analyze_duration
decoding: maximum time (in AV_TIME_BASE units) during which the input should be analyzed in avformat_...
struct AVInputFormat * iformat
Can only be iformat or oformat, not both at the same time.
void avformat_close_input(AVFormatContext **ps)
Close an opened input AVFormatContext.
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...
CodecID
Identify the syntax and semantics of the bitstream.
int av_read_packet(AVFormatContext *s, AVPacket *pkt)
Read a transport packet from a media file.
unsigned int index_entries_allocated_size
#define AVERROR_DECODER_NOT_FOUND
Decoder not found.
struct AVFrac pts
encoding: pts generation when outputting stream
int channels
number of audio channels
int ff_id3v2_tag_len(const uint8_t *buf)
Get the length of an ID3v2 tag.
struct AVCodecParserContext * parser
void * priv_data
Format private data.
int codec_info_nb_frames
Number of frames that have been demuxed during av_find_stream_info()
#define AVERROR_STREAM_NOT_FOUND
Stream not found.
int64_t dts
Decompression timestamp in AVStream->time_base units; the time at which the packet is decompressed...
int av_write_trailer(AVFormatContext *s)
Write the stream trailer to an output media file and free the file private data.
int bit_rate
Decoding: total stream bitrate in bit/s, 0 if not available.
int repeat_pict
This field is used for proper frame duration computation in lavf.
int64_t duration
Decoding: duration of the stream, in AV_TIME_BASE fractional seconds.
int av_parser_parse2(AVCodecParserContext *s, AVCodecContext *avctx, uint8_t **poutbuf, int *poutbuf_size, const uint8_t *buf, int buf_size, int64_t pts, int64_t dts, int64_t pos)
Parse a packet.
static void comp(unsigned char *dst, int dst_stride, unsigned char *src, int src_stride, int add)
#define AV_DICT_IGNORE_SUFFIX
unbuffered private I/O API
#define FFSWAP(type, a, b)
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.
AVRational time_base
This is the fundamental unit of time (in seconds) in terms of which frame timestamps are represented...
#define CODEC_FLAG_BITEXACT
Use only bitexact stuff (except (I)DCT).
enum AVDiscard discard
Selects which packets can be discarded at will and do not need to be demuxed.
AVRational r_frame_rate
Real base framerate of the stream.
size_t av_get_codec_tag_string(char *buf, size_t buf_size, unsigned int codec_tag)
Put a string representing the codec tag codec_tag in buf.
AVInputFormat * av_probe_input_format(AVProbeData *pd, int is_opened)
Guess the file format.
struct AVPacketList * raw_packet_buffer_end
int key_frame
Set by parser to 1 for key frames and 0 for non-key frames.
int strict_std_compliance
strictly follow the standard (MPEG4, ...).
int dts_sync_point
Synchronization point for start of timestamp generation.
int64_t pts
Presentation timestamp in AVStream->time_base units; the time at which the decompressed packet will b...
struct AVPacketList * last_in_packet_buffer
last packet in packet_buffer for this stream when muxing.
#define AV_NOPTS_VALUE
Undefined timestamp value.
preferred ID for decoding MPEG audio layer 1, 2 or 3
int64_t av_compare_mod(uint64_t a, uint64_t b, uint64_t mod)
Compare 2 integers modulo mod.
uint8_t * subtitle_header
Header containing style information for text subtitles.
int64_t av_gettime(void)
Get the current time in microseconds.