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;
251 static const struct {
274 "Probe with size=%d, packets=%d detected %s with score=%d\n",
277 for (i = 0; fmt_id_type[i].name; i++) {
278 if (!strcmp(fmt->
name, fmt_id_type[i].name)) {
321 "will be ignored with AVFMT_NOFILE format.\n");
346 (*plast_pktl)->next = pktl;
348 *packet_buffer = pktl;
363 if (copy.
size <= 0) {
365 "Attached picture on stream %d has invalid size, "
390 av_log(NULL,
AV_LOG_ERROR,
"Input context has not been properly allocated by avformat_alloc_context() and is not NULL either\n");
402 if ((ret =
init_input(s, filename, &tmp)) < 0)
440 if (id3v2_extra_meta) {
507 "Failed to reallocate probe buffer for stream %d\n",
520 "nothing to probe for stream %d\n", st->
index);
547 int64_t ref = pkt->
dts;
548 int i, pts_wrap_behavior;
549 int64_t pts_wrap_reference;
567 if (!first_program) {
592 program = first_program;
636 if (!pktl || ret ==
AVERROR(EAGAIN))
651 "Dropped corrupted packet (stream = %d)\n",
694 #if FF_API_READ_PACKET
751 if (frame_size <= 0 || st->codec->sample_rate <= 0)
782 #if CONFIG_H264_DECODER
813 int64_t best_score = INT64_MAX;
814 for (i = 0; i<delay; i++) {
817 if (score < best_score) {
824 for (i = 0; i<delay; i++) {
826 int64_t diff =
FFABS(pts_buffer[i] - dts)
885 pts_buffer[0] = pktl->
pkt.
pts;
886 for (i = 0; i<delay && pts_buffer[i] > pts_buffer[i + 1]; i++)
887 FFSWAP(int64_t, pts_buffer[i], pts_buffer[i + 1]);
918 av_log(s,
AV_LOG_DEBUG,
"first_dts %s not matching first dts %s (pts %s, duration %d) in the queue\n",
953 int num, den, presentation_delayed, delay, i;
968 "DTS %"PRIi64
" < %"PRIi64
" out of order\n",
994 presentation_delayed = 0;
1000 presentation_delayed = 1;
1015 if (delay == 1 && pkt->
dts == pkt->
pts &&
1018 if ( strcmp(s->
iformat->
name,
"mov,mp4,m4a,3gp,3g2,mj2")
1053 presentation_delayed = 1;
1056 "IN delayed:%d pts:%s, dts:%s cur_dts:%s st:%d pc:%p duration:%d\n",
1061 if ((delay == 0 || (delay == 1 && pc)) &&
1063 if (presentation_delayed) {
1113 av_dlog(NULL,
"OUTdelayed:%d/%d pts:%s, dts:%s cur_dts:%s\n",
1127 *pkt_buf = pktl->
next;
1131 *pkt_buf_end = NULL;
1145 int ret = 0, got_output = 0;
1156 while (size > 0 || (pkt == &
flush_pkt && got_output)) {
1161 &out_pkt.
data, &out_pkt.
size, data, size,
1170 got_output = !!out_pkt.
size;
1215 #if FF_API_DESTRUCT_PACKET
1251 *pkt_buffer = pktl->
next;
1253 *pkt_buffer_end = NULL;
1260 int ret = 0, i, got_packet = 0;
1289 cur_pkt.
pts < cur_pkt.
dts) {
1291 "Invalid timestamps stream=%d, pts=%s, dts=%s, size=%d\n",
1299 "ff_read_packet stream=%d, pts=%s, dts=%s, size=%d, duration=%d, flags=%d\n",
1309 "%s, packets or times may be invalid.\n",
1378 memcpy(dst_data, src_sd->
data, src_sd->
size);
1397 "read_frame_internal stream=%d, pts=%s, dts=%s, "
1398 "size=%d, duration=%d, flags=%d\n",
1434 int64_t last_dts = next_pkt->
dts;
1444 last_dts = pktl->
pkt.
dts;
1472 if (pktl && ret !=
AVERROR(EAGAIN)) {
1517 int best_stream = 0;
1518 int best_score = -1;
1539 if (score > best_score) {
1609 int *nb_index_entries,
1610 unsigned int *index_entries_allocated_size,
1611 int64_t pos, int64_t timestamp,
1617 if ((
unsigned) *nb_index_entries + 1 >= UINT_MAX /
sizeof(
AVIndexEntry))
1630 index_entries_allocated_size,
1631 (*nb_index_entries + 1) *
1636 *index_entries = entries;
1642 index = (*nb_index_entries)++;
1643 ie = &entries[
index];
1644 av_assert0(index == 0 || ie[-1].timestamp < timestamp);
1646 ie = &entries[
index];
1650 memmove(entries + index + 1, entries + index,
1652 (*nb_index_entries)++;
1653 }
else if (ie->
pos == pos && distance < ie->min_distance)
1673 timestamp, size, distance, flags);
1677 int64_t wanted_timestamp,
int flags)
1686 if (b && entries[b - 1].timestamp < wanted_timestamp)
1692 if (timestamp >= wanted_timestamp)
1694 if (timestamp <= wanted_timestamp)
1700 while (m >= 0 && m < nb_entries &&
1704 if (m == nb_entries)
1712 wanted_timestamp, flags);
1716 int64_t (*read_timestamp)(
struct AVFormatContext *,
int , int64_t *, int64_t ))
1718 int64_t ts = read_timestamp(s, stream_index, ppos, pos_limit);
1719 if (stream_index >= 0)
1725 int64_t target_ts,
int flags)
1729 int64_t ts_min, ts_max, ts;
1734 if (stream_index < 0)
1743 st = s->
streams[stream_index];
1751 index =
FFMAX(index, 0);
1757 av_dlog(s,
"using cached pos_min=0x%"PRIx64
" dts_min=%s\n",
1772 av_dlog(s,
"using cached pos_max=0x%"PRIx64
" pos_limit=0x%"PRIx64
1773 " dts_max=%s\n", pos_max, pos_limit,
av_ts2str(ts_max));
1777 pos =
ff_gen_search(s, stream_index, target_ts, pos_min, pos_max, pos_limit,
1793 int64_t (*read_timestamp)(
struct AVFormatContext *,
int , int64_t *, int64_t ))
1795 int64_t step = 1024;
1796 int64_t limit, ts_max;
1798 int64_t pos_max = filesize - 1;
1801 pos_max =
FFMAX(0, (pos_max) - step);
1803 &pos_max, limit, read_timestamp);
1810 int64_t tmp_pos = pos_max + 1;
1812 &tmp_pos, INT64_MAX, read_timestamp);
1818 if (tmp_pos >= filesize)
1831 int64_t pos_min, int64_t pos_max, int64_t pos_limit,
1832 int64_t ts_min, int64_t ts_max,
1833 int flags, int64_t *ts_ret,
1835 int64_t *, int64_t))
1846 ts_min =
ff_read_timestamp(s, stream_index, &pos_min, INT64_MAX, read_timestamp);
1851 if (ts_min >= target_ts) {
1857 if ((ret =
ff_find_last_ts(s, stream_index, &ts_max, &pos_max, read_timestamp)) < 0)
1859 pos_limit = pos_max;
1862 if (ts_max <= target_ts) {
1867 if (ts_min > ts_max)
1869 else if (ts_min == ts_max)
1870 pos_limit = pos_min;
1873 while (pos_min < pos_limit) {
1875 "pos_min=0x%"PRIx64
" pos_max=0x%"PRIx64
" dts_min=%s dts_max=%s\n",
1877 assert(pos_limit <= pos_max);
1879 if (no_change == 0) {
1880 int64_t approximate_keyframe_distance = pos_max - pos_limit;
1882 pos =
av_rescale(target_ts - ts_min, pos_max - pos_min,
1884 pos_min - approximate_keyframe_distance;
1885 }
else if (no_change == 1) {
1887 pos = (pos_min + pos_limit) >> 1;
1895 else if (pos > pos_limit)
1905 av_dlog(s,
"%"PRId64
" %"PRId64
" %"PRId64
" / %s %s %s"
1906 " target:%s limit:%"PRId64
" start:%"PRId64
" noc:%d\n",
1907 pos_min, pos, pos_max,
1909 pos_limit, start_pos, no_change);
1914 if (target_ts <= ts) {
1915 pos_limit = start_pos - 1;
1919 if (target_ts >= ts) {
1929 ts_min =
ff_read_timestamp(s, stream_index, &pos_min, INT64_MAX, read_timestamp);
1931 ts_max =
ff_read_timestamp(s, stream_index, &pos_min, INT64_MAX, read_timestamp);
1932 av_dlog(s,
"pos=0x%"PRIx64
" %s<=%s<=%s\n",
1940 int64_t pos,
int flags)
1942 int64_t pos_min, pos_max;
1949 else if (pos > pos_max)
1960 int64_t timestamp,
int flags)
1967 st = s->
streams[stream_index];
1971 if (index < 0 && st->nb_index_entries &&
1972 timestamp < st->index_entries[0].timestamp)
1975 if (index < 0 || index == st->nb_index_entries - 1) {
1993 }
while (read_status ==
AVERROR(EAGAIN));
1994 if (read_status < 0)
2001 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);
2024 int64_t timestamp,
int flags)
2036 if (stream_index < 0) {
2038 if (stream_index < 0)
2041 st = s->
streams[stream_index];
2068 int64_t timestamp,
int flags)
2073 int64_t min_ts = INT64_MIN, max_ts = INT64_MAX;
2079 flags & ~AVSEEK_FLAG_BACKWARD);
2091 int64_t ts, int64_t max_ts,
int flags)
2093 if (min_ts > ts || max_ts < ts)
2095 if (stream_index < -1 || stream_index >= (
int)s->
nb_streams)
2106 if (stream_index == -1 && s->
nb_streams == 1) {
2113 time_base.
num * (int64_t)AV_TIME_BASE,
2134 if (ret<0 && ts != min_ts && max_ts != ts) {
2135 ret =
av_seek_frame(s, stream_index, dir ? max_ts : min_ts, flags | dir);
2175 int64_t
start_time, start_time1, start_time_text, end_time, end_time1;
2176 int64_t
duration, duration1, filesize;
2181 start_time = INT64_MAX;
2182 start_time_text = INT64_MAX;
2183 end_time = INT64_MIN;
2184 duration = INT64_MIN;
2191 if (start_time1 < start_time_text)
2192 start_time_text = start_time1;
2194 start_time =
FFMIN(start_time, start_time1);
2197 end_time1 = start_time1 +
2200 end_time =
FFMAX(end_time, end_time1);
2212 duration =
FFMAX(duration, duration1);
2215 if (start_time == INT64_MAX || (start_time > start_time_text && start_time - start_time_text <
AV_TIME_BASE))
2216 start_time = start_time_text;
2217 else if (start_time > start_time_text)
2220 if (start_time != INT64_MAX) {
2222 if (end_time != INT64_MIN) {
2230 duration =
FFMAX(duration, end_time - start_time);
2238 double bitrate = (double) filesize * 8.0 * AV_TIME_BASE /
2240 if (bitrate >= 0 && bitrate <= INT_MAX)
2267 int i, show_warning = 0;
2307 "Estimating duration from bitrate, this may be inaccurate\n");
2310 #define DURATION_MAX_READ_SIZE 250000LL
2311 #define DURATION_MAX_RETRY 4
2318 int num, den, read_size, i,
ret;
2319 int found_duration = 0;
2333 "start time for stream %d is not set in estimate_timings_from_pts\n", i);
2346 is_end = found_duration;
2359 }
while (ret ==
AVERROR(EAGAIN));
2362 read_size += pkt->
size;
2419 av_log(ic,
AV_LOG_DEBUG,
"stream %d : no PTS found at end of file, duration not set\n", i);
2421 av_log(ic,
AV_LOG_DEBUG,
"stream %d : no TS found at start of file, duration not set\n", i);
2449 file_size =
FFMAX(0, file_size);
2475 av_dlog(ic,
"%d: start_time: %0.3f duration: %0.3f\n", i,
2480 "stream: start_time: %0.3f duration: %0.3f bitrate=%d kb/s\n",
2491 #define FAIL(errmsg) do { \
2493 *errmsg_ptr = errmsg; \
2499 FAIL(
"unknown codec");
2503 FAIL(
"unspecified frame size");
2506 FAIL(
"unspecified sample format");
2508 FAIL(
"unspecified sample rate");
2510 FAIL(
"unspecified number of channels");
2512 FAIL(
"no decodable DTS frames");
2516 FAIL(
"unspecified size");
2518 FAIL(
"unspecified pixel format");
2521 FAIL(
"no frame in rv30/40 and no sar");
2525 FAIL(
"unspecified size");
2539 int got_picture = 1,
ret = 0;
2562 av_dict_set(options ? options : &thread_opt,
"threads",
"1", 0);
2579 while ((pkt.
size > 0 || (!pkt.
data && got_picture)) &&
2588 &got_picture, &pkt);
2595 &got_picture, &pkt);
2610 if (!pkt.
data && !got_picture)
2632 if (tag == tags[i].tag)
2654 if (sflags & (1 << (bps - 1))) {
2696 for (i = 0; tags && tags[i]; i++) {
2699 if (codec_tags->
id ==
id) {
2700 *tag = codec_tags->
tag;
2712 for (i = 0; tags && tags[i]; i++) {
2737 if (j != i && next_start > ch->
start && next_start < end)
2740 ch->
end = (end == INT64_MAX) ? ch->
start : end;
2747 return (i + 1) * 1001;
2749 return ((
const int[]) { 24, 30, 60, 12, 15, 48 })[i - 60 * 12] * 1000 * 12;
2772 #if FF_API_FORMAT_PARAMETERS
2821 && ts - (uint64_t)last < INT64_MAX) {
2835 double sdts = dts*framerate/(1001*12);
2836 for (j= 0; j<2; j++) {
2837 int64_t ticks =
llrint(sdts+j*0.5);
2838 double error= sdts - ticks + j*0.5;
2855 if (error0 > 0.04 && error1 > 0.04) {
2890 double best_error= 0.01;
2904 for (k= 0; k<2; k++) {
2909 if (error < best_error && best_error> 0.000000001) {
2918 if (num && (!ref_rate.
num || (
double)num/(12*1001) < 1.01 *
av_q2d(ref_rate)))
2951 if (!max_analyze_duration)
2955 flush_codecs = probesize > 0;
2959 if (!max_analyze_duration) {
2967 av_log(ic,
AV_LOG_DEBUG,
"Before avformat_find_stream_info() pos: %"PRId64
" bytes read:%"PRId64
" seeks:%d\n",
2993 "%s, packets or times may be invalid.\n",
3001 av_dict_set(options ? &options[i] : &thread_opt,
"threads",
"1", 0);
3008 "Failed to open codec in av_find_stream_info\n");
3016 "Failed to open codec in av_find_stream_info\n");
3023 #if FF_API_R_FRAME_RATE
3041 int fps_analyze_framecount = 20;
3050 fps_analyze_framecount *= 2;
3052 fps_analyze_framecount = 0;
3056 fps_analyze_framecount = 0;
3084 if (read_size >= probesize) {
3087 "Probe buffer size limit of %"PRId64
" bytes reached\n", probesize);
3094 "Stream #%d: not enough frames to estimate rate; "
3095 "consider increasing probesize\n", i);
3117 goto find_stream_info_err;
3120 goto find_stream_info_err;
3125 read_size += pkt->
size;
3132 "Non-increasing DTS in stream %d: packet %d with DTS "
3133 "%"PRId64
", packet %d with DTS %"PRId64
"\n",
3149 "DTS discontinuity in stream %d: packet %d with DTS "
3150 "%"PRId64
", packet %d with DTS %"PRId64
"\n",
3180 if (t >= max_analyze_duration) {
3181 av_log(ic,
AV_LOG_VERBOSE,
"max_analyze_duration %"PRId64
" reached at %"PRId64
" microseconds\n",
3182 max_analyze_duration,
3191 #if FF_API_R_FRAME_RATE
3215 (options && i < orig_nb_streams) ? &options[i] : NULL);
3234 (options && i < orig_nb_streams)
3235 ? &options[i] : NULL);
3240 "decoding for stream %d failed\n", st->
index);
3269 double best_error = 0.01;
3286 if (error < best_error) {
3288 best_fps = std_fps.
num;
3293 best_fps, 12 * 1001, INT_MAX);
3344 "Could not find codec parameters for stream %d (%s): %s\n"
3345 "Consider increasing the value for the 'analyzeduration' and 'probesize' options\n",
3354 find_stream_info_err:
3364 av_log(ic,
AV_LOG_DEBUG,
"After avformat_find_stream_info() pos: %"PRId64
" bytes read:%"PRId64
" seeks:%d frames:%d\n",
3387 int wanted_stream_nb,
int related_stream,
3388 AVCodec **decoder_ret,
int flags)
3392 unsigned *program = NULL;
3395 if (related_stream >= 0 && wanted_stream_nb < 0) {
3403 int real_stream_index = program ? program[i] : i;
3408 if (wanted_stream_nb >= 0 && real_stream_index != wanted_stream_nb)
3410 if (wanted_stream_nb != real_stream_index &&
3429 if ((best_multiframe > multiframe) ||
3430 (best_multiframe == multiframe && best_bitrate > bitrate) ||
3431 (best_multiframe == multiframe && best_bitrate == bitrate && best_count >=
count))
3434 best_bitrate = bitrate;
3435 best_multiframe = multiframe;
3436 ret = real_stream_index;
3438 if (program && i == nb_streams - 1 && ret < 0) {
3446 *decoder_ret = (
AVCodec*)best_decoder;
3533 #if FF_API_CLOSE_INPUT_FILE
3568 #if FF_API_NEW_STREAM
3584 if (s->
nb_streams >= INT_MAX/
sizeof(*streams))
3629 #if FF_API_R_FRAME_RATE
3646 av_dlog(ac,
"new_program: id=0x%04x\n",
id);
3670 int64_t
start, int64_t
end,
const char *title)
3676 av_log(s,
AV_LOG_ERROR,
"Chapter end time %"PRId64
" before start %"PRId64
"\n", end, start);
3735 char *q, buf1[20],
c;
3736 int nd,
len, percentd_found;
3749 nd = nd * 10 + *p++ -
'0';
3760 snprintf(buf1,
sizeof(buf1),
"%0*d", nd, number);
3762 if ((q - buf + len) > buf_size - 1)
3764 memcpy(q, buf1, len);
3772 if ((q - buf) < buf_size - 1)
3776 if (!percentd_found)
3786 char *authorization,
int authorization_size,
3787 char *hostname,
int hostname_size,
3788 int *port_ptr,
char *path,
int path_size,
const char *url)
3790 const char *p, *ls, *ls2, *at, *at2, *col, *brk;
3796 if (authorization_size > 0)
3797 authorization[0] = 0;
3798 if (hostname_size > 0)
3804 if ((p = strchr(url,
':'))) {
3818 ls = strchr(p,
'/');
3819 ls2 = strchr(p,
'?');
3823 ls =
FFMIN(ls, ls2);
3833 while ((at = strchr(p,
'@')) && at < ls) {
3835 FFMIN(authorization_size, at + 1 - at2));
3839 if (*p ==
'[' && (brk = strchr(p,
']')) && brk < ls) {
3842 FFMIN(hostname_size, brk - p));
3843 if (brk[1] ==
':' && port_ptr)
3844 *port_ptr = atoi(brk + 2);
3845 }
else if ((col = strchr(p,
':')) && col < ls) {
3847 FFMIN(col + 1 - p, hostname_size));
3849 *port_ptr = atoi(col + 1);
3852 FFMIN(ls + 1 - p, hostname_size));
3859 static const char hex_table_uc[16] = {
'0',
'1',
'2',
'3',
3862 'C',
'D',
'E',
'F' };
3863 static const char hex_table_lc[16] = {
'0',
'1',
'2',
'3',
3866 'c',
'd',
'e',
'f' };
3867 const char *hex_table = lowercase ? hex_table_lc : hex_table_uc;
3869 for (i = 0; i <
s; i++) {
3870 buff[i * 2] = hex_table[src[i] >> 4];
3871 buff[i * 2 + 1] = hex_table[src[i] & 0xF];
3888 if (c >=
'0' && c <=
'9')
3890 else if (c >=
'A' && c <=
'F')
3905 #if FF_API_SET_PTS_INFO
3906 void av_set_pts_info(
AVStream *s,
int pts_wrap_bits,
3907 unsigned int pts_num,
unsigned int pts_den)
3914 unsigned int pts_num,
unsigned int pts_den)
3918 if (new_tb.
num != pts_num)
3920 "st:%d removing common factor %d from timebase\n",
3924 "st:%d has too large timebase, reducing\n", s->
index);
3926 if (new_tb.
num <= 0 || new_tb.
den <= 0) {
3928 "Ignoring attempt to set invalid timebase %d/%d for st:%d\n",
3941 const char *ptr = str;
3946 char *dest = NULL, *dest_end;
3947 int key_len, dest_len = 0;
3950 while (*ptr && (
av_isspace(*ptr) || *ptr ==
','))
3957 if (!(ptr = strchr(key,
'=')))
3960 key_len = ptr - key;
3962 callback_get_buf(context, key, key_len, &dest, &dest_len);
3963 dest_end = dest + dest_len - 1;
3967 while (*ptr && *ptr !=
'\"') {
3971 if (dest && dest < dest_end)
3975 if (dest && dest < dest_end)
3983 for (; *ptr && !(
av_isspace(*ptr) || *ptr ==
','); ptr++)
3984 if (dest && dest < dest_end)
4003 struct tm time1 = { 0 }, time2 = { 0 };
4018 return ofmt->
query_codec(codec_id, std_compliance);
4063 if (channel_layout) {
4071 if (width || height) {
4078 bytestream_put_le32(&data, flags);
4080 bytestream_put_le32(&data, channels);
4082 bytestream_put_le64(&data, channel_layout);
4084 bytestream_put_le32(&data, sample_rate);
4085 if (width || height) {
4086 bytestream_put_le32(&data, width);
4087 bytestream_put_le32(&data, height);
4099 av_reduce(&stream_sample_aspect_ratio.
num, &stream_sample_aspect_ratio.
den,
4100 stream_sample_aspect_ratio.
num, stream_sample_aspect_ratio.
den, INT_MAX);
4101 if (stream_sample_aspect_ratio.
num <= 0 || stream_sample_aspect_ratio.
den <= 0)
4102 stream_sample_aspect_ratio = undef;
4104 av_reduce(&frame_sample_aspect_ratio.
num, &frame_sample_aspect_ratio.
den,
4105 frame_sample_aspect_ratio.
num, frame_sample_aspect_ratio.
den, INT_MAX);
4106 if (frame_sample_aspect_ratio.
num <= 0 || frame_sample_aspect_ratio.
den <= 0)
4107 frame_sample_aspect_ratio = undef;
4109 if (stream_sample_aspect_ratio.
num)
4110 return stream_sample_aspect_ratio;
4112 return frame_sample_aspect_ratio;
4121 if (avg_fr.
num > 0 && avg_fr.
den > 0 && fr.
num > 0 && fr.
den > 0 &&
4140 if (*spec <= '9' && *spec >=
'0')
4141 return strtol(spec, NULL, 0) == st->
index;
4142 else if (*spec ==
'v' || *spec ==
'a' || *spec ==
's' || *spec ==
'd' ||
4156 if (*spec++ ==
':') {
4157 int i,
index = strtol(spec, NULL, 0);
4160 return i == st->
index;
4164 }
else if (*spec ==
'p' && *(spec + 1) ==
':') {
4168 prog_id = strtol(spec, &endptr, 0);
4173 if (*endptr++ ==
':') {
4174 int stream_idx = strtol(endptr, NULL, 0);
4175 return stream_idx >= 0 &&
4185 }
else if (*spec ==
'#' ||
4186 (*spec ==
'i' && *(spec + 1) ==
':')) {