bitrate(0),
sampleRate(0),
sampleWidth(0),
- channels(0) {}
+ channels(0),
+ sampleFrames(0) {}
ByteVector data;
long streamLength;
int sampleRate;
int sampleWidth;
int channels;
+ unsigned long long sampleFrames;
ByteVector signature;
};
return d->channels;
}
+unsigned long long FLAC::Properties::sampleFrames() const
+{
+ return d->sampleFrames;
+}
+
ByteVector FLAC::Properties::signature() const
{
return d->signature;
pos += 3;
uint flags = d->data.mid(pos, 4).toUInt(true);
+ pos += 4;
+
d->sampleRate = flags >> 12;
d->channels = ((flags >> 9) & 7) + 1;
d->sampleWidth = ((flags >> 4) & 31) + 1;
// 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 =d->sampleRate > 0 ? (((flags & 0xf) << 28) / d->sampleRate) << 4 : 0;
+ unsigned long long hi = flags & 0xf;
+ unsigned long long lo = d->data.mid(pos, 4).toUInt(true);
pos += 4;
- d->length = d->sampleRate > 0 ?
- (d->data.mid(pos, 4).toUInt(true)) / d->sampleRate + highLength : 0;
- pos += 4;
+ d->sampleFrames = (hi << 32) | lo;
+
+ if(d->sampleRate > 0)
+ d->length = int(d->sampleFrames / d->sampleRate);
// Uncompressed bitrate:
*/
int sampleWidth() const;
+ /*!
+ * Return the number of sample frames
+ */
+ unsigned long long sampleFrames() const;
+
/*!
* Returns the MD5 signature of the uncompressed audio stream as read
* from the stream info header header.