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

Commit 3feff541 authored by Treehugger Robot's avatar Treehugger Robot Committed by Automerger Merge Worker
Browse files

Merge "stagefright: rtsp: handle overflow in jitter calculation" into main am:...

Merge "stagefright: rtsp: handle overflow in jitter calculation" into main am: 92201ec2 am: 44370a78 am: a4dc6642

Original change: https://android-review.googlesource.com/c/platform/frameworks/av/+/2765647



Change-Id: I0f9a3a6fbcd35fe7f83e3996ee6f2969ea6881c1
Signed-off-by: default avatarAutomerger Merge Worker <android-build-automerger-merge-worker@system.gserviceaccount.com>
parents 51f3e91a a4dc6642
Loading
Loading
Loading
Loading
+8 −1
Original line number Diff line number Diff line
@@ -47,7 +47,14 @@ void JitterCalc::putBaseData(uint32_t rtpTime, int64_t arrivalTimeUs) {
    int64_t scheduledTimeUs = ((int32_t)diff) * 1000000ll / mClockRate;
    int64_t elapsedTimeUs = arrivalTimeUs - mFirstArrivalTimeUs;
    int64_t correctionTimeUs = elapsedTimeUs - scheduledTimeUs; // additional propagation delay;
    mBaseJitterUs = (mBaseJitterUs * 15 + correctionTimeUs) / 16;

    // We want to approximate correctionTimeUs by slowly (1:15) averaging into jitter base, but
    // both correction time and base jitter can roll over. Adjust correctionTime to be close to
    // base jitter. Accomplish this by calculating the closest 32-bit delta (positive or
    // negative) and applying 1/16th of it to the base jitter.
    int32_t correctionDiff;
    (void)__builtin_sub_overflow(correctionTimeUs, mBaseJitterUs, &correctionDiff);
    mBaseJitterUs = int32_t(int64_t(mBaseJitterUs) + correctionDiff / 16);
    ALOGV("BaseJitterUs : %lld \t\t correctionTimeUs : %lld",
            (long long)mBaseJitterUs, (long long)correctionTimeUs);
}