mirror of
https://gitlab.freedesktop.org/gstreamer/gstreamer.git
synced 2024-11-25 11:11:08 +00:00
oggdemux: enhance flac packet duration calculation
This commit is contained in:
parent
fe970cb856
commit
8fb183c7c9
1 changed files with 26 additions and 1 deletions
|
@ -637,6 +637,31 @@ packet_duration_flac (GstOggStream * pad, ogg_packet * packet)
|
||||||
if (block_size_index >= 8) {
|
if (block_size_index >= 8) {
|
||||||
return 256 << (block_size_index - 8);
|
return 256 << (block_size_index - 8);
|
||||||
}
|
}
|
||||||
|
if (block_size_index == 6 || block_size_index == 7) {
|
||||||
|
guint len, bytes = (block_size_index - 6) + 1;
|
||||||
|
guint8 tmp;
|
||||||
|
|
||||||
|
if (packet->bytes < 4 + 1 + bytes)
|
||||||
|
return -1;
|
||||||
|
tmp = packet->packet[4];
|
||||||
|
/* utf-8 prefix */
|
||||||
|
len = 0;
|
||||||
|
while (tmp & 0x80) {
|
||||||
|
len++;
|
||||||
|
tmp <<= 1;
|
||||||
|
}
|
||||||
|
if (len == 2)
|
||||||
|
return -1;
|
||||||
|
if (len == 0)
|
||||||
|
len++;
|
||||||
|
if (packet->bytes < 4 + len + bytes)
|
||||||
|
return -1;
|
||||||
|
if (bytes == 1) {
|
||||||
|
return packet->packet[4 + len] + 1;
|
||||||
|
} else {
|
||||||
|
return GST_READ_UINT16_BE (packet->packet + 4 + len) + 1;
|
||||||
|
}
|
||||||
|
}
|
||||||
return -1;
|
return -1;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -1156,7 +1181,7 @@ static const GstOggMap mappers[] = {
|
||||||
NULL
|
NULL
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
"\177FLAC", 4, 36,
|
"\177FLAC", 5, 36,
|
||||||
"audio/x-flac",
|
"audio/x-flac",
|
||||||
setup_flac_mapper,
|
setup_flac_mapper,
|
||||||
granulepos_to_granule_default,
|
granulepos_to_granule_default,
|
||||||
|
|
Loading…
Reference in a new issue