Commit ff4bc623 by huangdarwin Committed by Tofunmi Adigun-Hameed

Effects: Have VFP texture output disable surface output.

Also, document that texture output disables manual frame release.

In the past, texture output would lead to surface output methods throwing. Now,
they're simply no-ops instead.

PiperOrigin-RevId: 534894168
(cherry picked from commit 21ee2e2243c2d0f2875ae7506e90217fe6044bc7)
parent 9b5040f5
......@@ -134,10 +134,10 @@ public final class DefaultVideoFrameProcessor implements VideoFrameProcessor {
* regain capacity, output textures must be released using {@link
* ReleaseOutputTextureCallback}.
*
* <p>If not set, there will be no texture output.
* <p>If set, {@linkplain #setOutputSurfaceInfo} and {@link #renderOutputFrame} will be
* no-ops, and {@code renderFramesAutomatically} will behave as if it is set to {@code true}.
*
* <p>This must not be set if the {@linkplain #setOutputSurfaceInfo output surface info} is
* also set.
* <p>If not set, there will be no texture output.
*
* @param textureOutputListener The {@link TextureOutputListener}.
* @param textureOutputCapacity The amount of output textures that may be allocated at a time
......@@ -209,6 +209,10 @@ public final class DefaultVideoFrameProcessor implements VideoFrameProcessor {
*
* <p>If invoking the {@code listener} on {@link DefaultVideoFrameProcessor}'s internal thread
* is desired, pass a {@link MoreExecutors#directExecutor() direct listenerExecutor}.
*
* <p>If {@linkplain Factory.Builder#setTextureOutput texture output} is set, {@linkplain
* #setOutputSurfaceInfo} and {@link #renderOutputFrame} will be no-ops, and {@code
* renderFramesAutomatically} will behave as if it is set to {@code true}.
*/
@Override
public DefaultVideoFrameProcessor create(
......@@ -233,7 +237,7 @@ public final class DefaultVideoFrameProcessor implements VideoFrameProcessor {
if (inputColorInfo.colorSpace != outputColorInfo.colorSpace
|| ColorInfo.isTransferHdr(inputColorInfo) != ColorInfo.isTransferHdr(outputColorInfo)) {
// GL Tone mapping is only implemented for BT2020 to BT709 and HDR to SDR (Gamma 2.2).
// OpenGL tone mapping is only implemented for BT2020 to BT709 and HDR to SDR (Gamma 2.2).
// Gamma 2.2 is used instead of SMPTE 170M for SDR, despite MediaFormat's
// COLOR_TRANSFER_SDR_VIDEO being defined as SMPTE 170M. This is to match
// other known tone-mapping behavior within the Android ecosystem.
......@@ -442,8 +446,8 @@ public final class DefaultVideoFrameProcessor implements VideoFrameProcessor {
/**
* {@inheritDoc}
*
* <p>This must not be set on an instance where {@linkplain Factory.Builder#setTextureOutput
* texture output} is set.
* <p>If {@linkplain Factory.Builder#setTextureOutput texture output} is set, calling this method
* will be a no-op.
*/
@Override
public void setOutputSurfaceInfo(@Nullable SurfaceInfo outputSurfaceInfo) {
......@@ -453,8 +457,8 @@ public final class DefaultVideoFrameProcessor implements VideoFrameProcessor {
/**
* {@inheritDoc}
*
* <p>This may also be used for rendering from an output texture, if a {@link
* TextureOutputListener} {@linkplain Factory.Builder#setTextureOutput is set}
* <p>If {@linkplain Factory.Builder#setTextureOutput texture output} is set, calling this method
* will be a no-op.
*/
@Override
public void renderOutputFrame(long renderTimeNs) {
......
......@@ -266,6 +266,9 @@ import org.checkerframework.checker.nullness.qual.MonotonicNonNull;
}
public void renderOutputFrame(long renderTimeNs) {
if (textureOutputListener != null) {
return;
}
frameProcessingStarted = true;
checkState(!renderFramesAutomatically);
Pair<GlTextureInfo, Long> oldestAvailableFrame = availableFrames.remove();
......@@ -275,13 +278,11 @@ import org.checkerframework.checker.nullness.qual.MonotonicNonNull;
renderTimeNs);
}
/**
* Sets the output {@link SurfaceInfo}.
*
* @see VideoFrameProcessor#setOutputSurfaceInfo(SurfaceInfo)
*/
/** See {@link DefaultVideoFrameProcessor#setOutputSurfaceInfo} */
public synchronized void setOutputSurfaceInfo(@Nullable SurfaceInfo outputSurfaceInfo) {
checkState(textureOutputListener == null);
if (textureOutputListener != null) {
return;
}
if (Util.areEqual(this.outputSurfaceInfo, outputSurfaceInfo)) {
return;
}
......
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