Bug 1235427: [mp4] Properly parse tfhd box. r=jya

This commit is contained in:
Rudolfs Bundulis 2016-02-05 15:45:14 +11:00 committed by Jean-Yves Avenard
parent b32a205f1f
commit 91ff19af88

View File

@ -693,9 +693,10 @@ Tfhd::Tfhd(Box& aBox, Trex& aTrex)
mFlags = reader->ReadU32();
size_t need = sizeof(uint32_t) /* trackid */;
uint8_t flag[] = { 1, 2, 8, 0x10, 0x20, 0 };
uint8_t flagSize[] = { sizeof(uint64_t), sizeof(uint32_t), sizeof(uint32_t), sizeof(uint32_t), sizeof(uint32_t) };
for (size_t i = 0; flag[i]; i++) {
if (mFlags & flag[i]) {
need += sizeof(uint32_t);
need += flagSize[i];
}
}
if (reader->Remaining() < need) {
@ -703,9 +704,9 @@ Tfhd::Tfhd(Box& aBox, Trex& aTrex)
(uint64_t)reader->Remaining(), (uint64_t)need);
return;
}
mBaseDataOffset =
mFlags & 1 ? reader->ReadU32() : aBox.Parent()->Parent()->Offset();
mTrackId = reader->ReadU32();
mBaseDataOffset =
mFlags & 1 ? reader->ReadU64() : aBox.Parent()->Parent()->Offset();
if (mFlags & 2) {
mDefaultSampleDescriptionIndex = reader->ReadU32();
}