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
This commit is contained in:
hoangtc 2017-07-25 02:37:22 +01:00 committed by Oliver Woodman
parent 60de157410
commit 7665571ff9

View File

@ -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;
}