Bug 1531839 - Don't assume that MP4 blocks are in pts order. r=gerald
authorJean-Yves Avenard <jyavenard@mozilla.com>
Sat, 02 Mar 2019 07:36:55 +0000
changeset 520017 52fc794e22ee068c2444682cc3329aec53001a53
parent 520016 06b992be418341f5eb3051405826a812dc4a5b27
child 520018 5f699370c77528d0d84c45b11b41661df1a48bc2
push id10862
push userffxbld-merge
push dateMon, 11 Mar 2019 13:01:11 +0000
treeherdermozilla-beta@a2e7f5c935da [default view] [failures only]
perfherder[talos] [build metrics] [platform microbench] (compared to previous push)
reviewersgerald
bugs1531839, 1531241
milestone67.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 1531839 - Don't assume that MP4 blocks are in pts order. r=gerald It usually is, but obviously, not always. Include reversal of bug 1531241. Differential Revision: https://phabricator.services.mozilla.com/D21823
dom/media/mp4/Index.cpp
--- a/dom/media/mp4/Index.cpp
+++ b/dom/media/mp4/Index.cpp
@@ -404,20 +404,16 @@ Index::Index(const IndiceWrapper& aIndic
         return;
       }
       if (indice.sync || mIsAudio) {
         haveSync = true;
       }
       if (!haveSync) {
         continue;
       }
-      if (indice.start_composition == indice.end_composition) {
-        // Ignore this sample as it doesn't account for the buffered range.
-        continue;
-      }
       Sample sample;
       sample.mByteRange =
           MediaByteRange(indice.start_offset, indice.end_offset);
       sample.mCompositionRange = MP4Interval<Microseconds>(
           indice.start_composition, indice.end_composition);
       sample.mDecodeTime = indice.start_decode;
       sample.mSync = indice.sync || mIsAudio;
       // FIXME: Make this infallible after bug 968520 is done.
@@ -556,19 +552,21 @@ TimeIntervals Index::ConvertByteRangesTo
           if (range.ContainsStrict(mIndex[i].mByteRange)) {
             timeRanges += TimeInterval(
                 TimeUnit::FromMicroseconds(mIndex[i].mCompositionRange.start),
                 TimeUnit::FromMicroseconds(mIndex[i].mCompositionRange.end));
           }
         }
       }
       if (end > start) {
-        timeRanges += TimeInterval(
-            TimeUnit::FromMicroseconds(mDataOffset[start].mTime.start),
-            TimeUnit::FromMicroseconds(mDataOffset[end - 1].mTime.end));
+        for (uint32_t i = start; i < end; i++) {
+          timeRanges += TimeInterval(
+              TimeUnit::FromMicroseconds(mDataOffset[i].mTime.start),
+              TimeUnit::FromMicroseconds(mDataOffset[i].mTime.end));
+        }
       }
       if (end < mDataOffset.Length()) {
         // Find samples in partial block contained in the byte range.
         for (size_t i = mDataOffset[end].mIndex;
              i < mIndex.Length() && range.ContainsStrict(mIndex[i].mByteRange);
              i++) {
           timeRanges += TimeInterval(
               TimeUnit::FromMicroseconds(mIndex[i].mCompositionRange.start),