69 return FFMPEG_CONFIGURATION;
74 #define LICENSE_PREFIX "libavformat license: "
78 #define RELATIVE_TS_BASE (INT64_MAX - (1LL<<48))
96 timestamp < st->pts_wrap_reference)
108 MAKE_ACCESSORS(AVFormatContext, format, AVCodec *, subtitle_codec)
109 MAKE_ACCESSORS(AVFormatContext, format,
int, metadata_header_padding)
159 #define SANE_CHUNK_SIZE (50000000)
165 if (remaining < size) {
168 s->
maxsize = newsize - !newsize;
170 remaining=
FFMAX(remaining, 0);
173 if (s->
maxsize>= 0 && remaining+1 < size) {
185 int64_t orig_pos = pkt->
pos;
186 int orig_size = pkt->
size;
190 int prev_size = pkt->
size;
208 if (ret != read_size) {
221 return pkt->
size > orig_size ? pkt->
size - orig_size :
ret;
253 int score, nodat = 0, score_max = 0;
257 lpd.
buf = zerobuffer;
278 if (nodat == 0) score =
FFMAX(score, 1);
286 if (score > score_max) {
289 }
else if (score == score_max)
294 *score_ret = score_max;
303 if (score_ret > *score_max) {
304 *score_max = score_ret;
319 static const struct {
342 "Probe with size=%d, packets=%d detected %s with score=%d\n",
345 for (i = 0; fmt_id_type[i].name; i++) {
346 if (!strcmp(fmt->
name, fmt_id_type[i].name)) {
376 const char *filename,
void *logctx,
377 unsigned int offset,
unsigned int max_probe_size)
382 int ret = 0, probe_size, buf_offset = 0;
389 "Specified probe size value %u cannot be < %u\n", max_probe_size,
PROBE_BUF_MIN);
393 if (offset >= max_probe_size)
404 probe_size =
FFMIN(probe_size << 1,
405 FFMAX(max_probe_size, probe_size + 1))) {
411 if ((ret =
avio_read(pb, buf + buf_offset,
412 probe_size - buf_offset)) < 0) {
422 if (buf_offset < offset)
435 "Format %s detected only with low score of %d, "
436 "misdetection possible!\n", (*fmt)->name, score);
439 "Format %s probed with size=%d and score=%d\n",
440 (*fmt)->name, probe_size, score);
442 FILE *f = fopen(
"probestat.tmp",
"ab");
443 fprintf(f,
"probe_size:%d format:%s score:%d filename:%s\n", probe_size, (*fmt)->name, score, filename);
457 return ret < 0 ? ret : score;
461 const char *filename,
void *logctx,
462 unsigned int offset,
unsigned int max_probe_size)
465 return ret < 0 ? ret : 0;
483 "will be ignored with AVFMT_NOFILE format.\n");
508 (*plast_pktl)->next = pktl;
510 *packet_buffer = pktl;
525 if (copy.
size <= 0) {
527 "Attached picture on stream %d has invalid size, "
552 av_log(NULL,
AV_LOG_ERROR,
"Input context has not been properly allocated by avformat_alloc_context() and is not NULL either\n");
564 if ((ret =
init_input(s, filename, &tmp)) < 0)
602 if (id3v2_extra_meta) {
669 "Failed to reallocate probe buffer for stream %d\n",
682 "nothing to probe for stream %d\n", st->
index);
709 int64_t ref = pkt->
dts;
710 int i, pts_wrap_behavior;
711 int64_t pts_wrap_reference;
729 if (!first_program) {
754 program = first_program;
798 if (!pktl || ret ==
AVERROR(EAGAIN))
813 "Dropped corrupted packet (stream = %d)\n",
856 #if FF_API_READ_PACKET
941 if (frame_size <= 0 || st->codec->sample_rate <= 0)
972 #if CONFIG_H264_DECODER
1003 int64_t best_score = INT64_MAX;
1004 for (i = 0; i<delay; i++) {
1007 if (score < best_score) {
1009 dts = pts_buffer[i];
1014 for (i = 0; i<delay; i++) {
1016 int64_t diff =
FFABS(pts_buffer[i] - dts)
1031 dts = pts_buffer[0];
1075 pts_buffer[0] = pktl->
pkt.
pts;
1076 for (i = 0; i<delay && pts_buffer[i] > pts_buffer[i + 1]; i++)
1077 FFSWAP(int64_t, pts_buffer[i], pts_buffer[i + 1]);
1108 av_log(s,
AV_LOG_DEBUG,
"first_dts %s not matching first dts %s (pts %s, duration %d) in the queue\n",
1143 int num, den, presentation_delayed, delay, i;
1158 "DTS %"PRIi64
" < %"PRIi64
" out of order\n",
1184 presentation_delayed = 0;
1190 presentation_delayed = 1;
1205 if (delay == 1 && pkt->
dts == pkt->
pts &&
1208 if ( strcmp(s->
iformat->
name,
"mov,mp4,m4a,3gp,3g2,mj2")
1243 presentation_delayed = 1;
1246 "IN delayed:%d pts:%s, dts:%s cur_dts:%s st:%d pc:%p duration:%d\n",
1251 if ((delay == 0 || (delay == 1 && pc)) &&
1253 if (presentation_delayed) {
1303 av_dlog(NULL,
"OUTdelayed:%d/%d pts:%s, dts:%s cur_dts:%s\n",
1317 *pkt_buf = pktl->
next;
1321 *pkt_buf_end = NULL;
1335 int ret = 0, got_output = 0;
1346 while (size > 0 || (pkt == &
flush_pkt && got_output)) {
1351 &out_pkt.
data, &out_pkt.
size, data, size,
1360 got_output = !!out_pkt.
size;
1405 #if FF_API_DESTRUCT_PACKET
1441 *pkt_buffer = pktl->
next;
1443 *pkt_buffer_end = NULL;
1450 int ret = 0, i, got_packet = 0;
1478 cur_pkt.
pts < cur_pkt.
dts) {
1480 "Invalid timestamps stream=%d, pts=%s, dts=%s, size=%d\n",
1488 "ff_read_packet stream=%d, pts=%s, dts=%s, size=%d, duration=%d, flags=%d\n",
1498 "%s, packets or times may be invalid.\n",
1567 memcpy(dst_data, src_sd->
data, src_sd->
size);
1578 "read_frame_internal stream=%d, pts=%s, dts=%s, "
1579 "size=%d, duration=%d, flags=%d\n",
1615 int64_t last_dts = next_pkt->
dts;
1625 last_dts = pktl->
pkt.
dts;
1653 if (pktl && ret !=
AVERROR(EAGAIN)) {
1696 int first_audio_index = -1;
1708 if (first_audio_index < 0 &&
1710 first_audio_index = i;
1712 return first_audio_index >= 0 ? first_audio_index : 0;
1777 int *nb_index_entries,
1778 unsigned int *index_entries_allocated_size,
1779 int64_t pos, int64_t timestamp,
1785 if ((
unsigned) *nb_index_entries + 1 >= UINT_MAX /
sizeof(
AVIndexEntry))
1798 index_entries_allocated_size,
1799 (*nb_index_entries + 1) *
1804 *index_entries = entries;
1810 index = (*nb_index_entries)++;
1811 ie = &entries[
index];
1812 av_assert0(index == 0 || ie[-1].timestamp < timestamp);
1814 ie = &entries[
index];
1818 memmove(entries + index + 1, entries + index,
1820 (*nb_index_entries)++;
1821 }
else if (ie->
pos == pos && distance < ie->min_distance)
1841 timestamp, size, distance, flags);
1845 int64_t wanted_timestamp,
int flags)
1854 if (b && entries[b - 1].timestamp < wanted_timestamp)
1860 if (timestamp >= wanted_timestamp)
1862 if (timestamp <= wanted_timestamp)
1868 while (m >= 0 && m < nb_entries &&
1872 if (m == nb_entries)
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);
1925 av_dlog(s,
"using cached pos_min=0x%"PRIx64
" dts_min=%s\n",
1940 av_dlog(s,
"using cached pos_max=0x%"PRIx64
" pos_limit=0x%"PRIx64
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,
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) {
2035 if (ts_min > ts_max)
2037 else if (ts_min == ts_max)
2038 pos_limit = pos_min;
2041 while (pos_min < pos_limit) {
2043 "pos_min=0x%"PRIx64
" pos_max=0x%"PRIx64
" dts_min=%s dts_max=%s\n",
2045 assert(pos_limit <= pos_max);
2047 if (no_change == 0) {
2048 int64_t approximate_keyframe_distance = pos_max - pos_limit;
2050 pos =
av_rescale(target_ts - ts_min, pos_max - pos_min,
2052 pos_min - approximate_keyframe_distance;
2053 }
else if (no_change == 1) {
2055 pos = (pos_min + pos_limit) >> 1;
2063 else if (pos > pos_limit)
2073 av_dlog(s,
"%"PRId64
" %"PRId64
" %"PRId64
" / %s %s %s"
2074 " target:%s limit:%"PRId64
" start:%"PRId64
" noc:%d\n",
2075 pos_min, pos, pos_max,
2077 pos_limit, start_pos, no_change);
2083 if (target_ts <= ts) {
2084 pos_limit = start_pos - 1;
2088 if (target_ts >= ts) {
2098 ts_min =
ff_read_timestamp(s, stream_index, &pos_min, INT64_MAX, read_timestamp);
2100 ts_max =
ff_read_timestamp(s, stream_index, &pos_min, INT64_MAX, read_timestamp);
2101 av_dlog(s,
"pos=0x%"PRIx64
" %s<=%s<=%s\n",
2109 int64_t pos,
int flags)
2111 int64_t pos_min, pos_max;
2118 else if (pos > pos_max)
2129 int64_t timestamp,
int flags)
2136 st = s->
streams[stream_index];
2140 if (index < 0 && st->nb_index_entries &&
2141 timestamp < st->index_entries[0].timestamp)
2144 if (index < 0 || index == st->nb_index_entries - 1) {
2162 }
while (read_status ==
AVERROR(EAGAIN));
2163 if (read_status < 0)
2170 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);
2193 int64_t timestamp,
int flags)
2205 if (stream_index < 0) {
2207 if (stream_index < 0)
2210 st = s->
streams[stream_index];
2237 int64_t timestamp,
int flags)
2242 int64_t min_ts = INT64_MIN, max_ts = INT64_MAX;
2248 flags & ~AVSEEK_FLAG_BACKWARD);
2260 int64_t ts, int64_t max_ts,
int flags)
2262 if (min_ts > ts || max_ts < ts)
2264 if (stream_index < -1 || stream_index >= (
int)s->
nb_streams)
2275 if (stream_index == -1 && s->
nb_streams == 1) {
2282 time_base.
num * (int64_t)AV_TIME_BASE,
2303 if (ret<0 && ts != min_ts && max_ts != ts) {
2304 ret =
av_seek_frame(s, stream_index, dir ? max_ts : min_ts, flags | dir);
2344 int64_t
start_time, start_time1, start_time_text, end_time, end_time1;
2345 int64_t
duration, duration1, filesize;
2350 start_time = INT64_MAX;
2351 start_time_text = INT64_MAX;
2352 end_time = INT64_MIN;
2353 duration = INT64_MIN;
2360 if (start_time1 < start_time_text)
2361 start_time_text = start_time1;
2363 start_time =
FFMIN(start_time, start_time1);
2366 end_time1 = start_time1 +
2369 end_time =
FFMAX(end_time, end_time1);
2381 duration =
FFMAX(duration, duration1);
2384 if (start_time == INT64_MAX || (start_time > start_time_text && start_time - start_time_text <
AV_TIME_BASE))
2385 start_time = start_time_text;
2386 else if (start_time > start_time_text)
2389 if (start_time != INT64_MAX) {
2391 if (end_time != INT64_MIN) {
2399 duration =
FFMAX(duration, end_time - start_time);
2407 double bitrate = (double) filesize * 8.0 * AV_TIME_BASE /
2409 if (bitrate >= 0 && bitrate <= INT_MAX)
2436 int i, show_warning = 0;
2475 "Estimating duration from bitrate, this may be inaccurate\n");
2478 #define DURATION_MAX_READ_SIZE 250000LL
2479 #define DURATION_MAX_RETRY 4
2486 int num, den, read_size, i,
ret;
2487 int found_duration = 0;
2501 "start time for stream %d is not set in estimate_timings_from_pts\n", i);
2514 is_end = found_duration;
2527 }
while (ret ==
AVERROR(EAGAIN));
2530 read_size += pkt->
size;
2587 av_log(ic,
AV_LOG_DEBUG,
"stream %d : no PTS found at end of file, duration not set\n", i);
2589 av_log(ic,
AV_LOG_DEBUG,
"stream %d : no TS found at start of file, duration not set\n", i);
2617 file_size =
FFMAX(0, file_size);
2643 av_dlog(ic,
"%d: start_time: %0.3f duration: %0.3f\n", i,
2648 "stream: start_time: %0.3f duration: %0.3f bitrate=%d kb/s\n",
2659 #define FAIL(errmsg) do { \
2661 *errmsg_ptr = errmsg; \
2667 FAIL(
"unknown codec");
2671 FAIL(
"unspecified frame size");
2674 FAIL(
"unspecified sample format");
2676 FAIL(
"unspecified sample rate");
2678 FAIL(
"unspecified number of channels");
2680 FAIL(
"no decodable DTS frames");
2684 FAIL(
"unspecified size");
2686 FAIL(
"unspecified pixel format");
2689 FAIL(
"no frame in rv30/40 and no sar");
2693 FAIL(
"unspecified size");
2707 int got_picture = 1,
ret = 0;
2730 av_dict_set(options ? options : &thread_opt,
"threads",
"1", 0);
2747 while ((pkt.
size > 0 || (!pkt.
data && got_picture)) &&
2756 &got_picture, &pkt);
2763 &got_picture, &pkt);
2778 if (!pkt.
data && !got_picture)
2800 if (tag == tags[i].tag)
2822 if (sflags & (1 << (bps - 1))) {
2864 for (i = 0; tags && tags[i]; i++) {
2867 if (codec_tags->
id ==
id) {
2868 *tag = codec_tags->
tag;
2880 for (i = 0; tags && tags[i]; i++) {
2905 if (j != i && next_start > ch->
start && next_start < end)
2908 ch->
end = (end == INT64_MAX) ? ch->
start : end;
2915 return (i + 1) * 1001;
2917 return ((
const int[]) { 24, 30, 60, 12, 15, 48 })[i - 60 * 12] * 1000 * 12;
2940 #if FF_API_FORMAT_PARAMETERS
2989 && ts - (uint64_t)last < INT64_MAX) {
3003 double sdts = dts*framerate/(1001*12);
3004 for (j= 0; j<2; j++) {
3005 int64_t ticks =
llrint(sdts+j*0.5);
3006 double error= sdts - ticks + j*0.5;
3023 if (error0 > 0.04 && error1 > 0.04) {
3058 double best_error= 0.01;
3072 for (k= 0; k<2; k++) {
3077 if (error < best_error && best_error> 0.000000001) {
3086 if (num && (!ref_rate.
num || (
double)num/(12*1001) < 1.01 *
av_q2d(ref_rate)))
3117 if (!max_analyze_duration)
3122 if (!max_analyze_duration) {
3130 av_log(ic,
AV_LOG_DEBUG,
"Before avformat_find_stream_info() pos: %"PRId64
" bytes read:%"PRId64
" seeks:%d\n",
3156 "%s, packets or times may be invalid.\n",
3164 av_dict_set(options ? &options[i] : &thread_opt,
"threads",
"1", 0);
3171 "Failed to open codec in av_find_stream_info\n");
3179 "Failed to open codec in av_find_stream_info\n");
3186 #if FF_API_R_FRAME_RATE
3204 int fps_analyze_framecount = 20;
3213 fps_analyze_framecount *= 2;
3215 fps_analyze_framecount = 0;
3219 fps_analyze_framecount = 0;
3249 "Probe buffer size limit of %d bytes reached\n", ic->
probesize);
3256 "Stream #%d: not enough frames to estimate rate; "
3257 "consider increasing probesize\n", i);
3279 goto find_stream_info_err;
3282 goto find_stream_info_err;
3287 read_size += pkt->
size;
3294 "Non-increasing DTS in stream %d: packet %d with DTS "
3295 "%"PRId64
", packet %d with DTS %"PRId64
"\n",
3311 "DTS discontinuity in stream %d: packet %d with DTS "
3312 "%"PRId64
", packet %d with DTS %"PRId64
"\n",
3342 if (t >= max_analyze_duration) {
3343 av_log(ic,
AV_LOG_VERBOSE,
"max_analyze_duration %"PRId64
" reached at %"PRId64
" microseconds\n",
3344 max_analyze_duration,
3353 #if FF_API_R_FRAME_RATE
3377 (options && i < orig_nb_streams) ? &options[i] : NULL);
3396 (options && i < orig_nb_streams)
3397 ? &options[i] : NULL);
3402 "decoding for stream %d failed\n", st->
index);
3431 double best_error = 0.01;
3448 if (error < best_error) {
3450 best_fps = std_fps.
num;
3455 best_fps, 12 * 1001, INT_MAX);
3506 "Could not find codec parameters for stream %d (%s): %s\n"
3507 "Consider increasing the value for the 'analyzeduration' and 'probesize' options\n",
3516 find_stream_info_err:
3526 av_log(ic,
AV_LOG_DEBUG,
"After avformat_find_stream_info() pos: %"PRId64
" bytes read:%"PRId64
" seeks:%d frames:%d\n",
3549 int wanted_stream_nb,
int related_stream,
3550 AVCodec **decoder_ret,
int flags)
3554 unsigned *program = NULL;
3557 if (related_stream >= 0 && wanted_stream_nb < 0) {
3565 int real_stream_index = program ? program[i] : i;
3570 if (wanted_stream_nb >= 0 && real_stream_index != wanted_stream_nb)
3572 if (wanted_stream_nb != real_stream_index &&
3591 if ((best_multiframe > multiframe) ||
3592 (best_multiframe == multiframe && best_bitrate > bitrate) ||
3593 (best_multiframe == multiframe && best_bitrate == bitrate && best_count >=
count))
3596 best_bitrate = bitrate;
3597 best_multiframe = multiframe;
3598 ret = real_stream_index;
3600 if (program && i == nb_streams - 1 && ret < 0) {
3608 *decoder_ret = (
AVCodec*)best_decoder;
3694 #if FF_API_CLOSE_INPUT_FILE
3729 #if FF_API_NEW_STREAM
3745 if (s->
nb_streams >= INT_MAX/
sizeof(*streams))
3790 #if FF_API_R_FRAME_RATE
3807 av_dlog(ac,
"new_program: id=0x%04x\n",
id);
3831 int64_t
start, int64_t
end,
const char *title)
3837 av_log(s,
AV_LOG_ERROR,
"Chapter end time %"PRId64
" before start %"PRId64
"\n", end, start);
3896 char *q, buf1[20],
c;
3897 int nd,
len, percentd_found;
3910 nd = nd * 10 + *p++ -
'0';
3921 snprintf(buf1,
sizeof(buf1),
"%0*d", nd, number);
3923 if ((q - buf + len) > buf_size - 1)
3925 memcpy(q, buf1, len);
3933 if ((q - buf) < buf_size - 1)
3937 if (!percentd_found)
3947 char *authorization,
int authorization_size,
3948 char *hostname,
int hostname_size,
3949 int *port_ptr,
char *path,
int path_size,
const char *url)
3951 const char *p, *ls, *ls2, *at, *at2, *col, *brk;
3957 if (authorization_size > 0)
3958 authorization[0] = 0;
3959 if (hostname_size > 0)
3965 if ((p = strchr(url,
':'))) {
3979 ls = strchr(p,
'/');
3980 ls2 = strchr(p,
'?');
3984 ls =
FFMIN(ls, ls2);
3994 while ((at = strchr(p,
'@')) && at < ls) {
3996 FFMIN(authorization_size, at + 1 - at2));
4000 if (*p ==
'[' && (brk = strchr(p,
']')) && brk < ls) {
4003 FFMIN(hostname_size, brk - p));
4004 if (brk[1] ==
':' && port_ptr)
4005 *port_ptr = atoi(brk + 2);
4006 }
else if ((col = strchr(p,
':')) && col < ls) {
4008 FFMIN(col + 1 - p, hostname_size));
4010 *port_ptr = atoi(col + 1);
4013 FFMIN(ls + 1 - p, hostname_size));
4020 static const char hex_table_uc[16] = {
'0',
'1',
'2',
'3',
4023 'C',
'D',
'E',
'F' };
4024 static const char hex_table_lc[16] = {
'0',
'1',
'2',
'3',
4027 'c',
'd',
'e',
'f' };
4028 const char *hex_table = lowercase ? hex_table_lc : hex_table_uc;
4030 for (i = 0; i <
s; i++) {
4031 buff[i * 2] = hex_table[src[i] >> 4];
4032 buff[i * 2 + 1] = hex_table[src[i] & 0xF];
4049 if (c >=
'0' && c <=
'9')
4051 else if (c >=
'A' && c <=
'F')
4066 #if FF_API_SET_PTS_INFO
4067 void av_set_pts_info(
AVStream *s,
int pts_wrap_bits,
4068 unsigned int pts_num,
unsigned int pts_den)
4075 unsigned int pts_num,
unsigned int pts_den)
4079 if (new_tb.
num != pts_num)
4081 "st:%d removing common factor %d from timebase\n",
4085 "st:%d has too large timebase, reducing\n", s->
index);
4087 if (new_tb.
num <= 0 || new_tb.
den <= 0) {
4089 "Ignoring attempt to set invalid timebase %d/%d for st:%d\n",
4102 const char *ptr = str;
4107 char *dest = NULL, *dest_end;
4108 int key_len, dest_len = 0;
4111 while (*ptr && (
av_isspace(*ptr) || *ptr ==
','))
4118 if (!(ptr = strchr(key,
'=')))
4121 key_len = ptr - key;
4123 callback_get_buf(context, key, key_len, &dest, &dest_len);
4124 dest_end = dest + dest_len - 1;
4128 while (*ptr && *ptr !=
'\"') {
4132 if (dest && dest < dest_end)
4136 if (dest && dest < dest_end)
4144 for (; *ptr && !(
av_isspace(*ptr) || *ptr ==
','); ptr++)
4145 if (dest && dest < dest_end)
4164 struct tm time1 = { 0 }, time2 = { 0 };
4179 return ofmt->
query_codec(codec_id, std_compliance);
4224 if (channel_layout) {
4232 if (width || height) {
4239 bytestream_put_le32(&data, flags);
4241 bytestream_put_le32(&data, channels);
4243 bytestream_put_le64(&data, channel_layout);
4245 bytestream_put_le32(&data, sample_rate);
4246 if (width || height) {
4247 bytestream_put_le32(&data, width);
4248 bytestream_put_le32(&data, height);
4260 av_reduce(&stream_sample_aspect_ratio.
num, &stream_sample_aspect_ratio.
den,
4261 stream_sample_aspect_ratio.
num, stream_sample_aspect_ratio.
den, INT_MAX);
4262 if (stream_sample_aspect_ratio.
num <= 0 || stream_sample_aspect_ratio.
den <= 0)
4263 stream_sample_aspect_ratio = undef;
4265 av_reduce(&frame_sample_aspect_ratio.
num, &frame_sample_aspect_ratio.
den,
4266 frame_sample_aspect_ratio.
num, frame_sample_aspect_ratio.
den, INT_MAX);
4267 if (frame_sample_aspect_ratio.
num <= 0 || frame_sample_aspect_ratio.
den <= 0)
4268 frame_sample_aspect_ratio = undef;
4270 if (stream_sample_aspect_ratio.
num)
4271 return stream_sample_aspect_ratio;
4273 return frame_sample_aspect_ratio;
4282 if (avg_fr.
num > 0 && avg_fr.
den > 0 && fr.
num > 0 && fr.
den > 0 &&
4301 if (*spec <= '9' && *spec >=
'0')
4302 return strtol(spec, NULL, 0) == st->
index;
4303 else if (*spec ==
'v' || *spec ==
'a' || *spec ==
's' || *spec ==
'd' ||
4317 if (*spec++ ==
':') {
4318 int i,
index = strtol(spec, NULL, 0);
4321 return i == st->
index;
4325 }
else if (*spec ==
'p' && *(spec + 1) ==
':') {
4329 prog_id = strtol(spec, &endptr, 0);
4334 if (*endptr++ ==
':') {
4335 int stream_idx = strtol(endptr, NULL, 0);
4336 return stream_idx >= 0 &&
4346 }
else if (*spec ==
'#' ||
4347 (*spec ==
'i' && *(spec + 1) ==
':')) {
4350 spec += 1 + (*spec ==
'i');
4351 stream_id = strtol(spec, &endptr, 0);
4353 return stream_id == st->
id;
4363 static const uint8_t avci100_1080p_extradata[] = {
4365 0x00, 0x00, 0x00, 0x01, 0x67, 0x7a, 0x10, 0x29,
4366 0xb6, 0xd4, 0x20, 0x22, 0x33, 0x19, 0xc6, 0x63,
4367 0x23, 0x21, 0x01, 0x11, 0x98, 0xce, 0x33, 0x19,
4368 0x18, 0x21, 0x02, 0x56, 0xb9, 0x3d, 0x7d, 0x7e,
4369 0x4f, 0xe3, 0x3f, 0x11, 0xf1, 0x9e, 0x08, 0xb8,
4370 0x8c, 0x54, 0x43, 0xc0, 0x78, 0x02, 0x27, 0xe2,
4371 0x70, 0x1e, 0x30, 0x10, 0x10, 0x14, 0x00, 0x00,
4372 0x03, 0x00, 0x04, 0x00, 0x00, 0x03, 0x00, 0xca,
4373 0x10, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
4375 0x00, 0x00, 0x00, 0x01, 0x68, 0xce, 0x33, 0x48,
4378 static const uint8_t avci100_1080i_extradata[] = {
4380 0x00, 0x00, 0x00, 0x01, 0x67, 0x7a, 0x10, 0x29,
4381 0xb6, 0xd4, 0x20, 0x22, 0x33, 0x19, 0xc6, 0x63,
4382 0x23, 0x21, 0x01, 0x11, 0x98, 0xce, 0x33, 0x19,
4383 0x18, 0x21, 0x03, 0x3a, 0x46, 0x65, 0x6a, 0x65,
4384 0x24, 0xad, 0xe9, 0x12, 0x32, 0x14, 0x1a, 0x26,
4385 0x34, 0xad, 0xa4, 0x41, 0x82, 0x23, 0x01, 0x50,
4386 0x2b, 0x1a, 0x24, 0x69, 0x48, 0x30, 0x40, 0x2e,
4387 0x11, 0x12, 0x08, 0xc6, 0x8c, 0x04, 0x41, 0x28,
4388 0x4c, 0x34, 0xf0, 0x1e, 0x01, 0x13, 0xf2, 0xe0,
4389 0x3c, 0x60, 0x20, 0x20, 0x28, 0x00, 0x00, 0x03,
4390 0x00, 0x08, 0x00, 0x00, 0x03, 0x01, 0x94, 0x00,
4392 0x00, 0x00, 0x00, 0x01, 0x68, 0xce, 0x33, 0x48,
4395 static const uint8_t avci50_1080i_extradata[] = {
4397 0x00, 0x00, 0x00, 0x01, 0x67, 0x6e, 0x10, 0x28,
4398 0xa6, 0xd4, 0x20, 0x32, 0x33, 0x0c, 0x71, 0x18,
4399 0x88, 0x62, 0x10, 0x19, 0x19, 0x86, 0x38, 0x8c,
4400 0x44, 0x30, 0x21, 0x02, 0x56, 0x4e, 0x6e, 0x61,
4401 0x87, 0x3e, 0x73, 0x4d, 0x98, 0x0c, 0x03, 0x06,
4402 0x9c, 0x0b, 0x73, 0xe6, 0xc0, 0xb5, 0x18, 0x63,
4403 0x0d, 0x39, 0xe0, 0x5b, 0x02, 0xd4, 0xc6, 0x19,
4404 0x1a, 0x79, 0x8c, 0x32, 0x34, 0x24, 0xf0, 0x16,
4405 0x81, 0x13, 0xf7, 0xff, 0x80, 0x02, 0x00, 0x01,
4406 0xf1, 0x80, 0x80, 0x80, 0xa0, 0x00, 0x00, 0x03,
4407 0x00, 0x20, 0x00, 0x00, 0x06, 0x50, 0x80, 0x00,
4409 0x00, 0x00, 0x00, 0x01, 0x68, 0xee, 0x31, 0x12,
4412 static const uint8_t avci100_720p_extradata[] = {
4414 0x00, 0x00, 0x00, 0x01, 0x67, 0x7a, 0x10, 0x29,
4415 0xb6, 0xd4, 0x20, 0x2a, 0x33, 0x1d, 0xc7, 0x62,
4416 0xa1, 0x08, 0x40, 0x54, 0x66, 0x3b, 0x8e, 0xc5,
4417 0x42, 0x02, 0x10, 0x25, 0x64, 0x2c, 0x89, 0xe8,
4418 0x85, 0xe4, 0x21, 0x4b, 0x90, 0x83, 0x06, 0x95,
4419 0xd1, 0x06, 0x46, 0x97, 0x20, 0xc8, 0xd7, 0x43,
4420 0x08, 0x11, 0xc2, 0x1e, 0x4c, 0x91, 0x0f, 0x01,
4421 0x40, 0x16, 0xec, 0x07, 0x8c, 0x04, 0x04, 0x05,
4422 0x00, 0x00, 0x03, 0x00, 0x01, 0x00, 0x00, 0x03,
4423 0x00, 0x64, 0x84, 0x00, 0x00, 0x00, 0x00, 0x00,
4425 0x00, 0x00, 0x00, 0x01, 0x68, 0xce, 0x31, 0x12,
4434 data = avci100_1080p_extradata;
4435 size =
sizeof(avci100_1080p_extradata);
4437 data = avci100_1080i_extradata;
4438 size =
sizeof(avci100_1080i_extradata);
4441 data = avci50_1080i_extradata;
4442 size =
sizeof(avci50_1080i_extradata);
4444 data = avci100_720p_extradata;
4445 size =
sizeof(avci100_720p_extradata);