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