Commit 75c72f3b by hschlueter Committed by Ian Baker

Return recommended output size for FrameProcessorChain.

Also add warning for what can happen if this is ignored.

Previously the return value was overridden by setOutputSurface, now
setOutputSurface only overrides the values using internally.

PiperOrigin-RevId: 445377036
parent a840f973
...@@ -236,7 +236,8 @@ import org.checkerframework.checker.nullness.qual.RequiresNonNull; ...@@ -236,7 +236,8 @@ import org.checkerframework.checker.nullness.qual.RequiresNonNull;
*/ */
private final int[] framebuffers; private final int[] framebuffers;
private Size outputSize; private int outputWidth;
private int outputHeight;
/** /**
* Wraps the output {@link Surface} that is populated with the output of the final {@link * Wraps the output {@link Surface} that is populated with the output of the final {@link
* GlFrameProcessor} for each frame. * GlFrameProcessor} for each frame.
...@@ -277,20 +278,27 @@ import org.checkerframework.checker.nullness.qual.RequiresNonNull; ...@@ -277,20 +278,27 @@ import org.checkerframework.checker.nullness.qual.RequiresNonNull;
inputSurfaceTexture = new SurfaceTexture(inputExternalTexId); inputSurfaceTexture = new SurfaceTexture(inputExternalTexId);
inputSurface = new Surface(inputSurfaceTexture); inputSurface = new Surface(inputSurfaceTexture);
textureTransformMatrix = new float[16]; textureTransformMatrix = new float[16];
outputSize = getLast(frameProcessors).getOutputSize(); outputWidth = C.LENGTH_UNSET;
outputHeight = C.LENGTH_UNSET;
debugPreviewWidth = C.LENGTH_UNSET; debugPreviewWidth = C.LENGTH_UNSET;
debugPreviewHeight = C.LENGTH_UNSET; debugPreviewHeight = C.LENGTH_UNSET;
} }
/** Returns the output {@link Size}. */ /**
* Returns the recommended output size.
*
* <p>This is the recommended size to use for the {@linkplain #setOutputSurface(Surface, int, int,
* SurfaceView) output surface}.
*/
public Size getOutputSize() { public Size getOutputSize() {
return outputSize; return getLast(frameProcessors).getOutputSize();
} }
/** /**
* Sets the output {@link Surface}. * Sets the output {@link Surface}.
* *
* <p>This method may override the output size of the final {@link GlFrameProcessor}. * <p>The recommended output size is given by {@link #getOutputSize()}. Setting a different output
* size may cause poor quality or distortion.
* *
* @param outputSurface The output {@link Surface}. * @param outputSurface The output {@link Surface}.
* @param outputWidth The output width, in pixels. * @param outputWidth The output width, in pixels.
...@@ -304,7 +312,8 @@ import org.checkerframework.checker.nullness.qual.RequiresNonNull; ...@@ -304,7 +312,8 @@ import org.checkerframework.checker.nullness.qual.RequiresNonNull;
@Nullable SurfaceView debugSurfaceView) { @Nullable SurfaceView debugSurfaceView) {
// TODO(b/218488308): Don't override output size for encoder fallback. Instead allow the final // TODO(b/218488308): Don't override output size for encoder fallback. Instead allow the final
// GlFrameProcessor to be re-configured or append another GlFrameProcessor. // GlFrameProcessor to be re-configured or append another GlFrameProcessor.
outputSize = new Size(outputWidth, outputHeight); this.outputWidth = outputWidth;
this.outputHeight = outputHeight;
if (debugSurfaceView != null) { if (debugSurfaceView != null) {
debugPreviewWidth = debugSurfaceView.getWidth(); debugPreviewWidth = debugSurfaceView.getWidth();
...@@ -483,8 +492,7 @@ import org.checkerframework.checker.nullness.qual.RequiresNonNull; ...@@ -483,8 +492,7 @@ import org.checkerframework.checker.nullness.qual.RequiresNonNull;
clearOutputFrame(); clearOutputFrame();
frameProcessors.get(i).drawFrame(presentationTimeUs); frameProcessors.get(i).drawFrame(presentationTimeUs);
} }
GlUtil.focusEglSurface( GlUtil.focusEglSurface(eglDisplay, eglContext, eglSurface, outputWidth, outputHeight);
eglDisplay, eglContext, eglSurface, outputSize.getWidth(), outputSize.getHeight());
clearOutputFrame(); clearOutputFrame();
getLast(frameProcessors).drawFrame(presentationTimeUs); getLast(frameProcessors).drawFrame(presentationTimeUs);
......
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