Bug 1413702 - avoid dividing by zero. r?kinetik
MozReview-Commit-ID: 38ZdC9udcH1
--- a/media/libstagefright/binding/MoofParser.cpp
+++ b/media/libstagefright/binding/MoofParser.cpp
@@ -442,17 +442,17 @@ Moof::Moof(Box& aBox, Trex& aTrex, Mvhd&
int64_t presentationDuration =
ctsOrder.LastElement()->mCompositionRange.end
- ctsOrder[0]->mCompositionRange.start;
auto decodeOffset = aMdhd.ToMicroseconds((int64_t)*aDecodeTime - aEdts.mMediaStart);
auto offsetOffset = aMvhd.ToMicroseconds(aEdts.mEmptyOffset);
int64_t endDecodeTime = decodeOffset.isOk() & offsetOffset.isOk() ?
decodeOffset.unwrap() + offsetOffset.unwrap() : 0;
int64_t decodeDuration = endDecodeTime - mIndex[0].mDecodeTime;
- double adjust = (double)decodeDuration / presentationDuration;
+ double adjust = !!presentationDuration ? (double)decodeDuration / presentationDuration : 0;
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 + int64_t(compositionDuration * adjust);
compositionDuration += sample.mCompositionRange.Length();
}