mirror of
https://github.com/taglib/taglib.git
synced 2025-06-04 01:28:21 -04:00
Check if the header is TTA1 before parsing
This commit is contained in:
parent
dc628204c0
commit
fa662a23db
@ -125,19 +125,26 @@ void TrueAudio::Properties::read()
|
||||
int pos = 3;
|
||||
|
||||
d->version = d->data[pos] - '0';
|
||||
pos += 1 + 2;
|
||||
pos += 1;
|
||||
|
||||
d->channels = d->data.mid(pos, 2).toShort(false);
|
||||
pos += 2;
|
||||
// According to http://en.true-audio.com/TTA_Lossless_Audio_Codec_-_Format_Description
|
||||
// TTA2 headers are in development, and have a different format
|
||||
if(1 == d->version) {
|
||||
// Skip the audio format
|
||||
pos += 2;
|
||||
|
||||
d->bitsPerSample = d->data.mid(pos, 2).toShort(false);
|
||||
pos += 2;
|
||||
d->channels = d->data.mid(pos, 2).toShort(false);
|
||||
pos += 2;
|
||||
|
||||
d->sampleRate = d->data.mid(pos, 4).toUInt(false);
|
||||
pos += 4;
|
||||
d->bitsPerSample = d->data.mid(pos, 2).toShort(false);
|
||||
pos += 2;
|
||||
|
||||
d->sampleFrames = d->data.mid(pos, 4).toUInt(false);
|
||||
d->length = d->sampleFrames / d->sampleRate;
|
||||
d->sampleRate = d->data.mid(pos, 4).toUInt(false);
|
||||
pos += 4;
|
||||
|
||||
d->bitrate = d->length > 0 ? ((d->streamLength * 8L) / d->length) / 1000 : 0;
|
||||
d->sampleFrames = d->data.mid(pos, 4).toUInt(false);
|
||||
d->length = d->sampleFrames / d->sampleRate;
|
||||
|
||||
d->bitrate = d->length > 0 ? ((d->streamLength * 8L) / d->length) / 1000 : 0;
|
||||
}
|
||||
}
|
||||
|
Loading…
x
Reference in New Issue
Block a user