54 #include "libavutil/ffversion.h"
70 return FFMPEG_CONFIGURATION;
75 #define LICENSE_PREFIX "libavformat license: "
79 #define RELATIVE_TS_BASE (INT64_MAX - (1LL<<48))
97 timestamp < st->pts_wrap_reference)
110 MAKE_ACCESSORS(AVFormatContext, format, AVCodec *, subtitle_codec)
112 MAKE_ACCESSORS(AVFormatContext, format,
int, metadata_header_padding)
120 return st->priv_pts->val;
145 if ( (src-> codec_whitelist && !dst-> codec_whitelist)
179 #define SANE_CHUNK_SIZE (50000000)
185 if (remaining < size) {
188 s->
maxsize = newsize - !newsize;
190 remaining=
FFMAX(remaining, 0);
193 if (s->
maxsize>= 0 && remaining+1 < size) {
205 int64_t orig_pos = pkt->
pos;
206 int orig_size = pkt->
size;
210 int prev_size = pkt->
size;
228 if (ret != read_size) {
241 return pkt->
size > orig_size ? pkt->
size - orig_size : ret;
271 static const struct {
295 "Probe with size=%d, packets=%d detected %s with score=%d\n",
298 for (i = 0; fmt_id_type[i].name; i++) {
299 if (!strcmp(fmt->
name, fmt_id_type[i].name)) {
347 "will be ignored with AVFMT_NOFILE format.\n");
372 (*plast_pktl)->next = pktl;
374 *packet_buffer = pktl;
389 if (copy.
size <= 0) {
391 "Attached picture on stream %d has invalid size, "
416 av_log(
NULL,
AV_LOG_ERROR,
"Input context has not been properly allocated by avformat_alloc_context() and is not NULL either\n");
431 if ((ret =
init_input(s, filename, &tmp)) < 0)
476 if (id3v2_extra_meta) {
543 "Failed to reallocate probe buffer for stream %d\n",
556 "nothing to probe for stream %d\n", st->
index);
583 int64_t ref = pkt->
dts;
584 int i, pts_wrap_behavior;
585 int64_t pts_wrap_reference;
603 if (!first_program) {
630 program = first_program;
674 if (!pktl || ret ==
AVERROR(EAGAIN))
689 "Dropped corrupted packet (stream = %d)\n",
759 switch (st->codec->codec_type) {
761 if (st->r_frame_rate.num && !pc &&
s->iformat) {
762 *pnum = st->r_frame_rate.den;
763 *pden = st->r_frame_rate.num;
764 }
else if (st->time_base.num * 1000LL > st->time_base.den) {
765 *pnum = st->time_base.num;
766 *pden = st->time_base.den;
767 }
else if (codec_framerate.den * 1000LL > codec_framerate.num) {
771 codec_framerate.num * (int64_t)st->codec->ticks_per_frame,
774 if (pc && pc->repeat_pict) {
777 (*pnum) * (1LL + pc->repeat_pict),
784 if (st->codec->ticks_per_frame > 1 && !pc)
790 if (frame_size <= 0 || st->codec->sample_rate <= 0)
793 *pden = st->codec->sample_rate;
821 #if CONFIG_H264_DECODER
852 int64_t best_score = INT64_MAX;
853 for (i = 0; i<delay; i++) {
856 if (score < best_score) {
863 for (i = 0; i<delay; i++) {
865 int64_t
diff =
FFABS(pts_buffer[i] - dts)
924 pts_buffer[0] = pktl->
pkt.
pts;
925 for (i = 0; i<delay && pts_buffer[i] > pts_buffer[i + 1]; i++)
926 FFSWAP(int64_t, pts_buffer[i], pts_buffer[i + 1]);
957 av_log(s,
AV_LOG_DEBUG,
"first_dts %s not matching first dts %s (pts %s, duration %d) in the queue\n",
991 int64_t next_dts, int64_t next_pts)
993 int num, den, presentation_delayed, delay, i;
1008 "DTS %"PRIi64
" < %"PRIi64
" out of order\n",
1034 presentation_delayed = 0;
1040 presentation_delayed = 1;
1055 if (delay == 1 && pkt->
dts == pkt->
pts &&
1058 if ( strcmp(s->
iformat->
name,
"mov,mp4,m4a,3gp,3g2,mj2")
1093 presentation_delayed = 1;
1097 "IN delayed:%d pts:%s, dts:%s cur_dts:%s st:%d pc:%p duration:%d delay:%d onein_oneout:%d\n",
1103 if ((delay == 0 || (delay == 1 && pc)) &&
1105 if (presentation_delayed) {
1123 ((uint64_t)st->
cur_dts - (uint64_t)next_dts + 1) <= 2 &&
1124 next_dts != next_pts &&
1126 pkt->
pts = next_dts;
1178 *pkt_buf = pktl->
next;
1182 *pkt_buf_end =
NULL;
1196 int ret = 0, got_output = 0;
1207 while (size > 0 || (pkt == &
flush_pkt && got_output)) {
1209 int64_t next_pts = pkt->
pts;
1210 int64_t next_dts = pkt->
dts;
1214 &out_pkt.
data, &out_pkt.
size, data, size,
1223 got_output = !!out_pkt.
size;
1268 #if FF_API_DESTRUCT_PACKET
1304 *pkt_buffer = pktl->
next;
1306 *pkt_buffer_end =
NULL;
1318 int ret = 0, i, got_packet = 0;
1347 cur_pkt.
pts < cur_pkt.
dts) {
1349 "Invalid timestamps stream=%d, pts=%s, dts=%s, size=%d\n",
1357 "ff_read_packet stream=%d, pts=%s, dts=%s, size=%d, duration=%d, flags=%d\n",
1367 "%s, packets or times may be invalid.\n",
1413 int discard_padding = 0;
1418 int64_t end_sample = sample +
duration;
1420 sample < st->last_discard_sample)
1429 AV_WL32(p + 4, discard_padding);
1449 memcpy(dst_data, src_sd->
data, src_sd->
size);
1468 "read_frame_internal stream=%d, pts=%s, dts=%s, "
1469 "size=%d, duration=%d, flags=%d\n",
1505 int64_t last_dts = next_pkt->
dts;
1515 last_dts = pktl->
pkt.
dts;
1543 if (pktl && ret !=
AVERROR(EAGAIN)) {
1590 int best_stream = 0;
1591 int best_score = INT_MIN;
1615 if (score > best_score) {
1687 int *nb_index_entries,
1688 unsigned int *index_entries_allocated_size,
1689 int64_t pos, int64_t timestamp,
1695 if ((
unsigned) *nb_index_entries + 1 >= UINT_MAX /
sizeof(
AVIndexEntry))
1708 index_entries_allocated_size,
1709 (*nb_index_entries + 1) *
1714 *index_entries = entries;
1720 index = (*nb_index_entries)++;
1721 ie = &entries[
index];
1722 av_assert0(index == 0 || ie[-1].timestamp < timestamp);
1724 ie = &entries[
index];
1728 memmove(entries + index + 1, entries + index,
1730 (*nb_index_entries)++;
1731 }
else if (ie->
pos == pos && distance < ie->min_distance)
1751 timestamp, size, distance, flags);
1755 int64_t wanted_timestamp,
int flags)
1764 if (b && entries[b - 1].timestamp < wanted_timestamp)
1770 if (timestamp >= wanted_timestamp)
1772 if (timestamp <= wanted_timestamp)
1778 while (m >= 0 && m < nb_entries &&
1782 if (m == nb_entries)
1790 int64_t pos_delta = 0;
1797 "Protocol name not provided, cannot determine if input is local or "
1798 "a network protocol, buffers and access patterns cannot be configured "
1799 "optimally without knowing the protocol\n");
1802 if (proto && !(strcmp(proto,
"file") && strcmp(proto,
"pipe") && strcmp(proto,
"cache")))
1805 for (ist1 = 0; ist1 < s->
nb_streams; ist1++) {
1807 for (ist2 = 0; ist2 < s->
nb_streams; ist2++) {
1822 if (e2_pts - e1_pts < time_tolerance)
1833 if (s->
pb->
buffer_size < pos_delta && pos_delta < (1<<24)) {
1839 if (skip < (1<<23)) {
1847 wanted_timestamp, flags);
1851 int64_t (*read_timestamp)(
struct AVFormatContext *,
int , int64_t *, int64_t ))
1853 int64_t ts = read_timestamp(s, stream_index, ppos, pos_limit);
1854 if (stream_index >= 0)
1860 int64_t target_ts,
int flags)
1864 int64_t ts_min, ts_max, ts;
1869 if (stream_index < 0)
1878 st = s->
streams[stream_index];
1886 index =
FFMAX(index, 0);
1908 " dts_max=%s\n", pos_max, pos_limit,
av_ts2str(ts_max));
1912 pos =
ff_gen_search(s, stream_index, target_ts, pos_min, pos_max, pos_limit,
1928 int64_t (*read_timestamp)(
struct AVFormatContext *,
int , int64_t *, int64_t ))
1930 int64_t step = 1024;
1931 int64_t limit, ts_max;
1933 int64_t pos_max = filesize - 1;
1936 pos_max =
FFMAX(0, (pos_max) - step);
1938 &pos_max, limit, read_timestamp);
1945 int64_t tmp_pos = pos_max + 1;
1947 &tmp_pos, INT64_MAX, read_timestamp);
1953 if (tmp_pos >= filesize)
1966 int64_t pos_min, int64_t pos_max, int64_t pos_limit,
1967 int64_t ts_min, int64_t ts_max,
1968 int flags, int64_t *ts_ret,
1970 int64_t *, int64_t))
1981 ts_min =
ff_read_timestamp(s, stream_index, &pos_min, INT64_MAX, read_timestamp);
1986 if (ts_min >= target_ts) {
1992 if ((ret =
ff_find_last_ts(s, stream_index, &ts_max, &pos_max, read_timestamp)) < 0)
1994 pos_limit = pos_max;
1997 if (ts_max <= target_ts) {
2005 while (pos_min < pos_limit) {
2007 "pos_min=0x%"PRIx64
" pos_max=0x%"PRIx64
" dts_min=%s dts_max=%s\n",
2011 if (no_change == 0) {
2012 int64_t approximate_keyframe_distance = pos_max - pos_limit;
2014 pos =
av_rescale(target_ts - ts_min, pos_max - pos_min,
2016 pos_min - approximate_keyframe_distance;
2017 }
else if (no_change == 1) {
2019 pos = (pos_min + pos_limit) >> 1;
2027 else if (pos > pos_limit)
2038 " target:%s limit:%"PRId64
" start:%"PRId64
" noc:%d\n",
2039 pos_min, pos, pos_max,
2041 pos_limit, start_pos, no_change);
2046 if (target_ts <= ts) {
2047 pos_limit = start_pos - 1;
2051 if (target_ts >= ts) {
2061 ts_min =
ff_read_timestamp(s, stream_index, &pos_min, INT64_MAX, read_timestamp);
2063 ts_max =
ff_read_timestamp(s, stream_index, &pos_min, INT64_MAX, read_timestamp);
2072 int64_t pos,
int flags)
2074 int64_t pos_min, pos_max;
2081 else if (pos > pos_max)
2092 int64_t timestamp,
int flags)
2099 st = s->
streams[stream_index];
2103 if (index < 0 && st->nb_index_entries &&
2104 timestamp < st->index_entries[0].timestamp)
2107 if (index < 0 || index == st->nb_index_entries - 1) {
2125 }
while (read_status ==
AVERROR(EAGAIN));
2126 if (read_status < 0)
2133 av_log(s,
AV_LOG_ERROR,
"seek_frame_generic failed as this stream seems to contain no keyframes after the target timestamp, %d non keyframes found\n", nonkey);
2156 int64_t timestamp,
int flags)
2168 if (stream_index < 0) {
2170 if (stream_index < 0)
2173 st = s->
streams[stream_index];
2200 int64_t timestamp,
int flags)
2205 int64_t min_ts = INT64_MIN, max_ts = INT64_MAX;
2211 flags & ~AVSEEK_FLAG_BACKWARD);
2223 int64_t ts, int64_t max_ts,
int flags)
2225 if (min_ts > ts || max_ts < ts)
2227 if (stream_index < -1 || stream_index >= (
int)s->
nb_streams)
2238 if (stream_index == -1 && s->
nb_streams == 1) {
2245 time_base.
num * (int64_t)AV_TIME_BASE,
2266 if (ret<0 && ts != min_ts && max_ts != ts) {
2267 ret =
av_seek_frame(s, stream_index, dir ? max_ts : min_ts, flags | dir);
2313 int64_t
start_time, start_time1, start_time_text, end_time, end_time1;
2314 int64_t
duration, duration1, filesize;
2319 start_time = INT64_MAX;
2320 start_time_text = INT64_MAX;
2321 end_time = INT64_MIN;
2322 duration = INT64_MIN;
2329 if (start_time1 < start_time_text)
2330 start_time_text = start_time1;
2332 start_time =
FFMIN(start_time, start_time1);
2335 end_time1 = start_time1 +
2338 end_time =
FFMAX(end_time, end_time1);
2350 duration =
FFMAX(duration, duration1);
2353 if (start_time == INT64_MAX || (start_time > start_time_text && start_time - start_time_text <
AV_TIME_BASE))
2354 start_time = start_time_text;
2355 else if (start_time > start_time_text)
2358 if (start_time != INT64_MAX) {
2360 if (end_time != INT64_MIN) {
2368 duration =
FFMAX(duration, end_time - start_time);
2376 double bitrate = (double) filesize * 8.0 * AV_TIME_BASE /
2378 if (bitrate >= 0 && bitrate <= INT_MAX)
2405 int i, show_warning = 0;
2450 "Estimating duration from bitrate, this may be inaccurate\n");
2453 #define DURATION_MAX_READ_SIZE 250000LL
2454 #define DURATION_MAX_RETRY 4
2461 int num, den, read_size, i, ret;
2462 int found_duration = 0;
2476 "start time for stream %d is not set in estimate_timings_from_pts\n", i);
2489 is_end = found_duration;
2502 }
while (ret ==
AVERROR(EAGAIN));
2505 read_size += pkt->
size;
2562 av_log(ic,
AV_LOG_DEBUG,
"stream %d : no PTS found at end of file, duration not set\n", i);
2564 av_log(ic,
AV_LOG_DEBUG,
"stream %d : no TS found at start of file, duration not set\n", i);
2592 file_size =
FFMAX(0, file_size);
2623 "stream: start_time: %0.3f duration: %0.3f bitrate=%d kb/s\n",
2634 #define FAIL(errmsg) do { \
2636 *errmsg_ptr = errmsg; \
2642 FAIL(
"unknown codec");
2646 FAIL(
"unspecified frame size");
2649 FAIL(
"unspecified sample format");
2651 FAIL(
"unspecified sample rate");
2653 FAIL(
"unspecified number of channels");
2655 FAIL(
"no decodable DTS frames");
2659 FAIL(
"unspecified size");
2661 FAIL(
"unspecified pixel format");
2664 FAIL(
"no frame in rv30/40 and no sar");
2668 FAIL(
"unspecified size");
2682 int got_picture = 1, ret = 0;
2705 av_dict_set(options ? options : &thread_opt,
"threads",
"1", 0);
2724 while ((pkt.
size > 0 || (!pkt.
data && got_picture)) &&
2733 &got_picture, &pkt);
2740 &got_picture, &pkt);
2755 if (!pkt.
data && !got_picture)
2777 if (tag == tags[i].tag)
2799 if (sflags & (1 << (bps - 1))) {
2841 for (i = 0; tags && tags[i]; i++) {
2844 if (codec_tags->
id ==
id) {
2845 *tag = codec_tags->
tag;
2857 for (i = 0; tags && tags[i]; i++) {
2882 if (j != i && next_start > ch->
start && next_start < end)
2885 ch->
end = (end == INT64_MAX) ? ch->
start : end;
2892 return (i + 1) * 1001;
2896 return ((
const int[]) { 40, 48, 50, 60, 80, 120, 240})[i] * 1001 * 12;
2900 return ((
const int[]) { 24, 30, 60, 12, 15, 48 })[i] * 1000 * 12;
2967 && ts - (uint64_t)last < INT64_MAX) {
2981 double sdts = dts*framerate/(1001*12);
2982 for (j= 0; j<2; j++) {
2983 int64_t ticks =
llrint(sdts+j*0.5);
2984 double error= sdts - ticks + j*0.5;
3001 if (error0 > 0.04 && error1 > 0.04) {
3036 double best_error= 0.01;
3050 for (k= 0; k<2; k++) {
3055 if (error < best_error && best_error> 0.000000001) {
3064 if (num && (!ref_rate.
num || (
double)num/(12*1001) < 1.01 *
av_q2d(ref_rate)))
3086 int i,
count, ret = 0, j;
3094 #if FF_API_PROBESIZE_32
3095 int64_t max_analyze_duration = ic->max_analyze_duration2;
3099 int64_t max_stream_analyze_duration;
3100 int64_t max_subtitle_analyze_duration;
3101 #if FF_API_PROBESIZE_32
3102 int64_t probesize = ic->probesize2;
3107 if (!max_analyze_duration)
3111 flush_codecs = probesize > 0;
3115 max_stream_analyze_duration = max_analyze_duration;
3116 max_subtitle_analyze_duration = max_analyze_duration;
3117 if (!max_analyze_duration) {
3118 max_stream_analyze_duration =
3126 av_log(ic,
AV_LOG_DEBUG,
"Before avformat_find_stream_info() pos: %"PRId64
" bytes read:%"PRId64
" seeks:%d\n",
3152 "%s, packets or times may be invalid.\n",
3160 av_dict_set(options ? &options[i] : &thread_opt,
"threads",
"1", 0);
3170 "Failed to open codec in av_find_stream_info\n");
3178 "Failed to open codec in av_find_stream_info\n");
3185 #if FF_API_R_FRAME_RATE
3195 int analyzed_all_streams;
3204 int fps_analyze_framecount = 20;
3213 fps_analyze_framecount *= 2;
3215 fps_analyze_framecount = 0;
3219 fps_analyze_framecount = 0;
3226 if (count < fps_analyze_framecount)
3239 analyzed_all_streams = 0;
3241 analyzed_all_streams = 1;
3253 if (read_size >= probesize) {
3256 "Probe buffer size limit of %"PRId64
" bytes reached\n", probesize);
3263 "Stream #%d: not enough frames to estimate rate; "
3264 "consider increasing probesize\n", i);
3287 goto find_stream_info_err;
3290 goto find_stream_info_err;
3295 read_size += pkt->
size;
3302 "Non-increasing DTS in stream %d: packet %d with DTS "
3303 "%"PRId64
", packet %d with DTS %"PRId64
"\n",
3319 "DTS discontinuity in stream %d: packet %d with DTS "
3320 "%"PRId64
", packet %d with DTS %"PRId64
"\n",
3351 if (analyzed_all_streams) limit = max_analyze_duration;
3353 else limit = max_stream_analyze_duration;
3356 av_log(ic,
AV_LOG_VERBOSE,
"max_analyze_duration %"PRId64
" reached at %"PRId64
" microseconds st:%d\n",
3357 max_analyze_duration,
3368 #if FF_API_R_FRAME_RATE
3392 (options && i < orig_nb_streams) ? &options[i] :
NULL);
3414 (options && i < orig_nb_streams)
3415 ? &options[i] :
NULL);
3420 "decoding for stream %d failed\n", st->
index);
3448 double best_error = 0.01;
3465 if (error < best_error) {
3467 best_fps = std_fps.
num;
3472 best_fps, 12 * 1001, INT_MAX);
3530 "Could not find codec parameters for stream %d (%s): %s\n"
3531 "Consider increasing the value for the 'analyzeduration' and 'probesize' options\n",
3540 find_stream_info_err:
3550 av_log(ic,
AV_LOG_DEBUG,
"After avformat_find_stream_info() pos: %"PRId64
" bytes read:%"PRId64
" seeks:%d frames:%d\n",
3573 int wanted_stream_nb,
int related_stream,
3574 AVCodec **decoder_ret,
int flags)
3578 unsigned *program =
NULL;
3581 if (related_stream >= 0 && wanted_stream_nb < 0) {
3589 int real_stream_index = program ? program[i] : i;
3594 if (wanted_stream_nb >= 0 && real_stream_index != wanted_stream_nb)
3596 if (wanted_stream_nb != real_stream_index &&
3615 if ((best_multiframe > multiframe) ||
3616 (best_multiframe == multiframe && best_bitrate > bitrate) ||
3617 (best_multiframe == multiframe && best_bitrate == bitrate && best_count >=
count))
3620 best_bitrate = bitrate;
3621 best_multiframe = multiframe;
3622 ret = real_stream_index;
3624 if (program && i == nb_streams - 1 && ret < 0) {
3632 *decoder_ret = (
AVCodec*)best_decoder;
3755 if (s->
nb_streams >= INT_MAX/
sizeof(*streams))
3805 #if FF_API_R_FRAME_RATE
3846 int64_t
start, int64_t
end,
const char *title)
3852 av_log(s,
AV_LOG_ERROR,
"Chapter end time %"PRId64
" before start %"PRId64
"\n", end, start);
3911 char *q, buf1[20],
c;
3912 int nd,
len, percentd_found;
3925 nd = nd * 10 + *p++ -
'0';
3938 snprintf(buf1,
sizeof(buf1),
"%0*d", nd, number);
3940 if ((q - buf + len) > buf_size - 1)
3942 memcpy(q, buf1, len);
3950 if ((q - buf) < buf_size - 1)
3954 if (!percentd_found)
3964 char *authorization,
int authorization_size,
3965 char *hostname,
int hostname_size,
3966 int *port_ptr,
char *path,
int path_size,
const char *url)
3968 const char *p, *ls, *ls2, *at, *at2, *col, *brk;
3974 if (authorization_size > 0)
3975 authorization[0] = 0;
3976 if (hostname_size > 0)
3982 if ((p = strchr(url,
':'))) {
3996 ls = strchr(p,
'/');
3997 ls2 = strchr(p,
'?');
4001 ls =
FFMIN(ls, ls2);
4011 while ((at = strchr(p,
'@')) && at < ls) {
4013 FFMIN(authorization_size, at + 1 - at2));
4017 if (*p ==
'[' && (brk = strchr(p,
']')) && brk < ls) {
4020 FFMIN(hostname_size, brk - p));
4021 if (brk[1] ==
':' && port_ptr)
4022 *port_ptr = atoi(brk + 2);
4023 }
else if ((col = strchr(p,
':')) && col < ls) {
4025 FFMIN(col + 1 - p, hostname_size));
4027 *port_ptr = atoi(col + 1);
4030 FFMIN(ls + 1 - p, hostname_size));
4037 static const char hex_table_uc[16] = {
'0',
'1',
'2',
'3',
4040 'C',
'D',
'E',
'F' };
4041 static const char hex_table_lc[16] = {
'0',
'1',
'2',
'3',
4044 'c',
'd',
'e',
'f' };
4045 const char *hex_table = lowercase ? hex_table_lc : hex_table_uc;
4047 for (i = 0; i <
s; i++) {
4048 buff[i * 2] = hex_table[src[i] >> 4];
4049 buff[i * 2 + 1] = hex_table[src[i] & 0xF];
4066 if (c >=
'0' && c <=
'9')
4068 else if (c >=
'A' && c <=
'F')
4084 unsigned int pts_num,
unsigned int pts_den)
4088 if (new_tb.
num != pts_num)
4090 "st:%d removing common factor %d from timebase\n",
4094 "st:%d has too large timebase, reducing\n", s->
index);
4096 if (new_tb.
num <= 0 || new_tb.
den <= 0) {
4098 "Ignoring attempt to set invalid timebase %d/%d for st:%d\n",
4111 const char *ptr = str;
4116 char *dest =
NULL, *dest_end;
4117 int key_len, dest_len = 0;
4120 while (*ptr && (
av_isspace(*ptr) || *ptr ==
','))
4127 if (!(ptr = strchr(key,
'=')))
4130 key_len = ptr - key;
4132 callback_get_buf(context, key, key_len, &dest, &dest_len);
4133 dest_end = dest + dest_len - 1;
4137 while (*ptr && *ptr !=
'\"') {
4141 if (dest && dest < dest_end)
4145 if (dest && dest < dest_end)
4153 for (; *ptr && !(
av_isspace(*ptr) || *ptr ==
','); ptr++)
4154 if (dest && dest < dest_end)
4173 struct tm time1 = { 0 }, time2 = { 0 };
4174 const char *ret1, *ret2;
4187 unsigned int codec_tag;
4189 return ofmt->
query_codec(codec_id, std_compliance);
4236 if (channel_layout) {
4244 if (width || height) {
4251 bytestream_put_le32(&data, flags);
4253 bytestream_put_le32(&data, channels);
4255 bytestream_put_le64(&data, channel_layout);
4257 bytestream_put_le32(&data, sample_rate);
4258 if (width || height) {
4259 bytestream_put_le32(&data, width);
4260 bytestream_put_le32(&data, height);
4272 av_reduce(&stream_sample_aspect_ratio.
num, &stream_sample_aspect_ratio.
den,
4273 stream_sample_aspect_ratio.
num, stream_sample_aspect_ratio.
den, INT_MAX);
4274 if (stream_sample_aspect_ratio.
num <= 0 || stream_sample_aspect_ratio.
den <= 0)
4275 stream_sample_aspect_ratio = undef;
4277 av_reduce(&frame_sample_aspect_ratio.
num, &frame_sample_aspect_ratio.
den,
4278 frame_sample_aspect_ratio.
num, frame_sample_aspect_ratio.
den, INT_MAX);
4279 if (frame_sample_aspect_ratio.
num <= 0 || frame_sample_aspect_ratio.
den <= 0)
4280 frame_sample_aspect_ratio = undef;
4282 if (stream_sample_aspect_ratio.
num)
4283 return stream_sample_aspect_ratio;
4285 return frame_sample_aspect_ratio;
4294 if (avg_fr.
num > 0 && avg_fr.
den > 0 && fr.
num > 0 && fr.
den > 0 &&
4301 if ( codec_fr.
num > 0 && codec_fr.
den > 0 &&
4312 if (*spec <= '9' && *spec >=
'0')
4313 return strtol(spec,
NULL, 0) == st->
index;
4314 else if (*spec ==
'v' || *spec ==
'a' || *spec ==
's' || *spec ==
'd' ||
4315 *spec ==
't' || *spec ==
'V') {
4332 if (*spec++ ==
':') {
4338 return i == st->
index;
4342 }
else if (*spec ==
'p' && *(spec + 1) ==
':') {
4346 prog_id = strtol(spec, &endptr, 0);
4351 if (*endptr++ ==
':') {
4352 int stream_idx = strtol(endptr,
NULL, 0);
4353 return stream_idx >= 0 &&
4363 }
else if (*spec ==
'#' ||
4364 (*spec ==
'i' && *(spec + 1) ==
':')) {
4367 spec += 1 + (*spec ==
'i');
4368 stream_id = strtol(spec, &endptr, 0);
4370 return stream_id == st->
id;
4371 }
else if (*spec ==
'm' && *(spec + 1) ==
':') {
4377 val = strchr(spec,
':');
4385 if (!val || !strcmp(tag->
value, val + 1))
4394 }
else if (*spec ==
'u') {
4425 static const uint8_t avci100_1080p_extradata[] = {
4427 0x00, 0x00, 0x00, 0x01, 0x67, 0x7a, 0x10, 0x29,
4428 0xb6, 0xd4, 0x20, 0x22, 0x33, 0x19, 0xc6, 0x63,
4429 0x23, 0x21, 0x01, 0x11, 0x98, 0xce, 0x33, 0x19,
4430 0x18, 0x21, 0x02, 0x56, 0xb9, 0x3d, 0x7d, 0x7e,
4431 0x4f, 0xe3, 0x3f, 0x11, 0xf1, 0x9e, 0x08, 0xb8,
4432 0x8c, 0x54, 0x43, 0xc0, 0x78, 0x02, 0x27, 0xe2,
4433 0x70, 0x1e, 0x30, 0x10, 0x10, 0x14, 0x00, 0x00,
4434 0x03, 0x00, 0x04, 0x00, 0x00, 0x03, 0x00, 0xca,
4435 0x10, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
4437 0x00, 0x00, 0x00, 0x01, 0x68, 0xce, 0x33, 0x48,
4440 static const uint8_t avci100_1080i_extradata[] = {
4442 0x00, 0x00, 0x00, 0x01, 0x67, 0x7a, 0x10, 0x29,
4443 0xb6, 0xd4, 0x20, 0x22, 0x33, 0x19, 0xc6, 0x63,
4444 0x23, 0x21, 0x01, 0x11, 0x98, 0xce, 0x33, 0x19,
4445 0x18, 0x21, 0x03, 0x3a, 0x46, 0x65, 0x6a, 0x65,
4446 0x24, 0xad, 0xe9, 0x12, 0x32, 0x14, 0x1a, 0x26,
4447 0x34, 0xad, 0xa4, 0x41, 0x82, 0x23, 0x01, 0x50,
4448 0x2b, 0x1a, 0x24, 0x69, 0x48, 0x30, 0x40, 0x2e,
4449 0x11, 0x12, 0x08, 0xc6, 0x8c, 0x04, 0x41, 0x28,
4450 0x4c, 0x34, 0xf0, 0x1e, 0x01, 0x13, 0xf2, 0xe0,
4451 0x3c, 0x60, 0x20, 0x20, 0x28, 0x00, 0x00, 0x03,
4452 0x00, 0x08, 0x00, 0x00, 0x03, 0x01, 0x94, 0x20,
4454 0x00, 0x00, 0x00, 0x01, 0x68, 0xce, 0x33, 0x48,
4457 static const uint8_t avci50_1080p_extradata[] = {
4459 0x00, 0x00, 0x00, 0x01, 0x67, 0x6e, 0x10, 0x28,
4460 0xa6, 0xd4, 0x20, 0x32, 0x33, 0x0c, 0x71, 0x18,
4461 0x88, 0x62, 0x10, 0x19, 0x19, 0x86, 0x38, 0x8c,
4462 0x44, 0x30, 0x21, 0x02, 0x56, 0x4e, 0x6f, 0x37,
4463 0xcd, 0xf9, 0xbf, 0x81, 0x6b, 0xf3, 0x7c, 0xde,
4464 0x6e, 0x6c, 0xd3, 0x3c, 0x05, 0xa0, 0x22, 0x7e,
4465 0x5f, 0xfc, 0x00, 0x0c, 0x00, 0x13, 0x8c, 0x04,
4466 0x04, 0x05, 0x00, 0x00, 0x03, 0x00, 0x01, 0x00,
4467 0x00, 0x03, 0x00, 0x32, 0x84, 0x00, 0x00, 0x00,
4469 0x00, 0x00, 0x00, 0x01, 0x68, 0xee, 0x31, 0x12,
4472 static const uint8_t avci50_1080i_extradata[] = {
4474 0x00, 0x00, 0x00, 0x01, 0x67, 0x6e, 0x10, 0x28,
4475 0xa6, 0xd4, 0x20, 0x32, 0x33, 0x0c, 0x71, 0x18,
4476 0x88, 0x62, 0x10, 0x19, 0x19, 0x86, 0x38, 0x8c,
4477 0x44, 0x30, 0x21, 0x02, 0x56, 0x4e, 0x6e, 0x61,
4478 0x87, 0x3e, 0x73, 0x4d, 0x98, 0x0c, 0x03, 0x06,
4479 0x9c, 0x0b, 0x73, 0xe6, 0xc0, 0xb5, 0x18, 0x63,
4480 0x0d, 0x39, 0xe0, 0x5b, 0x02, 0xd4, 0xc6, 0x19,
4481 0x1a, 0x79, 0x8c, 0x32, 0x34, 0x24, 0xf0, 0x16,
4482 0x81, 0x13, 0xf7, 0xff, 0x80, 0x02, 0x00, 0x01,
4483 0xf1, 0x80, 0x80, 0x80, 0xa0, 0x00, 0x00, 0x03,
4484 0x00, 0x20, 0x00, 0x00, 0x06, 0x50, 0x80, 0x00,
4486 0x00, 0x00, 0x00, 0x01, 0x68, 0xee, 0x31, 0x12,
4489 static const uint8_t avci100_720p_extradata[] = {
4491 0x00, 0x00, 0x00, 0x01, 0x67, 0x7a, 0x10, 0x29,
4492 0xb6, 0xd4, 0x20, 0x2a, 0x33, 0x1d, 0xc7, 0x62,
4493 0xa1, 0x08, 0x40, 0x54, 0x66, 0x3b, 0x8e, 0xc5,
4494 0x42, 0x02, 0x10, 0x25, 0x64, 0x2c, 0x89, 0xe8,
4495 0x85, 0xe4, 0x21, 0x4b, 0x90, 0x83, 0x06, 0x95,
4496 0xd1, 0x06, 0x46, 0x97, 0x20, 0xc8, 0xd7, 0x43,
4497 0x08, 0x11, 0xc2, 0x1e, 0x4c, 0x91, 0x0f, 0x01,
4498 0x40, 0x16, 0xec, 0x07, 0x8c, 0x04, 0x04, 0x05,
4499 0x00, 0x00, 0x03, 0x00, 0x01, 0x00, 0x00, 0x03,
4500 0x00, 0x64, 0x84, 0x00, 0x00, 0x00, 0x00, 0x00,
4502 0x00, 0x00, 0x00, 0x01, 0x68, 0xce, 0x31, 0x12,
4505 static const uint8_t avci50_720p_extradata[] = {
4507 0x00, 0x00, 0x00, 0x01, 0x67, 0x6e, 0x10, 0x20,
4508 0xa6, 0xd4, 0x20, 0x32, 0x33, 0x0c, 0x71, 0x18,
4509 0x88, 0x62, 0x10, 0x19, 0x19, 0x86, 0x38, 0x8c,
4510 0x44, 0x30, 0x21, 0x02, 0x56, 0x4e, 0x6f, 0x37,
4511 0xcd, 0xf9, 0xbf, 0x81, 0x6b, 0xf3, 0x7c, 0xde,
4512 0x6e, 0x6c, 0xd3, 0x3c, 0x0f, 0x01, 0x6e, 0xff,
4513 0xc0, 0x00, 0xc0, 0x01, 0x38, 0xc0, 0x40, 0x40,
4514 0x50, 0x00, 0x00, 0x03, 0x00, 0x10, 0x00, 0x00,
4515 0x06, 0x48, 0x40, 0x00, 0x00, 0x00, 0x00, 0x00,
4517 0x00, 0x00, 0x00, 0x01, 0x68, 0xee, 0x31, 0x12,
4526 data = avci100_1080p_extradata;
4527 size =
sizeof(avci100_1080p_extradata);
4529 data = avci100_1080i_extradata;
4530 size =
sizeof(avci100_1080i_extradata);
4534 data = avci50_1080p_extradata;
4535 size =
sizeof(avci50_1080p_extradata);
4537 data = avci50_1080i_extradata;
4538 size =
sizeof(avci50_1080i_extradata);
4541 data = avci100_720p_extradata;
4542 size =
sizeof(avci100_720p_extradata);
4544 data = avci50_720p_extradata;
4545 size =
sizeof(avci50_720p_extradata);
4587 if (sd->
type == type) {
unsigned int nb_chapters
Number of chapters in AVChapter array.
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.
int64_t probesize
Maximum size of the data read from input for determining the input container format.
int av_opt_get_dict_val(void *obj, const char *name, int search_flags, AVDictionary **out_val)
int64_t first_dts
Timestamp corresponding to the last dts sync point.
int av_isdigit(int c)
Locale-independent conversion of ASCII isdigit.
const struct AVCodec * codec
const char const char void * val
#define AV_CODEC_PROP_INTRA_ONLY
Codec uses only intra compression.
#define AVERROR_INVALIDDATA
Invalid data found when processing input.
int64_t avio_size(AVIOContext *s)
Get the filesize.
static int shift(int a, int b)
int av_demuxer_open(AVFormatContext *ic)
void av_free_packet(AVPacket *pkt)
Free a packet.
char * recommended_encoder_configuration
String containing paris of key and values describing recommended encoder configuration.
This structure describes decoded (raw) audio or video data.
AVIOInterruptCB interrupt_callback
Custom interrupt callbacks for the I/O layer.
ptrdiff_t const GLvoid * data
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.
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 AVDurationEstimationMethod duration_estimation_method
The duration field can be estimated through various ways, and this field can be used to know how the ...
int64_t start_skip_samples
If not 0, the number of samples that should be skipped from the start of the stream (the samples are ...
#define AV_LOG_WARNING
Something somehow does not look correct.
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.
void av_shrink_packet(AVPacket *pkt, int size)
Reduce packet size, correctly zeroing padding.
int64_t pts_buffer[MAX_REORDER_DELAY+1]
int probe_packets
Number of packets to buffer for codec probing.
int av_probe_input_buffer2(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.
AVRational av_guess_sample_aspect_ratio(AVFormatContext *format, AVStream *stream, AVFrame *frame)
Guess the sample aspect ratio of a frame, based on both the stream and the frame aspect ratio...
void av_opt_set_defaults(void *s)
Set the values of all AVOption fields to their default values.
int64_t first_discard_sample
If not 0, the first audio sample that should be discarded from the stream.
int64_t pts_wrap_reference
Internal data to check for wrapping of the time stamp.
AVRational sample_aspect_ratio
sample aspect ratio (0 if unknown)
void av_codec_set_pkt_timebase(AVCodecContext *avctx, AVRational val)
int index
stream index in AVFormatContext
#define ID3v2_DEFAULT_MAGIC
Default magic bytes for ID3v2 header: "ID3".
int avio_flags
avio flags, used to force AVIO_FLAG_DIRECT.
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.
AVFormatInternal * internal
An opaque field for libavformat internal usage.
AVRational sample_aspect_ratio
sample aspect ratio (0 if unknown) That is the width of a pixel divided by the height of the pixel...
enum AVPixelFormat pix_fmt
Pixel format, see AV_PIX_FMT_xxx.
uint8_t * av_stream_get_side_data(AVStream *st, enum AV