MP4Mp4vAtom::MP4Mp4vAtom(MP4File &file) : MP4Atom(file, "mp4v") { AddReserved(*this, "reserved1", 6); /* 0 */ AddProperty( /* 1 */ new MP4Integer16Property(*this, "dataReferenceIndex")); AddReserved(*this, "reserved2", 16); /* 2 */ AddProperty( /* 3 */ new MP4Integer16Property(*this, "width")); AddProperty( /* 4 */ new MP4Integer16Property(*this, "height")); AddReserved(*this, "reserved3", 14); /* 5 */ MP4StringProperty* pProp = new MP4StringProperty(*this, "compressorName"); pProp->SetFixedLength(32); pProp->SetCountedFormat(true); pProp->SetValue(""); AddProperty(pProp); /* 6 */ AddReserved(*this, "reserved4", 4); /* 7 */ ExpectChildAtom("colr", Optional, OnlyOne); ExpectChildAtom("esds", Required, OnlyOne); ExpectChildAtom("pasp", Optional, OnlyOne); }
MP4VideoAtom::MP4VideoAtom (const char *type) : MP4Atom(type) { AddReserved("reserved1", 6); /* 0 */ AddProperty( /* 1 */ new MP4Integer16Property("dataReferenceIndex")); AddReserved("reserved2", 16); /* 2 */ AddProperty( /* 3 */ new MP4Integer16Property("width")); AddProperty( /* 4 */ new MP4Integer16Property("height")); AddReserved("reserved3", 14); /* 5 */ MP4StringProperty* pProp = new MP4StringProperty("compressorName"); pProp->SetFixedLength(32); pProp->SetCountedFormat(true); pProp->SetValue(""); AddProperty(pProp); /* 6 */ AddProperty(/* 7 */ new MP4Integer16Property("depth")); AddProperty(/* 8 */ new MP4Integer16Property("colorTableId")); ExpectChildAtom("smi ", Optional, OnlyOne); }
// There is a spec incompatiblity between QT and MP4 // QT says name field is a counted string // MP4 says name field is a null terminated string // Here we attempt to make all things work void MP4HdlrAtom::Read() { // read all the properties but the "name" field ReadProperties(0, 5); // take a peek at the next byte u_int8_t strLength; m_pFile->PeekBytes(&strLength, 1); // if the value matches the remaining atom length if (m_pFile->GetPosition() + strLength + 1 == GetEnd()) { // read a counted string MP4StringProperty* pNameProp = (MP4StringProperty*)m_pProperties[5]; pNameProp->SetCountedFormat(true); ReadProperties(5); pNameProp->SetCountedFormat(false); } else { // read a null terminated string ReadProperties(5); } Skip(); // to end of atom }