Commit 35466ac3 by claincly Committed by Tofunmi Adigun-Hameed

Always use sRGB/BT.709 for bitmap inputs

PiperOrigin-RevId: 533117700
(cherry picked from commit c5ec457dae7120d3c08d3b19c27435afdf1dd1b7)
parent 16db5db3
......@@ -83,8 +83,8 @@ public interface VideoFrameProcessor {
* @param effects The {@link Effect} instances to apply to each frame. Applied on the {@code
* outputColorInfo}'s color space.
* @param debugViewProvider A {@link DebugViewProvider}.
* @param inputColorInfo The {@link ColorInfo} for input frames.
* @param outputColorInfo The {@link ColorInfo} for output frames.
* @param inputColorInfo The {@link ColorInfo} for the input frames.
* @param outputColorInfo The {@link ColorInfo} for the output frames.
* @param renderFramesAutomatically If {@code true}, the instance will render output frames to
* the {@linkplain #setOutputSurfaceInfo(SurfaceInfo) output surface} automatically as
* {@link VideoFrameProcessor} is done processing them. If {@code false}, the {@link
......
......@@ -375,7 +375,6 @@ import java.util.List;
glProgram.setIntUniform("uOutputColorTransfer", outputColorTransfer);
} else {
glProgram.setIntUniform("uEnableColorTransfer", enableColorTransfers ? GL_TRUE : GL_FALSE);
checkArgument(inputColorInfo.colorSpace == outputColorInfo.colorSpace);
checkArgument(
outputColorTransfer == C.COLOR_TRANSFER_SDR
|| outputColorTransfer == C.COLOR_TRANSFER_LINEAR);
......
......@@ -46,7 +46,6 @@ import com.google.android.exoplayer2.util.SurfaceInfo;
import com.google.android.exoplayer2.util.Util;
import com.google.android.exoplayer2.util.VideoFrameProcessingException;
import com.google.android.exoplayer2.util.VideoFrameProcessor;
import com.google.android.exoplayer2.util.VideoFrameProcessor.OnInputFrameProcessedListener;
import com.google.android.exoplayer2.video.ColorInfo;
import com.google.common.collect.ImmutableList;
import com.google.common.util.concurrent.MoreExecutors;
......@@ -594,7 +593,6 @@ public final class DefaultVideoFrameProcessor implements VideoFrameProcessor {
InputSwitcher inputSwitcher =
new InputSwitcher(
context,
inputColorInfo,
/* outputColorInfo= */ linearColorInfo,
glObjectsProvider,
videoFrameProcessingTaskExecutor,
......@@ -616,14 +614,14 @@ public final class DefaultVideoFrameProcessor implements VideoFrameProcessor {
textureOutputListener,
textureOutputCapacity);
inputSwitcher.registerInput(INPUT_TYPE_SURFACE);
inputSwitcher.registerInput(inputColorInfo, INPUT_TYPE_SURFACE);
if (!ColorInfo.isTransferHdr(inputColorInfo)) {
// HDR bitmap input is not supported.
inputSwitcher.registerInput(INPUT_TYPE_BITMAP);
// HDR bitmap input is not supported. Bitmaps are always sRGB/Full range/BT.709.
inputSwitcher.registerInput(ColorInfo.SRGB_BT709_FULL, INPUT_TYPE_BITMAP);
}
if (inputColorInfo.colorTransfer != C.COLOR_TRANSFER_SRGB) {
// Image and textureId concatenation not supported.
inputSwitcher.registerInput(INPUT_TYPE_TEXTURE_ID);
inputSwitcher.registerInput(inputColorInfo, INPUT_TYPE_TEXTURE_ID);
}
inputSwitcher.setDownstreamShaderProgram(effectsShaderPrograms.get(0));
......
......@@ -39,7 +39,6 @@ import org.checkerframework.checker.nullness.qual.MonotonicNonNull;
*/
/* package */ final class InputSwitcher {
private final Context context;
private final ColorInfo inputColorInfo;
private final ColorInfo outputColorInfo;
private final GlObjectsProvider glObjectsProvider;
private final VideoFrameProcessingTaskExecutor videoFrameProcessingTaskExecutor;
......@@ -52,13 +51,11 @@ import org.checkerframework.checker.nullness.qual.MonotonicNonNull;
public InputSwitcher(
Context context,
ColorInfo inputColorInfo,
ColorInfo outputColorInfo,
GlObjectsProvider glObjectsProvider,
VideoFrameProcessingTaskExecutor videoFrameProcessingTaskExecutor,
boolean enableColorTransfers) {
this.context = context;
this.inputColorInfo = inputColorInfo;
this.outputColorInfo = outputColorInfo;
this.glObjectsProvider = glObjectsProvider;
this.videoFrameProcessingTaskExecutor = videoFrameProcessingTaskExecutor;
......@@ -78,8 +75,12 @@ import org.checkerframework.checker.nullness.qual.MonotonicNonNull;
*
* <p>Creates an {@link TextureManager} and an appropriate {@linkplain DefaultShaderProgram
* sampler} to sample from the input.
*
* @param inputColorInfo The {@link ColorInfo} for the input frames.
* @param inputType The {@linkplain VideoFrameProcessor.InputType type} of the input being
* registered.
*/
public void registerInput(@VideoFrameProcessor.InputType int inputType)
public void registerInput(ColorInfo inputColorInfo, @VideoFrameProcessor.InputType int inputType)
throws VideoFrameProcessingException {
// TODO(b/274109008): Investigate lazy instantiating the texture managers.
DefaultShaderProgram samplingShaderProgram;
......
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