mirror of
https://github.com/taglib/taglib.git
synced 2025-06-04 01:28:21 -04:00
Calculate bitrate for IEEE Float WAV files without fact chunk (#959)
When a WAV file with float format without a fact chunk containing a totalSamples value is encountered, the bitrate is not calculated. However, since all samples have the same number of bits, the number of samples can be calculated from the size of the data chunk and number of channels and bits per sample, as it is done in the PCM case.
This commit is contained in:
parent
30d839538d
commit
e4813f4996
@ -35,7 +35,8 @@ namespace
|
||||
enum WaveFormat
|
||||
{
|
||||
FORMAT_UNKNOWN = 0x0000,
|
||||
FORMAT_PCM = 0x0001
|
||||
FORMAT_PCM = 0x0001,
|
||||
FORMAT_IEEE_FLOAT = 0x0003
|
||||
};
|
||||
}
|
||||
|
||||
@ -183,7 +184,7 @@ void RIFF::WAV::Properties::read(File *file)
|
||||
}
|
||||
|
||||
d->format = data.toShort(0, false);
|
||||
if(d->format != FORMAT_PCM && totalSamples == 0) {
|
||||
if(d->format != FORMAT_PCM && d->format != FORMAT_IEEE_FLOAT && totalSamples == 0) {
|
||||
debug("RIFF::WAV::Properties::read() - Non-PCM format, but 'fact' chunk not found.");
|
||||
return;
|
||||
}
|
||||
@ -192,7 +193,7 @@ void RIFF::WAV::Properties::read(File *file)
|
||||
d->sampleRate = data.toUInt(4, false);
|
||||
d->bitsPerSample = data.toShort(14, false);
|
||||
|
||||
if(d->format != FORMAT_PCM)
|
||||
if(d->format != FORMAT_PCM && !(d->format == FORMAT_IEEE_FLOAT && totalSamples == 0))
|
||||
d->sampleFrames = totalSamples;
|
||||
else if(d->channels > 0 && d->bitsPerSample > 0)
|
||||
d->sampleFrames = streamLength / (d->channels * ((d->bitsPerSample + 7) / 8));
|
||||
|
Loading…
x
Reference in New Issue
Block a user