Bug 1207021: [mp4] Properly set dts on plain mp4 media. r=edwin
authorJean-Yves Avenard <jyavenard@mozilla.com>
Tue, 22 Sep 2015 14:37:58 +1000
changeset 263888 a6e7048c2cced04ae9b3bc79c96bf9d9dbadc2de
parent 263887 f72556c17c7c37d2a30b879fdbfa6f208137527c
child 263889 97a161382b60f18a60c49de91df79135f720f9ac
push id65461
push userjyavenard@mozilla.com
push dateWed, 23 Sep 2015 03:00:50 +0000
treeherdermozilla-inbound@0f7f4567efef [default view] [failures only]
perfherder[talos] [build metrics] [platform microbench] (compared to previous push)
reviewersedwin
bugs1207021
milestone44.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 1207021: [mp4] Properly set dts on plain mp4 media. r=edwin
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;