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)
115 if (st->codec->codec)
116 return st->codec->codec;
118 switch (st->codec->codec_type) {
120 if (s->video_codec)
return s->video_codec;
123 if (s->audio_codec)
return s->audio_codec;
126 if (s->subtitle_codec)
return s->subtitle_codec;
139 #define SANE_CHUNK_SIZE (50000000)
145 if (remaining < size) {
148 s->
maxsize = newsize - !newsize;
150 remaining=
FFMAX(remaining, 0);
153 if (s->
maxsize>= 0 && remaining+1 < size) {
165 int64_t orig_pos = pkt->
pos;
166 int orig_size = pkt->
size;
170 int prev_size = pkt->
size;
188 if (ret != read_size) {
201 return pkt->
size > orig_size ? pkt->
size - orig_size :
ret;
233 int score, nodat = 0, score_max = 0;
237 lpd.
buf = zerobuffer;
261 if (score > score_max) {
264 }
else if (score == score_max)
269 *score_ret = score_max;
278 if (score_ret > *score_max) {
279 *score_max = score_ret;
294 static const struct {
317 "Probe with size=%d, packets=%d detected %s with score=%d\n",
320 for (i = 0; fmt_id_type[i].name; i++) {
321 if (!strcmp(fmt->
name, fmt_id_type[i].name)) {
351 const char *filename,
void *logctx,
352 unsigned int offset,
unsigned int max_probe_size)
357 int ret = 0, probe_size, buf_offset = 0;
366 "Specified probe size value %u cannot be < %u\n", max_probe_size,
PROBE_BUF_MIN);
370 if (offset >= max_probe_size)
381 probe_size =
FFMIN(probe_size << 1,
382 FFMAX(max_probe_size, probe_size + 1))) {
388 if ((ret =
avio_read(pb, buf + buf_offset,
389 probe_size - buf_offset)) < 0) {
399 if (buf_offset < offset)
412 "Format %s detected only with low score of %d, "
413 "misdetection possible!\n", (*fmt)->name, score);
416 "Format %s probed with size=%d and score=%d\n",
417 (*fmt)->name, probe_size, score);
419 FILE *f = fopen(
"probestat.tmp",
"ab");
420 fprintf(f,
"probe_size:%d format:%s score:%d filename:%s\n", probe_size, (*fmt)->name, score, filename);
434 return ret < 0 ? ret : score;
438 const char *filename,
void *logctx,
439 unsigned int offset,
unsigned int max_probe_size)
442 return ret < 0 ? ret : 0;
460 "will be ignored with AVFMT_NOFILE format.\n");
485 (*plast_pktl)->next = pktl;
487 *packet_buffer = pktl;
523 av_log(NULL,
AV_LOG_ERROR,
"Input context has not been properly allocated by avformat_alloc_context() and is not NULL either\n");
535 if ((ret =
init_input(s, filename, &tmp)) < 0)
573 if (id3v2_extra_meta) {
640 "Failed to reallocate probe buffer for stream %d\n",
653 "nothing to probe for stream %d\n", st->
index);
680 int64_t ref = pkt->
dts;
681 int i, pts_wrap_behavior;
682 int64_t pts_wrap_reference;
700 if (!first_program) {
725 program = first_program;
769 if (!pktl || ret ==
AVERROR(EAGAIN))
784 "Dropped corrupted packet (stream = %d)\n",
827 #if FF_API_READ_PACKET
912 if (frame_size <= 0 || st->codec->sample_rate <= 0)
943 #if CONFIG_H264_DECODER
974 int64_t best_score = INT64_MAX;
975 for (i = 0; i<delay; i++) {
978 if (score < best_score) {
985 for (i = 0; i<delay; i++) {
987 int64_t diff =
FFABS(pts_buffer[i] - dts)
1002 dts = pts_buffer[0];
1046 pts_buffer[0] = pktl->
pkt.
pts;
1047 for (i = 0; i<delay && pts_buffer[i] > pts_buffer[i + 1]; i++)
1048 FFSWAP(int64_t, pts_buffer[i], pts_buffer[i + 1]);
1079 av_log(s,
AV_LOG_DEBUG,
"first_dts %s not matching first dts %s (pts %s, duration %d) in the queue\n",
1114 int num, den, presentation_delayed, delay, i;
1129 "DTS %"PRIi64
" < %"PRIi64
" out of order\n",
1155 presentation_delayed = 0;
1161 presentation_delayed = 1;
1176 if (delay == 1 && pkt->
dts == pkt->
pts &&
1179 if ( strcmp(s->
iformat->
name,
"mov,mp4,m4a,3gp,3g2,mj2")
1214 presentation_delayed = 1;
1217 "IN delayed:%d pts:%s, dts:%s cur_dts:%s st:%d pc:%p duration:%d\n",
1222 if ((delay == 0 || (delay == 1 && pc)) &&
1224 if (presentation_delayed) {
1274 av_dlog(NULL,
"OUTdelayed:%d/%d pts:%s, dts:%s cur_dts:%s\n",
1288 *pkt_buf = pktl->
next;
1292 *pkt_buf_end = NULL;
1306 int ret = 0, got_output = 0;
1317 while (size > 0 || (pkt == &
flush_pkt && got_output)) {
1322 &out_pkt.
data, &out_pkt.
size, data, size,
1331 got_output = !!out_pkt.
size;
1382 #if FF_API_DESTRUCT_PACKET
1418 *pkt_buffer = pktl->
next;
1420 *pkt_buffer_end = NULL;
1427 int ret = 0, i, got_packet = 0;
1455 cur_pkt.
pts < cur_pkt.
dts) {
1457 "Invalid timestamps stream=%d, pts=%s, dts=%s, size=%d\n",
1465 "ff_read_packet stream=%d, pts=%s, dts=%s, size=%d, duration=%d, flags=%d\n",
1475 "%s, packets or times may be invalid.\n",
1536 "read_frame_internal stream=%d, pts=%s, dts=%s, "
1537 "size=%d, duration=%d, flags=%d\n",
1573 int64_t last_dts = next_pkt->
dts;
1583 last_dts = pktl->
pkt.
dts;
1610 if (pktl && ret !=
AVERROR(EAGAIN)) {
1653 int first_audio_index = -1;
1665 if (first_audio_index < 0 &&
1667 first_audio_index = i;
1669 return first_audio_index >= 0 ? first_audio_index : 0;
1731 int *nb_index_entries,
1732 unsigned int *index_entries_allocated_size,
1733 int64_t pos, int64_t timestamp,
1739 if ((
unsigned) *nb_index_entries + 1 >= UINT_MAX /
sizeof(
AVIndexEntry))
1752 index_entries_allocated_size,
1753 (*nb_index_entries + 1) *
1758 *index_entries = entries;
1764 index = (*nb_index_entries)++;
1765 ie = &entries[
index];
1766 av_assert0(index == 0 || ie[-1].timestamp < timestamp);
1768 ie = &entries[
index];
1772 memmove(entries + index + 1, entries + index,
1774 (*nb_index_entries)++;
1775 }
else if (ie->
pos == pos && distance < ie->min_distance)
1795 timestamp, size, distance, flags);
1799 int64_t wanted_timestamp,
int flags)
1808 if (b && entries[b - 1].timestamp < wanted_timestamp)
1814 if (timestamp >= wanted_timestamp)
1816 if (timestamp <= wanted_timestamp)
1822 while (m >= 0 && m < nb_entries &&
1826 if (m == nb_entries)
1834 wanted_timestamp, flags);
1838 int64_t (*read_timestamp)(
struct AVFormatContext *,
int , int64_t *, int64_t ))
1840 int64_t ts = read_timestamp(s, stream_index, ppos, pos_limit);
1841 if (stream_index >= 0)
1847 int64_t target_ts,
int flags)
1851 int64_t ts_min, ts_max, ts;
1856 if (stream_index < 0)
1865 st = s->
streams[stream_index];
1873 index =
FFMAX(index, 0);
1879 av_dlog(s,
"using cached pos_min=0x%"PRIx64
" dts_min=%s\n",
1894 av_dlog(s,
"using cached pos_max=0x%"PRIx64
" pos_limit=0x%"PRIx64
1895 " dts_max=%s\n", pos_max, pos_limit,
av_ts2str(ts_max));
1899 pos =
ff_gen_search(s, stream_index, target_ts, pos_min, pos_max, pos_limit,
1915 int64_t (*read_timestamp)(
struct AVFormatContext *,
int , int64_t *, int64_t ))
1917 int64_t step = 1024;
1918 int64_t limit, ts_max;
1920 int64_t pos_max = filesize - 1;
1923 pos_max =
FFMAX(0, (pos_max) - step);
1925 &pos_max, limit, read_timestamp);
1932 int64_t tmp_pos = pos_max + 1;
1934 &tmp_pos, INT64_MAX, read_timestamp);
1940 if (tmp_pos >= filesize)
1953 int64_t pos_min, int64_t pos_max, int64_t pos_limit,
1954 int64_t ts_min, int64_t ts_max,
1955 int flags, int64_t *ts_ret,
1957 int64_t *, int64_t))
1968 ts_min =
ff_read_timestamp(s, stream_index, &pos_min, INT64_MAX, read_timestamp);
1973 if (ts_min >= target_ts) {
1979 if ((ret =
ff_find_last_ts(s, stream_index, &ts_max, &pos_max, read_timestamp)) < 0)
1981 pos_limit = pos_max;
1984 if (ts_max <= target_ts) {
1989 if (ts_min > ts_max)
1991 else if (ts_min == ts_max)
1992 pos_limit = pos_min;
1995 while (pos_min < pos_limit) {
1997 "pos_min=0x%"PRIx64
" pos_max=0x%"PRIx64
" dts_min=%s dts_max=%s\n",
1999 assert(pos_limit <= pos_max);
2001 if (no_change == 0) {
2002 int64_t approximate_keyframe_distance = pos_max - pos_limit;
2004 pos =
av_rescale(target_ts - ts_min, pos_max - pos_min,
2006 pos_min - approximate_keyframe_distance;
2007 }
else if (no_change == 1) {
2009 pos = (pos_min + pos_limit) >> 1;
2017 else if (pos > pos_limit)
2027 av_dlog(s,
"%"PRId64
" %"PRId64
" %"PRId64
" / %s %s %s"
2028 " target:%s limit:%"PRId64
" start:%"PRId64
" noc:%d\n",
2029 pos_min, pos, pos_max,
2031 pos_limit, start_pos, no_change);
2037 if (target_ts <= ts) {
2038 pos_limit = start_pos - 1;
2042 if (target_ts >= ts) {
2052 ts_min =
ff_read_timestamp(s, stream_index, &pos_min, INT64_MAX, read_timestamp);
2054 ts_max =
ff_read_timestamp(s, stream_index, &pos_min, INT64_MAX, read_timestamp);
2055 av_dlog(s,
"pos=0x%"PRIx64
" %s<=%s<=%s\n",
2063 int64_t pos,
int flags)
2065 int64_t pos_min, pos_max;
2072 else if (pos > pos_max)
2083 int64_t timestamp,
int flags)
2090 st = s->
streams[stream_index];
2094 if (index < 0 && st->nb_index_entries &&
2095 timestamp < st->index_entries[0].timestamp)
2098 if (index < 0 || index == st->nb_index_entries - 1) {
2116 }
while (read_status ==
AVERROR(EAGAIN));
2117 if (read_status < 0)
2124 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);
2147 int64_t timestamp,
int flags)
2159 if (stream_index < 0) {
2161 if (stream_index < 0)
2164 st = s->
streams[stream_index];
2191 int64_t timestamp,
int flags)
2196 int64_t min_ts = INT64_MIN, max_ts = INT64_MAX;
2202 flags & ~AVSEEK_FLAG_BACKWARD);
2214 int64_t ts, int64_t max_ts,
int flags)
2216 if (min_ts > ts || max_ts < ts)
2218 if (stream_index < -1 || stream_index >= (
int)s->
nb_streams)
2229 if (stream_index == -1 && s->
nb_streams == 1) {
2236 time_base.
num * (int64_t)AV_TIME_BASE,
2257 if (ret<0 && ts != min_ts && max_ts != ts) {
2258 ret =
av_seek_frame(s, stream_index, dir ? max_ts : min_ts, flags | dir);
2298 int64_t
start_time, start_time1, start_time_text, end_time, end_time1;
2299 int64_t
duration, duration1, filesize;
2304 start_time = INT64_MAX;
2305 start_time_text = INT64_MAX;
2306 end_time = INT64_MIN;
2307 duration = INT64_MIN;
2314 if (start_time1 < start_time_text)
2315 start_time_text = start_time1;
2317 start_time =
FFMIN(start_time, start_time1);
2320 end_time1 = start_time1 +
2323 end_time =
FFMAX(end_time, end_time1);
2335 duration =
FFMAX(duration, duration1);
2338 if (start_time == INT64_MAX || (start_time > start_time_text && start_time - start_time_text <
AV_TIME_BASE))
2339 start_time = start_time_text;
2340 else if (start_time > start_time_text)
2343 if (start_time != INT64_MAX) {
2345 if (end_time != INT64_MIN) {
2353 duration =
FFMAX(duration, end_time - start_time);
2361 double bitrate = (double) filesize * 8.0 * AV_TIME_BASE /
2363 if (bitrate >= 0 && bitrate <= INT_MAX)
2390 int i, show_warning = 0;
2429 "Estimating duration from bitrate, this may be inaccurate\n");
2432 #define DURATION_MAX_READ_SIZE 250000LL
2433 #define DURATION_MAX_RETRY 4
2440 int read_size, i,
ret;
2454 "start time is not set in estimate_timings_from_pts\n");
2479 }
while (ret ==
AVERROR(EAGAIN));
2482 read_size += pkt->
size;
2487 duration = end_time = pkt->
pts;
2529 file_size =
FFMAX(0, file_size);
2555 av_dlog(ic,
"%d: start_time: %0.3f duration: %0.3f\n", i,
2560 "stream: start_time: %0.3f duration: %0.3f bitrate=%d kb/s\n",
2571 #define FAIL(errmsg) do { \
2573 *errmsg_ptr = errmsg; \
2580 FAIL(
"unspecified frame size");
2583 FAIL(
"unspecified sample format");
2585 FAIL(
"unspecified sample rate");
2587 FAIL(
"unspecified number of channels");
2589 FAIL(
"no decodable DTS frames");
2593 FAIL(
"unspecified size");
2595 FAIL(
"unspecified pixel format");
2598 FAIL(
"no frame in rv30/40 and no sar");
2602 FAIL(
"unspecified size");
2609 FAIL(
"unknown codec");
2618 int got_picture = 1,
ret = 0;
2639 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;
2826 return ((
const int[]) { 24, 30, 60, 12, 15, 48 })[i - 60 * 12] * 1000 * 12;
2848 #if FF_API_FORMAT_PARAMETERS
2897 && ts - (uint64_t)last < INT64_MAX) {
2911 double sdts = dts*framerate/(1001*12);
2912 for (j= 0; j<2; j++) {
2913 int64_t ticks =
llrint(sdts+j*0.5);
2914 double error= sdts - ticks + j*0.5;
2931 if (error0 > 0.04 && error1 > 0.04) {
2966 double best_error= 0.01;
2979 for (k= 0; k<2; k++) {
2984 if (error < best_error && best_error> 0.000000001) {
3016 av_log(ic,
AV_LOG_DEBUG,
"Before avformat_find_stream_info() pos: %"PRId64
" bytes read:%"PRId64
" seeks:%d\n",
3042 "%s, packets or times may be invalid.\n",
3050 av_dict_set(options ? &options[i] : &thread_opt,
"threads",
"1", 0);
3057 "Failed to open codec in av_find_stream_info\n");
3065 "Failed to open codec in av_find_stream_info\n");
3072 #if FF_API_R_FRAME_RATE
3090 int fps_analyze_framecount = 20;
3099 fps_analyze_framecount *= 2;
3103 fps_analyze_framecount = 0;
3133 "Probe buffer size limit of %d bytes reached\n", ic->
probesize);
3140 "Stream #%d: not enough frames to estimate rate; "
3141 "consider increasing probesize\n", i);
3163 goto find_stream_info_err;
3166 goto find_stream_info_err;
3171 read_size += pkt->
size;
3178 "Non-increasing DTS in stream %d: packet %d with DTS "
3179 "%"PRId64
", packet %d with DTS %"PRId64
"\n",
3195 "DTS discontinuity in stream %d: packet %d with DTS "
3196 "%"PRId64
", packet %d with DTS %"PRId64
"\n",
3234 #if FF_API_R_FRAME_RATE
3257 (options && i < orig_nb_streams) ? &options[i] : NULL);
3276 (options && i < orig_nb_streams)
3277 ? &options[i] : NULL);
3282 "decoding for stream %d failed\n", st->
index);
3310 double best_error = 0.01;
3327 if (error < best_error) {
3329 best_fps = std_fps.
num;
3334 best_fps, 12 * 1001, INT_MAX);
3385 "Could not find codec parameters for stream %d (%s): %s\n"
3386 "Consider increasing the value for the 'analyzeduration' and 'probesize' options\n",
3395 find_stream_info_err:
3405 av_log(ic,
AV_LOG_DEBUG,
"After avformat_find_stream_info() pos: %"PRId64
" bytes read:%"PRId64
" seeks:%d frames:%d\n",
3428 int wanted_stream_nb,
int related_stream,
3429 AVCodec **decoder_ret,
int flags)
3433 unsigned *program = NULL;
3436 if (related_stream >= 0 && wanted_stream_nb < 0) {
3443 for (i = 0; i < nb_streams; i++) {
3444 int real_stream_index = program ? program[i] : i;
3449 if (wanted_stream_nb >= 0 && real_stream_index != wanted_stream_nb)
3451 if (wanted_stream_nb != real_stream_index &&
3468 if ((best_multiframe > multiframe) ||
3469 (best_multiframe == multiframe && best_bitrate > bitrate) ||
3470 (best_multiframe == multiframe && best_bitrate == bitrate && best_count >=
count))
3473 best_bitrate = bitrate;
3474 best_multiframe = multiframe;
3475 ret = real_stream_index;
3477 if (program && i == nb_streams - 1 && ret < 0) {
3485 *decoder_ret = best_decoder;
3563 #if FF_API_CLOSE_INPUT_FILE
3598 #if FF_API_NEW_STREAM
3614 if (s->
nb_streams >= INT_MAX/
sizeof(*streams))
3656 #if FF_API_R_FRAME_RATE
3671 av_dlog(ac,
"new_program: id=0x%04x\n",
id);
3695 int64_t
start, int64_t
end,
const char *title)
3752 else if (v % (100 * 1000))
3765 if (strcmp(
"language", tag->
key)) {
3766 const char *p = tag->
value;
3768 "%s %-16s: ", indent, tag->
key);
3771 size_t len = strcspn(p,
"\x8\xa\xb\xc\xd");
3786 int index,
int is_output)
3813 display_aspect_ratio.
num, display_aspect_ratio.
den);
3818 #if FF_API_R_FRAME_RATE
3852 const char *url,
int is_output)
3860 is_output ?
"Output" :
"Input",
3863 is_output ?
"to" :
"from", url);
3868 int hours, mins, secs, us;
3907 int j, k, total = 0;
3912 name ? name->
value :
"");
3921 if (total < ic->nb_streams)
3939 char *q, buf1[20],
c;
3940 int nd,
len, percentd_found;
3953 nd = nd * 10 + *p++ -
'0';
3964 snprintf(buf1,
sizeof(buf1),
"%0*d", nd, number);
3966 if ((q - buf + len) > buf_size - 1)
3968 memcpy(q, buf1, len);
3976 if ((q - buf) < buf_size - 1)
3980 if (!percentd_found)
3989 #define HEXDUMP_PRINT(...) \
3992 av_log(avcl, level, __VA_ARGS__); \
3994 fprintf(f, __VA_ARGS__); \
4002 for (i = 0; i <
size; i += 16) {
4007 for (j = 0; j < 16; j++) {
4014 for (j = 0; j <
len; j++) {
4016 if (c < ' ' || c >
'~')
4070 char *authorization,
int authorization_size,
4071 char *hostname,
int hostname_size,
4072 int *port_ptr,
char *path,
int path_size,
const char *url)
4074 const char *p, *ls, *ls2, *at, *at2, *col, *brk;
4080 if (authorization_size > 0)
4081 authorization[0] = 0;
4082 if (hostname_size > 0)
4088 if ((p = strchr(url,
':'))) {
4102 ls = strchr(p,
'/');
4103 ls2 = strchr(p,
'?');
4107 ls =
FFMIN(ls, ls2);
4117 while ((at = strchr(p,
'@')) && at < ls) {
4119 FFMIN(authorization_size, at + 1 - at2));
4123 if (*p ==
'[' && (brk = strchr(p,
']')) && brk < ls) {
4126 FFMIN(hostname_size, brk - p));
4127 if (brk[1] ==
':' && port_ptr)
4128 *port_ptr = atoi(brk + 2);
4129 }
else if ((col = strchr(p,
':')) && col < ls) {
4131 FFMIN(col + 1 - p, hostname_size));
4133 *port_ptr = atoi(col + 1);
4136 FFMIN(ls + 1 - p, hostname_size));
4143 static const char hex_table_uc[16] = {
'0',
'1',
'2',
'3',
4146 'C',
'D',
'E',
'F' };
4147 static const char hex_table_lc[16] = {
'0',
'1',
'2',
'3',
4150 'c',
'd',
'e',
'f' };
4151 const char *hex_table = lowercase ? hex_table_lc : hex_table_uc;
4153 for (i = 0; i <
s; i++) {
4154 buff[i * 2] = hex_table[src[i] >> 4];
4155 buff[i * 2 + 1] = hex_table[src[i] & 0xF];
4172 if (c >=
'0' && c <=
'9')
4174 else if (c >=
'A' && c <=
'F')
4189 #if FF_API_SET_PTS_INFO
4190 void av_set_pts_info(
AVStream *s,
int pts_wrap_bits,
4191 unsigned int pts_num,
unsigned int pts_den)
4198 unsigned int pts_num,
unsigned int pts_den)
4202 if (new_tb.
num != pts_num)
4204 "st:%d removing common factor %d from timebase\n",
4208 "st:%d has too large timebase, reducing\n", s->
index);
4210 if (new_tb.
num <= 0 || new_tb.
den <= 0) {
4212 "Ignoring attempt to set invalid timebase %d/%d for st:%d\n",
4225 const char *ptr = str;
4230 char *dest = NULL, *dest_end;
4231 int key_len, dest_len = 0;
4234 while (*ptr && (
av_isspace(*ptr) || *ptr ==
','))
4241 if (!(ptr = strchr(key,
'=')))
4244 key_len = ptr - key;
4246 callback_get_buf(context, key, key_len, &dest, &dest_len);
4247 dest_end = dest + dest_len - 1;
4251 while (*ptr && *ptr !=
'\"') {
4255 if (dest && dest < dest_end)
4259 if (dest && dest < dest_end)
4267 for (; *ptr && !(
av_isspace(*ptr) || *ptr ==
','); ptr++)
4268 if (dest && dest < dest_end)
4287 struct tm time1 = { 0 }, time2 = { 0 };
4302 return ofmt->
query_codec(codec_id, std_compliance);
4347 if (channel_layout) {
4355 if (width || height) {
4362 bytestream_put_le32(&data, flags);
4364 bytestream_put_le32(&data, channels);
4366 bytestream_put_le64(&data, channel_layout);
4368 bytestream_put_le32(&data, sample_rate);
4369 if (width || height) {
4370 bytestream_put_le32(&data, width);
4371 bytestream_put_le32(&data, height);
4383 av_reduce(&stream_sample_aspect_ratio.
num, &stream_sample_aspect_ratio.
den,
4384 stream_sample_aspect_ratio.
num, stream_sample_aspect_ratio.
den, INT_MAX);
4385 if (stream_sample_aspect_ratio.
num <= 0 || stream_sample_aspect_ratio.
den <= 0)
4386 stream_sample_aspect_ratio = undef;
4388 av_reduce(&frame_sample_aspect_ratio.
num, &frame_sample_aspect_ratio.
den,
4389 frame_sample_aspect_ratio.
num, frame_sample_aspect_ratio.
den, INT_MAX);
4390 if (frame_sample_aspect_ratio.
num <= 0 || frame_sample_aspect_ratio.
den <= 0)
4391 frame_sample_aspect_ratio = undef;
4393 if (stream_sample_aspect_ratio.
num)
4394 return stream_sample_aspect_ratio;
4396 return frame_sample_aspect_ratio;
4405 if (avg_fr.
num > 0 && avg_fr.
den > 0 && fr.
num > 0 && fr.
den > 0 &&
4424 if (*spec <= '9' && *spec >=
'0')
4425 return strtol(spec, NULL, 0) == st->
index;
4426 else if (*spec ==
'v' || *spec ==
'a' || *spec ==
's' || *spec ==
'd' ||
4440 if (*spec++ ==
':') {
4441 int i,
index = strtol(spec, NULL, 0);
4444 return i == st->
index;
4448 }
else if (*spec ==
'p' && *(spec + 1) ==
':') {
4452 prog_id = strtol(spec, &endptr, 0);
4457 if (*endptr++ ==
':') {
4458 int stream_idx = strtol(endptr, NULL, 0);
4459 return stream_idx >= 0 &&
4469 }
else if (*spec ==
'#') {
4472 sid = strtol(spec + 1, &endptr, 0);
4474 return st->
id == sid;
4484 static const uint8_t avci100_1080p_extradata[] = {
4486 0x00, 0x00, 0x00, 0x01, 0x67, 0x7a, 0x10, 0x29,
4487 0xb6, 0xd4, 0x20, 0x22, 0x33, 0x19, 0xc6, 0x63,
4488 0x23, 0x21, 0x01, 0x11, 0x98, 0xce, 0x33, 0x19,
4489 0x18, 0x21, 0x02, 0x56, 0xb9, 0x3d, 0x7d, 0x7e,
4490 0x4f, 0xe3, 0x3f, 0x11, 0xf1, 0x9e, 0x08, 0xb8,
4491 0x8c, 0x54, 0x43, 0xc0, 0x78, 0x02, 0x27, 0xe2,
4492 0x70, 0x1e, 0x30, 0x10, 0x10, 0x14, 0x00, 0x00,
4493 0x03, 0x00, 0x04, 0x00, 0x00, 0x03, 0x00, 0xca,
4494 0x10, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
4496 0x00, 0x00, 0x00, 0x01, 0x68, 0xce, 0x33, 0x48,
4499 static const uint8_t avci100_1080i_extradata[] = {
4501 0x00, 0x00, 0x00, 0x01, 0x67, 0x7a, 0x10, 0x29,
4502 0xb6, 0xd4, 0x20, 0x22, 0x33, 0x19, 0xc6, 0x63,
4503 0x23, 0x21, 0x01, 0x11, 0x98, 0xce, 0x33, 0x19,
4504 0x18, 0x21, 0x03, 0x3a, 0x46, 0x65, 0x6a, 0x65,
4505 0x24, 0xad, 0xe9, 0x12, 0x32, 0x14, 0x1a, 0x26,
4506 0x34, 0xad, 0xa4, 0x41, 0x82, 0x23, 0x01, 0x50,
4507 0x2b, 0x1a, 0x24, 0x69, 0x48, 0x30, 0x40, 0x2e,
4508 0x11, 0x12, 0x08, 0xc6, 0x8c, 0x04, 0x41, 0x28,
4509 0x4c, 0x34, 0xf0, 0x1e, 0x01, 0x13, 0xf2, 0xe0,
4510 0x3c, 0x60, 0x20, 0x20, 0x28, 0x00, 0x00, 0x03,
4511 0x00, 0x08, 0x00, 0x00, 0x03, 0x01, 0x94, 0x00,
4513 0x00, 0x00, 0x00, 0x01, 0x68, 0xce, 0x33, 0x48,
4516 static const uint8_t avci50_1080i_extradata[] = {
4518 0x00, 0x00, 0x00, 0x01, 0x67, 0x6e, 0x10, 0x28,
4519 0xa6, 0xd4, 0x20, 0x32, 0x33, 0x0c, 0x71, 0x18,
4520 0x88, 0x62, 0x10, 0x19, 0x19, 0x86, 0x38, 0x8c,
4521 0x44, 0x30, 0x21, 0x02, 0x56, 0x4e, 0x6e, 0x61,
4522 0x87, 0x3e, 0x73, 0x4d, 0x98, 0x0c, 0x03, 0x06,
4523 0x9c, 0x0b, 0x73, 0xe6, 0xc0, 0xb5, 0x18, 0x63,
4524 0x0d, 0x39, 0xe0, 0x5b, 0x02, 0xd4, 0xc6, 0x19,
4525 0x1a, 0x79, 0x8c, 0x32, 0x34, 0x24, 0xf0, 0x16,
4526 0x81, 0x13, 0xf7, 0xff, 0x80, 0x02, 0x00, 0x01,
4527 0xf1, 0x80, 0x80, 0x80, 0xa0, 0x00, 0x00, 0x03,
4528 0x00, 0x20, 0x00, 0x00, 0x06, 0x50, 0x80, 0x00,
4530 0x00, 0x00, 0x00, 0x01, 0x68, 0xee, 0x31, 0x12,
4533 static const uint8_t avci100_720p_extradata[] = {
4535 0x00, 0x00, 0x00, 0x01, 0x67, 0x7a, 0x10, 0x29,
4536 0xb6, 0xd4, 0x20, 0x2a, 0x33, 0x1d, 0xc7, 0x62,
4537 0xa1, 0x08, 0x40, 0x54, 0x66, 0x3b, 0x8e, 0xc5,
4538 0x42, 0x02, 0x10, 0x25, 0x64, 0x2c, 0x89, 0xe8,
4539 0x85, 0xe4, 0x21, 0x4b, 0x90, 0x83, 0x06, 0x95,
4540 0xd1, 0x06, 0x46, 0x97, 0x20, 0xc8, 0xd7, 0x43,
4541 0x08, 0x11, 0xc2, 0x1e, 0x4c, 0x91, 0x0f, 0x01,
4542 0x40, 0x16, 0xec, 0x07, 0x8c, 0x04, 0x04, 0x05,
4543 0x00, 0x00, 0x03, 0x00, 0x01, 0x00, 0x00, 0x03,
4544 0x00, 0x64, 0x84, 0x00, 0x00, 0x00, 0x00, 0x00,
4546 0x00, 0x00, 0x00, 0x01, 0x68, 0xce, 0x31, 0x12,
4555 data = avci100_1080p_extradata;
4556 size =
sizeof(avci100_1080p_extradata);
4558 data = avci100_1080i_extradata;
4559 size =
sizeof(avci100_1080i_extradata);
4562 data = avci50_1080i_extradata;
4563 size =
sizeof(avci50_1080i_extradata);
4565 data = avci100_720p_extradata;
4566 size =
sizeof(avci100_720p_extradata);