mirror of
https://github.com/samsonjs/media.git
synced 2026-04-27 15:07:40 +00:00
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:
parent
90325c699e
commit
8a0fb6b78f
2 changed files with 18 additions and 2 deletions
|
|
@ -60,8 +60,8 @@ public final class VpxOutputBuffer extends OutputBuffer {
|
||||||
* Initializes the buffer.
|
* Initializes the buffer.
|
||||||
*
|
*
|
||||||
* @param timeUs The presentation timestamp for the buffer, in microseconds.
|
* @param timeUs The presentation timestamp for the buffer, in microseconds.
|
||||||
* @param mode The output mode. One of {@link VpxDecoder#OUTPUT_MODE_NONE} and {@link
|
* @param mode The output mode. One of {@link VpxDecoder#OUTPUT_MODE_NONE}, {@link
|
||||||
* VpxDecoder#OUTPUT_MODE_YUV}.
|
* VpxDecoder#OUTPUT_MODE_YUV} and {@link VpxDecoder#OUTPUT_MODE_SURFACE_YUV}.
|
||||||
*/
|
*/
|
||||||
public void init(long timeUs, int mode) {
|
public void init(long timeUs, int mode) {
|
||||||
this.timeUs = timeUs;
|
this.timeUs = timeUs;
|
||||||
|
|
@ -110,6 +110,15 @@ public final class VpxOutputBuffer extends OutputBuffer {
|
||||||
return true;
|
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) {
|
private void initData(int size) {
|
||||||
if (data == null || data.capacity() < size) {
|
if (data == null || data.capacity() < size) {
|
||||||
data = ByteBuffer.allocateDirect(size);
|
data = ByteBuffer.allocateDirect(size);
|
||||||
|
|
|
||||||
|
|
@ -60,6 +60,7 @@
|
||||||
|
|
||||||
// JNI references for VpxOutputBuffer class.
|
// JNI references for VpxOutputBuffer class.
|
||||||
static jmethodID initForYuvFrame;
|
static jmethodID initForYuvFrame;
|
||||||
|
static jmethodID initForPrivateFrame;
|
||||||
static jfieldID dataField;
|
static jfieldID dataField;
|
||||||
static jfieldID outputModeField;
|
static jfieldID outputModeField;
|
||||||
static jfieldID decoderPrivateField;
|
static jfieldID decoderPrivateField;
|
||||||
|
|
@ -481,6 +482,8 @@ DECODER_FUNC(jlong, vpxInit, jboolean disableLoopFilter,
|
||||||
"com/google/android/exoplayer2/ext/vp9/VpxOutputBuffer");
|
"com/google/android/exoplayer2/ext/vp9/VpxOutputBuffer");
|
||||||
initForYuvFrame = env->GetMethodID(outputBufferClass, "initForYuvFrame",
|
initForYuvFrame = env->GetMethodID(outputBufferClass, "initForYuvFrame",
|
||||||
"(IIIII)Z");
|
"(IIIII)Z");
|
||||||
|
initForPrivateFrame =
|
||||||
|
env->GetMethodID(outputBufferClass, "initForPrivateFrame", "(II)V");
|
||||||
dataField = env->GetFieldID(outputBufferClass, "data",
|
dataField = env->GetFieldID(outputBufferClass, "data",
|
||||||
"Ljava/nio/ByteBuffer;");
|
"Ljava/nio/ByteBuffer;");
|
||||||
outputModeField = env->GetFieldID(outputBufferClass, "mode", "I");
|
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_w = img->d_w;
|
||||||
jfb->d_h = img->d_h;
|
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,
|
env->SetIntField(jOutputBuffer, decoderPrivateField,
|
||||||
id + kDecoderPrivateBase);
|
id + kDecoderPrivateBase);
|
||||||
}
|
}
|
||||||
|
|
|
||||||
Loading…
Reference in a new issue