Skip to content

Instantly share code, notes, and snippets.

@nirslsk
Created January 29, 2015 20:44
Show Gist options
  • Save nirslsk/b4f28409c9ea1aa3c14b to your computer and use it in GitHub Desktop.
Save nirslsk/b4f28409c9ea1aa3c14b to your computer and use it in GitHub Desktop.
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