diff options
author | Urs Fleisch <ufleisch@users.sourceforge.net> | 2020-12-06 19:55:25 +0100 |
---|---|---|
committer | Urs Fleisch <ufleisch@users.sourceforge.net> | 2020-12-22 15:46:48 +0100 |
commit | e4813f4996d788e0a4c5b8a6fd495b30eca24a9e (patch) | |
tree | cead5b6b3ee5e5164060366a706b2947d1d1662d /taglib/riff | |
parent | 30d839538d4330f63e9e21e26bcdfb331b802740 (diff) |
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.
Diffstat (limited to 'taglib/riff')
-rw-r--r-- | taglib/riff/wav/wavproperties.cpp | 7 |
1 files 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)); |