return"parsing "+idToString()+" atom at "+numberToString(startOffset());
}
/*!
*\briefParsestheMP4atom.
*/
voidMp4Atom::internalParse()
{
invalidateStatus();
staticconststringcontext("parsing MP4 atom");
if(maxTotalSize()<8){
addNotification(NotificationType::Critical,"Atom is smaller then 8 byte and hence invalid. The maximum size within the parent atom is "+numberToString(maxTotalSize())+".",context);
throwTruncatedDataException();
}
stream().seekg(startOffset());
m_dataSize=reader().readUInt32BE();
if(m_dataSize==0){
// atom size extends to rest of the file/enclosing container
m_dataSize=maxTotalSize();
}
if(!m_dataSize){
addNotification(NotificationType::Critical,"No data found (only null bytes).",context);
throwNoDataFoundException();
}
if(m_dataSize<8&&m_dataSize!=1){
addNotification(NotificationType::Critical,"Atom is smaller then 8 byte and hence invalid.",context);
throwTruncatedDataException();
}
m_id=reader().readUInt32BE();
m_idLength=4;
if(dataSize()==1){// mp4 atom denotes 64 bit size
m_dataSize=reader().readUInt64BE();
m_sizeLength=12;// 4 bytes indicate long size denotation + 8 bytes for actual size denotation
if(dataSize()<16&&m_dataSize!=1){
addNotification(NotificationType::Critical,"Atom denoting 64-bit size is smaller then 16 byte and hence invalid.",parsingContext());
throwTruncatedDataException();
}
}else{
m_sizeLength=4;
}
if(maxTotalSize()<m_dataSize){// currently m_dataSize holds data size plus header size!
addNotification(NotificationType::Warning,"The atom seems to be truncated; unable to parse siblings of that ",parsingContext());
m_dataSize=maxTotalSize();// using max size instead
}
// currently m_dataSize holds data size plus header size!