Bug 1133478: Postpone parsing TRUN atom until we have all dependent atoms. r=k17e
authorJean-Yves Avenard <jyavenard@mozilla.com>
Tue, 17 Feb 2015 16:22:52 +1300
changeset 229428 9bb4736948d2
parent 229427 4c294d64d19f
child 229429 355f5e2dee58
push id28287
push userryanvm@gmail.com
push dateTue, 17 Feb 2015 20:08:22 +0000
treeherdermozilla-central@b6c56fab513d [default view] [failures only]
perfherder[talos] [build metrics] [platform microbench] (compared to previous push)
reviewersk17e
bugs1133478
milestone38.0a1
first release with
nightly linux32
nightly linux64
nightly mac
nightly win32
nightly win64
last release without
nightly linux32
nightly linux64
nightly mac
nightly win32
nightly win64
Bug 1133478: Postpone parsing TRUN atom until we have all dependent atoms. r=k17e Atoms may be out of order inside MOOF, in particular the TFDT may only be defined after TRUN.
media/libstagefright/binding/MoofParser.cpp
--- a/media/libstagefright/binding/MoofParser.cpp
+++ b/media/libstagefright/binding/MoofParser.cpp
@@ -296,25 +296,35 @@ Moof::ParseTraf(Box& aBox, Trex& aTrex, 
   Tfhd tfhd(aTrex);
   Tfdt tfdt;
   for (Box box = aBox.FirstChild(); box.IsAvailable(); box = box.Next()) {
     if (box.IsType("tfhd")) {
       tfhd = Tfhd(box, aTrex);
     } else if (!aTrex.mTrackId || tfhd.mTrackId == aTrex.mTrackId) {
       if (box.IsType("tfdt")) {
         tfdt = Tfdt(box);
-      } else if (box.IsType("trun")) {
-        ParseTrun(box, tfhd, tfdt, aMdhd, aEdts);
       } else if (box.IsType("saiz")) {
         mSaizs.AppendElement(Saiz(box, aSinf.mDefaultEncryptionType));
       } else if (box.IsType("saio")) {
         mSaios.AppendElement(Saio(box, aSinf.mDefaultEncryptionType));
       }
     }
   }
+  if (aTrex.mTrackId && tfhd.mTrackId != aTrex.mTrackId) {
+    return;
+  }
+  // Now search for TRUN box.
+  for (Box box = aBox.FirstChild(); box.IsAvailable(); box = box.Next()) {
+    if (box.IsType("trun")) {
+      ParseTrun(box, tfhd, tfdt, aMdhd, aEdts);
+      if (IsValid()) {
+        break;
+      }
+    }
+  }
 }
 
 void
 Moof::FixRounding(const Moof& aMoof) {
   Microseconds gap = aMoof.mTimeRange.start - mTimeRange.end;
   if (gap > 0 && gap <= mMaxRoundingError) {
     mTimeRange.end = aMoof.mTimeRange.start;
   }