// The last 4 bits are the most significant 4 bits for the 36 bit
// stream length in samples. (Audio files measured in days)
- uint highLength = (((flags & 0xf) << 28) / d->sampleRate) << 4;
+ uint highLength =d->sampleRate > 0 ? (((flags & 0xf) << 28) / d->sampleRate) << 4 : 0;
pos += 4;
- d->length = (d->data.mid(pos, 4).toUInt(true)) / d->sampleRate + highLength;
+ d->length = d->sampleRate > 0 ?
+ (d->data.mid(pos, 4).toUInt(true)) / d->sampleRate + highLength : 0;
pos += 4;
// Uncompressed bitrate:
// Real bitrate:
- if(d->length)
- d->bitrate = ((d->streamLength * 8L) / d->length) / 1000;
- else
- d->bitrate = 0;
-
+ d->bitrate = d->length > 0 ? ((d->streamLength * 8L) / d->length) / 1000 : 0;
}
}
unsigned int samples = frames * 1152 - 576;
- d->length = (samples + (d->sampleRate / 2)) / d->sampleRate;
+ d->length = d->sampleRate > 0 ? (samples + (d->sampleRate / 2)) / d->sampleRate : 0;
if(!d->bitrate)
- d->bitrate = ((d->streamLength * 8L) / d->length) / 1000;
+ d->bitrate = d->length > 0 ? ((d->streamLength * 8L) / d->length) / 1000 : 0;
}
static const int blockSize[] = { 0, 384, 1152, 1152 };
double timePerFrame = blockSize[firstHeader.layer()];
- timePerFrame = timePerFrame / firstHeader.sampleRate();
+ timePerFrame = firstHeader.sampleRate() > 0 ? timePerFrame / firstHeader.sampleRate() : 0;
d->length = int(timePerFrame * xingHeader.totalFrames());
- d->bitrate = d->length == 0 ? 0 : xingHeader.totalSize() * 8 / d->length / 1000;
+ d->bitrate = d->length > 0 ? xingHeader.totalSize() * 8 / d->length / 1000 : 0;
}
// Since there was no valid Xing header found, we hope that we're in a constant
* information specific to Ogg FLAC files.
*/
- class File : public TagLib::Ogg::File
+ class File : public Ogg::File
{
public:
/*!