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

Commit 28f939db authored by pmehendale's avatar pmehendale Committed by James Dong
Browse files

Awesomeplayer : Frame dropping logic change

Changed late frame drop policy, now we are dropping only 1 in 8,
late (> 40ms) frames. Dropping every late frame result in lot of noticible
pauses, usually with peaky bitrate activity these pauses become more prominant.
Dropping few frames is still required to allow overall playback chain,
to regain the performance.
Experimentally decided to drop Max one late frame in 8.

Change-Id: If20848d619a76aaf8179b1e5c3155610e3bc85fd
parent 2c602e6a
Loading
Loading
Loading
Loading
+12 −6
Original line number Diff line number Diff line
@@ -52,6 +52,7 @@
#include "include/LiveSession.h"

#define USE_SURFACE_ALLOC 1
#define FRAME_DROP_FREQ 7

namespace android {

@@ -1255,7 +1256,7 @@ void AwesomePlayer::onVideoEvent() {

    if (mFlags & FIRST_FRAME) {
        mFlags &= ~FIRST_FRAME;

        mSinceLastDropped = 0;
        mTimeSourceDeltaUs = ts->getRealTimeUs() - timeUs;
    }

@@ -1283,13 +1284,17 @@ void AwesomePlayer::onVideoEvent() {
    if (latenessUs > 40000) {
        // We're more than 40ms late.
        LOGV("we're late by %lld us (%.2f secs)", latenessUs, latenessUs / 1E6);

        if ( mSinceLastDropped > FRAME_DROP_FREQ)
        {
            LOGV("we're late by %lld us (%.2f secs) dropping one after %d frames", latenessUs, latenessUs / 1E6, mSinceLastDropped);
            mSinceLastDropped = 0;
            mVideoBuffer->release();
            mVideoBuffer = NULL;

            postVideoEvent_l();
            return;
        }
    }

    if (latenessUs < -10000) {
        // We're more than 10ms early.
@@ -1305,6 +1310,7 @@ void AwesomePlayer::onVideoEvent() {
    }

    if (mVideoRenderer != NULL) {
        mSinceLastDropped++;
        mVideoRenderer->render(mVideoBuffer);
    }

+1 −0
Original line number Diff line number Diff line
@@ -151,6 +151,7 @@ private:

    uint32_t mFlags;
    uint32_t mExtractorFlags;
    uint32_t mSinceLastDropped;

    int64_t mTimeSourceDeltaUs;
    int64_t mVideoTimeUs;