Bug 1027875 - Fix CTS offset processing in fMP4; r=cpearce
authorAnthony Jones <ajones@mozilla.com>
Fri, 04 Jul 2014 20:31:19 +1200
changeset 192392 8be7f28c5dddbc244f2deed033a0afa3b5b806a8
parent 192391 3fb0089cfb28d9d89ac8968911f9fc2f92091e3b
child 192393 5c1a090ccc63e19bfb42b8425031a12ec1dec24b
push id27086
push userttaubert@mozilla.com
push dateSun, 06 Jul 2014 16:11:25 +0000
treeherdermozilla-central@9f59e39f70a5 [default view] [failures only]
perfherder[talos] [build metrics] [platform microbench] (compared to previous push)
reviewerscpearce
bugs1027875
milestone33.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 1027875 - Fix CTS offset processing in fMP4; r=cpearce
media/libstagefright/frameworks/av/media/libstagefright/MPEG4Extractor.cpp
--- a/media/libstagefright/frameworks/av/media/libstagefright/MPEG4Extractor.cpp
+++ b/media/libstagefright/frameworks/av/media/libstagefright/MPEG4Extractor.cpp
@@ -133,16 +133,17 @@ private:
         uint64_t mDataOffset;
     };
     TrackFragmentHeaderInfo mTrackFragmentHeaderInfo;
 
     struct Sample {
         off64_t offset;
         size_t size;
         uint32_t duration;
+        uint32_t ctsOffset;
         uint8_t iv[16];
         Vector<size_t> clearsizes;
         Vector<size_t> encryptedsizes;
     };
     Vector<Sample> mCurrentSamples;
 
     MPEG4Source(const MPEG4Source &);
     MPEG4Source &operator=(const MPEG4Source &);
@@ -3008,16 +3009,17 @@ status_t MPEG4Source::parseTrackFragment
         ALOGV("adding sample %d at offset 0x%08llx, size %u, duration %u, "
               " flags 0x%08x", i + 1,
                 dataOffset, sampleSize, sampleDuration,
                 (flags & kFirstSampleFlagsPresent) && i == 0
                     ? firstSampleFlags : sampleFlags);
         tmp.offset = dataOffset;
         tmp.size = sampleSize;
         tmp.duration = sampleDuration;
+        tmp.ctsOffset = sampleCtsOffset;
         mCurrentSamples.add(tmp);
 
         dataOffset += sampleSize;
     }
 
     mTrackFragmentHeaderInfo.mDataOffset = dataOffset;
 
     return OK;
@@ -3425,17 +3427,17 @@ status_t MPEG4Source::fragmentedRead(
                 if (mCurrentSampleIndex >= mCurrentSamples.size()) {
                     return ERROR_END_OF_STREAM;
                 }
         }
 
         const Sample *smpl = &mCurrentSamples[mCurrentSampleIndex];
         offset = smpl->offset;
         size = smpl->size;
-        cts = mCurrentTime;
+        cts = mCurrentTime + smpl->ctsOffset;
         duration = smpl->duration;
         mCurrentTime += smpl->duration;
         isSyncSample = (mCurrentSampleIndex == 0); // XXX
 
         status_t err = mGroup->acquire_buffer(&mBuffer);
 
         if (err != OK) {
             CHECK(mBuffer == NULL);