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)
141 if ( (src-> codec_whitelist && !dst-> codec_whitelist)
175 #define SANE_CHUNK_SIZE (50000000)
181 if (remaining < size) {
184 s->
maxsize = newsize - !newsize;
186 remaining=
FFMAX(remaining, 0);
189 if (s->
maxsize>= 0 && remaining+1 < size) {
201 int64_t orig_pos = pkt->
pos;
202 int orig_size = pkt->
size;
206 int prev_size = pkt->
size;
224 if (ret != read_size) {
237 return pkt->
size > orig_size ? pkt->
size - orig_size :
ret;
267 static const struct {
291 "Probe with size=%d, packets=%d detected %s with score=%d\n",
294 for (i = 0; fmt_id_type[i].name; i++) {
295 if (!strcmp(fmt->
name, fmt_id_type[i].name)) {
343 "will be ignored with AVFMT_NOFILE format.\n");
368 (*plast_pktl)->next = pktl;
370 *packet_buffer = pktl;
385 if (copy.
size <= 0) {
387 "Attached picture on stream %d has invalid size, "
412 av_log(
NULL,
AV_LOG_ERROR,
"Input context has not been properly allocated by avformat_alloc_context() and is not NULL either\n");
427 if ((ret =
init_input(s, filename, &tmp)) < 0)
472 if (id3v2_extra_meta) {
539 "Failed to reallocate probe buffer for stream %d\n",
552 "nothing to probe for stream %d\n", st->
index);
579 int64_t ref = pkt->
dts;
580 int i, pts_wrap_behavior;
581 int64_t pts_wrap_reference;
599 if (!first_program) {
626 program = first_program;
670 if (!pktl || ret ==
AVERROR(EAGAIN))
685 "Dropped corrupted packet (stream = %d)\n",
755 switch (st->codec->codec_type) {
757 if (st->r_frame_rate.num && !pc &&
s->iformat) {
758 *pnum = st->r_frame_rate.den;
759 *pden = st->r_frame_rate.num;
760 }
else if (st->time_base.num * 1000LL > st->time_base.den) {
761 *pnum = st->time_base.num;
762 *pden = st->time_base.den;
763 }
else if (codec_framerate.den * 1000LL > codec_framerate.num) {
767 codec_framerate.num * (int64_t)st->codec->ticks_per_frame,
770 if (pc && pc->repeat_pict) {
773 (*pnum) * (1LL + pc->repeat_pict),
780 if (st->codec->ticks_per_frame > 1 && !pc)
786 if (frame_size <= 0 || st->codec->sample_rate <= 0)
789 *pden = st->codec->sample_rate;
817 #if CONFIG_H264_DECODER
848 int64_t best_score = INT64_MAX;
849 for (i = 0; i<delay; i++) {
852 if (score < best_score) {
859 for (i = 0; i<delay; i++) {
861 int64_t
diff =
FFABS(pts_buffer[i] - dts)
920 pts_buffer[0] = pktl->
pkt.
pts;
921 for (i = 0; i<delay && pts_buffer[i] > pts_buffer[i + 1]; i++)
922 FFSWAP(int64_t, pts_buffer[i], pts_buffer[i + 1]);
953 av_log(s,
AV_LOG_DEBUG,
"first_dts %s not matching first dts %s (pts %s, duration %d) in the queue\n",
987 int64_t next_dts, int64_t next_pts)
989 int num, den, presentation_delayed, delay, i;
1004 "DTS %"PRIi64
" < %"PRIi64
" out of order\n",
1030 presentation_delayed = 0;
1036 presentation_delayed = 1;
1051 if (delay == 1 && pkt->
dts == pkt->
pts &&
1054 if ( strcmp(s->
iformat->
name,
"mov,mp4,m4a,3gp,3g2,mj2")
1089 presentation_delayed = 1;
1092 "IN delayed:%d pts:%s, dts:%s cur_dts:%s st:%d pc:%p duration:%d delay:%d onein_oneout:%d\n",
1097 if ((delay == 0 || (delay == 1 && pc)) &&
1099 if (presentation_delayed) {
1117 ((uint64_t)st->
cur_dts - (uint64_t)next_dts + 1) <= 2 &&
1118 next_dts != next_pts &&
1120 pkt->
pts = next_dts;
1157 av_dlog(
NULL,
"OUTdelayed:%d/%d pts:%s, dts:%s cur_dts:%s\n",
1171 *pkt_buf = pktl->
next;
1175 *pkt_buf_end =
NULL;
1189 int ret = 0, got_output = 0;
1200 while (size > 0 || (pkt == &
flush_pkt && got_output)) {
1202 int64_t next_pts = pkt->
pts;
1203 int64_t next_dts = pkt->
dts;
1207 &out_pkt.
data, &out_pkt.
size, data, size,
1216 got_output = !!out_pkt.
size;
1261 #if FF_API_DESTRUCT_PACKET
1297 *pkt_buffer = pktl->
next;
1299 *pkt_buffer_end =
NULL;
1311 int ret = 0, i, got_packet = 0;
1340 cur_pkt.
pts < cur_pkt.
dts) {
1342 "Invalid timestamps stream=%d, pts=%s, dts=%s, size=%d\n",
1350 "ff_read_packet stream=%d, pts=%s, dts=%s, size=%d, duration=%d, flags=%d\n",
1360 "%s, packets or times may be invalid.\n",
1406 int discard_padding = 0;
1411 int64_t end_sample = sample +
duration;
1413 sample < st->last_discard_sample)
1420 AV_WL32(p + 4, discard_padding);
1440 memcpy(dst_data, src_sd->
data, src_sd->
size);
1459 "read_frame_internal stream=%d, pts=%s, dts=%s, "
1460 "size=%d, duration=%d, flags=%d\n",
1496 int64_t last_dts = next_pkt->
dts;
1506 last_dts = pktl->
pkt.
dts;
1534 if (pktl && ret !=
AVERROR(EAGAIN)) {
1581 int best_stream = 0;
1582 int best_score = -1;
1606 if (score > best_score) {
1676 int *nb_index_entries,
1677 unsigned int *index_entries_allocated_size,
1678 int64_t pos, int64_t timestamp,
1684 if ((
unsigned) *nb_index_entries + 1 >= UINT_MAX /
sizeof(
AVIndexEntry))
1697 index_entries_allocated_size,
1698 (*nb_index_entries + 1) *
1703 *index_entries = entries;
1709 index = (*nb_index_entries)++;
1710 ie = &entries[
index];
1711 av_assert0(index == 0 || ie[-1].timestamp < timestamp);
1713 ie = &entries[
index];
1717 memmove(entries + index + 1, entries + index,
1719 (*nb_index_entries)++;
1720 }
else if (ie->
pos == pos && distance < ie->min_distance)
1740 timestamp, size, distance, flags);
1744 int64_t wanted_timestamp,
int flags)
1753 if (b && entries[b - 1].timestamp < wanted_timestamp)
1759 if (timestamp >= wanted_timestamp)
1761 if (timestamp <= wanted_timestamp)
1767 while (m >= 0 && m < nb_entries &&
1771 if (m == nb_entries)
1779 wanted_timestamp, flags);
1783 int64_t (*read_timestamp)(
struct AVFormatContext *,
int , int64_t *, int64_t ))
1785 int64_t ts = read_timestamp(s, stream_index, ppos, pos_limit);
1786 if (stream_index >= 0)
1792 int64_t target_ts,
int flags)
1796 int64_t ts_min, ts_max, ts;
1801 if (stream_index < 0)
1810 st = s->
streams[stream_index];
1818 index =
FFMAX(index, 0);
1824 av_dlog(s,
"using cached pos_min=0x%"PRIx64
" dts_min=%s\n",
1839 av_dlog(s,
"using cached pos_max=0x%"PRIx64
" pos_limit=0x%"PRIx64
1840 " dts_max=%s\n", pos_max, pos_limit,
av_ts2str(ts_max));
1844 pos =
ff_gen_search(s, stream_index, target_ts, pos_min, pos_max, pos_limit,
1860 int64_t (*read_timestamp)(
struct AVFormatContext *,
int , int64_t *, int64_t ))
1862 int64_t step = 1024;
1863 int64_t limit, ts_max;
1865 int64_t pos_max = filesize - 1;
1868 pos_max =
FFMAX(0, (pos_max) - step);
1870 &pos_max, limit, read_timestamp);
1877 int64_t tmp_pos = pos_max + 1;
1879 &tmp_pos, INT64_MAX, read_timestamp);
1885 if (tmp_pos >= filesize)
1898 int64_t pos_min, int64_t pos_max, int64_t pos_limit,
1899 int64_t ts_min, int64_t ts_max,
1900 int flags, int64_t *ts_ret,
1902 int64_t *, int64_t))
1913 ts_min =
ff_read_timestamp(s, stream_index, &pos_min, INT64_MAX, read_timestamp);
1918 if (ts_min >= target_ts) {
1924 if ((ret =
ff_find_last_ts(s, stream_index, &ts_max, &pos_max, read_timestamp)) < 0)
1926 pos_limit = pos_max;
1929 if (ts_max <= target_ts) {
1937 while (pos_min < pos_limit) {
1939 "pos_min=0x%"PRIx64
" pos_max=0x%"PRIx64
" dts_min=%s dts_max=%s\n",
1943 if (no_change == 0) {
1944 int64_t approximate_keyframe_distance = pos_max - pos_limit;
1946 pos =
av_rescale(target_ts - ts_min, pos_max - pos_min,
1948 pos_min - approximate_keyframe_distance;
1949 }
else if (no_change == 1) {
1951 pos = (pos_min + pos_limit) >> 1;
1959 else if (pos > pos_limit)
1969 av_dlog(s,
"%"PRId64
" %"PRId64
" %"PRId64
" / %s %s %s"
1970 " target:%s limit:%"PRId64
" start:%"PRId64
" noc:%d\n",
1971 pos_min, pos, pos_max,
1973 pos_limit, start_pos, no_change);
1978 if (target_ts <= ts) {
1979 pos_limit = start_pos - 1;
1983 if (target_ts >= ts) {
1993 ts_min =
ff_read_timestamp(s, stream_index, &pos_min, INT64_MAX, read_timestamp);
1995 ts_max =
ff_read_timestamp(s, stream_index, &pos_min, INT64_MAX, read_timestamp);
1996 av_dlog(s,
"pos=0x%"PRIx64
" %s<=%s<=%s\n",
2004 int64_t pos,
int flags)
2006 int64_t pos_min, pos_max;
2013 else if (pos > pos_max)
2024 int64_t timestamp,
int flags)
2031 st = s->
streams[stream_index];
2035 if (index < 0 && st->nb_index_entries &&
2036 timestamp < st->index_entries[0].timestamp)
2039 if (index < 0 || index == st->nb_index_entries - 1) {
2057 }
while (read_status ==
AVERROR(EAGAIN));
2058 if (read_status < 0)
2065 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);
2088 int64_t timestamp,
int flags)
2100 if (stream_index < 0) {
2102 if (stream_index < 0)
2105 st = s->
streams[stream_index];
2132 int64_t timestamp,
int flags)
2137 int64_t min_ts = INT64_MIN, max_ts = INT64_MAX;
2143 flags & ~AVSEEK_FLAG_BACKWARD);
2155 int64_t ts, int64_t max_ts,
int flags)
2157 if (min_ts > ts || max_ts < ts)
2159 if (stream_index < -1 || stream_index >= (
int)s->
nb_streams)
2170 if (stream_index == -1 && s->
nb_streams == 1) {
2177 time_base.
num * (int64_t)AV_TIME_BASE,
2198 if (ret<0 && ts != min_ts && max_ts != ts) {
2199 ret =
av_seek_frame(s, stream_index, dir ? max_ts : min_ts, flags | dir);
2245 int64_t
start_time, start_time1, start_time_text, end_time, end_time1;
2246 int64_t
duration, duration1, filesize;
2251 start_time = INT64_MAX;
2252 start_time_text = INT64_MAX;
2253 end_time = INT64_MIN;
2254 duration = INT64_MIN;
2261 if (start_time1 < start_time_text)
2262 start_time_text = start_time1;
2264 start_time =
FFMIN(start_time, start_time1);
2267 end_time1 = start_time1 +
2270 end_time =
FFMAX(end_time, end_time1);
2282 duration =
FFMAX(duration, duration1);
2285 if (start_time == INT64_MAX || (start_time > start_time_text && start_time - start_time_text <
AV_TIME_BASE))
2286 start_time = start_time_text;
2287 else if (start_time > start_time_text)
2290 if (start_time != INT64_MAX) {
2292 if (end_time != INT64_MIN) {
2300 duration =
FFMAX(duration, end_time - start_time);
2308 double bitrate = (double) filesize * 8.0 * AV_TIME_BASE /
2310 if (bitrate >= 0 && bitrate <= INT_MAX)
2337 int i, show_warning = 0;
2382 "Estimating duration from bitrate, this may be inaccurate\n");
2385 #define DURATION_MAX_READ_SIZE 250000LL
2386 #define DURATION_MAX_RETRY 6
2393 int num, den, read_size, i,
ret;
2394 int found_duration = 0;
2408 "start time for stream %d is not set in estimate_timings_from_pts\n", i);
2421 is_end = found_duration;
2434 }
while (ret ==
AVERROR(EAGAIN));
2437 read_size += pkt->
size;
2494 av_log(ic,
AV_LOG_DEBUG,
"stream %d : no PTS found at end of file, duration not set\n", i);
2496 av_log(ic,
AV_LOG_DEBUG,
"stream %d : no TS found at start of file, duration not set\n", i);
2524 file_size =
FFMAX(0, file_size);
2550 av_dlog(ic,
"%d: start_time: %0.3f duration: %0.3f\n", i,
2555 "stream: start_time: %0.3f duration: %0.3f bitrate=%d kb/s\n",
2566 #define FAIL(errmsg) do { \
2568 *errmsg_ptr = errmsg; \
2574 FAIL(
"unknown codec");
2578 FAIL(
"unspecified frame size");
2581 FAIL(
"unspecified sample format");
2583 FAIL(
"unspecified sample rate");
2585 FAIL(
"unspecified number of channels");
2587 FAIL(
"no decodable DTS frames");
2591 FAIL(
"unspecified size");
2593 FAIL(
"unspecified pixel format");
2596 FAIL(
"no frame in rv30/40 and no sar");
2600 FAIL(
"unspecified size");
2614 int got_picture = 1,
ret = 0;
2637 av_dict_set(options ? options : &thread_opt,
"threads",
"1", 0);
2656 while ((pkt.
size > 0 || (!pkt.
data && got_picture)) &&
2665 &got_picture, &pkt);
2672 &got_picture, &pkt);
2687 if (!pkt.
data && !got_picture)
2709 if (tag == tags[i].tag)
2731 if (sflags & (1 << (bps - 1))) {
2773 for (i = 0; tags && tags[i]; i++) {
2776 if (codec_tags->
id ==
id) {
2777 *tag = codec_tags->
tag;
2789 for (i = 0; tags && tags[i]; i++) {
2814 if (j != i && next_start > ch->
start && next_start < end)
2817 ch->
end = (end == INT64_MAX) ? ch->
start : end;
2824 return (i + 1) * 1001;
2828 return (i + 31) * 1001 * 12;
2832 return ((
const int[]) { 80, 120, 240})[i] * 1001 * 12;
2836 return ((
const int[]) { 24, 30, 60, 12, 15, 48 })[i] * 1000 * 12;
2902 && ts - (uint64_t)last < INT64_MAX) {
2916 double sdts = dts*framerate/(1001*12);
2917 for (j= 0; j<2; j++) {
2918 int64_t ticks =
llrint(sdts+j*0.5);
2919 double error= sdts - ticks + j*0.5;
2936 if (error0 > 0.04 && error1 > 0.04) {
2971 double best_error= 0.01;
2985 for (k= 0; k<2; k++) {
2990 if (error < best_error && best_error> 0.000000001) {
2999 if (num && (!ref_rate.
num || (
double)num/(12*1001) < 1.01 *
av_q2d(ref_rate)))
3030 int64_t max_stream_analyze_duration;
3033 if (!max_analyze_duration)
3037 flush_codecs = probesize > 0;
3041 max_stream_analyze_duration = max_analyze_duration;
3042 if (!max_analyze_duration) {
3043 max_stream_analyze_duration =
3050 av_log(ic,
AV_LOG_DEBUG,
"Before avformat_find_stream_info() pos: %"PRId64
" bytes read:%"PRId64
" seeks:%d\n",
3076 "%s, packets or times may be invalid.\n",
3084 av_dict_set(options ? &options[i] : &thread_opt,
"threads",
"1", 0);
3094 "Failed to open codec in av_find_stream_info\n");
3102 "Failed to open codec in av_find_stream_info\n");
3109 #if FF_API_R_FRAME_RATE
3119 int analyzed_all_streams;
3128 int fps_analyze_framecount = 20;
3137 fps_analyze_framecount *= 2;
3139 fps_analyze_framecount = 0;
3143 fps_analyze_framecount = 0;
3159 analyzed_all_streams = 0;
3161 analyzed_all_streams = 1;
3173 if (read_size >= probesize) {
3176 "Probe buffer size limit of %"PRId64
" bytes reached\n", probesize);
3183 "Stream #%d: not enough frames to estimate rate; "
3184 "consider increasing probesize\n", i);
3207 goto find_stream_info_err;
3210 goto find_stream_info_err;
3215 read_size += pkt->
size;
3222 "Non-increasing DTS in stream %d: packet %d with DTS "
3223 "%"PRId64
", packet %d with DTS %"PRId64
"\n",
3239 "DTS discontinuity in stream %d: packet %d with DTS "
3240 "%"PRId64
", packet %d with DTS %"PRId64
"\n",
3270 if (t >= (analyzed_all_streams ? max_analyze_duration : max_stream_analyze_duration)) {
3271 av_log(ic,
AV_LOG_VERBOSE,
"max_analyze_duration %"PRId64
" reached at %"PRId64
" microseconds\n",
3272 max_analyze_duration,
3283 #if FF_API_R_FRAME_RATE
3307 (options && i < orig_nb_streams) ? &options[i] :
NULL);
3329 (options && i < orig_nb_streams)
3330 ? &options[i] :
NULL);
3335 "decoding for stream %d failed\n", st->
index);
3363 double best_error = 0.01;
3380 if (error < best_error) {
3382 best_fps = std_fps.
num;
3387 best_fps, 12 * 1001, INT_MAX);
3445 "Could not find codec parameters for stream %d (%s): %s\n"
3446 "Consider increasing the value for the 'analyzeduration' and 'probesize' options\n",
3455 find_stream_info_err:
3465 av_log(ic,
AV_LOG_DEBUG,
"After avformat_find_stream_info() pos: %"PRId64
" bytes read:%"PRId64
" seeks:%d frames:%d\n",
3488 int wanted_stream_nb,
int related_stream,
3489 AVCodec **decoder_ret,
int flags)
3493 unsigned *program =
NULL;
3496 if (related_stream >= 0 && wanted_stream_nb < 0) {
3504 int real_stream_index = program ? program[i] : i;
3509 if (wanted_stream_nb >= 0 && real_stream_index != wanted_stream_nb)
3511 if (wanted_stream_nb != real_stream_index &&
3530 if ((best_multiframe > multiframe) ||
3531 (best_multiframe == multiframe && best_bitrate > bitrate) ||
3532 (best_multiframe == multiframe && best_bitrate == bitrate && best_count >=
count))
3535 best_bitrate = bitrate;
3536 best_multiframe = multiframe;
3537 ret = real_stream_index;
3539 if (program && i == nb_streams - 1 && ret < 0) {
3547 *decoder_ret = (
AVCodec*)best_decoder;
3669 if (s->
nb_streams >= INT_MAX/
sizeof(*streams))
3719 #if FF_API_R_FRAME_RATE
3736 av_dlog(ac,
"new_program: id=0x%04x\n",
id);
3760 int64_t
start, int64_t
end,
const char *title)
3766 av_log(s,
AV_LOG_ERROR,
"Chapter end time %"PRId64
" before start %"PRId64
"\n", end, start);
3825 char *q, buf1[20],
c;
3826 int nd,
len, percentd_found;
3839 nd = nd * 10 + *p++ -
'0';
3852 snprintf(buf1,
sizeof(buf1),
"%0*d", nd, number);
3854 if ((q - buf + len) > buf_size - 1)
3856 memcpy(q, buf1, len);
3864 if ((q - buf) < buf_size - 1)
3868 if (!percentd_found)
3878 char *authorization,
int authorization_size,
3879 char *hostname,
int hostname_size,
3880 int *port_ptr,
char *path,
int path_size,
const char *url)
3882 const char *p, *ls, *ls2, *at, *at2, *col, *brk;
3888 if (authorization_size > 0)
3889 authorization[0] = 0;
3890 if (hostname_size > 0)
3896 if ((p = strchr(url,
':'))) {
3910 ls = strchr(p,
'/');
3911 ls2 = strchr(p,
'?');
3915 ls =
FFMIN(ls, ls2);
3925 while ((at = strchr(p,
'@')) && at < ls) {
3927 FFMIN(authorization_size, at + 1 - at2));
3931 if (*p ==
'[' && (brk = strchr(p,
']')) && brk < ls) {
3934 FFMIN(hostname_size, brk - p));
3935 if (brk[1] ==
':' && port_ptr)
3936 *port_ptr = atoi(brk + 2);
3937 }
else if ((col = strchr(p,
':')) && col < ls) {
3939 FFMIN(col + 1 - p, hostname_size));
3941 *port_ptr = atoi(col + 1);
3944 FFMIN(ls + 1 - p, hostname_size));
3951 static const char hex_table_uc[16] = {
'0',
'1',
'2',
'3',
3954 'C',
'D',
'E',
'F' };
3955 static const char hex_table_lc[16] = {
'0',
'1',
'2',
'3',
3958 'c',
'd',
'e',
'f' };
3959 const char *hex_table = lowercase ? hex_table_lc : hex_table_uc;
3961 for (i = 0; i <
s; i++) {
3962 buff[i * 2] = hex_table[src[i] >> 4];
3963 buff[i * 2 + 1] = hex_table[src[i] & 0xF];
3980 if (c >=
'0' && c <=
'9')
3982 else if (c >=
'A' && c <=
'F')
3998 unsigned int pts_num,
unsigned int pts_den)
4002 if (new_tb.
num != pts_num)
4004 "st:%d removing common factor %d from timebase\n",
4008 "st:%d has too large timebase, reducing\n", s->
index);
4010 if (new_tb.
num <= 0 || new_tb.
den <= 0) {
4012 "Ignoring attempt to set invalid timebase %d/%d for st:%d\n",
4025 const char *ptr = str;
4030 char *dest =
NULL, *dest_end;
4031 int key_len, dest_len = 0;
4034 while (*ptr && (
av_isspace(*ptr) || *ptr ==
','))
4041 if (!(ptr = strchr(key,
'=')))
4044 key_len = ptr - key;
4046 callback_get_buf(context, key, key_len, &dest, &dest_len);
4047 dest_end = dest + dest_len - 1;
4051 while (*ptr && *ptr !=
'\"') {
4055 if (dest && dest < dest_end)
4059 if (dest && dest < dest_end)
4067 for (; *ptr && !(
av_isspace(*ptr) || *ptr ==
','); ptr++)
4068 if (dest && dest < dest_end)
4087 struct tm time1 = { 0 }, time2 = { 0 };
4102 return ofmt->
query_codec(codec_id, std_compliance);
4149 if (channel_layout) {
4157 if (width || height) {
4164 bytestream_put_le32(&data, flags);
4166 bytestream_put_le32(&data, channels);
4168 bytestream_put_le64(&data, channel_layout);
4170 bytestream_put_le32(&data, sample_rate);
4171 if (width || height) {
4172 bytestream_put_le32(&data, width);
4173 bytestream_put_le32(&data, height);
4185 av_reduce(&stream_sample_aspect_ratio.
num, &stream_sample_aspect_ratio.
den,
4186 stream_sample_aspect_ratio.
num, stream_sample_aspect_ratio.
den, INT_MAX);
4187 if (stream_sample_aspect_ratio.
num <= 0 || stream_sample_aspect_ratio.
den <= 0)
4188 stream_sample_aspect_ratio = undef;
4190 av_reduce(&frame_sample_aspect_ratio.
num, &frame_sample_aspect_ratio.
den,
4191 frame_sample_aspect_ratio.
num, frame_sample_aspect_ratio.
den, INT_MAX);
4192 if (frame_sample_aspect_ratio.
num <= 0 || frame_sample_aspect_ratio.
den <= 0)
4193 frame_sample_aspect_ratio = undef;
4195 if (stream_sample_aspect_ratio.
num)
4196 return stream_sample_aspect_ratio;
4198 return frame_sample_aspect_ratio;
4207 if (avg_fr.
num > 0 && avg_fr.
den > 0 && fr.
num > 0 && fr.
den > 0 &&
4214 if ( codec_fr.
num > 0 && codec_fr.
den > 0 &&
4225 if (*spec <= '9' && *spec >=
'0')
4226 return strtol(spec,
NULL, 0) == st->
index;
4227 else if (*spec ==
'v' || *spec ==
'a' || *spec ==
's' || *spec ==
'd' ||
4241 if (*spec++ ==
':') {
4245 return i == st->
index;
4249 }
else if (*spec ==
'p' && *(spec + 1) ==
':') {
4253 prog_id = strtol(spec, &endptr, 0);
4258 if (*endptr++ ==
':') {
4259 int stream_idx = strtol(endptr,
NULL, 0);
4260 return stream_idx >= 0 &&
4270 }
else if (*spec ==
'#' ||
4271 (*spec ==
'i' && *(spec + 1) ==
':')) {
4274 spec += 1 + (*spec ==
'i');
4275 stream_id = strtol(spec, &endptr, 0);
4277 return stream_id == st->
id;
4278 }
else if (*spec ==
'm' && *(spec + 1) ==
':') {
4284 val = strchr(spec,
':');
4292 if (!val || !strcmp(tag->
value, val + 1))
4310 static const uint8_t avci100_1080p_extradata[] = {
4312 0x00, 0x00, 0x00, 0x01, 0x67, 0x7a, 0x10, 0x29,
4313 0xb6, 0xd4, 0x20, 0x22, 0x33, 0x19, 0xc6, 0x63,
4314 0x23, 0x21, 0x01, 0x11, 0x98, 0xce, 0x33, 0x19,
4315 0x18, 0x21, 0x02, 0x56, 0xb9, 0x3d, 0x7d, 0x7e,
4316 0x4f, 0xe3, 0x3f, 0x11, 0xf1, 0x9e, 0x08, 0xb8,
4317 0x8c, 0x54, 0x43, 0xc0, 0x78, 0x02, 0x27, 0xe2,
4318 0x70, 0x1e, 0x30, 0x10, 0x10, 0x14, 0x00, 0x00,
4319 0x03, 0x00, 0x04, 0x00, 0x00, 0x03, 0x00, 0xca,
4320 0x10, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
4322 0x00, 0x00, 0x00, 0x01, 0x68, 0xce, 0x33, 0x48,
4325 static const uint8_t avci100_1080i_extradata[] = {
4327 0x00, 0x00, 0x00, 0x01, 0x67, 0x7a, 0x10, 0x29,
4328 0xb6, 0xd4, 0x20, 0x22, 0x33, 0x19, 0xc6, 0x63,
4329 0x23, 0x21, 0x01, 0x11, 0x98, 0xce, 0x33, 0x19,
4330 0x18, 0x21, 0x03, 0x3a, 0x46, 0x65, 0x6a, 0x65,
4331 0x24, 0xad, 0xe9, 0x12, 0x32, 0x14, 0x1a, 0x26,
4332 0x34, 0xad, 0xa4, 0x41, 0x82, 0x23, 0x01, 0x50,
4333 0x2b, 0x1a, 0x24, 0x69, 0x48, 0x30, 0x40, 0x2e,
4334 0x11, 0x12, 0x08, 0xc6, 0x8c, 0x04, 0x41, 0x28,
4335 0x4c, 0x34, 0xf0, 0x1e, 0x01, 0x13, 0xf2, 0xe0,
4336 0x3c, 0x60, 0x20, 0x20, 0x28, 0x00, 0x00, 0x03,
4337 0x00, 0x08, 0x00, 0x00, 0x03, 0x01, 0x94, 0x00,
4339 0x00, 0x00, 0x00, 0x01, 0x68, 0xce, 0x33, 0x48,
4342 static const uint8_t avci50_1080p_extradata[] = {
4344 0x00, 0x00, 0x00, 0x01, 0x67, 0x6e, 0x10, 0x28,
4345 0xa6, 0xd4, 0x20, 0x32, 0x33, 0x0c, 0x71, 0x18,
4346 0x88, 0x62, 0x10, 0x19, 0x19, 0x86, 0x38, 0x8c,
4347 0x44, 0x30, 0x21, 0x02, 0x56, 0x4e, 0x6f, 0x37,
4348 0xcd, 0xf9, 0xbf, 0x81, 0x6b, 0xf3, 0x7c, 0xde,
4349 0x6e, 0x6c, 0xd3, 0x3c, 0x05, 0xa0, 0x22, 0x7e,
4350 0x5f, 0xfc, 0x00, 0x0c, 0x00, 0x13, 0x8c, 0x04,
4351 0x04, 0x05, 0x00, 0x00, 0x03, 0x00, 0x01, 0x00,
4352 0x00, 0x03, 0x00, 0x32, 0x84, 0x00, 0x00, 0x00,
4354 0x00, 0x00, 0x00, 0x01, 0x68, 0xee, 0x31, 0x12,
4357 static const uint8_t avci50_1080i_extradata[] = {
4359 0x00, 0x00, 0x00, 0x01, 0x67, 0x6e, 0x10, 0x28,
4360 0xa6, 0xd4, 0x20, 0x32, 0x33, 0x0c, 0x71, 0x18,
4361 0x88, 0x62, 0x10, 0x19, 0x19, 0x86, 0x38, 0x8c,
4362 0x44, 0x30, 0x21, 0x02, 0x56, 0x4e, 0x6e, 0x61,
4363 0x87, 0x3e, 0x73, 0x4d, 0x98, 0x0c, 0x03, 0x06,
4364 0x9c, 0x0b, 0x73, 0xe6, 0xc0, 0xb5, 0x18, 0x63,
4365 0x0d, 0x39, 0xe0, 0x5b, 0x02, 0xd4, 0xc6, 0x19,
4366 0x1a, 0x79, 0x8c, 0x32, 0x34, 0x24, 0xf0, 0x16,
4367 0x81, 0x13, 0xf7, 0xff, 0x80, 0x02, 0x00, 0x01,
4368 0xf1, 0x80, 0x80, 0x80, 0xa0, 0x00, 0x00, 0x03,
4369 0x00, 0x20, 0x00, 0x00, 0x06, 0x50, 0x80, 0x00,
4371 0x00, 0x00, 0x00, 0x01, 0x68, 0xee, 0x31, 0x12,
4374 static const uint8_t avci100_720p_extradata[] = {
4376 0x00, 0x00, 0x00, 0x01, 0x67, 0x7a, 0x10, 0x29,
4377 0xb6, 0xd4, 0x20, 0x2a, 0x33, 0x1d, 0xc7, 0x62,
4378 0xa1, 0x08, 0x40, 0x54, 0x66, 0x3b, 0x8e, 0xc5,
4379 0x42, 0x02, 0x10, 0x25, 0x64, 0x2c, 0x89, 0xe8,
4380 0x85, 0xe4, 0x21, 0x4b, 0x90, 0x83, 0x06, 0x95,
4381 0xd1, 0x06, 0x46, 0x97, 0x20, 0xc8, 0xd7, 0x43,
4382 0x08, 0x11, 0xc2, 0x1e, 0x4c, 0x91, 0x0f, 0x01,
4383 0x40, 0x16, 0xec, 0x07, 0x8c, 0x04, 0x04, 0x05,
4384 0x00, 0x00, 0x03, 0x00, 0x01, 0x00, 0x00, 0x03,
4385 0x00, 0x64, 0x84, 0x00, 0x00, 0x00, 0x00, 0x00,
4387 0x00, 0x00, 0x00, 0x01, 0x68, 0xce, 0x31, 0x12,
4390 static const uint8_t avci50_720p_extradata[] = {
4392 0x00, 0x00, 0x00, 0x01, 0x67, 0x6e, 0x10, 0x20,
4393 0xa6, 0xd4, 0x20, 0x32, 0x33, 0x0c, 0x71, 0x18,
4394 0x88, 0x62, 0x10, 0x19, 0x19, 0x86, 0x38, 0x8c,
4395 0x44, 0x30, 0x21, 0x02, 0x56, 0x4e, 0x6f, 0x37,
4396 0xcd, 0xf9, 0xbf, 0x81, 0x6b, 0xf3, 0x7c, 0xde,
4397 0x6e, 0x6c, 0xd3, 0x3c, 0x0f, 0x01, 0x6e, 0xff,
4398 0xc0, 0x00, 0xc0, 0x01, 0x38, 0xc0, 0x40, 0x40,
4399 0x50, 0x00, 0x00, 0x03, 0x00, 0x10, 0x00, 0x00,
4400 0x06, 0x48, 0x40, 0x00, 0x00, 0x00, 0x00, 0x00,
4402 0x00, 0x00, 0x00, 0x01, 0x68, 0xee, 0x31, 0x12,
4411 data = avci100_1080p_extradata;
4412 size =
sizeof(avci100_1080p_extradata);
4414 data = avci100_1080i_extradata;
4415 size =
sizeof(avci100_1080i_extradata);
4419 data = avci50_1080p_extradata;
4420 size =
sizeof(avci50_1080p_extradata);
4422 data = avci50_1080i_extradata;
4423 size =
sizeof(avci50_1080i_extradata);
4426 data = avci100_720p_extradata;
4427 size =
sizeof(avci100_720p_extradata);
4429 data = avci50_720p_extradata;
4430 size =
sizeof(avci50_720p_extradata);
4472 if (sd->
type == type) {