Created
January 29, 2015 20:44
-
-
Save nirslsk/b4f28409c9ea1aa3c14b to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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