Commit 1f9a3327 by andrewlewis Committed by christosts

Add a way to specify default buffer size

Based on experimentation, when CameraX is producing input for frame processor the buffer size is not being set to match the camera capture resolution, so the output has lower resolution than expected. Expose the default buffer size setter on `SurfaceTexture` to allow apps to process frames at full resolution for use cases like this one where the producer doesn't override the default buffer size.

PiperOrigin-RevId: 504022107
parent fdf86661
......@@ -21,6 +21,7 @@ import static com.google.android.exoplayer2.util.Assertions.checkStateNotNull;
import static com.google.common.collect.Iterables.getLast;
import android.content.Context;
import android.graphics.SurfaceTexture;
import android.opengl.EGLContext;
import android.opengl.EGLDisplay;
import android.view.Surface;
......@@ -378,6 +379,22 @@ public final class GlEffectsFrameProcessor implements FrameProcessor {
return frameProcessingTaskExecutor;
}
/**
* Sets the default size for input buffers, for the case where the producer providing input does
* not override the buffer size.
*
* <p>When input comes from a media codec it's not necessary to call this method because the codec
* (producer) sets the buffer size automatically. For the case where input comes from CameraX,
* call this method after instantiation to ensure that buffers are handled at full resolution. See
* {@link SurfaceTexture#setDefaultBufferSize(int, int)} for more information.
*
* @param width The default width for input buffers, in pixels.
* @param height The default height for input buffers, in pixels.
*/
public void setInputDefaultBufferSize(int width, int height) {
inputExternalTextureManager.getSurfaceTexture().setDefaultBufferSize(width, height);
}
@Override
public Surface getInputSurface() {
return inputSurface;
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or sign in to comment