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)
115 #if FF_API_OLD_OPEN_CALLBACKS
152 if ( (src-> codec_whitelist && !dst-> codec_whitelist)
153 || (src-> format_whitelist && !dst-> format_whitelist)
187 #define SANE_CHUNK_SIZE (50000000)
193 if (remaining < size) {
196 s->
maxsize = newsize - !newsize;
198 remaining=
FFMAX(remaining, 0);
201 if (s->
maxsize>= 0 && remaining+1 < size) {
213 int64_t orig_pos = pkt->
pos;
214 int orig_size = pkt->
size;
218 int prev_size = pkt->
size;
236 if (ret != read_size) {
249 return pkt->
size > orig_size ? pkt->
size - orig_size : ret;
279 static const struct {
303 "Probe with size=%d, packets=%d detected %s with score=%d\n",
306 for (i = 0; fmt_id_type[i].name; i++) {
307 if (!strcmp(fmt->
name, fmt_id_type[i].name)) {
355 "will be ignored with AVFMT_NOFILE format.\n");
391 (*plast_pktl)->next = pktl;
393 *packet_buffer = pktl;
408 "Attached picture on stream %d has invalid size, "
425 AVFormatContext *
s = *ps;
433 av_log(
NULL,
AV_LOG_ERROR,
"Input context has not been properly allocated by avformat_alloc_context() and is not NULL either\n");
448 if ((ret =
init_input(s, filename, &tmp)) < 0)
501 if (id3v2_extra_meta) {
568 "Failed to reallocate probe buffer for stream %d\n",
581 "nothing to probe for stream %d\n", st->
index);
608 int64_t ref = pkt->
dts;
609 int i, pts_wrap_behavior;
610 int64_t pts_wrap_reference;
628 if (!first_program) {
655 program = first_program;
704 if (!pktl || ret ==
AVERROR(EAGAIN))
727 "Dropped corrupted packet (stream = %d)\n",
799 switch (st->codec->codec_type) {
801 if (st->r_frame_rate.num && !pc &&
s->iformat) {
802 *pnum = st->r_frame_rate.den;
803 *pden = st->r_frame_rate.num;
804 }
else if (st->time_base.num * 1000LL > st->time_base.den) {
805 *pnum = st->time_base.num;
806 *pden = st->time_base.den;
807 }
else if (codec_framerate.den * 1000LL > codec_framerate.num) {
811 codec_framerate.num * (int64_t)st->codec->ticks_per_frame,
814 if (pc && pc->repeat_pict) {
817 (*pnum) * (1LL + pc->repeat_pict),
824 if (st->codec->ticks_per_frame > 1 && !pc)
830 if (frame_size <= 0 || st->codec->sample_rate <= 0)
833 *pden = st->codec->sample_rate;
861 #if CONFIG_H264_DECODER
892 int64_t best_score = INT64_MAX;
893 for (i = 0; i<delay; i++) {
896 if (score < best_score) {
903 for (i = 0; i<delay; i++) {
905 int64_t
diff =
FFABS(pts_buffer[i] - dts)
928 AVStream *st = s->
streams[stream_index];
964 pts_buffer[0] = pktl->
pkt.
pts;
965 for (i = 0; i<delay && pts_buffer[i] > pts_buffer[i + 1]; i++)
966 FFSWAP(int64_t, pts_buffer[i], pts_buffer[i + 1]);
997 av_log(s,
AV_LOG_DEBUG,
"first_dts %s not matching first dts %s (pts %s, duration %"PRId64
") in the queue\n",
1031 int64_t next_dts, int64_t next_pts)
1033 int num, den, presentation_delayed, delay, i;
1048 "DTS %"PRIi64
" < %"PRIi64
" out of order\n",
1074 presentation_delayed = 0;
1080 presentation_delayed = 1;
1095 if (delay == 1 && pkt->
dts == pkt->
pts &&
1098 if ( strcmp(s->
iformat->
name,
"mov,mp4,m4a,3gp,3g2,mj2")
1133 presentation_delayed = 1;
1137 "IN delayed:%d pts:%s, dts:%s cur_dts:%s st:%d pc:%p duration:%"PRId64
" delay:%d onein_oneout:%d\n",
1143 if ((delay == 0 || (delay == 1 && pc)) &&
1145 if (presentation_delayed) {
1163 ((uint64_t)st->
cur_dts - (uint64_t)next_dts + 1) <= 2 &&
1164 next_dts != next_pts &&
1166 pkt->
pts = next_dts;
1210 #if FF_API_CONVERGENCE_DURATION
1222 *pkt_buf = pktl->
next;
1226 *pkt_buf_end =
NULL;
1237 AVStream *st = s->
streams[stream_index];
1240 int ret = 0, got_output = 0;
1251 while (size > 0 || (pkt == &
flush_pkt && got_output)) {
1253 int64_t next_pts = pkt->
pts;
1254 int64_t next_dts = pkt->
dts;
1258 &out_pkt.
data, &out_pkt.
size, data, size,
1267 got_output = !!out_pkt.
size;
1335 *pkt_buffer = pktl->
next;
1337 *pkt_buffer_end =
NULL;
1349 int ret = 0, i, got_packet = 0;
1378 cur_pkt.
pts < cur_pkt.
dts) {
1380 "Invalid timestamps stream=%d, pts=%s, dts=%s, size=%d\n",
1388 "ff_read_packet stream=%d, pts=%s, dts=%s, size=%d, duration=%"PRId64
", flags=%d\n",
1398 "%s, packets or times may be invalid.\n",
1444 int discard_padding = 0;
1449 int64_t end_sample = sample +
duration;
1451 sample < st->last_discard_sample)
1460 AV_WL32(p + 4, discard_padding);
1480 memcpy(dst_data, src_sd->
data, src_sd->
size);
1499 "read_frame_internal stream=%d, pts=%s, dts=%s, "
1500 "size=%d, duration=%"PRId64
", flags=%d\n",
1536 int64_t last_dts = next_pkt->
dts;
1546 last_dts = pktl->
pkt.
dts;
1574 if (pktl && ret !=
AVERROR(EAGAIN)) {
1623 int best_stream = 0;
1624 int best_score = INT_MIN;
1648 if (score > best_score) {
1708 AVStream *st = s->
streams[stream_index];
1720 int *nb_index_entries,
1721 unsigned int *index_entries_allocated_size,
1722 int64_t pos, int64_t timestamp,
1728 if ((
unsigned) *nb_index_entries + 1 >= UINT_MAX /
sizeof(
AVIndexEntry))
1741 index_entries_allocated_size,
1742 (*nb_index_entries + 1) *
1747 *index_entries = entries;
1753 index = (*nb_index_entries)++;
1754 ie = &entries[
index];
1755 av_assert0(index == 0 || ie[-1].timestamp < timestamp);
1757 ie = &entries[
index];
1761 memmove(entries + index + 1, entries + index,
1763 (*nb_index_entries)++;
1764 }
else if (ie->
pos == pos && distance < ie->min_distance)
1784 timestamp, size, distance, flags);
1788 int64_t wanted_timestamp,
int flags)
1797 if (b && entries[b - 1].timestamp < wanted_timestamp)
1803 if (timestamp >= wanted_timestamp)
1805 if (timestamp <= wanted_timestamp)
1811 while (m >= 0 && m < nb_entries &&
1815 if (m == nb_entries)
1823 int64_t pos_delta = 0;
1830 "Protocol name not provided, cannot determine if input is local or "
1831 "a network protocol, buffers and access patterns cannot be configured "
1832 "optimally without knowing the protocol\n");
1835 if (proto && !(strcmp(proto,
"file") && strcmp(proto,
"pipe") && strcmp(proto,
"cache")))
1838 for (ist1 = 0; ist1 < s->
nb_streams; ist1++) {
1839 AVStream *st1 = s->
streams[ist1];
1840 for (ist2 = 0; ist2 < s->
nb_streams; ist2++) {
1841 AVStream *st2 = s->
streams[ist2];
1855 if (e2_pts - e1_pts < time_tolerance)
1866 if (s->
pb->
buffer_size < pos_delta && pos_delta < (1<<24)) {
1872 if (skip < (1<<23)) {
1880 wanted_timestamp, flags);
1884 int64_t (*read_timestamp)(
struct AVFormatContext *,
int , int64_t *, int64_t ))
1886 int64_t ts = read_timestamp(s, stream_index, ppos, pos_limit);
1887 if (stream_index >= 0)
1893 int64_t target_ts,
int flags)
1897 int64_t ts_min, ts_max, ts;
1902 if (stream_index < 0)
1911 st = s->
streams[stream_index];
1919 index =
FFMAX(index, 0);
1941 " dts_max=%s\n", pos_max, pos_limit,
av_ts2str(ts_max));
1945 pos =
ff_gen_search(s, stream_index, target_ts, pos_min, pos_max, pos_limit,
1961 int64_t (*read_timestamp)(
struct AVFormatContext *,
int , int64_t *, int64_t ))
1963 int64_t step = 1024;
1964 int64_t limit, ts_max;
1966 int64_t pos_max = filesize - 1;
1969 pos_max =
FFMAX(0, (pos_max) - step);
1971 &pos_max, limit, read_timestamp);
1978 int64_t tmp_pos = pos_max + 1;
1980 &tmp_pos, INT64_MAX, read_timestamp);
1986 if (tmp_pos >= filesize)
1999 int64_t pos_min, int64_t pos_max, int64_t pos_limit,
2000 int64_t ts_min, int64_t ts_max,
2001 int flags, int64_t *ts_ret,
2002 int64_t (*read_timestamp)(
struct AVFormatContext *,
int,
2003 int64_t *, int64_t))
2014 ts_min =
ff_read_timestamp(s, stream_index, &pos_min, INT64_MAX, read_timestamp);
2019 if (ts_min >= target_ts) {
2025 if ((ret =
ff_find_last_ts(s, stream_index, &ts_max, &pos_max, read_timestamp)) < 0)
2027 pos_limit = pos_max;
2030 if (ts_max <= target_ts) {
2038 while (pos_min < pos_limit) {
2040 "pos_min=0x%"PRIx64
" pos_max=0x%"PRIx64
" dts_min=%s dts_max=%s\n",
2044 if (no_change == 0) {
2045 int64_t approximate_keyframe_distance = pos_max - pos_limit;
2047 pos =
av_rescale(target_ts - ts_min, pos_max - pos_min,
2049 pos_min - approximate_keyframe_distance;
2050 }
else if (no_change == 1) {
2052 pos = (pos_min + pos_limit) >> 1;
2060 else if (pos > pos_limit)
2071 " target:%s limit:%"PRId64
" start:%"PRId64
" noc:%d\n",
2072 pos_min, pos, pos_max,
2074 pos_limit, start_pos, no_change);
2079 if (target_ts <= ts) {
2080 pos_limit = start_pos - 1;
2084 if (target_ts >= ts) {
2094 ts_min =
ff_read_timestamp(s, stream_index, &pos_min, INT64_MAX, read_timestamp);
2096 ts_max =
ff_read_timestamp(s, stream_index, &pos_min, INT64_MAX, read_timestamp);
2105 int64_t pos,
int flags)
2107 int64_t pos_min, pos_max;
2114 else if (pos > pos_max)
2125 int64_t timestamp,
int flags)
2132 st = s->
streams[stream_index];
2136 if (index < 0 && st->nb_index_entries &&
2137 timestamp < st->index_entries[0].timestamp)
2140 if (index < 0 || index == st->nb_index_entries - 1) {
2158 }
while (read_status ==
AVERROR(EAGAIN));
2159 if (read_status < 0)
2167 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);
2192 int64_t timestamp,
int flags)
2204 if (stream_index < 0) {
2206 if (stream_index < 0)
2209 st = s->
streams[stream_index];
2236 int64_t timestamp,
int flags)
2241 int64_t min_ts = INT64_MIN, max_ts = INT64_MAX;
2247 flags & ~AVSEEK_FLAG_BACKWARD);
2259 int64_t ts, int64_t max_ts,
int flags)
2261 if (min_ts > ts || max_ts < ts)
2263 if (stream_index < -1 || stream_index >= (
int)s->
nb_streams)
2274 if (stream_index == -1 && s->
nb_streams == 1) {
2281 time_base.
num * (int64_t)AV_TIME_BASE,
2302 if (ret<0 && ts != min_ts && max_ts != ts) {
2303 ret =
av_seek_frame(s, stream_index, dir ? max_ts : min_ts, flags | dir);
2349 int64_t
start_time, start_time1, start_time_text, end_time, end_time1;
2350 int64_t
duration, duration1, filesize;
2355 start_time = INT64_MAX;
2356 start_time_text = INT64_MAX;
2357 end_time = INT64_MIN;
2358 duration = INT64_MIN;
2365 if (start_time1 < start_time_text)
2366 start_time_text = start_time1;
2368 start_time =
FFMIN(start_time, start_time1);
2373 end_time1 += start_time1;
2374 end_time =
FFMAX(end_time, end_time1);
2386 duration =
FFMAX(duration, duration1);
2389 if (start_time == INT64_MAX || (start_time > start_time_text && start_time - start_time_text <
AV_TIME_BASE))
2390 start_time = start_time_text;
2391 else if (start_time > start_time_text)
2394 if (start_time != INT64_MAX) {
2396 if (end_time != INT64_MIN) {
2404 duration =
FFMAX(duration, end_time - start_time);
2412 double bitrate = (double) filesize * 8.0 * AV_TIME_BASE /
2414 if (bitrate >= 0 && bitrate <= INT64_MAX)
2441 int i, show_warning = 0;
2486 "Estimating duration from bitrate, this may be inaccurate\n");
2489 #define DURATION_MAX_READ_SIZE 250000LL
2490 #define DURATION_MAX_RETRY 6
2497 int num, den, read_size, i, ret;
2498 int found_duration = 0;
2512 "start time for stream %d is not set in estimate_timings_from_pts\n", i);
2525 is_end = found_duration;
2538 }
while (ret ==
AVERROR(EAGAIN));
2541 read_size += pkt->
size;
2598 av_log(ic,
AV_LOG_DEBUG,
"stream %d : no PTS found at end of file, duration not set\n", i);
2600 av_log(ic,
AV_LOG_DEBUG,
"stream %d : no TS found at start of file, duration not set\n", i);
2628 file_size =
FFMAX(0, file_size);
2659 "stream: start_time: %0.3f duration: %0.3f bitrate=%"PRId64
" kb/s\n",
2670 #define FAIL(errmsg) do { \
2672 *errmsg_ptr = errmsg; \
2678 FAIL(
"unknown codec");
2682 FAIL(
"unspecified frame size");
2685 FAIL(
"unspecified sample format");
2687 FAIL(
"unspecified sample rate");
2689 FAIL(
"unspecified number of channels");
2691 FAIL(
"no decodable DTS frames");
2695 FAIL(
"unspecified size");
2697 FAIL(
"unspecified pixel format");
2700 FAIL(
"no frame in rv30/40 and no sar");
2704 FAIL(
"unspecified size");
2717 const AVCodec *codec;
2718 int got_picture = 1, ret = 0;
2722 int do_skip_frame = 0;
2743 av_dict_set(options ? options : &thread_opt,
"threads",
"1", 0);
2768 while ((pkt.
size > 0 || (!pkt.
data && got_picture)) &&
2777 &got_picture, &pkt);
2784 &got_picture, &pkt);
2799 if (!pkt.
data && !got_picture)
2803 if (do_skip_frame) {
2825 if (tag == tags[i].tag)
2847 if (sflags & (1 << (bps - 1))) {
2889 for (i = 0; tags && tags[i]; i++) {
2892 if (codec_tags->
id ==
id) {
2893 *tag = codec_tags->
tag;
2905 for (i = 0; tags && tags[i]; i++) {
2916 int64_t max_time = 0;
2933 if (j != i && next_start > ch->
start && next_start < end)
2936 ch->
end = (end == INT64_MAX) ? ch->
start : end;
2943 return (i + 1) * 1001;
2947 return (i + 31) * 1001 * 12;
2951 return ((
const int[]) { 80, 120, 240})[i] * 1001 * 12;
2955 return ((
const int[]) { 24, 30, 60, 12, 15, 48 })[i] * 1000 * 12;
3022 && ts - (uint64_t)last < INT64_MAX) {
3036 double sdts = dts*framerate/(1001*12);
3037 for (j= 0; j<2; j++) {
3038 int64_t ticks =
llrint(sdts+j*0.5);
3039 double error= sdts - ticks + j*0.5;
3056 if (error0 > 0.04 && error1 > 0.04) {
3079 AVStream *st = ic->
streams[i];
3091 double best_error= 0.01;
3105 for (k= 0; k<2; k++) {
3110 if (error < best_error && best_error> 0.000000001) {
3119 if (num && (!ref_rate.
num || (
double)num/(12*1001) < 1.01 *
av_q2d(ref_rate)))
3141 int i,
count, ret = 0, j;
3150 int64_t max_stream_analyze_duration;
3151 int64_t max_subtitle_analyze_duration;
3154 flush_codecs = probesize > 0;
3158 max_stream_analyze_duration = max_analyze_duration;
3159 max_subtitle_analyze_duration = max_analyze_duration;
3160 if (!max_analyze_duration) {
3161 max_stream_analyze_duration =
3169 av_log(ic,
AV_LOG_DEBUG,
"Before avformat_find_stream_info() pos: %"PRId64
" bytes read:%"PRId64
" seeks:%d\n",
3173 const AVCodec *codec;
3195 "%s, packets or times may be invalid.\n",
3203 av_dict_set(options ? &options[i] : &thread_opt,
"threads",
"1", 0);
3213 "Failed to open codec in av_find_stream_info\n");
3221 "Failed to open codec in av_find_stream_info\n");
3228 #if FF_API_R_FRAME_RATE
3238 int analyzed_all_streams;
3247 int fps_analyze_framecount = 20;
3256 fps_analyze_framecount *= 2;
3258 fps_analyze_framecount = 0;
3262 fps_analyze_framecount = 0;
3269 if (count < fps_analyze_framecount)
3282 analyzed_all_streams = 0;
3284 analyzed_all_streams = 1;
3296 if (read_size >= probesize) {
3299 "Probe buffer size limit of %"PRId64
" bytes reached\n", probesize);
3306 "Stream #%d: not enough frames to estimate rate; "
3307 "consider increasing probesize\n", i);
3328 goto find_stream_info_err;
3333 read_size += pkt->
size;
3340 "Non-increasing DTS in stream %d: packet %d with DTS "
3341 "%"PRId64
", packet %d with DTS %"PRId64
"\n",
3357 "DTS discontinuity in stream %d: packet %d with DTS "
3358 "%"PRId64
", packet %d with DTS %"PRId64
"\n",
3389 if (analyzed_all_streams) limit = max_analyze_duration;
3391 else limit = max_stream_analyze_duration;
3394 av_log(ic,
AV_LOG_VERBOSE,
"max_analyze_duration %"PRId64
" reached at %"PRId64
" microseconds st:%d\n",
3409 #if FF_API_R_FRAME_RATE
3433 (options && i < orig_nb_streams) ? &options[i] :
NULL);
3455 (options && i < orig_nb_streams)
3456 ? &options[i] :
NULL);
3461 "decoding for stream %d failed\n", st->
index);
3489 double best_error = 0.01;
3506 if (error < best_error) {
3508 best_fps = std_fps.
num;
3513 best_fps, 12 * 1001, INT_MAX);
3571 "Could not find codec parameters for stream %d (%s): %s\n"
3572 "Consider increasing the value for the 'analyzeduration' and 'probesize' options\n",
3581 find_stream_info_err:
3591 av_log(ic,
AV_LOG_DEBUG,
"After avformat_find_stream_info() pos: %"PRId64
" bytes read:%"PRId64
" seeks:%d frames:%d\n",
3614 int wanted_stream_nb,
int related_stream,
3615 AVCodec **decoder_ret,
int flags)
3619 unsigned *program =
NULL;
3622 if (related_stream >= 0 && wanted_stream_nb < 0) {
3630 int real_stream_index = program ? program[i] : i;
3631 AVStream *st = ic->
streams[real_stream_index];
3635 if (wanted_stream_nb >= 0 && real_stream_index != wanted_stream_nb)
3637 if (wanted_stream_nb != real_stream_index &&
3656 if ((best_multiframe > multiframe) ||
3657 (best_multiframe == multiframe && best_bitrate > bitrate) ||
3658 (best_multiframe == multiframe && best_bitrate == bitrate && best_count >=
count))
3661 best_bitrate = bitrate;
3662 best_multiframe = multiframe;
3663 ret = real_stream_index;
3665 if (program && i == nb_streams - 1 && ret < 0) {
3673 *decoder_ret = (AVCodec*)best_decoder;
3699 AVStream *st = *pst;
3811 if (s->
nb_streams >= INT_MAX/
sizeof(*streams))
3868 #if FF_API_R_FRAME_RATE
3912 int64_t
start, int64_t
end,
const char *title)
3918 av_log(s,
AV_LOG_ERROR,
"Chapter end time %"PRId64
" before start %"PRId64
"\n", end, start);
3977 char *q, buf1[20],
c;
3978 int nd,
len, percentd_found;
3991 nd = nd * 10 + *p++ -
'0';
4004 snprintf(buf1,
sizeof(buf1),
"%0*d", nd, number);
4006 if ((q - buf + len) > buf_size - 1)
4008 memcpy(q, buf1, len);
4016 if ((q - buf) < buf_size - 1)
4020 if (!percentd_found)
4030 char *authorization,
int authorization_size,
4031 char *hostname,
int hostname_size,
4032 int *port_ptr,
char *path,
int path_size,
const char *url)
4034 const char *p, *ls, *ls2, *at, *at2, *col, *brk;
4040 if (authorization_size > 0)
4041 authorization[0] = 0;
4042 if (hostname_size > 0)
4048 if ((p = strchr(url,
':'))) {
4062 ls = strchr(p,
'/');
4063 ls2 = strchr(p,
'?');
4067 ls =
FFMIN(ls, ls2);
4077 while ((at = strchr(p,
'@')) && at < ls) {
4079 FFMIN(authorization_size, at + 1 - at2));
4083 if (*p ==
'[' && (brk = strchr(p,
']')) && brk < ls) {
4086 FFMIN(hostname_size, brk - p));
4087 if (brk[1] ==
':' && port_ptr)
4088 *port_ptr = atoi(brk + 2);
4089 }
else if ((col = strchr(p,
':')) && col < ls) {
4091 FFMIN(col + 1 - p, hostname_size));
4093 *port_ptr = atoi(col + 1);
4096 FFMIN(ls + 1 - p, hostname_size));
4103 static const char hex_table_uc[16] = {
'0',
'1',
'2',
'3',
4106 'C',
'D',
'E',
'F' };
4107 static const char hex_table_lc[16] = {
'0',
'1',
'2',
'3',
4110 'c',
'd',
'e',
'f' };
4111 const char *hex_table = lowercase ? hex_table_lc : hex_table_uc;
4113 for (i = 0; i <
s; i++) {
4114 buff[i * 2] = hex_table[src[i] >> 4];
4115 buff[i * 2 + 1] = hex_table[src[i] & 0xF];
4132 if (c >=
'0' && c <=
'9')
4134 else if (c >=
'A' && c <=
'F')
4150 unsigned int pts_num,
unsigned int pts_den)
4154 if (new_tb.
num != pts_num)
4156 "st:%d removing common factor %d from timebase\n",
4160 "st:%d has too large timebase, reducing\n", s->
index);
4162 if (new_tb.
num <= 0 || new_tb.
den <= 0) {
4164 "Ignoring attempt to set invalid timebase %d/%d for st:%d\n",
4177 const char *ptr = str;
4182 char *dest =
NULL, *dest_end;
4183 int key_len, dest_len = 0;
4186 while (*ptr && (
av_isspace(*ptr) || *ptr ==
','))
4193 if (!(ptr = strchr(key,
'=')))
4196 key_len = ptr - key;
4198 callback_get_buf(context, key, key_len, &dest, &dest_len);
4199 dest_end = dest + dest_len - 1;
4203 while (*ptr && *ptr !=
'\"') {
4207 if (dest && dest < dest_end)
4211 if (dest && dest < dest_end)
4219 for (; *ptr && !(
av_isspace(*ptr) || *ptr ==
','); ptr++)
4220 if (dest && dest < dest_end)
4241 unsigned int codec_tag;
4243 return ofmt->
query_codec(codec_id, std_compliance);
4290 if (channel_layout) {
4298 if (width || height) {
4305 bytestream_put_le32(&data, flags);
4307 bytestream_put_le32(&data, channels);
4309 bytestream_put_le64(&data, channel_layout);
4311 bytestream_put_le32(&data, sample_rate);
4312 if (width || height) {
4313 bytestream_put_le32(&data, width);
4314 bytestream_put_le32(&data, height);
4326 av_reduce(&stream_sample_aspect_ratio.
num, &stream_sample_aspect_ratio.
den,
4327 stream_sample_aspect_ratio.
num, stream_sample_aspect_ratio.
den, INT_MAX);
4328 if (stream_sample_aspect_ratio.
num <= 0 || stream_sample_aspect_ratio.
den <= 0)
4329 stream_sample_aspect_ratio = undef;
4331 av_reduce(&frame_sample_aspect_ratio.
num, &frame_sample_aspect_ratio.
den,
4332 frame_sample_aspect_ratio.
num, frame_sample_aspect_ratio.
den, INT_MAX);
4333 if (frame_sample_aspect_ratio.
num <= 0 || frame_sample_aspect_ratio.
den <= 0)
4334 frame_sample_aspect_ratio = undef;
4336 if (stream_sample_aspect_ratio.
num)
4337 return stream_sample_aspect_ratio;
4339 return frame_sample_aspect_ratio;
4348 if (avg_fr.
num > 0 && avg_fr.
den > 0 && fr.
num > 0 && fr.
den > 0 &&
4355 if ( codec_fr.
num > 0 && codec_fr.
den > 0 &&
4366 if (*spec <= '9' && *spec >=
'0')
4367 return strtol(spec,
NULL, 0) == st->
index;
4368 else if (*spec ==
'v' || *spec ==
'a' || *spec ==
's' || *spec ==
'd' ||
4369 *spec ==
't' || *spec ==
'V') {
4386 if (*spec++ ==
':') {
4392 return i == st->
index;
4396 }
else if (*spec ==
'p' && *(spec + 1) ==
':') {
4400 prog_id = strtol(spec, &endptr, 0);
4405 if (*endptr++ ==
':') {
4406 int stream_idx = strtol(endptr,
NULL, 0);
4407 return stream_idx >= 0 &&
4417 }
else if (*spec ==
'#' ||
4418 (*spec ==
'i' && *(spec + 1) ==
':')) {
4421 spec += 1 + (*spec ==
'i');
4422 stream_id = strtol(spec, &endptr, 0);
4424 return stream_id == st->
id;
4425 }
else if (*spec ==
'm' && *(spec + 1) ==
':') {
4431 val = strchr(spec,
':');
4439 if (!val || !strcmp(tag->
value, val + 1))
4448 }
else if (*spec ==
'u') {
4479 static const uint8_t avci100_1080p_extradata[] = {
4481 0x00, 0x00, 0x00, 0x01, 0x67, 0x7a, 0x10, 0x29,
4482 0xb6, 0xd4, 0x20, 0x22, 0x33, 0x19, 0xc6, 0x63,
4483 0x23, 0x21, 0x01, 0x11, 0x98, 0xce, 0x33, 0x19,
4484 0x18, 0x21, 0x02, 0x56, 0xb9, 0x3d, 0x7d, 0x7e,
4485 0x4f, 0xe3, 0x3f, 0x11, 0xf1, 0x9e, 0x08, 0xb8,
4486 0x8c, 0x54, 0x43, 0xc0, 0x78, 0x02, 0x27, 0xe2,
4487 0x70, 0x1e, 0x30, 0x10, 0x10, 0x14, 0x00, 0x00,
4488 0x03, 0x00, 0x04, 0x00, 0x00, 0x03, 0x00, 0xca,
4489 0x10, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
4491 0x00, 0x00, 0x00, 0x01, 0x68, 0xce, 0x33, 0x48,
4494 static const uint8_t avci100_1080i_extradata[] = {
4496 0x00, 0x00, 0x00, 0x01, 0x67, 0x7a, 0x10, 0x29,
4497 0xb6, 0xd4, 0x20, 0x22, 0x33, 0x19, 0xc6, 0x63,
4498 0x23, 0x21, 0x01, 0x11, 0x98, 0xce, 0x33, 0x19,
4499 0x18, 0x21, 0x03, 0x3a, 0x46, 0x65, 0x6a, 0x65,
4500 0x24, 0xad, 0xe9, 0x12, 0x32, 0x14, 0x1a, 0x26,
4501 0x34, 0xad, 0xa4, 0x41, 0x82, 0x23, 0x01, 0x50,
4502 0x2b, 0x1a, 0x24, 0x69, 0x48, 0x30, 0x40, 0x2e,
4503 0x11, 0x12, 0x08, 0xc6, 0x8c, 0x04, 0x41, 0x28,
4504 0x4c, 0x34, 0xf0, 0x1e, 0x01, 0x13, 0xf2, 0xe0,
4505 0x3c, 0x60, 0x20, 0x20, 0x28, 0x00, 0x00, 0x03,
4506 0x00, 0x08, 0x00, 0x00, 0x03, 0x01, 0x94, 0x20,
4508 0x00, 0x00, 0x00, 0x01, 0x68, 0xce, 0x33, 0x48,
4511 static const uint8_t avci50_1080p_extradata[] = {
4513 0x00, 0x00, 0x00, 0x01, 0x67, 0x6e, 0x10, 0x28,
4514 0xa6, 0xd4, 0x20, 0x32, 0x33, 0x0c, 0x71, 0x18,
4515 0x88, 0x62, 0x10, 0x19, 0x19, 0x86, 0x38, 0x8c,
4516 0x44, 0x30, 0x21, 0x02, 0x56, 0x4e, 0x6f, 0x37,
4517 0xcd, 0xf9, 0xbf, 0x81, 0x6b, 0xf3, 0x7c, 0xde,
4518 0x6e, 0x6c, 0xd3, 0x3c, 0x05, 0xa0, 0x22, 0x7e,
4519 0x5f, 0xfc, 0x00, 0x0c, 0x00, 0x13, 0x8c, 0x04,
4520 0x04, 0x05, 0x00, 0x00, 0x03, 0x00, 0x01, 0x00,
4521 0x00, 0x03, 0x00, 0x32, 0x84, 0x00, 0x00, 0x00,
4523 0x00, 0x00, 0x00, 0x01, 0x68, 0xee, 0x31, 0x12,
4526 static const uint8_t avci50_1080i_extradata[] = {
4528 0x00, 0x00, 0x00, 0x01, 0x67, 0x6e, 0x10, 0x28,
4529 0xa6, 0xd4, 0x20, 0x32, 0x33, 0x0c, 0x71, 0x18,
4530 0x88, 0x62, 0x10, 0x19, 0x19, 0x86, 0x38, 0x8c,
4531 0x44, 0x30, 0x21, 0x02, 0x56, 0x4e, 0x6e, 0x61,
4532 0x87, 0x3e, 0x73, 0x4d, 0x98, 0x0c, 0x03, 0x06,
4533 0x9c, 0x0b, 0x73, 0xe6, 0xc0, 0xb5, 0x18, 0x63,
4534 0x0d, 0x39, 0xe0, 0x5b, 0x02, 0xd4, 0xc6, 0x19,
4535 0x1a, 0x79, 0x8c, 0x32, 0x34, 0x24, 0xf0, 0x16,
4536 0x81, 0x13, 0xf7, 0xff, 0x80, 0x02, 0x00, 0x01,
4537 0xf1, 0x80, 0x80, 0x80, 0xa0, 0x00, 0x00, 0x03,
4538 0x00, 0x20, 0x00, 0x00, 0x06, 0x50, 0x80, 0x00,
4540 0x00, 0x00, 0x00, 0x01, 0x68, 0xee, 0x31, 0x12,
4543 static const uint8_t avci100_720p_extradata[] = {
4545 0x00, 0x00, 0x00, 0x01, 0x67, 0x7a, 0x10, 0x29,
4546 0xb6, 0xd4, 0x20, 0x2a, 0x33, 0x1d, 0xc7, 0x62,
4547 0xa1, 0x08, 0x40, 0x54, 0x66, 0x3b, 0x8e, 0xc5,
4548 0x42, 0x02, 0x10, 0x25, 0x64, 0x2c, 0x89, 0xe8,
4549 0x85, 0xe4, 0x21, 0x4b, 0x90, 0x83, 0x06, 0x95,
4550 0xd1, 0x06, 0x46, 0x97, 0x20, 0xc8, 0xd7, 0x43,
4551 0x08, 0x11, 0xc2, 0x1e, 0x4c, 0x91, 0x0f, 0x01,
4552 0x40, 0x16, 0xec, 0x07, 0x8c, 0x04, 0x04, 0x05,
4553 0x00, 0x00, 0x03, 0x00, 0x01, 0x00, 0x00, 0x03,
4554 0x00, 0x64, 0x84, 0x00, 0x00, 0x00, 0x00, 0x00,
4556 0x00, 0x00, 0x00, 0x01, 0x68, 0xce, 0x31, 0x12,
4559 static const uint8_t avci50_720p_extradata[] = {
4561 0x00, 0x00, 0x00, 0x01, 0x67, 0x6e, 0x10, 0x20,
4562 0xa6, 0xd4, 0x20, 0x32, 0x33, 0x0c, 0x71, 0x18,
4563 0x88, 0x62, 0x10, 0x19, 0x19, 0x86, 0x38, 0x8c,
4564 0x44, 0x30, 0x21, 0x02, 0x56, 0x4e, 0x6f, 0x37,
4565 0xcd, 0xf9, 0xbf, 0x81, 0x6b, 0xf3, 0x7c, 0xde,
4566 0x6e, 0x6c, 0xd3, 0x3c, 0x0f, 0x01, 0x6e, 0xff,
4567 0xc0, 0x00, 0xc0, 0x01, 0x38, 0xc0, 0x40, 0x40,
4568 0x50, 0x00, 0x00, 0x03, 0x00, 0x10, 0x00, 0x00,
4569 0x06, 0x48, 0x40, 0x00, 0x00, 0x00, 0x00, 0x00,
4571 0x00, 0x00, 0x00, 0x01, 0x68, 0xee, 0x31, 0x12,
4580 data = avci100_1080p_extradata;
4581 size =
sizeof(avci100_1080p_extradata);
4583 data = avci100_1080i_extradata;
4584 size =
sizeof(avci100_1080i_extradata);
4588 data = avci50_1080p_extradata;
4589 size =
sizeof(avci50_1080p_extradata);
4591 data = avci50_1080i_extradata;
4592 size =
sizeof(avci50_1080i_extradata);
4595 data = avci100_720p_extradata;
4596 size =
sizeof(avci100_720p_extradata);
4598 data = avci50_720p_extradata;
4599 size =
sizeof(avci50_720p_extradata);
4641 if (sd->
type == type) {
4669 while (*dest && (*dest)->
next)
4670 dest = &(*dest)->
next;
4681 "Automatically inserted bitstream filter '%s'; args='%s'\n",
4682 name, args ? args :
"");
4697 if(a == 0 && new_pkt.
data != pkt->
data) {
4700 memcpy(t, new_pkt.
data, new_pkt.
size);
4723 "Failed to open bitstream filter %s for stream %d with codec %s",
4746 int64_t parsed_timestamp;
4750 *timestamp = return_seconds ? parsed_timestamp / 1000000 : parsed_timestamp;
unsigned int nb_chapters
Number of chapters in AVChapter array.
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.
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)
static av_const int av_isdigit(int c)
Locale-independent conversion of ASCII isdigit.
int av_demuxer_open(AVFormatContext *ic)
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