Bug 1133572 - Remove duplication of logic from GetNextKeyframeTime(); r=cpearce a=lmandel
authorAnthony Jones <ajones@mozilla.com>
Wed, 18 Feb 2015 19:13:14 +1300
changeset 250281 8492532adb28
parent 250280 1a9d0193519a
child 250282 22f8facc4114
push id4535
push usercpearce@mozilla.com
push date2015-03-06 20:57 +0000
treeherdermozilla-beta@68707623b5a3 [default view] [failures only]
perfherder[talos] [build metrics] [platform microbench] (compared to previous push)
reviewerscpearce, lmandel
bugs1133572
milestone37.0
Bug 1133572 - Remove duplication of logic from GetNextKeyframeTime(); r=cpearce a=lmandel
media/libstagefright/binding/Index.cpp
--- a/media/libstagefright/binding/Index.cpp
+++ b/media/libstagefright/binding/Index.cpp
@@ -205,36 +205,25 @@ void SampleIterator::Seek(Microseconds a
   }
   mCurrentMoof = syncMoof;
   mCurrentSample = syncSample;
 }
 
 Microseconds
 SampleIterator::GetNextKeyframeTime()
 {
-  nsTArray<Moof>& moofs = mIndex->mMoofParser->Moofs();
-  size_t sample = mCurrentSample + 1;
-  size_t moof = mCurrentMoof;
-  while (true) {
-    while (true) {
-      if (moof == moofs.Length()) {
-        return -1;
-      }
-      if (sample < moofs[moof].mIndex.Length()) {
-        break;
-      }
-      sample = 0;
-      ++moof;
+  SampleIterator itr(*this);
+  Sample* sample;
+  while (!!(sample = itr.Get())) {
+    if (sample->mSync) {
+      return sample->mCompositionRange.start;
     }
-    if (moofs[moof].mIndex[sample].mSync) {
-      return moofs[moof].mIndex[sample].mDecodeTime;
-    }
-    ++sample;
+    itr.Next();
   }
-  MOZ_ASSERT(false); // should not be reached.
+  return -1;
 }
 
 Index::Index(const stagefright::Vector<MediaSource::Indice>& aIndex,
              Stream* aSource, uint32_t aTrackId, Monitor* aMonitor)
   : mSource(aSource)
   , mMonitor(aMonitor)
 {
   if (aIndex.isEmpty()) {