72 #define EBML_UNKNOWN_LENGTH UINT64_MAX
73 #define NEEDS_CHECKING 2
77 #define SKIP_THRESHOLD 1024 * 1024
80 #define UNKNOWN_EQUIV 50 * 1024
136 typedef struct Ebml {
412 #define CHILD_OF(parent) { .def = { .n = parent } }
803 uint32_t
id, int64_t position)
832 "Seek to desired resync point failed. Seeking to "
833 "earliest point available instead.\n");
835 last_pos + 1), SEEK_SET);
871 int max_size, uint64_t *number,
int eof_forbidden)
885 if (!total || read > max_size) {
889 "0x00 at pos %"PRId64
" (0x%"PRIx64
") invalid as first byte "
890 "of an EBML number\n",
pos,
pos);
893 "Length %d indicated by an EBML number's first byte 0x%02x "
894 "at pos %"PRId64
" (0x%"PRIx64
") exceeds max length %d.\n",
903 total = (total << 8) |
avio_r8(pb);
918 "Read error at pos. %"PRIu64
" (0x%"PRIx64
")\n",
924 "at pos. %"PRIu64
" (0x%"PRIx64
")\n",
pos,
pos);
939 if (res > 0 && *number + 1 == 1ULL << (7 * res))
949 uint64_t default_value, uint64_t *num)
954 *num = default_value;
960 *num = (*num << 8) |
avio_r8(pb);
970 int64_t default_value, int64_t *num)
975 *num = default_value;
982 *num = ((uint64_t)*num << 8) |
avio_r8(pb);
993 double default_value,
double *num)
996 *num = default_value;
998 }
else if (
size == 4) {
1000 }
else if (
size == 8) {
1013 const char *default_value,
char **
str)
1018 if (
size == 0 && default_value) {
1072 uint64_t length, int64_t
pos)
1084 level->length = length;
1104 *num = unum - ((1LL << (7 * res - 1)) - 1);
1118 for (
i = 0; syntax[
i].
id;
i++)
1119 if (
id == syntax[
i].
id)
1131 for (
int i = 0; syntax[
i].
id;
i++) {
1132 void *dst = (
char *)
data + syntax[
i].data_offset;
1133 switch (syntax[
i].
type) {
1135 *(uint64_t *)dst = syntax[
i].def.
u;
1138 *(int64_t *) dst = syntax[
i].
def.
i;
1141 *(
double *) dst = syntax[
i].def.
f;
1146 if (syntax[
i].def.
s) {
1174 return id && (
bits + 7) / 8 == (8 -
bits % 8);
1182 uint32_t
id, int64_t
pos)
1254 "at pos. %"PRIu64
" (0x%"PRIx64
")\n",
pos,
pos);
1261 pos_alt =
pos + res;
1274 while (syntax->
def.
n) {
1284 "%"PRId64
"\n",
id,
pos);
1297 &
list->alloc_elem_size,
1301 list->elem = newelem;
1318 uint64_t elem_end = pos_alt + length,
1321 if (elem_end < level_end) {
1323 }
else if (elem_end == level_end) {
1327 "Element at 0x%"PRIx64
" ending at 0x%"PRIx64
" exceeds "
1328 "containing master element ending at 0x%"PRIx64
"\n",
1329 pos, elem_end, level_end);
1336 "at 0x%"PRIx64
" inside parent with finite size\n",
pos);
1346 "Found unknown-length element 0x%"PRIX32
" other than "
1347 "a cluster at 0x%"PRIx64
". Spec-incompliant, but "
1348 "parsing will nevertheless be attempted.\n",
id,
pos);
1355 if (max_lengths[syntax->
type] && length > max_lengths[syntax->
type]) {
1358 "Invalid length 0x%"PRIx64
" > 0x%"PRIx64
" for element "
1359 "with ID 0x%"PRIX32
" at 0x%"PRIx64
"\n",
1360 length, max_lengths[syntax->
type],
id,
pos);
1363 "Element with ID 0x%"PRIX32
" at pos. 0x%"PRIx64
" has "
1364 "unknown length, yet the length of an element of its "
1365 "type must be known.\n",
id,
pos);
1368 "Found unknown-length element with ID 0x%"PRIX32
" at "
1369 "pos. 0x%"PRIx64
" for which no syntax for parsing is "
1370 "available.\n",
id,
pos);
1407 "Unknown element %"PRIX32
" at pos. 0x%"PRIx64
" with "
1408 "length 0x%"PRIx64
" considered as invalid data. Last "
1409 "known good position 0x%"PRIx64
", %d unknown elements"
1428 switch (syntax->
type) {
1455 if (!level1_elem->
pos) {
1458 }
else if (level1_elem->
pos !=
pos)
1476 if ((res2 =
avio_skip(pb, length - 1)) >= 0) {
1515 if (elem->
count != UINT_MAX)
1537 for (
i = 0; syntax[
i].
id;
i++) {
1538 void *data_off = (
char *)
data + syntax[
i].data_offset;
1539 switch (syntax[
i].
type) {
1549 if (syntax[
i].list_elem_size) {
1551 char *ptr =
list->elem;
1552 for (j = 0; j <
list->nb_elem;
1557 list->alloc_elem_size = 0;
1572 int len_mask = 0x80,
size = 1, n = 1,
i;
1580 while (
size <= 8 && !(total & len_mask)) {
1586 total &= (len_mask - 1);
1588 total = (total << 8) | p->
buf[4 + n++];
1590 if (total + 1 == 1ULL << (7 *
size)){
1605 if (total < probelen)
1607 for (n = 4 +
size; n <= 4 +
size + total - probelen; n++)
1623 if (tracks[
i].num == num)
1635 int isize = *buf_size;
1638 int pkt_size = isize;
1642 if (pkt_size >= 10000000
U)
1645 switch (encodings[0].compression.algo) {
1651 if (header_size && !
header) {
1659 pkt_size = isize + header_size;
1664 memcpy(pkt_data,
header, header_size);
1665 memcpy(pkt_data + header_size,
data, isize);
1672 olen = pkt_size *= 3;
1679 pkt_data = newpktdata;
1692 z_stream zstream = { 0 };
1693 if (!pkt_size || inflateInit(&zstream) != Z_OK)
1695 zstream.next_in =
data;
1696 zstream.avail_in = isize;
1701 inflateEnd(&zstream);
1705 pkt_data = newpktdata;
1706 zstream.avail_out = pkt_size - zstream.total_out;
1707 zstream.next_out = pkt_data + zstream.total_out;
1709 }
while (
result == Z_OK && pkt_size < 10000000);
1710 pkt_size = zstream.total_out;
1711 inflateEnd(&zstream);
1712 if (
result != Z_STREAM_END) {
1713 if (
result == Z_MEM_ERROR)
1725 bz_stream bzstream = { 0 };
1726 if (!pkt_size || BZ2_bzDecompressInit(&bzstream, 0, 0) != BZ_OK)
1728 bzstream.next_in =
data;
1729 bzstream.avail_in = isize;
1734 BZ2_bzDecompressEnd(&bzstream);
1738 pkt_data = newpktdata;
1739 bzstream.avail_out = pkt_size - bzstream.total_out_lo32;
1740 bzstream.next_out = pkt_data + bzstream.total_out_lo32;
1741 result = BZ2_bzDecompress(&bzstream);
1742 }
while (
result == BZ_OK && pkt_size < 10000000);
1743 pkt_size = bzstream.total_out_lo32;
1744 BZ2_bzDecompressEnd(&bzstream);
1745 if (
result != BZ_STREAM_END) {
1746 if (
result == BZ_MEM_ERROR)
1762 *buf_size = pkt_size;
1777 for (
i = 0;
i <
list->nb_elem;
i++) {
1778 const char *lang = tags[
i].
lang &&
1779 strcmp(tags[
i].lang,
"und") ? tags[
i].
lang :
NULL;
1781 if (!tags[
i].
name) {
1789 if (tags[
i].def || !lang) {
1791 if (tags[
i].
sub.nb_elem)
1798 if (tags[
i].
sub.nb_elem)
1812 if (tags[
i].target.attachuid) {
1816 if (attachment[j].
uid == tags[
i].target.attachuid &&
1817 attachment[j].stream) {
1819 &attachment[j].stream->metadata,
NULL);
1825 "The tags at index %d refer to a "
1826 "non-existent attachment %"PRId64
".\n",
1827 i, tags[
i].target.attachuid);
1829 }
else if (tags[
i].target.chapteruid) {
1833 if (chapter[j].
uid == tags[
i].target.chapteruid &&
1834 chapter[j].chapter) {
1836 &chapter[j].chapter->metadata,
NULL);
1842 "The tags at index %d refer to a non-existent chapter "
1844 i, tags[
i].target.chapteruid);
1846 }
else if (tags[
i].target.trackuid) {
1850 if (track[j].
uid == tags[
i].target.trackuid &&
1853 &track[j].stream->metadata,
NULL);
1859 "The tags at index %d refer to a non-existent track "
1861 i, tags[
i].target.trackuid);
1865 tags[
i].target.type);
1884 "Max EBML element depth (%d) reached, "
1917 for (
i = 0;
i < seekhead_list->
nb_elem;
i++) {
1919 uint32_t
id = seekheads[
i].
id;
1927 if (!elem || elem->
parsed)
1950 uint64_t index_scale = 1;
1956 index_list = &matroska->
index;
1967 for (j = 0; j < pos_list->
nb_elem; j++) {
1970 if (track && track->
stream)
2000 static const char *
const aac_profiles[] = {
"MAIN",
"LC",
"SSR" };
2046 int block_last, block_type, block_size;
2052 if (block_size >
size)
2061 chmask =
av_dict_get(dict,
"WAVEFORMATEXTENSIBLE_CHANNEL_MASK",
NULL, 0);
2066 "Invalid value of WAVEFORMATEXTENSIBLE_CHANNEL_MASK\n");
2082 int minor, micro, bttb = 0;
2087 bttb = (
minor >= 36 && minor <= 51 && micro >= 100);
2089 switch (field_order) {
2108 int *h_width,
int *h_height)
2110 switch (stereo_mode) {
2135 int has_mastering_primaries, has_mastering_luminance;
2140 mastering_meta = &
color->mastering_meta;
2142 has_mastering_primaries =
2143 mastering_meta->
r_x > 0 && mastering_meta->
r_y > 0 &&
2144 mastering_meta->
g_x > 0 && mastering_meta->
g_y > 0 &&
2145 mastering_meta->
b_x > 0 && mastering_meta->
b_y > 0 &&
2169 (
color->chroma_siting_vert - 1) << 7);
2187 if (has_mastering_primaries || has_mastering_luminance) {
2196 if (has_mastering_primaries) {
2207 if (has_mastering_luminance) {
2223 size_t spherical_size;
2224 uint32_t l = 0, t = 0,
r = 0,
b = 0;
2225 uint32_t padding = 0;
2228 if (mkv_projection->
private.
size && priv_data[0] != 0) {
2241 if (
b >= UINT_MAX - t ||
r >= UINT_MAX - l) {
2243 "Invalid bounding rectangle coordinates "
2244 "%"PRIu32
",%"PRIu32
",%"PRIu32
",%"PRIu32
"\n",
2253 if (l || t ||
r ||
b)
2266 "Unknown spherical cubemap layout %"PRIu32
"\n",
layout);
2270 padding =
AV_RB32(priv_data + 8);
2281 "Unknown spherical metadata type %"PRIu64
"\n",
2355 int extradata_size = 0;
2356 int extradata_offset = 0;
2359 char* key_id_base64 =
NULL;
2368 "Unknown or unsupported track type %"PRIu64
"\n",
2387 "Invalid sample rate %f, defaulting to 8000 instead.\n",
2395 if (default_duration > UINT64_MAX || default_duration < 0) {
2397 "Invalid frame rate %e. Cannot calculate default duration.\n",
2413 if (encodings_list->
nb_elem > 1) {
2415 "Multiple combined encodings not supported");
2416 }
else if (encodings_list->
nb_elem == 1) {
2417 if (encodings[0].
type) {
2418 if (encodings[0].encryption.key_id.size > 0) {
2421 const int b64_size =
AV_BASE64_SIZE(encodings[0].encryption.key_id.size);
2423 if (key_id_base64 ==
NULL)
2427 encodings[0].encryption.key_id.data,
2428 encodings[0].encryption.key_id.size);
2430 encodings[0].
scope = 0;
2432 "Unsupported encoding type");
2445 encodings[0].
scope = 0;
2447 "Unsupported encoding type");
2457 "Failed to decode codec private data\n");
2476 encodings[0].
scope & 1 &&
2494 if (key_id_base64) {
2500 if (!strcmp(track->
codec_id,
"V_MS/VFW/FOURCC") &&
2511 extradata_offset = 40;
2512 }
else if (!strcmp(track->
codec_id,
"A_MS/ACM") &&
2525 }
else if (!strcmp(track->
codec_id,
"A_QUICKTIME")
2529 uint16_t sample_size;
2535 if (sample_size == 8) {
2538 }
else if (sample_size == 16) {
2547 }
else if (!strcmp(track->
codec_id,
"V_QUICKTIME") &&
2603 extradata[0] = (
profile << 3) | ((sri & 0x0E) >> 1);
2604 extradata[1] = ((sri & 0x01) << 7) | (track->
audio.
channels << 3);
2605 if (strstr(track->
codec_id,
"SBR")) {
2607 extradata[2] = 0x56;
2608 extradata[3] = 0xE5;
2609 extradata[4] = 0x80 | (sri << 3);
2622 AV_WB32(extradata, extradata_size);
2623 memcpy(&extradata[4],
"alac", 4);
2632 "Too large audio channel number %"PRIu64
2633 " or bitdepth %"PRIu64
". Skipping track.\n",
2642 extradata_size = 22;
2647 bytestream_put_be32(&ptr,
AV_RB32(
"TTA1"));
2648 bytestream_put_le16(&ptr, 1);
2659 extradata_offset = 26;
2693 static const int sipr_bit_rate[4] = { 6504, 8496, 5000, 16000 };
2702 extradata_offset = 78;
2714 "in absence of valid CodecPrivate.\n");
2729 extradata_offset = 4;
2735 "Unknown/unsupported AVCodecID %s.\n", track->
codec_id);
2739 "Track TimestampScale too small %f, assuming 1.0.\n",
2744 1000 * 1000 * 1000);
2753 if (strcmp(track->
language,
"und"))
2786 int display_width_mul = 1;
2787 int display_height_mul = 1;
2818 #if FF_API_R_FRAME_RATE
2838 snprintf(buf,
sizeof(buf),
"%s_%d",
2841 if (
planes[j].
uid == tracks[k].
uid && tracks[k].stream) {
2843 "stereo_mode", buf, 0);
2877 (
AVRational){1, st->codecpar->codec_id == AV_CODEC_ID_OPUS ?
2878 48000 : st->codecpar->sample_rate});
2888 if (!strcmp(track->
codec_id,
"D_WEBVTT/CAPTIONS")) {
2890 }
else if (!strcmp(track->
codec_id,
"D_WEBVTT/DESCRIPTIONS")) {
2892 }
else if (!strcmp(track->
codec_id,
"D_WEBVTT/METADATA")) {
2913 uint64_t max_start = 0;
2928 ebml.
max_size >
sizeof(uint64_t) ||
2932 "EBML version %"PRIu64
", doctype %s, doc version %"PRIu64,
2938 "EBML header using unsupported features\n"
2939 "(EBML version %"PRIu64
", doctype %s, doc version %"PRIu64
")\n",
2993 attachments = attachments_list->
elem;
2994 for (j = 0; j < attachments_list->
nb_elem; j++) {
2995 if (!(attachments[j].filename && attachments[j].mime &&
2996 attachments[j].bin.data && attachments[j].bin.size > 0)) {
3015 attachments[j].
stream = st;
3035 attachments[j].bin.size);
3047 chapters = chapters_list->
elem;
3050 (max_start == 0 || chapters[
i].start > max_start)) {
3056 max_start = chapters[
i].
start;
3076 if (matroska->
queue) {
3107 uint32_t lace_size[256],
int *laces)
3114 lace_size[0] =
size;
3130 for (n = 0; n < *laces - 1; n++) {
3138 lace_size[n] +=
temp;
3141 }
while (
temp == 0xff);
3146 lace_size[n] =
size - total;
3151 if (
size % (*laces))
3153 for (n = 0; n < *laces; n++)
3154 lace_size[n] =
size / *laces;
3171 total = lace_size[0] = num;
3173 for (n = 1; n < *laces - 1; n++) {
3179 if (lace_size[n - 1] + snum > (uint64_t)INT_MAX)
3182 lace_size[n] = lace_size[n - 1] + snum;
3183 total += lace_size[n];
3191 lace_size[*laces - 1] =
size - total;
3218 if (
size < cfs *
h / 2) {
3220 "Corrupt int4 RM-style audio packet size\n");
3223 for (x = 0; x <
h / 2; x++)
3224 memcpy(track->
audio.
buf + x * 2 *
w + y * cfs,
3225 data + x * cfs, cfs);
3229 "Corrupt sipr RM-style audio packet size\n");
3236 "Corrupt generic RM-style audio packet size\n");
3239 for (x = 0; x <
w /
sps; x++)
3241 sps * (
h * x + ((
h + 1) / 2) * (y & 1) + (y >> 1)),
3300 while (srclen >= 8) {
3310 multiblock = (
flags & 0x1800) != 0x1800;
3322 if (blocksize > srclen) {
3333 dstlen += blocksize + 32;
3344 memcpy(dst +
offset + 32,
src, blocksize);
3347 srclen -= blocksize;
3348 offset += blocksize + 32;
3367 int dstlen = *
size + 8;
3375 memcpy(dst + 8, *
data, dstlen - 8);
3394 int id_len, settings_len, text_len;
3402 q =
data + data_len;
3407 if (*p ==
'\r' || *p ==
'\n') {
3416 if (p >= q || *p !=
'\n')
3423 if (*p ==
'\r' || *p ==
'\n') {
3424 settings_len = p - settings;
3432 if (p >= q || *p !=
'\n')
3438 while (text_len > 0) {
3439 const int len = text_len - 1;
3441 if (
c !=
'\r' &&
c !=
'\n')
3454 memcpy(
pkt->
data, text, text_len);
3464 memcpy(buf,
id, id_len);
3467 if (settings_len > 0) {
3475 memcpy(buf, settings, settings_len);
3502 uint64_t timecode, uint64_t lace_duration,
3504 uint8_t *additional, uint64_t additional_id,
int additional_size,
3505 int64_t discard_padding)
3515 "Error parsing a wavpack block.\n");
3528 "Error parsing a prores block.\n");
3536 if (!pkt_size && !additional_size)
3556 if (additional_size > 0) {
3559 additional_size + 8);
3564 AV_WB64(side_data, additional_id);
3565 memcpy(side_data + 8, additional, additional_size);
3568 if (discard_padding) {
3579 if (discard_padding > 0) {
3580 AV_WL32(side_data + 4, discard_padding);
3582 AV_WL32(side_data, -discard_padding);
3593 #if FF_API_CONVERGENCE_DURATION
3596 pkt->convergence_duration = lace_duration;
3617 int size, int64_t
pos, uint64_t cluster_time,
3619 uint8_t *additional, uint64_t additional_id,
int additional_size,
3620 int64_t cluster_pos, int64_t discard_padding)
3628 uint32_t lace_size[256];
3629 int n,
flags, laces = 0;
3631 int trust_default_duration;
3641 if (!track ||
size < 3)
3644 if (!(st = track->
stream)) {
3646 "No stream associated to TrackNumber %"PRIu64
". "
3647 "Ignoring Block with this TrackNumber.\n", num);
3653 if (block_duration > INT64_MAX)
3654 block_duration = INT64_MAX;
3663 if (cluster_time != (uint64_t) -1 &&
3664 (block_time >= 0 || cluster_time >= -block_time)) {
3665 uint64_t timecode_cluster_in_track_tb = (double) cluster_time / track->
time_scale;
3668 timecode < track->end_timecode)
3693 &pb, lace_size, &laces);
3704 trust_default_duration = 0;
3708 if (!block_duration && trust_default_duration)
3711 if (cluster_time != (uint64_t)-1 && (block_time >= 0 || cluster_time >= -block_time))
3715 for (n = 0; n < laces; n++) {
3716 int64_t lace_duration = block_duration*(n+1) / laces - block_duration*n / laces;
3742 timecode, lace_duration,
3752 additional, additional_id, additional_size,
3759 timecode = lace_duration ? timecode + lace_duration :
AV_NOPTS_VALUE;
3791 if (res >= 0 &&
block->bin.size > 0) {
3800 block->additional.size, cluster->
pos,
3801 block->discard_padding);
3811 "end of segment.\n");
3843 int64_t timestamp,
int flags)
3847 AVStream *st =
s->streams[stream_index];
3924 int64_t start_time_ns;
3925 int64_t end_time_ns;
3926 int64_t start_offset;
3938 int nb_index_entries =
s->streams[0]->nb_index_entries;
3942 return (
CueDesc) {-1, -1, -1, -1};
3943 for (
i = 1;
i < nb_index_entries;
i++) {
3944 if (index_entries[
i - 1].timestamp * matroska->
time_scale <= ts &&
3945 index_entries[
i].timestamp * matroska->
time_scale > ts) {
3952 if (
i != nb_index_entries - 1) {
3969 int64_t cluster_pos, before_pos;
3971 if (
s->streams[0]->nb_index_entries <= 0)
return 0;
3974 if (
index < 0)
return 0;
3975 cluster_pos =
s->streams[0]->index_entries[
index].pos;
3978 uint64_t cluster_id, cluster_length;
3984 if (read < 0 || cluster_id != 0xF43B675)
3998 cluster_pos += 4 + read + cluster_length;
4012 double min_buffer,
double*
buffer,
4016 double nano_seconds_per_second = 1000000000.0;
4017 double time_sec = time_ns / nano_seconds_per_second;
4019 int64_t time_to_search_ns = (int64_t)(search_sec * nano_seconds_per_second);
4020 int64_t end_time_ns = time_ns + time_to_search_ns;
4021 double sec_downloaded = 0.0;
4025 *sec_to_download = 0.0;
4029 int64_t cue_nano = desc_curr.
end_time_ns - time_ns;
4032 double timeToDownload = (cueBytes * 8.0) /
bps;
4034 sec_downloaded += (cue_nano / nano_seconds_per_second) - timeToDownload;
4035 *sec_to_download += timeToDownload;
4039 double desc_end_time_sec = desc_curr.
end_time_ns / nano_seconds_per_second;
4040 double percent_to_sub = search_sec / (desc_end_time_sec - time_sec);
4041 sec_downloaded = percent_to_sub * sec_downloaded;
4042 *sec_to_download = percent_to_sub * *sec_to_download;
4045 if ((sec_downloaded + *
buffer) <= min_buffer) {
4056 double desc_sec = desc_ns / nano_seconds_per_second;
4057 double bits = (desc_bytes * 8.0);
4058 double time_to_download =
bits /
bps;
4060 sec_downloaded += desc_sec - time_to_download;
4061 *sec_to_download += time_to_download;
4064 double desc_end_time_sec = desc_curr.
end_time_ns / nano_seconds_per_second;
4065 double percent_to_sub = search_sec / (desc_end_time_sec - time_sec);
4066 sec_downloaded = percent_to_sub * sec_downloaded;
4067 *sec_to_download = percent_to_sub * *sec_to_download;
4069 if ((sec_downloaded + *
buffer) <= min_buffer)
4074 if ((sec_downloaded + *
buffer) <= min_buffer) {
4096 double bandwidth = 0.0;
4100 int64_t prebuffer_ns = 1000000000;
4102 double nano_seconds_per_second = 1000000000.0;
4103 int64_t prebuffered_ns = time_ns + prebuffer_ns;
4104 double prebuffer_bytes = 0.0;
4105 int64_t temp_prebuffer_ns = prebuffer_ns;
4106 int64_t pre_bytes, pre_ns;
4107 double pre_sec, prebuffer, bits_per_second;
4125 bits_per_second = 0.0;
4133 pre_sec = pre_ns / nano_seconds_per_second;
4135 pre_bytes * ((temp_prebuffer_ns / nano_seconds_per_second) / pre_sec);
4137 prebuffer = prebuffer_ns / nano_seconds_per_second;
4140 bits_per_second = 0.0;
4144 double desc_sec, calc_bits_per_second, percent, mod_bits_per_second;
4145 if (desc_bytes <= 0)
4148 desc_sec = desc_ns / nano_seconds_per_second;
4149 calc_bits_per_second = (desc_bytes * 8) / desc_sec;
4152 percent = (desc_bytes - prebuffer_bytes) / desc_bytes;
4153 mod_bits_per_second = calc_bits_per_second * percent;
4155 if (prebuffer < desc_sec) {
4161 int64_t
bps = (int64_t)(mod_bits_per_second) + 1;
4162 const double min_buffer = 0.0;
4163 double buffer = prebuffer;
4164 double sec_to_download = 0.0;
4167 min_buffer, &
buffer, &sec_to_download,
4171 }
else if (
rv == 0) {
4172 bits_per_second = (double)(
bps);
4180 if (bandwidth < bits_per_second) bandwidth = bits_per_second;
4182 return (int64_t)bandwidth;
4191 int64_t cues_start = -1, cues_end = -1, before_pos, bandwidth;
4200 if (
i >= seekhead_list->
nb_elem)
return -1;
4204 if (
avio_seek(matroska->
ctx->
pb, cues_start, SEEK_SET) == cues_start) {
4208 uint64_t cues_length, cues_id;
4216 cues_end = cues_start + 4 + bytes_read + cues_length - 1;
4219 if (cues_start == -1 || cues_end == -1)
return -1;
4232 if (cues_start <= init_range)
4237 if (bandwidth < 0)
return -1;
4246 if (!buf)
return -1;
4248 for (
i = 0;
i <
s->streams[0]->nb_index_entries;
i++) {
4250 "%" PRId64
"%s",
s->streams[0]->index_entries[
i].timestamp,
4251 i !=
s->streams[0]->nb_index_entries - 1 ?
"," :
"");
4252 if (
ret <= 0 || (
ret == 20 &&
i ==
s->streams[0]->nb_index_entries - 1)) {
4298 buf = strrchr(
s->url,
'/');
4330 #define OFFSET(x) offsetof(MatroskaDemuxContext, x)
4345 .
name =
"matroska,webm",
4347 .extensions =
"mkv,mk3d,mka,mks,webm",
4354 .mime_type =
"audio/webm,audio/x-matroska,video/webm,video/x-matros