Skip to content

Instantly share code, notes, and snippets.

Embed
What would you like to do?
void MPEG::XingHeader::parse(const ByteVector &data)
{
// Check to see if a valid Xing header is available.
if(!data.startsWith("Xing") && !data.startsWith("Info"))
return;
// If the XingHeader doesn't contain the number of frames and the total stream
// info it's invalid.
d->valid = true;
unsigned int qualityOffset = 8;
if(data[7] & 0x01)
qualityOffset += 4;
else
d->valid = false;
if(data[7] & 0x02)
qualityOffset += 4;
else
d->valid = false;
if(data[7] & 0x04)
qualityOffset += 100;
if (d->valid) {
d->frames = data.toUInt(8U);
d->size = data.toUInt(12U);
}
if(data[7] & 0x08) {
d->hasQuality = true;
d->quality = data.toUInt(qualityOffset);
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment