Fix video size reporting in surface YUV mode

In surface YUV output mode the width/height fields of the VpxOutputBuffer were
never populated. Fix this by adding a new method to set the width/height and
calling it from JNI like we do for GL YUV mode.

PiperOrigin-RevId: 250449734
This commit is contained in:
andrewlewis 2019-05-29 10:09:54 +01:00 committed by Toni
parent 90325c699e
commit 8a0fb6b78f
2 changed files with 18 additions and 2 deletions

View file

@ -60,8 +60,8 @@ public final class VpxOutputBuffer extends OutputBuffer {
* Initializes the buffer.
*
* @param timeUs The presentation timestamp for the buffer, in microseconds.
* @param mode The output mode. One of {@link VpxDecoder#OUTPUT_MODE_NONE} and {@link
* VpxDecoder#OUTPUT_MODE_YUV}.
* @param mode The output mode. One of {@link VpxDecoder#OUTPUT_MODE_NONE}, {@link
* VpxDecoder#OUTPUT_MODE_YUV} and {@link VpxDecoder#OUTPUT_MODE_SURFACE_YUV}.
*/
public void init(long timeUs, int mode) {
this.timeUs = timeUs;
@ -110,6 +110,15 @@ public final class VpxOutputBuffer extends OutputBuffer {
return true;
}
/**
* Configures the buffer for the given frame dimensions when passing actual frame data via {@link
* #decoderPrivate}. Called via JNI after decoding completes.
*/
public void initForPrivateFrame(int width, int height) {
this.width = width;
this.height = height;
}
private void initData(int size) {
if (data == null || data.capacity() < size) {
data = ByteBuffer.allocateDirect(size);

View file

@ -60,6 +60,7 @@
// JNI references for VpxOutputBuffer class.
static jmethodID initForYuvFrame;
static jmethodID initForPrivateFrame;
static jfieldID dataField;
static jfieldID outputModeField;
static jfieldID decoderPrivateField;
@ -481,6 +482,8 @@ DECODER_FUNC(jlong, vpxInit, jboolean disableLoopFilter,
"com/google/android/exoplayer2/ext/vp9/VpxOutputBuffer");
initForYuvFrame = env->GetMethodID(outputBufferClass, "initForYuvFrame",
"(IIIII)Z");
initForPrivateFrame =
env->GetMethodID(outputBufferClass, "initForPrivateFrame", "(II)V");
dataField = env->GetFieldID(outputBufferClass, "data",
"Ljava/nio/ByteBuffer;");
outputModeField = env->GetFieldID(outputBufferClass, "mode", "I");
@ -602,6 +605,10 @@ DECODER_FUNC(jint, vpxGetFrame, jlong jContext, jobject jOutputBuffer) {
}
jfb->d_w = img->d_w;
jfb->d_h = img->d_h;
env->CallVoidMethod(jOutputBuffer, initForPrivateFrame, img->d_w, img->d_h);
if (env->ExceptionCheck()) {
return -1;
}
env->SetIntField(jOutputBuffer, decoderPrivateField,
id + kDecoderPrivateBase);
}