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
This commit is contained in:
andrewlewis 2023-01-23 18:31:20 +00:00 committed by christosts
parent fdf866617f
commit 1f9a33279e

View file

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