From 7665571ff92a55fd7059ff3e03a3b96c11fb308e Mon Sep 17 00:00:00 2001 From: hoangtc Date: Tue, 25 Jul 2017 02:37:22 +0100 Subject: [PATCH] Do not copy data to output frame in libvpx unless necessary. In out libvpx extension, currently we always call vpxGetFrame and copy the data from the native decoder to output frame. However, if the inputBuffer has isDecoderOnly set, we can avoid populating the output buffer, but only setting BUFFER_FLAG_DECODE_ONLY. ------------- Created by MOE: https://github.com/google/moe MOE_MIGRATED_REVID=170318527 --- .../android/exoplayer2/ext/vp9/VpxDecoder.java | 16 +++++++++------- 1 file changed, 9 insertions(+), 7 deletions(-) diff --git a/extensions/vp9/src/main/java/com/google/android/exoplayer2/ext/vp9/VpxDecoder.java b/extensions/vp9/src/main/java/com/google/android/exoplayer2/ext/vp9/VpxDecoder.java index 4bec5bdf4c..ef999d5d2b 100644 --- a/extensions/vp9/src/main/java/com/google/android/exoplayer2/ext/vp9/VpxDecoder.java +++ b/extensions/vp9/src/main/java/com/google/android/exoplayer2/ext/vp9/VpxDecoder.java @@ -120,14 +120,16 @@ import java.nio.ByteBuffer; } } - outputBuffer.init(inputBuffer.timeUs, outputMode); - int getFrameResult = vpxGetFrame(vpxDecContext, outputBuffer); - if (getFrameResult == 1) { - outputBuffer.addFlag(C.BUFFER_FLAG_DECODE_ONLY); - } else if (getFrameResult == -1) { - return new VpxDecoderException("Buffer initialization failed."); + if (!inputBuffer.isDecodeOnly()) { + outputBuffer.init(inputBuffer.timeUs, outputMode); + int getFrameResult = vpxGetFrame(vpxDecContext, outputBuffer); + if (getFrameResult == 1) { + outputBuffer.addFlag(C.BUFFER_FLAG_DECODE_ONLY); + } else if (getFrameResult == -1) { + return new VpxDecoderException("Buffer initialization failed."); + } + outputBuffer.colorInfo = inputBuffer.colorInfo; } - outputBuffer.colorInfo = inputBuffer.colorInfo; return null; }