Bug 1207021: [mp4] Properly set dts on plain mp4 media. r=edwin a=lizzard
authorJean-Yves Avenard <jyavenard@mozilla.com>
Tue, 22 Sep 2015 14:37:58 +1000
changeset 296463 b7ebe44d84c5b3bd63bd2d37f37f05566cb74ced
parent 296462 702f9f75086944f21ce4e4ed58c17d27b3f97fa5
child 296464 83842b8ca1e39ab5c244d1fc809d0796c2d3c18c
push id5245
push userraliiev@mozilla.com
push dateThu, 29 Oct 2015 11:30:51 +0000
treeherdermozilla-beta@dac831dc1bd0 [default view] [failures only]
perfherder[talos] [build metrics] [platform microbench] (compared to previous push)
reviewersedwin, lizzard
bugs1207021
milestone43.0a2
Bug 1207021: [mp4] Properly set dts on plain mp4 media. r=edwin a=lizzard
media/libstagefright/binding/Index.cpp
media/libstagefright/binding/MP4Metadata.cpp
media/libstagefright/binding/include/mp4_demuxer/Index.h
media/libstagefright/frameworks/av/include/media/stagefright/MediaSource.h
media/libstagefright/frameworks/av/media/libstagefright/MPEG4Extractor.cpp
--- a/media/libstagefright/binding/Index.cpp
+++ b/media/libstagefright/binding/Index.cpp
@@ -250,16 +250,17 @@ Index::Index(const nsTArray<Indice>& aIn
     }
     for (size_t i = 0; i < aIndex.Length(); i++) {
       const Indice& indice = aIndex[i];
       Sample sample;
       sample.mByteRange = MediaByteRange(indice.start_offset,
                                          indice.end_offset);
       sample.mCompositionRange = Interval<Microseconds>(indice.start_composition,
                                                         indice.end_composition);
+      sample.mDecodeTime = indice.start_decode;
       sample.mSync = indice.sync;
       // FIXME: Make this infallible after bug 968520 is done.
       MOZ_ALWAYS_TRUE(mIndex.AppendElement(sample, fallible));
     }
   }
 }
 
 Index::~Index() {}
--- a/media/libstagefright/binding/MP4Metadata.cpp
+++ b/media/libstagefright/binding/MP4Metadata.cpp
@@ -76,16 +76,17 @@ ConvertIndex(FallibleTArray<Index::Indic
   }
   for (size_t i = 0; i < aIndex.Length(); i++) {
     Index::Indice indice;
     const stagefright::MediaSource::Indice& s_indice = aIndex[i];
     indice.start_offset = s_indice.start_offset;
     indice.end_offset = s_indice.end_offset;
     indice.start_composition = s_indice.start_composition - aMediaTime;
     indice.end_composition = s_indice.end_composition - aMediaTime;
+    indice.start_decode = s_indice.start_decode;
     indice.sync = s_indice.sync;
     // FIXME: Make this infallible after bug 968520 is done.
     MOZ_ALWAYS_TRUE(aDest.AppendElement(indice, mozilla::fallible));
   }
   return true;
 }
 
 MP4Metadata::MP4Metadata(Stream* aSource)
--- a/media/libstagefright/binding/include/mp4_demuxer/Index.h
+++ b/media/libstagefright/binding/include/mp4_demuxer/Index.h
@@ -46,16 +46,17 @@ public:
   NS_INLINE_DECL_THREADSAFE_REFCOUNTING(Index)
 
   struct Indice
   {
     uint64_t start_offset;
     uint64_t end_offset;
     uint64_t start_composition;
     uint64_t end_composition;
+    uint64_t start_decode;
     bool sync;
   };
 
   Index(const nsTArray<Indice>& aIndex,
         Stream* aSource,
         uint32_t aTrackId,
         bool aIsAudio,
         mozilla::Monitor* aMonitor);
--- a/media/libstagefright/frameworks/av/include/media/stagefright/MediaSource.h
+++ b/media/libstagefright/frameworks/av/include/media/stagefright/MediaSource.h
@@ -111,16 +111,17 @@ struct MediaSource : public virtual RefB
     }
 
     struct Indice
     {
       uint64_t start_offset;
       uint64_t end_offset;
       uint64_t start_composition;
       uint64_t end_composition;
+      uint64_t start_decode;
       bool sync;
     };
 
     virtual nsTArray<Indice> exportIndex() = 0;
 
 protected:
     virtual ~MediaSource();
 
--- a/media/libstagefright/frameworks/av/media/libstagefright/MPEG4Extractor.cpp
+++ b/media/libstagefright/frameworks/av/media/libstagefright/MPEG4Extractor.cpp
@@ -4253,32 +4253,34 @@ nsTArray<MediaSource::Indice> MPEG4Sourc
   }
   for (uint32_t sampleIndex = 0; sampleIndex < mSampleTable->countSamples();
           sampleIndex++) {
       off64_t offset;
       size_t size;
       uint32_t compositionTime;
       uint32_t duration;
       bool isSyncSample;
+      uint32_t decodeTime;
       if (mSampleTable->getMetaDataForSample(sampleIndex, &offset, &size,
                                              &compositionTime, &duration,
-                                             &isSyncSample) != OK) {
+                                             &isSyncSample, &decodeTime) != OK) {
           ALOGE("Unexpected sample table problem");
           continue;
       }
 
       Indice indice;
       indice.start_offset = offset;
       indice.end_offset = offset + size;
       indice.start_composition = (compositionTime * 1000000ll) / mTimescale;
       // end_composition is overwritten everywhere except the last frame, where
       // the presentation duration is equal to the sample duration.
       indice.end_composition =
           (compositionTime * 1000000ll + duration * 1000000ll) / mTimescale;
       indice.sync = isSyncSample;
+      indice.start_decode = (decodeTime * 1000000ll) / mTimescale;
       index.AppendElement(indice);
   }
 
   // Fix up composition durations so we don't end up with any unsightly gaps.
   if (index.Length() != 0) {
       nsTArray<Indice*> composition_order;
       if (!composition_order.SetCapacity(index.Length(), mozilla::fallible)) {
         return index;