From e4813f4996d788e0a4c5b8a6fd495b30eca24a9e Mon Sep 17 00:00:00 2001 From: Urs Fleisch Date: Sun, 6 Dec 2020 19:55:25 +0100 Subject: [PATCH] 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. --- taglib/riff/wav/wavproperties.cpp | 7 ++++--- 1 file changed, 4 insertions(+), 3 deletions(-) diff --git a/taglib/riff/wav/wavproperties.cpp b/taglib/riff/wav/wavproperties.cpp index 181e3a6c..64ce78eb 100644 --- a/taglib/riff/wav/wavproperties.cpp +++ b/taglib/riff/wav/wavproperties.cpp @@ -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));