Bug 1278005: Fix rounding problems. r=cpearce, a=tomcat
authorJean-Yves Avenard <jyavenard@mozilla.com>
Sat, 04 Jun 2016 12:22:39 +1000
changeset 341336 f3740cfc4b04fb61a1da306df4b1c2437f6bfb65
parent 341335 e27fe24a746fa839f1cabe198faf1bad42c7dc4b
child 341337 4636490d9e6a4c85855912216a0e7ecb5dbe1fd8
child 341541 d5a74fc98333a8ebae36ae7b47e37742490cb566
push id1183
push userraliiev@mozilla.com
push dateMon, 05 Sep 2016 20:01:49 +0000
treeherdermozilla-release@3148731bed45 [default view] [failures only]
perfherder[talos] [build metrics] [platform microbench] (compared to previous push)
reviewerscpearce, tomcat
bugs1278005
milestone49.0a1
first release with
nightly linux32
f3740cfc4b04 / 49.0a1 / 20160604030215 / files
nightly linux64
f3740cfc4b04 / 49.0a1 / 20160604030215 / files
nightly mac
f3740cfc4b04 / 49.0a1 / 20160604030215 / files
nightly win32
f3740cfc4b04 / 49.0a1 / 20160604030215 / files
nightly win64
f3740cfc4b04 / 49.0a1 / 20160604030215 / files
last release without
nightly linux32
nightly linux64
nightly mac
nightly win32
nightly win64
releases
nightly linux32
nightly linux64
nightly mac
nightly win32
nightly win64
Bug 1278005: Fix rounding problems. r=cpearce, a=tomcat We had two potentials rounding issue occurring. The one causing the problem is that adding an int64 with a float is a float, and would be limited to 24bits mantissa. The other, could be that rounding would occur if the segment duration was over 16s long, as that too would exceed the representation range as we using microseconds representation internally. MozReview-Commit-ID: FyBTGvfg25I
media/libstagefright/binding/MoofParser.cpp
--- a/media/libstagefright/binding/MoofParser.cpp
+++ b/media/libstagefright/binding/MoofParser.cpp
@@ -389,23 +389,23 @@ Moof::Moof(Box& aBox, Trex& aTrex, Mvhd&
       // duration, so we rewrite the dts accordingly.
       int64_t presentationDuration =
         ctsOrder.LastElement()->mCompositionRange.end
         - ctsOrder[0]->mCompositionRange.start;
       int64_t endDecodeTime =
         aMdhd.ToMicroseconds((int64_t)*aDecodeTime - aEdts.mMediaStart)
         + aMvhd.ToMicroseconds(aEdts.mEmptyOffset);
       int64_t decodeDuration = endDecodeTime - mIndex[0].mDecodeTime;
-      float adjust = (float)decodeDuration / presentationDuration;
+      double adjust = (double)decodeDuration / presentationDuration;
       int64_t dtsOffset = mIndex[0].mDecodeTime;
       int64_t compositionDuration = 0;
       // Adjust the dts, ensuring that the new adjusted dts will never be greater
       // than decodeTime (the next moof's decode start time).
       for (auto& sample : mIndex) {
-        sample.mDecodeTime = dtsOffset + compositionDuration * adjust;
+        sample.mDecodeTime = dtsOffset + int64_t(compositionDuration * adjust);
         compositionDuration += sample.mCompositionRange.Length();
       }
       mTimeRange = Interval<Microseconds>(ctsOrder[0]->mCompositionRange.start,
           ctsOrder.LastElement()->mCompositionRange.end);
     }
     ProcessCenc();
   }
 }