Bug 1389304 - Don't include samples that won't be demuxed in range calculation. r=kikuo
authorJean-Yves Avenard <jyavenard@mozilla.com>
Tue, 19 Sep 2017 09:11:26 +0200
changeset 381651 a766b936e0b14bc59303f39943579156e5a2f4d6
parent 381650 5bce0c884d7af72c4c3b9a463b17fceee7a2a8ab
child 381652 ea4c53366f8dbedbe1c8d4bf717c6cfc9c09e591
push id32535
push userkwierso@gmail.com
push dateTue, 19 Sep 2017 21:06:08 +0000
treeherdermozilla-central@c0d1f9eb2a40 [default view] [failures only]
perfherder[talos] [build metrics] [platform microbench] (compared to previous push)
reviewerskikuo
bugs1389304
milestone57.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 1389304 - Don't include samples that won't be demuxed in range calculation. r=kikuo Invalid samples with empty content won't ever be demuxed. As such they can't participate in buffered range calculations. MozReview-Commit-ID: 9LPhyKKMSyM
media/libstagefright/binding/MoofParser.cpp
--- a/media/libstagefright/binding/MoofParser.cpp
+++ b/media/libstagefright/binding/MoofParser.cpp
@@ -671,35 +671,37 @@ Moof::ParseTrun(Box& aBox, Tfhd& aTfhd, 
     uint32_t sampleFlags =
       flags & 0x400 ? reader->ReadU32()
                     : i ? aTfhd.mDefaultSampleFlags : firstSampleFlags;
     int32_t ctsOffset = 0;
     if (flags & 0x800) {
       ctsOffset = reader->Read32();
     }
 
-    Sample sample;
-    sample.mByteRange = MediaByteRange(offset, offset + sampleSize);
-    offset += sampleSize;
+    if (sampleSize) {
+      Sample sample;
+      sample.mByteRange = MediaByteRange(offset, offset + sampleSize);
+      offset += sampleSize;
 
-    sample.mDecodeTime =
-      aMdhd.ToMicroseconds((int64_t)decodeTime - aEdts.mMediaStart) + aMvhd.ToMicroseconds(aEdts.mEmptyOffset);
-    sample.mCompositionRange = Interval<Microseconds>(
-      aMdhd.ToMicroseconds((int64_t)decodeTime + ctsOffset - aEdts.mMediaStart) + aMvhd.ToMicroseconds(aEdts.mEmptyOffset),
-      aMdhd.ToMicroseconds((int64_t)decodeTime + ctsOffset + sampleDuration - aEdts.mMediaStart) + aMvhd.ToMicroseconds(aEdts.mEmptyOffset));
+      sample.mDecodeTime =
+        aMdhd.ToMicroseconds((int64_t)decodeTime - aEdts.mMediaStart) + aMvhd.ToMicroseconds(aEdts.mEmptyOffset);
+      sample.mCompositionRange = Interval<Microseconds>(
+        aMdhd.ToMicroseconds((int64_t)decodeTime + ctsOffset - aEdts.mMediaStart) + aMvhd.ToMicroseconds(aEdts.mEmptyOffset),
+        aMdhd.ToMicroseconds((int64_t)decodeTime + ctsOffset + sampleDuration - aEdts.mMediaStart) + aMvhd.ToMicroseconds(aEdts.mEmptyOffset));
+
+      // Sometimes audio streams don't properly mark their samples as keyframes,
+      // because every audio sample is a keyframe.
+      sample.mSync = !(sampleFlags & 0x1010000) || aIsAudio;
+
+      // FIXME: Make this infallible after bug 968520 is done.
+      MOZ_ALWAYS_TRUE(mIndex.AppendElement(sample, fallible));
+
+      mMdatRange = mMdatRange.Span(sample.mByteRange);
+    }
     decodeTime += sampleDuration;
-
-    // Sometimes audio streams don't properly mark their samples as keyframes,
-    // because every audio sample is a keyframe.
-    sample.mSync = !(sampleFlags & 0x1010000) || aIsAudio;
-
-    // FIXME: Make this infallible after bug 968520 is done.
-    MOZ_ALWAYS_TRUE(mIndex.AppendElement(sample, fallible));
-
-    mMdatRange = mMdatRange.Span(sample.mByteRange);
   }
   mMaxRoundingError += aMdhd.ToMicroseconds(sampleCount);
 
   *aDecodeTime = decodeTime;
 
   return true;
 }