Bug 1111311 - Use 32 bits signed for storing CTS in order to properly calculate PTS. r=kentuckyfriedtakahe, a=sledru
authorJean-Yves Avenard <jyavenard@mozilla.com>
Wed, 17 Dec 2014 22:21:10 +1100
changeset 234409 a6f176bb961f229255d31f46bccbe1aa2488b6f2
parent 234408 a0f19d8c4bd66b255de8e82d704929495b010875
child 234410 c4fdc95dd1fc20c5103530f0cc723e73ba7ad5a2
push id7381
push userryanvm@gmail.com
push dateThu, 18 Dec 2014 17:53:42 +0000
treeherdermozilla-aurora@a6f176bb961f [default view] [failures only]
perfherder[talos] [build metrics] [platform microbench] (compared to previous push)
reviewerskentuckyfriedtakahe, sledru
bugs1111311
milestone36.0a2
Bug 1111311 - Use 32 bits signed for storing CTS in order to properly calculate PTS. r=kentuckyfriedtakahe, a=sledru
media/libstagefright/binding/MoofParser.cpp
media/libstagefright/frameworks/av/media/libstagefright/MPEG4Extractor.cpp
--- a/media/libstagefright/binding/MoofParser.cpp
+++ b/media/libstagefright/binding/MoofParser.cpp
@@ -315,23 +315,19 @@ Moof::ParseTrun(Box& aBox, Tfhd& aTfhd, 
     uint32_t sampleDuration =
       flags & 0x100 ? reader->ReadU32() : aTfhd.mDefaultSampleDuration;
     uint32_t sampleSize =
       flags & 0x200 ? reader->ReadU32() : aTfhd.mDefaultSampleSize;
     uint32_t sampleFlags =
       flags & 0x400 ? reader->ReadU32() : hasFirstSampleFlags && i == 0
                                             ? firstSampleFlags
                                             : aTfhd.mDefaultSampleFlags;
-    int64_t ctsOffset = 0;
+    int32_t ctsOffset = 0;
     if (flags & 0x800) {
-      if (version == 0) {
-        ctsOffset = reader->ReadU32();
-      } else {
-        ctsOffset = reader->Read32();
-      }
+      ctsOffset = reader->Read32();
     }
 
     Sample sample;
     sample.mByteRange = MediaByteRange(offset, offset + sampleSize);
     offset += sampleSize;
 
     sample.mDecodeTime = aMdhd.ToMicroseconds(decodeTime);
     sample.mCompositionRange = Interval<Microseconds>(
--- a/media/libstagefright/frameworks/av/media/libstagefright/MPEG4Extractor.cpp
+++ b/media/libstagefright/frameworks/av/media/libstagefright/MPEG4Extractor.cpp
@@ -135,17 +135,17 @@ private:
         uint64_t mDataOffset;
     };
     TrackFragmentHeaderInfo mTrackFragmentHeaderInfo;
 
     struct Sample {
         off64_t offset;
         uint32_t size;
         uint32_t duration;
-        int64_t ctsOffset;
+        int32_t ctsOffset;
         uint32_t flags;
         uint8_t iv[16];
         Vector<uint16_t> clearsizes;
         Vector<uint32_t> encryptedsizes;
 
         bool isSync() const { return !(flags & 0x1010000); }
     };
     Vector<Sample> mCurrentSamples;
@@ -3156,21 +3156,17 @@ status_t MPEG4Source::parseTrackFragment
                 dataOffset, sampleSize, sampleDuration,
                 (flags & kFirstSampleFlagsPresent) && i == 0
                     ? firstSampleFlags : sampleFlags);
         tmp.flags = (flags & kFirstSampleFlagsPresent) && i == 0
                 ? firstSampleFlags : sampleFlags;
         tmp.offset = dataOffset;
         tmp.size = sampleSize;
         tmp.duration = sampleDuration;
-        if (version == 0) {
-          tmp.ctsOffset = sampleCtsOffset;
-        } else {
-          tmp.ctsOffset = (int32_t)sampleCtsOffset;
-        }
+        tmp.ctsOffset = (int32_t)sampleCtsOffset;
         mCurrentSamples.add(tmp);
 
         dataOffset += sampleSize;
     }
 
     mTrackFragmentHeaderInfo.mDataOffset = dataOffset;
 
     for (size_t i = 0; i < mDeferredSaio.size() && i < mDeferredSaiz.size(); i++) {