Donate to e Foundation | Murena handsets with /e/OS | Own a part of Murena! Learn more

Commit 69f6f29f authored by Marco Nelissen's avatar Marco Nelissen
Browse files

Fix issue with previous CL to use 64-bit sample times

Bug: 122746532
Test: manual
Change-Id: I52070ac126baa1fbea33cf7d3566a91306ed6514
parent 6f4aa5c6
Loading
Loading
Loading
Loading
+3 −3
Original line number Diff line number Diff line
@@ -330,7 +330,7 @@ status_t SampleIterator::findSampleTimeAndDuration(

    // below is equivalent to:
    // *time = mTTSSampleTime + mTTSDuration * (sampleIndex - mTTSSampleIndex);
    uint32_t tmp;
    uint64_t tmp;
    if (__builtin_sub_overflow(sampleIndex, mTTSSampleIndex, &tmp) ||
            __builtin_mul_overflow(mTTSDuration, tmp, &tmp) ||
            __builtin_add_overflow(mTTSSampleTime, tmp, &tmp)) {
@@ -340,7 +340,7 @@ status_t SampleIterator::findSampleTimeAndDuration(

    int32_t offset = mTable->getCompositionTimeOffset(sampleIndex);
    if ((offset < 0 && *time < (offset == INT32_MIN ?
            INT32_MAX : uint32_t(-offset))) ||
            INT64_MAX : uint64_t(-offset))) ||
            (offset > 0 && *time > UINT64_MAX - offset)) {
        ALOGE("%llu + %d would overflow", (unsigned long long) *time, offset);
        return ERROR_OUT_OF_RANGE;
@@ -348,7 +348,7 @@ status_t SampleIterator::findSampleTimeAndDuration(
    if (offset > 0) {
        *time += offset;
    } else {
        *time -= (offset == INT32_MIN ? INT32_MAX : (-offset));
        *time -= (offset == INT64_MIN ? INT64_MAX : (-offset));
    }

    *duration = mTTSDuration;