Update taglib

This commit is contained in:
Jonas Kvinge 2019-09-11 00:36:03 +02:00
parent c66c1e17d3
commit 9fb50b8a73
5 changed files with 36 additions and 7 deletions

View File

@ -163,8 +163,14 @@ void Opus::Properties::read(File *file)
if(frameCount > 0) {
const double length = frameCount * 1000.0 / 48000.0;
long fileLengthWithoutOverhead = file->length();
// Ignore the two mandatory header packets, see "3. Packet Organization"
// in https://tools.ietf.org/html/rfc7845.html
for (unsigned int i = 0; i < 2; ++i) {
fileLengthWithoutOverhead -= file->packet(i).size();
}
d->length = static_cast<int>(length + 0.5);
d->bitrate = static_cast<int>(file->length() * 8.0 / length + 0.5);
d->bitrate = static_cast<int>(fileLengthWithoutOverhead * 8.0 / length + 0.5);
}
}
else {

View File

@ -131,6 +131,7 @@ void Speex::File::read(bool readProperties)
if(!speexHeaderData.startsWith("Speex ")) {
debug("Speex::File::read() -- invalid Speex identification header");
setValid(false);
return;
}

View File

@ -182,8 +182,14 @@ void Speex::Properties::read(File *file)
if(frameCount > 0) {
const double length = frameCount * 1000.0 / d->sampleRate;
long fileLengthWithoutOverhead = file->length();
// Ignore the two header packets, see "Ogg file format" in
// https://www.speex.org/docs/manual/speex-manual/node8.html
for (unsigned int i = 0; i < 2; ++i) {
fileLengthWithoutOverhead -= file->packet(i).size();
}
d->length = static_cast<int>(length + 0.5);
d->bitrate = static_cast<int>(file->length() * 8.0 / length + 0.5);
d->bitrate = static_cast<int>(fileLengthWithoutOverhead * 8.0 / length + 0.5);
}
}
else {

View File

@ -188,9 +188,14 @@ void Vorbis::Properties::read(File *file)
if(frameCount > 0) {
const double length = frameCount * 1000.0 / d->sampleRate;
long fileLengthWithoutOverhead = file->length();
// Ignore the three initial header packets, see "1.3.1. Decode Setup" in
// https://xiph.org/vorbis/doc/Vorbis_I_spec.html
for (unsigned int i = 0; i < 3; ++i) {
fileLengthWithoutOverhead -= file->packet(i).size();
}
d->length = static_cast<int>(length + 0.5);
d->bitrate = static_cast<int>(file->length() * 8.0 / length + 0.5);
d->bitrate = static_cast<int>(fileLengthWithoutOverhead * 8.0 / length + 0.5);
}
}
else {

View File

@ -325,9 +325,20 @@ void RIFF::File::read()
if(offset & 1) {
seek(offset);
const ByteVector iByte = readBlock(1);
if(iByte.size() == 1 && iByte[0] == '\0') {
chunk.padding = 1;
offset++;
if(iByte.size() == 1) {
bool skipPadding = iByte[0] == '\0';
if(!skipPadding) {
// Padding byte is not zero, check if it is good to ignore it
const ByteVector fourCcAfterPadding = readBlock(4);
if(isValidChunkName(fourCcAfterPadding)) {
// Use the padding, it is followed by a valid chunk name.
skipPadding = true;
}
}
if(skipPadding) {
chunk.padding = 1;
offset++;
}
}
}