772 if ((ret =
avio_seek(pb, last_pos + 1, SEEK_SET)) < 0) {
822 int max_size, uint64_t *number)
835 "Read error at pos. %"PRIu64
" (0x%"PRIx64
")\n",
844 if (read > max_size) {
847 "Invalid EBML number size tag 0x%02x at pos %"PRIu64
" (0x%"PRIx64
")\n",
855 total = (total << 8) |
avio_r8(pb);
871 if (res > 0 && *number + 1 == 1ULL << (7 * res))
872 *number = 0xffffffffffffffULL;
890 *num = (*num << 8) |
avio_r8(pb);
913 *num = ((uint64_t)*num << 8) |
avio_r8(pb);
1035 *num = unum - ((1LL << (7 * res - 1)) - 1);
1044 uint32_t
id,
void *
data)
1047 for (i = 0; syntax[i].
id; i++)
1048 if (
id == syntax[i].
id)
1081 for (i = 0; syntax[i].
id; i++)
1082 switch (syntax[i].
type) {
1084 *(int64_t *) ((
char *) data + syntax[i].
data_offset) = syntax[i].def.
i;
1087 *(uint64_t *) ((
char *) data + syntax[i].data_offset) = syntax[i].
def.
u;
1090 *(
double *) ((
char *) data + syntax[i].
data_offset) = syntax[i].def.
f;
1095 if (syntax[i].def.
s) {
1115 unsigned int bits =
av_log2(
id);
1116 return id && (bits + 7) / 8 == (8 - bits % 8);
1172 uint32_t
id = syntax->
id;
1184 list->
elem = newelem;
1194 if (max_lengths[syntax->
type] && length > max_lengths[syntax->
type]) {
1196 "Invalid length 0x%"PRIx64
" > 0x%"PRIx64
" for syntax element %i\n",
1197 length, max_lengths[syntax->
type], syntax->
type);
1202 switch (syntax->
type) {
1253 for (i = 0; syntax[i].
id; i++) {
1254 void *data_off = (
char *) data + syntax[i].data_offset;
1255 switch (syntax[i].
type) {
1265 if (syntax[i].list_elem_size) {
1267 char *ptr = list->
elem;
1268 for (j = 0; j < list->
nb_elem;
1287 int len_mask = 0x80,
size = 1,
n = 1, i;
1295 while (
size <= 8 && !(total & len_mask)) {
1301 total &= (len_mask - 1);
1303 total = (total << 8) | p->
buf[4 +
n++];
1315 if (total < probelen)
1317 for (
n = 4 +
size;
n <= 4 +
size + total - probelen;
n++)
1333 if (tracks[i].num == num)
1345 int isize = *buf_size;
1348 int pkt_size = isize;
1352 if (pkt_size >= 10000000
U)
1355 switch (encodings[0].compression.algo) {
1361 if (header_size && !header) {
1369 pkt_size = isize + header_size;
1374 memcpy(pkt_data, header, header_size);
1375 memcpy(pkt_data + header_size, data, isize);
1381 olen = pkt_size *= 3;
1388 pkt_data = newpktdata;
1401 z_stream zstream = { 0 };
1402 if (inflateInit(&zstream) != Z_OK)
1404 zstream.next_in =
data;
1405 zstream.avail_in = isize;
1410 inflateEnd(&zstream);
1414 pkt_data = newpktdata;
1415 zstream.avail_out = pkt_size - zstream.total_out;
1416 zstream.next_out = pkt_data + zstream.total_out;
1417 result =
inflate(&zstream, Z_NO_FLUSH);
1418 }
while (result == Z_OK && pkt_size < 10000000);
1419 pkt_size = zstream.total_out;
1420 inflateEnd(&zstream);
1421 if (result != Z_STREAM_END) {
1422 if (result == Z_MEM_ERROR)
1434 bz_stream bzstream = { 0 };
1435 if (BZ2_bzDecompressInit(&bzstream, 0, 0) != BZ_OK)
1437 bzstream.next_in =
data;
1438 bzstream.avail_in = isize;
1443 BZ2_bzDecompressEnd(&bzstream);
1447 pkt_data = newpktdata;
1448 bzstream.avail_out = pkt_size - bzstream.total_out_lo32;
1449 bzstream.next_out = pkt_data + bzstream.total_out_lo32;
1450 result = BZ2_bzDecompress(&bzstream);
1451 }
while (result == BZ_OK && pkt_size < 10000000);
1452 pkt_size = bzstream.total_out_lo32;
1453 BZ2_bzDecompressEnd(&bzstream);
1454 if (result != BZ_STREAM_END) {
1455 if (result == BZ_MEM_ERROR)
1471 *buf_size = pkt_size;
1486 for (i = 0; i < list->
nb_elem; i++) {
1487 const char *lang = tags[i].
lang &&
1488 strcmp(tags[i].lang,
"und") ? tags[i].
lang :
NULL;
1490 if (!tags[i].
name) {
1495 snprintf(key,
sizeof(key),
"%s/%s", prefix, tags[i].name);
1498 if (tags[i].def || !lang) {
1500 if (tags[i].sub.nb_elem)
1507 if (tags[i].sub.nb_elem)
1521 if (tags[i].target.attachuid) {
1525 if (attachment[j].
uid == tags[i].target.attachuid &&
1528 &attachment[j].stream->metadata,
NULL);
1534 "The tags at index %d refer to a "
1535 "non-existent attachment %"PRId64
".\n",
1536 i, tags[i].target.attachuid);
1538 }
else if (tags[i].target.chapteruid) {
1542 if (chapter[j].
uid == tags[i].target.chapteruid &&
1545 &chapter[j].chapter->metadata,
NULL);
1551 "The tags at index %d refer to a non-existent chapter "
1553 i, tags[i].target.chapteruid);
1555 }
else if (tags[i].target.trackuid) {
1559 if (track[j].
uid == tags[i].target.trackuid &&
1562 &track[j].stream->metadata,
NULL);
1568 "The tags at index %d refer to a non-existent track "
1570 i, tags[i].target.trackuid);
1582 uint32_t level_up = matroska->
level_up;
1596 "Max EBML element depth (%d) reached, "
1601 level.
length = (uint64_t) -1;
1606 ret =
ebml_parse(matroska, matroska_segment, matroska);
1611 if (length == (uint64_t) -1)
1633 for (i = 0; i < seekhead_list->
nb_elem; i++) {
1635 uint32_t
id = seekheads[i].
id;
1636 uint64_t pos = seekheads[i].
pos;
1639 if (!elem || elem->
parsed)
1662 uint64_t index_scale = 1;
1668 index_list = &matroska->
index;
1669 index = index_list->
elem;
1672 if (index[1].time > 1E14 / matroska->
time_scale) {
1676 for (i = 0; i < index_list->
nb_elem; i++) {
1679 for (j = 0; j < pos_list->
nb_elem; j++) {
1682 if (track && track->stream)
1685 index[i].
time / index_scale, 0, 0,
1712 static const char *
const aac_profiles[] = {
"MAIN",
"LC",
"SSR" };
1715 for (profile = 0; profile <
FF_ARRAY_ELEMS(aac_profiles); profile++)
1716 if (strstr(codec_id, aac_profiles[profile]))
1758 int block_last, block_type, block_size;
1764 if (block_size > size)
1773 chmask =
av_dict_get(dict,
"WAVEFORMATEXTENSIBLE_CHANNEL_MASK",
NULL, 0);
1776 if (!mask || mask & ~0x3ffffULL) {
1778 "Invalid value of WAVEFORMATEXTENSIBLE_CHANNEL_MASK\n");
1794 int major, minor, micro, bttb = 0;
1798 if (matroska->
muxingapp && sscanf(matroska->
muxingapp,
"Lavf%d.%d.%d", &major, &minor, µ) == 3)
1799 bttb = (major == 57 && minor >= 36 && minor <= 51 && micro >= 100);
1801 switch (field_order) {
1820 int *h_width,
int *h_height)
1822 switch (stereo_mode) {
1847 int has_mastering_primaries, has_mastering_luminance;
1854 has_mastering_primaries =
1855 mastering_meta->
r_x > 0 && mastering_meta->
r_y > 0 &&
1856 mastering_meta->
g_x > 0 && mastering_meta->
g_y > 0 &&
1857 mastering_meta->
b_x > 0 && mastering_meta->
b_y > 0 &&
1859 has_mastering_luminance = mastering_meta->
max_luminance > 0;
1896 if (has_mastering_primaries || has_mastering_luminance) {
1898 const int chroma_den = 50000;
1899 const int luma_den = 10000;
1908 if (has_mastering_primaries) {
1910 round(mastering_meta->
r_x * chroma_den), chroma_den);
1912 round(mastering_meta->
r_y * chroma_den), chroma_den);
1914 round(mastering_meta->
g_x * chroma_den), chroma_den);
1916 round(mastering_meta->
g_y * chroma_den), chroma_den);
1918 round(mastering_meta->
b_x * chroma_den), chroma_den);
1920 round(mastering_meta->
b_y * chroma_den), chroma_den);
1922 round(mastering_meta->
white_x * chroma_den), chroma_den);
1924 round(mastering_meta->
white_y * chroma_den), chroma_den);
1927 if (has_mastering_luminance) {
1941 size_t spherical_size;
1942 uint32_t l = 0, t = 0,
r = 0,
b = 0;
1943 uint32_t padding = 0;
1950 if (bytestream2_get_byte(&gb) != 0) {
1960 t = bytestream2_get_be32(&gb);
1961 b = bytestream2_get_be32(&gb);
1962 l = bytestream2_get_be32(&gb);
1963 r = bytestream2_get_be32(&gb);
1965 if (
b >= UINT_MAX - t ||
r >= UINT_MAX - l) {
1967 "Invalid bounding rectangle coordinates "
1968 "%"PRIu32
",%"PRIu32
",%"PRIu32
",%"PRIu32
"\n",
1977 if (l || t ||
r ||
b)
1987 uint32_t
layout = bytestream2_get_be32(&gb);
1990 "Unknown spherical cubemap layout %"PRIu32
"\n", layout);
1994 padding = bytestream2_get_be32(&gb);
2005 "Unknown spherical metadata type %"PRIu64
"\n",
2079 int extradata_size = 0;
2080 int extradata_offset = 0;
2083 char* key_id_base64 =
NULL;
2092 "Unknown or unsupported track type %"PRIu64
"\n",
2102 "Invalid sample rate %f, defaulting to 8000 instead.\n",
2110 if (default_duration > UINT64_MAX || default_duration < 0) {
2112 "Invalid frame rate %e. Cannot calculate default duration.\n",
2128 if (encodings_list->
nb_elem > 1) {
2130 "Multiple combined encodings not supported");
2131 }
else if (encodings_list->
nb_elem == 1) {
2132 if (encodings[0].
type) {
2133 if (encodings[0].encryption.key_id.size > 0) {
2136 const int b64_size =
AV_BASE64_SIZE(encodings[0].encryption.key_id.size);
2138 if (key_id_base64 ==
NULL)
2142 encodings[0].encryption.key_id.data,
2145 encodings[0].
scope = 0;
2147 "Unsupported encoding type");
2160 encodings[0].
scope = 0;
2162 "Unsupported encoding type");
2172 "Failed to decode codec private data\n");
2205 if (key_id_base64) {
2211 if (!strcmp(track->
codec_id,
"V_MS/VFW/FOURCC") &&
2222 extradata_offset = 40;
2223 }
else if (!strcmp(track->
codec_id,
"A_MS/ACM") &&
2236 }
else if (!strcmp(track->
codec_id,
"A_QUICKTIME")
2240 uint16_t sample_size;
2246 if (sample_size == 8) {
2247 fourcc =
MKTAG(
'r',
'a',
'w',
' ');
2249 }
else if (sample_size == 16) {
2250 fourcc =
MKTAG(
't',
'w',
'o',
's');
2254 if ((fourcc ==
MKTAG(
't',
'w',
'o',
's') ||
2255 fourcc ==
MKTAG(
's',
'o',
'w',
't')) &&
2258 }
else if (!strcmp(track->
codec_id,
"V_QUICKTIME") &&
2265 fourcc =
MKTAG(
'S',
'V',
'Q',
'3');
2314 extradata[0] = (profile << 3) | ((sri & 0x0E) >> 1);
2315 extradata[1] = ((sri & 0x01) << 7) | (track->
audio.
channels << 3);
2316 if (strstr(track->
codec_id,
"SBR")) {
2318 extradata[2] = 0x56;
2319 extradata[3] = 0xE5;
2320 extradata[4] = 0x80 | (sri << 3);
2333 AV_WB32(extradata, extradata_size);
2334 memcpy(&extradata[4],
"alac", 4);
2339 extradata_size = 30;
2350 "Too large audio channel number %"PRIu64
2351 " or bitdepth %"PRIu64
". Skipping track.\n",
2371 extradata_offset = 26;
2407 static const int sipr_bit_rate[4] = { 6504, 8496, 5000, 16000 };
2412 extradata_offset = 78;
2427 extradata_offset = 4;
2433 "Unknown/unsupported AVCodecID %s.\n", track->
codec_id);
2438 1000 * 1000 * 1000);
2447 if (strcmp(track->language,
"und"))
2451 if (track->flag_default)
2453 if (track->flag_forced)
2460 }
else if (track->codec_priv.data && track->codec_priv.size > 0) {
2464 track->codec_priv.data + extradata_offset,
2465 track->codec_priv.size);
2471 int display_width_mul = 1;
2472 int display_height_mul = 1;
2492 st->
codecpar->
height * track->video.display_width * display_width_mul,
2493 st->
codecpar->
width * track->video.display_height * display_height_mul,
2499 if (track->default_duration) {
2501 1000000000, track->default_duration, 30000);
2502 #if FF_API_R_FRAME_RATE
2514 if (track->video.alpha_mode)
2518 for (j=0; j < track->operation.combine_planes.nb_elem; j++) {
2522 snprintf(buf,
sizeof(buf),
"%s_%d",
2525 if (planes[j].
uid == tracks[k].
uid && tracks[k].stream) {
2527 "stereo_mode", buf, 0);
2533 track->video.stereo_mode != 10 && track->video.stereo_mode != 12) {
2558 if (track->codec_delay > 0) {
2564 if (track->seek_preroll > 0) {
2572 if (!strcmp(track->codec_id,
"D_WEBVTT/CAPTIONS")) {
2574 }
else if (!strcmp(track->codec_id,
"D_WEBVTT/DESCRIPTIONS")) {
2576 }
else if (!strcmp(track->codec_id,
"D_WEBVTT/METADATA")) {
2582 matroska->contains_ssa = 1;
2596 uint64_t max_start = 0;
2611 ebml.
max_size >
sizeof(uint64_t) ||
2615 "EBML version %"PRIu64
", doctype %s, doc version %"PRIu64,
2621 "EBML header using unsupported features\n"
2622 "(EBML version %"PRIu64
", doctype %s, doc version %"PRIu64
")\n",
2639 res =
ebml_parse(matroska, matroska_segments, matroska);
2646 res =
ebml_parse(matroska, matroska_segment, matroska);
2665 attachments = attachments_list->
elem;
2666 for (j = 0; j < attachments_list->
nb_elem; j++) {
2667 if (!(attachments[j].filename && attachments[j].mime &&
2668 attachments[j].bin.data && attachments[j].
bin.
size > 0)) {
2686 attachments[j].
stream = st;
2716 chapters = chapters_list->
elem;
2717 for (i = 0; i < chapters_list->
nb_elem; i++)
2719 (max_start == 0 || chapters[i].
start > max_start)) {
2723 chapters[i].
start, chapters[i].
end,
2725 if (chapters[i].chapter) {
2727 "title", chapters[i].
title, 0);
2729 max_start = chapters[i].
start;
2749 if (matroska->
queue) {
2779 int *buf_size,
int type,
2780 uint32_t **lace_buf,
int *laces)
2782 int res = 0,
n,
size = *buf_size;
2784 uint32_t *lace_size;
2792 *lace_buf[0] =
size;
2800 lace_size =
av_mallocz(*laces *
sizeof(
int));
2809 for (
n = 0; res == 0 &&
n < *laces - 1;
n++) {
2811 if (size <= total) {
2817 lace_size[
n] +=
temp;
2824 if (size <= total) {
2829 lace_size[
n] = size - total;
2834 if (size % (*laces)) {
2838 for (
n = 0;
n < *laces;
n++)
2839 lace_size[
n] = size / *laces;
2847 if (n < 0 || num > INT_MAX) {
2849 "EBML block data error\n");
2855 total = lace_size[0] = num;
2856 for (
n = 1; res == 0 &&
n < *laces - 1;
n++) {
2860 if (r < 0 || lace_size[
n - 1] + snum > (uint64_t)INT_MAX) {
2862 "EBML block data error\n");
2868 lace_size[
n] = lace_size[
n - 1] + snum;
2869 total += lace_size[
n];
2871 if (size <= total) {
2875 lace_size[*laces - 1] = size - total;
2881 *lace_buf = lace_size;
2904 if (size < cfs * h / 2) {
2906 "Corrupt int4 RM-style audio packet size\n");
2909 for (x = 0; x < h / 2; x++)
2910 memcpy(track->
audio.
buf + x * 2 * w + y * cfs,
2911 data + x * cfs, cfs);
2915 "Corrupt sipr RM-style audio packet size\n");
2918 memcpy(track->
audio.
buf + y * w, data, w);
2920 if (size < sps * w / sps || h<=0 || w%sps) {
2922 "Corrupt generic RM-style audio packet size\n");
2925 for (x = 0; x < w /
sps; x++)
2927 sps * (h * x + ((h + 1) / 2) * (y & 1) + (y >> 1)),
2928 data + x * sps, sps);
2975 if (srclen < 12 || track->stream->codecpar->extradata_size < 2)
2984 while (srclen >= 8) {
2990 uint32_t crc =
AV_RL32(src + 4);
2994 multiblock = (flags & 0x1800) != 0x1800;
3006 if (blocksize > srclen) {
3017 dstlen += blocksize + 32;
3020 AV_WL32(dst + offset + 4, blocksize + 24);
3021 AV_WL16(dst + offset + 8, ver);
3022 AV_WL16(dst + offset + 10, 0);
3023 AV_WL32(dst + offset + 12, 0);
3024 AV_WL32(dst + offset + 16, 0);
3025 AV_WL32(dst + offset + 20, samples);
3026 AV_WL32(dst + offset + 24, flags);
3027 AV_WL32(dst + offset + 28, crc);
3028 memcpy(dst + offset + 32, src, blocksize);
3031 srclen -= blocksize;
3032 offset += blocksize + 32;
3060 memcpy(dst + 8, src, dstlen);
3081 int id_len, settings_len, text_len;
3089 q = data + data_len;
3094 if (*p ==
'\r' || *p ==
'\n') {
3103 if (p >= q || *p !=
'\n')
3110 if (*p ==
'\r' || *p ==
'\n') {
3111 settings_len = p - settings;
3119 if (p >= q || *p !=
'\n')
3125 while (text_len > 0) {
3126 const int len = text_len - 1;
3128 if (c !=
'\r' && c !=
'\n')
3141 memcpy(pkt->
data, text, text_len);
3151 memcpy(buf,
id, id_len);
3154 if (settings_len > 0) {
3162 memcpy(buf, settings, settings_len);
3169 pkt->
pts = timecode;
3189 uint64_t timecode, uint64_t lace_duration,
3191 uint8_t *additional, uint64_t additional_id,
int additional_size,
3192 int64_t discard_padding)
3199 if (encodings && !encodings->
type && encodings->
scope & 1) {
3210 "Error parsing a wavpack block.\n");
3213 if (pkt_data != data)
3223 "Error parsing a prores block.\n");
3226 if (pkt_data != data)
3232 if (pkt_data != data)
3243 pkt->
data = pkt_data;
3244 pkt->
size = pkt_size;
3248 if (additional_size > 0) {
3251 additional_size + 8);
3256 AV_WB64(side_data, additional_id);
3257 memcpy(side_data + 8, additional, additional_size);
3260 if (discard_padding) {
3271 if (discard_padding > 0) {
3272 AV_WL32(side_data + 4, discard_padding);
3274 AV_WL32(side_data, -discard_padding);
3279 pkt->
dts = timecode;
3281 pkt->
pts = timecode;
3285 #if FF_API_CONVERGENCE_DURATION
3302 if (pkt_data != data)
3308 int size, int64_t pos, uint64_t cluster_time,
3310 uint8_t *additional, uint64_t additional_id,
int additional_size,
3311 int64_t cluster_pos, int64_t discard_padding)
3318 uint32_t *lace_size =
NULL;
3321 int trust_default_duration = 1;
3331 if (!track || !track->
stream) {
3333 "Invalid stream %"PRIu64
" or size %u\n", num, size);
3335 }
else if (size <= 3)
3346 if (is_keyframe == -1)
3349 if (cluster_time != (uint64_t) -1 &&
3350 (block_time >= 0 || cluster_time >= -block_time)) {
3353 timecode < track->end_timecode)
3378 &lace_size, &laces);
3387 trust_default_duration = 0;
3391 if (!block_duration && trust_default_duration)
3394 if (cluster_time != (uint64_t)-1 && (block_time >= 0 || cluster_time >= -block_time))
3398 for (n = 0; n < laces; n++) {
3399 int64_t lace_duration = block_duration*(n+1) / laces - block_duration*n / laces;
3401 if (lace_size[n] > size) {
3420 timecode, lace_duration,
3426 timecode, lace_duration, pos,
3427 !n ? is_keyframe : 0,
3428 additional, additional_id, additional_size,
3435 timecode = lace_duration ? timecode + lace_duration :
AV_NOPTS_VALUE;
3436 data += lace_size[
n];
3437 size -= lace_size[
n];
3451 matroska_cluster_incremental_parsing,
3465 matroska_clusters_incremental,
3470 matroska_cluster_incremental_parsing,
3478 blocks = blocks_list->
elem;
3482 if (blocks[i].bin.size > 0 && blocks[i].
bin.
data) {
3486 if (!blocks[i].non_simple)
3515 res =
ebml_parse(matroska, matroska_clusters, &cluster);
3516 blocks_list = &cluster.
blocks;
3517 blocks = blocks_list->
elem;
3518 for (i = 0; i < blocks_list->
nb_elem; i++)
3519 if (blocks[i].bin.size > 0 && blocks[i].
bin.
data) {
3524 is_keyframe,
NULL, 0, 0, pos,
3548 int64_t timestamp,
int flags)
3553 int i,
index, index_min;
3650 for (i = 1; i < nb_index_entries; i++) {
3651 if (index_entries[i - 1].timestamp * matroska->
time_scale <= ts &&
3659 if (i != nb_index_entries - 1) {
3675 int64_t cluster_pos, before_pos;
3680 if (index < 0)
return 0;
3684 int64_t cluster_id = 0, cluster_length = 0;
3690 if (cluster_id != 0xF43B675) {
3701 cluster_pos += cluster_length + 12;
3712 double min_buffer,
double*
buffer,
3716 double nano_seconds_per_second = 1000000000.0;
3717 double time_sec = time_ns / nano_seconds_per_second;
3719 int64_t time_to_search_ns = (int64_t)(search_sec * nano_seconds_per_second);
3720 int64_t end_time_ns = time_ns + time_to_search_ns;
3721 double sec_downloaded = 0.0;
3725 *sec_to_download = 0.0;
3729 int64_t cue_nano = desc_curr.
end_time_ns - time_ns;
3732 double timeToDownload = (cueBytes * 8.0) /
bps;
3734 sec_downloaded += (cue_nano / nano_seconds_per_second) - timeToDownload;
3735 *sec_to_download += timeToDownload;
3739 double desc_end_time_sec = desc_curr.
end_time_ns / nano_seconds_per_second;
3740 double percent_to_sub = search_sec / (desc_end_time_sec - time_sec);
3741 sec_downloaded = percent_to_sub * sec_downloaded;
3742 *sec_to_download = percent_to_sub * *sec_to_download;
3745 if ((sec_downloaded + *buffer) <= min_buffer) {
3756 double desc_sec = desc_ns / nano_seconds_per_second;
3757 double bits = (desc_bytes * 8.0);
3758 double time_to_download = bits /
bps;
3760 sec_downloaded += desc_sec - time_to_download;
3761 *sec_to_download += time_to_download;
3764 double desc_end_time_sec = desc_curr.
end_time_ns / nano_seconds_per_second;
3765 double percent_to_sub = search_sec / (desc_end_time_sec - time_sec);
3766 sec_downloaded = percent_to_sub * sec_downloaded;
3767 *sec_to_download = percent_to_sub * *sec_to_download;
3769 if ((sec_downloaded + *buffer) <= min_buffer)
3774 if ((sec_downloaded + *buffer) <= min_buffer) {
3781 *buffer = *buffer + sec_downloaded;
3796 double bandwidth = 0.0;
3800 int64_t prebuffer_ns = 1000000000;
3802 double nano_seconds_per_second = 1000000000.0;
3803 int64_t prebuffered_ns = time_ns + prebuffer_ns;
3804 double prebuffer_bytes = 0.0;
3805 int64_t temp_prebuffer_ns = prebuffer_ns;
3806 int64_t pre_bytes, pre_ns;
3807 double pre_sec, prebuffer, bits_per_second;
3825 bits_per_second = 0.0;
3831 pre_sec = pre_ns / nano_seconds_per_second;
3833 pre_bytes * ((temp_prebuffer_ns / nano_seconds_per_second) / pre_sec);
3835 prebuffer = prebuffer_ns / nano_seconds_per_second;
3838 bits_per_second = 0.0;
3842 double desc_sec = desc_ns / nano_seconds_per_second;
3843 double calc_bits_per_second = (desc_bytes * 8) / desc_sec;
3846 double percent = (desc_bytes - prebuffer_bytes) / desc_bytes;
3847 double mod_bits_per_second = calc_bits_per_second * percent;
3849 if (prebuffer < desc_sec) {
3855 int64_t
bps = (int64_t)(mod_bits_per_second) + 1;
3856 const double min_buffer = 0.0;
3857 double buffer = prebuffer;
3858 double sec_to_download = 0.0;
3861 min_buffer, &buffer, &sec_to_download,
3865 }
else if (rv == 0) {
3866 bits_per_second = (double)(bps);
3874 if (bandwidth < bits_per_second) bandwidth = bits_per_second;
3876 return (int64_t)bandwidth;
3885 int64_t cues_start = -1, cues_end = -1, before_pos, bandwidth;
3890 for (i = 0; i < seekhead_list->
nb_elem; i++)
3894 if (i >= seekhead_list->
nb_elem)
return -1;
3898 if (
avio_seek(matroska->
ctx->
pb, cues_start, SEEK_SET) == cues_start) {
3902 uint64_t cues_length = 0, cues_id = 0, bytes_read = 0;
3905 cues_end = cues_start + cues_length + bytes_read - 1;
3908 if (cues_start == -1 || cues_end == -1)
return -1;
3921 if (cues_start <= init_range)
3926 if (bandwidth < 0)
return -1;
3935 if (!buf)
return -1;
3947 strncat(buf,
",", 1);
3976 if (!buf)
return AVERROR(ENOMEM);
3987 buf = strrchr(s->
url,
'/');
4016 #define OFFSET(x) offsetof(MatroskaDemuxContext, x)
4031 .
name =
"matroska,webm",
4033 .extensions =
"mkv,mk3d,mka,mks",
4040 .mime_type =
"audio/webm,audio/x-matroska,video/webm,video/x-matroska"
4044 .
name =
"webm_dash_manifest",
4050 .priv_class = &webm_dash_class,
int32_t pitch
Rotation around the right vector [-90, 90].
#define MATROSKA_ID_SEEKPREROLL
#define MATROSKA_ID_VIDEOPROJECTIONPOSEYAW
AVSphericalMapping * av_spherical_alloc(size_t *size)
Allocate a AVSphericalVideo structure and initialize its fields to default values.
uint64_t codec_delay_in_track_tb
enum AVChromaLocation chroma_location
#define MATROSKA_ID_BLOCKADDID
#define MATROSKA_ID_TRACKDEFAULTDURATION
enum AVFieldOrder field_order
Video only.
void avio_wl16(AVIOContext *s, unsigned int val)
static int matroska_parse_rm_audio(MatroskaDemuxContext *matroska, MatroskaTrack *track, AVStream *st, uint8_t *data, int size, uint64_t timecode, int64_t pos)
enum AVColorTransferCharacteristic color_trc
#define MATROSKA_ID_VIDEOFLAGINTERLACED
#define AVERROR_INVALIDDATA
Invalid data found when processing input.
#define MATROSKA_ID_VIDEOCOLOR_GX
static const EbmlSyntax matroska_blockgroup[]
const char *const ff_matroska_video_stereo_plane[MATROSKA_VIDEO_STEREO_PLANE_COUNT]
static const EbmlSyntax matroska_simpletag[]
static void matroska_convert_tags(AVFormatContext *s)
#define MATROSKA_ID_DATEUTC
void av_buffer_unref(AVBufferRef **buf)
Free a given reference and automatically free the buffer if there are no more references to it...
The optional first identifier line of a WebVTT cue.
static const EbmlSyntax matroska_tracks[]
unsigned MaxCLL
Max content light level (cd/m^2).
#define MATROSKA_ID_TRACKFLAGLACING
static int webm_dash_manifest_read_packet(AVFormatContext *s, AVPacket *pkt)
#define MATROSKA_ID_TRACKENTRY
static int matroska_deliver_packet(MatroskaDemuxContext *matroska, AVPacket *pkt)
#define MATROSKA_ID_VIDEODISPLAYHEIGHT
void * av_realloc(void *ptr, size_t size)
Allocate, reallocate, or free a block of memory.
AVInputFormat ff_matroska_demuxer
ptrdiff_t const GLvoid * data
static int is_keyframe(NalUnitType naltype)
int av_add_index_entry(AVStream *st, int64_t pos, int64_t timestamp, int size, int distance, int flags)
Add an index entry into a sorted list.
#define MATROSKA_ID_VIDEOPROJECTIONPOSEROLL
static const EbmlSyntax matroska_info[]
#define MATROSKA_ID_CUETRACKPOSITION
#define MATROSKA_ID_CODECPRIVATE
const unsigned char ff_sipr_subpk_size[4]
#define MATROSKA_ID_TAGTARGETS_TYPE
#define AV_LOG_WARNING
Something somehow does not look correct.
static int ebml_level_end(MatroskaDemuxContext *matroska)
#define LIBAVUTIL_VERSION_INT
#define INITIALIZATION_RANGE
int64_t pos
byte position in stream, -1 if unknown
static int matroska_ebmlnum_sint(MatroskaDemuxContext *matroska, uint8_t *data, uint32_t size, int64_t *num)
static int webm_clusters_start_with_keyframe(AVFormatContext *s)
static const EbmlSyntax matroska_tagtargets[]
#define MATROSKA_ID_ENCODINGTYPE
#define MATROSKA_ID_AUDIOBITDEPTH
static const EbmlSyntax matroska_track_video[]
static av_always_inline float av_int2float(uint32_t i)
Reinterpret a 32-bit integer as a float.
#define MATROSKA_ID_TRACKFLAGDEFAULT
static int read_seek(AVFormatContext *ctx, int stream_index, int64_t timestamp, int flags)
MatroskaCluster current_cluster
Video represents a portion of a sphere mapped on a flat surface using equirectangular projection...
enum AVCodecID codec_id
Specific type of the encoded data (the codec used).
AVRational sample_aspect_ratio
sample aspect ratio (0 if unknown)
#define MATROSKA_ID_TAGTARGETS_ATTACHUID
int index
stream index in AVFormatContext
#define MATROSKA_ID_CLUSTERPOSITION
int64_t avio_seek(AVIOContext *s, int64_t offset, int whence)
fseek() equivalent for AVIOContext.
#define MATROSKA_ID_FILEDATA
const char * av_default_item_name(void *ptr)
Return the context name.
AVIndexEntry * index_entries
Only used if the format does not support seeking natively.
MatroskaTrackVideoProjection projection
#define EBML_ID_DOCTYPEREADVERSION
#define MATROSKA_ID_BLOCKREFERENCE
#define MATROSKA_ID_TRACKTYPE
int current_cluster_num_blocks
#define MATROSKA_ID_TAGTARGETS_CHAPTERUID
static av_always_inline void bytestream2_init(GetByteContext *g, const uint8_t *buf, int buf_size)
#define MATROSKA_ID_VIDEOCOLOR_RX
Video represents a sphere mapped on a flat surface using equirectangular projection.
#define MATROSKA_ID_VIDEOASPECTRATIO
static const EbmlSyntax matroska_track_encodings[]
uint64_t chroma_siting_vert
#define MATROSKA_ID_MUXINGAPP
#define MATROSKA_ID_AUDIOCHANNELS
int64_t avio_skip(AVIOContext *s, int64_t offset)
Skip given number of bytes forward.
void * av_mallocz(size_t size)
Allocate a memory block with alignment suitable for all memory accesses (including vectors if availab...
#define MATROSKA_ID_VIDEOPROJECTIONTYPE
MatroskaLevel levels[EBML_MAX_DEPTH]
#define MATROSKA_ID_CUECLUSTERPOSITION
#define MATROSKA_ID_VIDEOCOLOR_LUMINANCEMAX
unsigned int avio_rb16(AVIOContext *s)
uint64_t_TMPL AV_WL64 unsigned int_TMPL AV_WL32 unsigned int_TMPL AV_WL24 unsigned int_TMPL AV_WL16 uint64_t_TMPL AV_WB64 unsigned int_TMPL AV_WB32 unsigned int_TMPL AV_WB24 unsigned int_TMPL AV_RB16
#define MATROSKA_ID_VIDEOCOLORCHROMASITINGHORZ
const struct EbmlSyntax * n
#define MATROSKA_ID_EDITIONFLAGDEFAULT
uint64_t_TMPL AV_WL64 unsigned int_TMPL AV_WL32 unsigned int_TMPL AV_WL24 unsigned int_TMPL AV_RL16
#define MATROSKA_ID_CLUSTERTIMECODE
#define MATROSKA_ID_ENCODINGENCALGO
#define MATROSKA_ID_CHAPTERTIMEEND
enum AVColorSpace color_space
static const EbmlSyntax matroska_track_plane[]
#define MATROSKA_ID_TRACKCONTENTENCODINGS
int frame_size
Audio only.
Mastering display metadata (based on SMPTE-2086:2014).
#define AV_LZO_OUTPUT_FULL
decoded data did not fit into output buffer
#define MATROSKA_ID_FILEDESC
#define MATROSKA_ID_TRACKCONTENTENCODING
static const EbmlSyntax matroska_cluster[]
#define MATROSKA_ID_CODECDOWNLOADURL
const char * class_name
The name of the class; usually it is the same name as the context structure type to which the AVClass...
static int webm_dash_manifest_read_header(AVFormatContext *s)
static int ebml_read_sint(AVIOContext *pb, int size, int64_t *num)
#define av_assert0(cond)
assert() equivalent, that is always enabled.
int avpriv_dict_set_timestamp(AVDictionary **dict, const char *key, int64_t timestamp)
Set a dictionary value to an ISO-8601 compliant timestamp string.
int ffio_limit(AVIOContext *s, int size)
static const EbmlSyntax matroska_chapters[]
static MatroskaLevel1Element * matroska_find_level1_elem(MatroskaDemuxContext *matroska, uint32_t id)
void avio_wl32(AVIOContext *s, unsigned int val)
uint64_t bits_per_channel
static av_always_inline double av_int2double(uint64_t i)
Reinterpret a 64-bit integer as a double.
#define MATROSKA_ID_VIDEOCOLOR_BX
#define MATROSKA_ID_CHAPLANG
MatroskaTrackOperation operation
#define MATROSKA_ID_EDITIONFLAGORDERED
static const EbmlSyntax matroska_track_video_projection[]
static CueDesc get_cue_desc(AVFormatContext *s, int64_t ts, int64_t cues_start)
#define MATROSKA_ID_TRACKLANGUAGE
MatroskaTrackCompression compression
const AVCodecTag ff_codec_movvideo_tags[]
unsigned int avio_rb32(AVIOContext *s)
int ff_mkv_stereo3d_conv(AVStream *st, MatroskaVideoStereoModeType stereo_mode)
static av_cold int end(AVCodecContext *avctx)
static int matroska_parse_prores(MatroskaTrack *track, uint8_t *src, uint8_t **pdst, int *size)
int64_t duration
Duration of this packet in AVStream->time_base units, 0 if unknown.
#define MATROSKA_ID_VIDEOPIXELCROPT
static const EbmlSyntax matroska_track_video_color[]
#define MATROSKA_ID_TIMECODESCALE
static int matroska_aac_sri(int samplerate)
enum AVStreamParseType need_parsing
#define MATROSKA_ID_VIDEOCOLORCBSUBVERT
#define MATROSKA_ID_SIMPLEBLOCK
#define MATROSKA_ID_TAGTARGETS_TYPEVALUE
#define MATROSKA_ID_EDITIONFLAGHIDDEN
#define AV_LZO_OUTPUT_PADDING
static const EbmlSyntax matroska_segment[]
AVStream * avformat_new_stream(AVFormatContext *s, const AVCodec *c)
Add a new stream to a media file.
#define MATROSKA_ID_CODECNAME
#define MATROSKA_ID_BLOCKMORE
uint64_t_TMPL AV_WL64 unsigned int_TMPL AV_WL32 unsigned int_TMPL AV_WL24 unsigned int_TMPL AV_WL16 uint64_t_TMPL AV_WB64 unsigned int_TMPL AV_RB32
AVStream ** streams
A list of all streams in the file.
#define MATROSKA_ID_CUERELATIVEPOSITION
#define MATROSKA_ID_AUDIOOUTSAMPLINGFREQ
#define MATROSKA_ID_VIDEOCOLOR
int initial_padding
Audio only.
static const EbmlSyntax matroska_segments[]
AVDictionaryEntry * av_dict_get(const AVDictionary *m, const char *key, const AVDictionaryEntry *prev, int flags)
Get a dictionary entry with matching key.
int flags
Flags modifying the (de)muxer behaviour.
static int matroska_parse_cluster_incremental(MatroskaDemuxContext *matroska)
static void inflate(uint8_t *dst, const uint8_t *p1, int width, int threshold, const uint8_t *coordinates[], int coord)
#define MATROSKA_ID_VIDEODISPLAYWIDTH
#define MATROSKA_ID_EDITIONUID
int ff_vorbis_comment(AVFormatContext *ms, AVDictionary **m, const uint8_t *buf, int size, int parse_picture)
#define MATROSKA_ID_BLOCKADDITIONS
static const EbmlSyntax matroska_index[]
#define AVERROR_EOF
End of file.
#define MATROSKA_ID_CODECDECODEALL
#define MATROSKA_ID_ENCODINGENCRYPTION
static av_cold int read_close(AVFormatContext *ctx)
static int mkv_parse_video_color(AVStream *st, const MatroskaTrack *track)
uint64_t avio_rb64(AVIOContext *s)
static av_always_inline int64_t avio_tell(AVIOContext *s)
ftell() equivalent for AVIOContext.
int av_reduce(int *dst_num, int *dst_den, int64_t num, int64_t den, int64_t max)
Reduce a fraction.
static const uint8_t header[24]
#define MATROSKA_ID_TRACKNUMBER
#define MATROSKA_ID_VIDEOCOLOR_WHITEY
void avio_write(AVIOContext *s, const unsigned char *buf, int size)
void * av_realloc_array(void *ptr, size_t nmemb, size_t size)
#define MATROSKA_ID_SEGMENTUID
uint64_t channel_layout
Audio only.
int avio_read(AVIOContext *s, unsigned char *buf, int size)
Read size bytes from AVIOContext into buf.
int ff_get_wav_header(AVFormatContext *s, AVIOContext *pb, AVCodecParameters *par, int size, int big_endian)
static int matroska_parse_seekhead_entry(MatroskaDemuxContext *matroska, uint64_t pos)
int64_t bit_rate
The average bitrate of the encoded data (in bits per second).
#define AV_PKT_FLAG_KEY
The packet contains a keyframe.
static int matroska_parse_cluster(MatroskaDemuxContext *matroska)
static int ebml_parse_nest(MatroskaDemuxContext *matroska, EbmlSyntax *syntax, void *data)
#define MATROSKA_ID_CUEBLOCKNUMBER
#define MATROSKA_ID_TRACKUID
int64_t av_rescale_q(int64_t a, AVRational bq, AVRational cq)
Rescale a 64-bit integer by 2 rational numbers.
#define MATROSKA_ID_ENCODINGORDER
#define MATROSKA_ID_VIDEOSTEREOMODE
int av_new_packet(AVPacket *pkt, int size)
Allocate the payload of a packet and initialize its fields with default values.
Content light level needed by to transmit HDR over HDMI (CTA-861.3).
AVCodecID
Identify the syntax and semantics of the bitstream.
#define MATROSKA_ID_VIDEOCOLOR_BY
#define AV_LOG_ERROR
Something went wrong and cannot losslessly be recovered.
AVDictionary * metadata
Metadata that applies to the whole file.
#define MATROSKA_ID_BLOCKDURATION
An AV_PKT_DATA_PALETTE side data packet contains exactly AVPALETTE_SIZE bytes worth of palette...
#define EBML_ID_EBMLREADVERSION
int av_index_search_timestamp(AVStream *st, int64_t timestamp, int flags)
Get the index for a specific timestamp.
#define MATROSKA_ID_VIDEOCOLORMAXCLL
MatroskaMasteringMeta mastering_meta
#define MATROSKA_ID_VIDEOCOLOR_WHITEX
static const uint16_t mask[17]
FLAC (Free Lossless Audio Codec) decoder/demuxer common functions.
static int ebml_read_length(MatroskaDemuxContext *matroska, AVIOContext *pb, uint64_t *number)
Read a EBML length value.
static av_always_inline void bytestream2_skip(GetByteContext *g, unsigned int size)
int64_t timestamp
Timestamp in AVStream.time_base units, preferably the time from which on correctly decoded frames are...
#define MATROSKA_ID_CLUSTER
#define MATROSKA_ID_VIDEOCOLORCHROMASITINGVERT
#define NULL_IF_CONFIG_SMALL(x)
Return NULL if CONFIG_SMALL is true, otherwise the argument without modification. ...
enum AVColorPrimaries color_primaries
#define MATROSKA_ID_FILEMIMETYPE
static const EbmlSyntax matroska_track_encoding[]
static int matroska_ebmlnum_uint(MatroskaDemuxContext *matroska, uint8_t *data, uint32_t size, uint64_t *num)
char * url
input or output URL.
#define MATROSKA_ID_WRITINGAPP
#define AV_LOG_DEBUG
Stuff which is only useful for libav* developers.
const char *const ff_matroska_video_stereo_mode[MATROSKA_VIDEO_STEREOMODE_TYPE_NB]
void av_dict_free(AVDictionary **pm)
Free all the memory allocated for an AVDictionary struct and all keys and values. ...
preferred ID for decoding MPEG audio layer 1, 2 or 3
#define av_fourcc2str(fourcc)
enum AVMediaType codec_type
General type of the encoded data.
AVBufferRef * buf
A reference to the reference-counted buffer where the packet data is stored.
#define MATROSKA_ID_TAGDEFAULT_BUG
int cues_parsing_deferred
#define MATROSKA_ID_VIDEOPIXELCROPR
#define MATROSKA_ID_TRACKPLANEUID
static av_always_inline av_const double round(double x)
#define MATROSKA_ID_ENCODINGCOMPSETTINGS
#define EBML_ID_EBMLMAXIDLENGTH
AVBufferRef * av_buffer_create(uint8_t *data, int size, void(*free)(void *opaque, uint8_t *data), void *opaque, int flags)
Create an AVBuffer from an existing array.
#define MATROSKA_ID_CHAPTERFLAGHIDDEN
static const EbmlSyntax matroska_index_entry[]
int av_buffer_realloc(AVBufferRef **pbuf, int size)
Reallocate a given buffer.
static const EbmlSyntax matroska_chapter_entry[]
static const uint8_t offset[127][2]
char * av_base64_encode(char *out, int out_size, const uint8_t *in, int in_size)
Encode data to base64 and null-terminate.
AVRational avg_frame_rate
Average framerate.
size_t av_strlcpy(char *dst, const char *src, size_t size)
Copy the string src to dst, but no more than size - 1 bytes, and null-terminate dst.
int flags
A combination of AV_PKT_FLAG values.
int extradata_size
Size of the extradata content in bytes.
uint64_t matrix_coefficients
int avio_r8(AVIOContext *s)
static void ebml_free(EbmlSyntax *syntax, void *data)
const CodecMime ff_mkv_mime_tags[]
int buf_size
Size of buf except extra allocated bytes.
char * av_asprintf(const char *fmt,...)
unsigned char * buf
Buffer must have AVPROBE_PADDING_SIZE of extra allocated bytes filled with zero.
static const EbmlSyntax matroska_seekhead_entry[]
unsigned int nb_streams
Number of elements in AVFormatContext.streams.
uint32_t bound_bottom
Distance from the bottom edge.
static const struct @304 planes[]
#define MATROSKA_ID_ENCODINGSIGHASHALGO
static const struct TransferCharacteristics transfer_characteristics[AVCOL_TRC_NB]
uint64_t skip_to_timecode
int block_align
Audio only.
static int matroska_read_header(AVFormatContext *s)
static void matroska_parse_cues(MatroskaDemuxContext *matroska)
static const EbmlSyntax matroska_mastering_meta[]
int seekable
A combination of AVIO_SEEKABLE_ flags or 0 when the stream is not seekable.
Video frame is split into 6 faces of a cube, and arranged on a 3x2 layout.
static void matroska_execute_seekhead(MatroskaDemuxContext *matroska)
#define MATROSKA_ID_VIDEOCOLOR_LUMINANCEMIN
#define EBML_ID_EBMLVERSION
#define av_assert1(cond)
assert() equivalent, that does not lie in speed critical code.
int64_t av_rescale(int64_t a, int64_t b, int64_t c)
Rescale a 64-bit integer with rounding to nearest.
#define AV_BASE64_SIZE(x)
Calculate the output size needed to base64-encode x bytes to a null-terminated string.
#define AV_TIME_BASE
Internal time base represented as integer.
static const EbmlSyntax matroska_clusters[]
#define MATROSKA_ID_TAGTARGETS
#define MATROSKA_ID_VIDEOCOLORBITSPERCHANNEL
union EbmlSyntax::@255 def
const AVCodecTag ff_codec_bmp_tags[]
int av_stream_add_side_data(AVStream *st, enum AVPacketSideDataType type, uint8_t *data, size_t size)
Wrap an existing array as stream side data.
#define MATROSKA_VIDEO_STEREO_PLANE_COUNT
#define MATROSKA_ID_TAGNAME
#define MATROSKA_ID_TRACKTIMECODESCALE
static int ebml_parse_elem(MatroskaDemuxContext *matroska, EbmlSyntax *syntax, void *data)
static int ebml_read_num(MatroskaDemuxContext *matroska, AVIOContext *pb, int max_size, uint64_t *number)
static const EbmlSyntax matroska_track_combine_planes[]
#define MATROSKA_ID_CHAPTERFLAGENABLED
static MatroskaTrack * matroska_find_track_by_num(MatroskaDemuxContext *matroska, int num)
static void bit_depth(AudioStatsContext *s, uint64_t mask, uint64_t imask, AVRational *depth)
static int webm_dash_manifest_cues(AVFormatContext *s, int64_t init_range)
This side data should be associated with a video stream and corresponds to the AVSphericalMapping str...
uint32_t bound_right
Distance from the right edge.
#define MATROSKA_ID_SIMPLETAG
internal header for RIFF based (de)muxers do NOT include this in end user applications ...
#define MATROSKA_ID_TRACKMAXCACHE
#define MATROSKA_ID_CHAPTERPHYSEQUIV
static int matroska_read_close(AVFormatContext *s)
#define FLAC_STREAMINFO_SIZE
static int ebml_read_ascii(AVIOContext *pb, int size, char **str)
static const EbmlSyntax ebml_syntax[]
static int matroska_decode_buffer(uint8_t **buf, int *buf_size, MatroskaTrack *track)
#define MATROSKA_ID_CHAPTERATOM
int av_lzo1x_decode(void *out, int *outlen, const void *in, int *inlen)
Decodes LZO 1x compressed data.
int32_t yaw
Rotation around the up vector [-180, 180].
#define AV_EF_EXPLODE
abort decoding on minor error detection
uint8_t * av_stream_new_side_data(AVStream *stream, enum AVPacketSideDataType type, int size)
Allocate new information from stream.
static const EbmlSyntax matroska_chapter[]
enum AVColorRange color_range
Video only.
Opaque data information usually sparse.
#define MATROSKA_ID_VIDEOCOLORSPACE
#define MATROSKA_ID_CHAPTERS
static int matroska_probe(AVProbeData *p)
static void mkv_stereo_mode_display_mul(int stereo_mode, int *h_width, int *h_height)
static void matroska_convert_tag(AVFormatContext *s, EbmlList *list, AVDictionary **metadata, char *prefix)
uint64_t max_block_additional_id
#define MATROSKA_ID_VIDEOCOLORCHROMASUBVERT
const uint8_t ff_log2_tab[256]
#define MATROSKA_ID_AUDIOSAMPLINGFREQ
#define FF_ARRAY_ELEMS(a)
#define MATROSKA_ID_TRACKMINCACHE
the normal 2^n-1 "JPEG" YUV ranges
static void matroska_metadata_creation_time(AVDictionary **metadata, int64_t date_utc)
static int matroska_parse_flac(AVFormatContext *s, MatroskaTrack *track, int *offset)
static int read_header(FFV1Context *f)
uint32_t padding
Number of pixels to pad from the edge of each cube face.
static int matroska_read_seek(AVFormatContext *s, int stream_index, int64_t timestamp, int flags)
static int matroska_parse_wavpack(MatroskaTrack *track, uint8_t *src, uint8_t **pdst, int *size)
#define AVERROR_PATCHWELCOME
Not yet implemented in FFmpeg, patches welcome.
#define MATROSKA_ID_TRACKPLANETYPE
static int read_packet(void *opaque, uint8_t *buf, int buf_size)
AVSphericalProjection
Projection of the video surface(s) on a sphere.
Content light level (based on CTA-861.3).
static const EbmlSyntax matroska_tags[]
#define AVIO_SEEKABLE_NORMAL
Seeking works like for a local file.
static const EbmlSyntax matroska_track_operation[]
static const EbmlSyntax matroska_cluster_incremental[]
int64_t current_cluster_pos
#define MATROSKA_ID_VIDEOPIXELCROPB
#define AV_LOG_INFO
Standard information.
#define MATROSKA_ID_VIDEOCOLORMATRIXCOEFF
static int matroska_parse_tracks(AVFormatContext *s)
int ff_get_qtpalette(int codec_id, AVIOContext *pb, uint32_t *palette)
Retrieve the palette (or "color table" in QuickTime terms), either from the video sample description...
char * av_strdup(const char *s)
Duplicate a string.
#define MATROSKA_ID_TRACKFLAGFORCED
#define MATROSKA_ID_VIDEOCOLORPRIMARIES
const AVCodecTag ff_codec_movaudio_tags[]
static int ebml_read_master(MatroskaDemuxContext *matroska, uint64_t length)
#define MATROSKA_ID_VIDEOPROJECTIONPOSEPITCH
#define MATROSKA_ID_TAGDEFAULT
#define MATROSKA_ID_SEEKID
static const EbmlSyntax matroska_track_encoding_compression[]
AVIOContext * pb
I/O context.
static const EbmlSyntax matroska_track[]
static AVRational av_make_q(int num, int den)
Create an AVRational.
uint64_t chroma_siting_horz
#define MATROSKA_ID_ENCODINGCOMPALGO
#define MATROSKA_ID_BLOCK
void av_packet_unref(AVPacket *pkt)
Wipe the packet.
#define MATROSKA_ID_TAGTARGETS_TRACKUID
uint8_t * data
The data buffer.
static const EbmlSyntax ebml_header[]
#define MATROSKA_ID_TAGLANG
#define MATROSKA_ID_TRACKCOMBINEPLANES
static const AVClass webm_dash_class
#define MATROSKA_ID_TRACKFLAGENABLED
#define MATROSKA_ID_TRACKS
#define MATROSKA_ID_TRACKPLANE
Data found in BlockAdditional element of matroska container.
#define MATROSKA_ID_VIDEOCOLORCHROMASUBHORZ
#define MATROSKA_ID_TRACKNAME
int av_dict_set(AVDictionary **pm, const char *key, const char *value, int flags)
Set the given entry in *pm, overwriting an existing entry.
#define MATROSKA_ID_SEEKENTRY
Describe the class of an AVClass context structure.
#define MATROSKA_ID_CHAPCOUNTRY
#define MATROSKA_ID_EDITIONENTRY
static const EbmlSyntax matroska_blockadditions[]
#define MATROSKA_ID_BLOCKGROUP
#define MATROSKA_ID_VIDEOPIXELHEIGHT
int32_t roll
Rotation around the forward vector [-180, 180].
Rational number (pair of numerator and denominator).
#define MATROSKA_ID_CUEDURATION
static int matroska_parse_laces(MatroskaDemuxContext *matroska, uint8_t **buf, int *buf_size, int type, uint32_t **lace_buf, int *laces)
#define MATROSKA_ID_CUETIME
#define AV_OPT_FLAG_DECODING_PARAM
a generic parameter which can be set by the user for demuxing or decoding
#define MATROSKA_ID_ENCODINGSIGALGO
static int matroska_read_packet(AVFormatContext *s, AVPacket *pkt)
Recommmends skipping the specified number of samples.
static int get_qt_codec(MatroskaTrack *track, uint32_t *fourcc, enum AVCodecID *codec_id)
static int ebml_parse(MatroskaDemuxContext *matroska, EbmlSyntax *syntax, void *data)
static av_always_inline void flac_parse_block_header(const uint8_t *block_header, int *last, int *type, int *size)
Parse the metadata block parameters from the header.
#define MATROSKA_ID_ENCODINGSIGKEYID
static int FUNC() sps(CodedBitstreamContext *ctx, RWContext *rw, H264RawSPS *current)
#define MATROSKA_ID_VIDEOCOLORTRANSFERCHARACTERISTICS
#define MATROSKA_ID_TITLE
#define MATROSKA_ID_TRACKVIDEO
static const EbmlSyntax matroska_attachments[]
This structure describes how to handle spherical videos, outlining information about projection...
int error
contains the error code or 0 if no error happened
static const EbmlSyntax matroska_clusters_incremental[]
This structure contains the data a format has to probe a file.
#define MATROSKA_ID_VIDEOPROJECTION
#define MATROSKA_ID_VIDEOCOLORMASTERINGMETA
static int ebml_parse_id(MatroskaDemuxContext *matroska, EbmlSyntax *syntax, uint32_t id, void *data)
size_t av_strlcat(char *dst, const char *src, size_t size)
Append the string src to the string dst, but to a total length of no more than size - 1 bytes...
static const EbmlSyntax matroska_cluster_incremental_parsing[]
#define MATROSKA_ID_VIDEOPROJECTIONPRIVATE
int seek_preroll
Audio only.
#define MATROSKA_ID_VIDEOFRAMERATE
static av_const int sign_extend(int val, unsigned bits)
#define MATROSKA_ID_ATTACHMENTS
void avpriv_report_missing_feature(void *avc, const char *msg,...) av_printf_format(2
Log a generic warning message about a missing feature.
static const EbmlSyntax matroska_chapter_display[]
#define MATROSKA_ID_TRACKOPERATION
#define flags(name, subs,...)
static const EbmlSyntax matroska_blockmore[]
#define MATROSKA_ID_CHAPTERDISPLAY
static const EbmlSyntax matroska_track_audio[]
MatroskaLevel1Element level1_elems[64]
#define MATROSKA_ID_FILENAME
#define MATROSKA_ID_BLOCKADDITIONAL
uint32_t bound_top
Distance from the top edge.
static int mkv_parse_video_projection(AVStream *st, const MatroskaTrack *track)
const int avpriv_mpeg4audio_sample_rates[16]
const AVMetadataConv ff_mkv_metadata_conv[]
static int mkv_field_order(MatroskaDemuxContext *matroska, int64_t field_order)
#define MATROSKA_ID_CODECID
#define MATROSKA_ID_VIDEOFIELDORDER
int sample_rate
Audio only.
#define MATROSKA_ID_VIDEOALPHAMODE
A reference to a data buffer.
void ff_rm_reorder_sipr_data(uint8_t *buf, int sub_packet_h, int framesize)
Perform 4-bit block reordering for SIPR data.
uint64_t_TMPL AV_WL64 unsigned int_TMPL AV_WL32 unsigned int_TMPL AV_WL24 unsigned int_TMPL AV_WL16 uint64_t_TMPL AV_RB64
#define MATROSKA_ID_ENCODINGENCAESSETTINGS
attribute_deprecated int64_t convergence_duration
#define MATROSKA_ID_CUETRACK
#define MATROSKA_ID_SEEKPOSITION
static int matroska_resync(MatroskaDemuxContext *matroska, int64_t last_pos)
#define MATROSKA_ID_CODECDELAY
#define FF_DISABLE_DEPRECATION_WARNINGS
#define MATROSKA_ID_CHAPTERTIMESTART
enum AVChromaLocation avcodec_chroma_pos_to_enum(int xpos, int ypos)
Converts swscale x/y chroma position to AVChromaLocation.
#define MATROSKA_ID_VIDEOCOLORRANGE
enum AVSphericalProjection projection
Projection type.
int ffio_init_context(AVIOContext *s, unsigned char *buffer, int buffer_size, int write_flag, void *opaque, int(*read_packet)(void *opaque, uint8_t *buf, int buf_size), int(*write_packet)(void *opaque, uint8_t *buf, int buf_size), int64_t(*seek)(void *opaque, int64_t offset, int whence))
static const EbmlSyntax matroska_seekhead[]
int av_dict_set_int(AVDictionary **pm, const char *key, int64_t value, int flags)
Convenience wrapper for av_dict_set that converts the value to a string and stores it...
int error_recognition
Error recognition; higher values will detect more errors but may misdetect some more or less valid pa...
int disposition
AV_DISPOSITION_* bit field.
AVBufferRef * av_buffer_ref(AVBufferRef *buf)
Create a new reference to an AVBuffer.
void av_init_packet(AVPacket *pkt)
Initialize optional fields of a packet with default values.
#define MATROSKA_ID_ENCODINGSIGNATURE
#define MATROSKA_ID_SEGMENT
The optional settings (rendering instructions) that immediately follow the timestamp specifier of a W...
#define MKBETAG(a, b, c, d)
#define AV_INPUT_BUFFER_PADDING_SIZE
Required number of additionally allocated bytes at the end of the input bitstream for decoding...
#define MATROSKA_ID_SEEKHEAD
static int matroska_parse_webvtt(MatroskaDemuxContext *matroska, MatroskaTrack *track, AVStream *st, uint8_t *data, int data_len, uint64_t timecode, uint64_t duration, int64_t pos)
int skip_to_keyframe
Indicates that everything up to the next keyframe should be discarded.
#define MATROSKA_ID_ENCODINGCOMPRESSION
#define MATROSKA_ID_CLUSTERPREVSIZE
int eof_reached
true if eof reached
#define FF_ENABLE_DEPRECATION_WARNINGS
#define MATROSKA_ID_POINTENTRY
#define MATROSKA_ID_FILEUID
static int matroska_parse_block(MatroskaDemuxContext *matroska, AVBufferRef *buf, uint8_t *data, int size, int64_t pos, uint64_t cluster_time, uint64_t block_duration, int is_keyframe, uint8_t *additional, uint64_t additional_id, int additional_size, int64_t cluster_pos, int64_t discard_padding)
#define MATROSKA_ID_VIDEOPIXELCROPL
static const EbmlSyntax matroska_index_pos[]
void * priv_data
Format private data.
#define MATROSKA_ID_CHAPTERUID
static const EbmlSyntax matroska_attachment[]
uint32_t bound_left
Distance from the left edge.
static int ebml_read_binary(AVIOContext *pb, int length, EbmlBin *bin)
int bits_per_coded_sample
The number of bits per sample in the codedwords.
uint8_t * extradata
Extra binary data needed for initializing the decoder, codec-dependent.
#define MATROSKA_ID_VIDEOCOLORMAXFALL
#define MATROSKA_ID_VIDEODISPLAYUNIT
static int ebml_read_uint(AVIOContext *pb, int size, uint64_t *num)
#define MATROSKA_ID_TRACKMAXBLKADDID
int64_t dts
Decompression timestamp in AVStream->time_base units; the time at which the packet is decompressed...
#define EBML_ID_EBMLMAXSIZELENGTH
int64_t duration
Duration of the stream, in AV_TIME_BASE fractional seconds.
MatroskaTrackEncryption encryption
#define MATROSKA_ID_CHAPSTRING
#define MATROSKA_ID_VIDEOCOLORCBSUBHORZ
#define MATROSKA_ID_TAGSTRING
static const AVOption options[]
const CodecMime ff_mkv_image_mime_tags[]
AVCodecParameters * codecpar
Codec parameters associated with this stream.
#define av_malloc_array(a, b)
int avio_feof(AVIOContext *s)
feof() equivalent for AVIOContext.
uint32_t codec_tag
Additional information about the codec (corresponds to the AVI FOURCC).
static int buffer_size_after_time_downloaded(int64_t time_ns, double search_sec, int64_t bps, double min_buffer, double *buffer, double *sec_to_download, AVFormatContext *s, int64_t cues_start)
uint64_t transfer_characteristics
static int ebml_read_float(AVIOContext *pb, int size, double *num)
#define MATROSKA_ID_DURATION
static int matroska_aac_profile(char *codec_id)
uint8_t * av_packet_new_side_data(AVPacket *pkt, enum AVPacketSideDataType type, int size)
Allocate new information of a packet.
static const EbmlSyntax matroska_track_encoding_encryption[]
#define EBML_ID_DOCTYPEVERSION
static void matroska_clear_queue(MatroskaDemuxContext *matroska)
AVRational time_base
This is the fundamental unit of time (in seconds) in terms of which frame timestamps are represented...
#define MKTAG(a, b, c, d)
enum AVDiscard discard
Selects which packets can be discarded at will and do not need to be demuxed.
AVRational r_frame_rate
Real base framerate of the stream.
#define MATROSKA_ID_ATTACHEDFILE
#define MATROSKA_ID_VIDEOCOLOR_GY
uint64_t_TMPL AV_WL64 unsigned int_TMPL AV_RL32
This structure stores compressed data.
unsigned MaxFALL
Max average light level per frame (cd/m^2).
#define MATROSKA_ID_CODECSTATE
uint64_t default_duration
static const EbmlSyntax matroska_tag[]
AVInputFormat ff_webm_dash_manifest_demuxer
#define MATROSKA_ID_VIDEOCOLOR_RY
#define MATROSKA_ID_CODECINFOURL
int64_t pts
Presentation timestamp in AVStream->time_base units; the time at which the decompressed packet will b...
#define MATROSKA_ID_VIDEOPIXELWIDTH
static void matroska_add_index_entries(MatroskaDemuxContext *matroska)
static int matroska_parse_frame(MatroskaDemuxContext *matroska, MatroskaTrack *track, AVStream *st, AVBufferRef *buf, uint8_t *data, int pkt_size, uint64_t timecode, uint64_t lace_duration, int64_t pos, int is_keyframe, uint8_t *additional, uint64_t additional_id, int additional_size, int64_t discard_padding)
AVPacket attached_pic
For streams with AV_DISPOSITION_ATTACHED_PIC disposition, this packet will contain the attached pictu...
#define MATROSKA_ID_TRACKAUDIO
#define AV_NOPTS_VALUE
Undefined timestamp value.
#define MATROSKA_ID_ENCODINGSCOPE
const CodecTags ff_mkv_codec_tags[]
#define MATROSKA_ID_ENCODINGENCKEYID
#define MATROSKA_ID_DISCARDPADDING
static int is_ebml_id_valid(uint32_t id)
uint32_t palette[AVPALETTE_COUNT]
static int64_t webm_dash_manifest_compute_bandwidth(AVFormatContext *s, int64_t cues_start)
static const char *const matroska_doctypes[]