From 91e68c05802a89666206de930935574bf51d9f8b Mon Sep 17 00:00:00 2001 From: Cameron Gutman Date: Thu, 10 Jul 2014 18:47:30 -0700 Subject: [PATCH] Include rendering time in the total decoding time --- .../binding/video/MediaCodecDecoderRenderer.java | 16 +++++++++------- 1 file changed, 9 insertions(+), 7 deletions(-) diff --git a/src/com/limelight/binding/video/MediaCodecDecoderRenderer.java b/src/com/limelight/binding/video/MediaCodecDecoderRenderer.java index 258cf641..28288c92 100644 --- a/src/com/limelight/binding/video/MediaCodecDecoderRenderer.java +++ b/src/com/limelight/binding/video/MediaCodecDecoderRenderer.java @@ -181,23 +181,25 @@ public class MediaCodecDecoderRenderer implements VideoDecoderRenderer { int outIndex = videoDecoder.dequeueOutputBuffer(info, 0); if (outIndex >= 0) { + long presentationTimeUs = info.presentationTimeUs; int lastIndex = outIndex; - // Add delta time to the totals (excluding probable outliers) - long delta = System.currentTimeMillis()-(info.presentationTimeUs/1000); - if (delta > 5 && delta < 300) { - decoderTimeMs += delta; - totalTimeMs += delta; - } - // Get the last output buffer in the queue while ((outIndex = videoDecoder.dequeueOutputBuffer(info, 0)) >= 0) { videoDecoder.releaseOutputBuffer(lastIndex, false); lastIndex = outIndex; + presentationTimeUs = info.presentationTimeUs; } // Render the last buffer videoDecoder.releaseOutputBuffer(lastIndex, true); + + // Add delta time to the totals (excluding probable outliers) + long delta = System.currentTimeMillis()-(presentationTimeUs/1000); + if (delta > 5 && delta < 300) { + decoderTimeMs += delta; + totalTimeMs += delta; + } } else { switch (outIndex) { case MediaCodec.INFO_OUTPUT_BUFFERS_CHANGED: