mirror of
https://github.com/samsonjs/media.git
synced 2026-04-08 11:45:51 +00:00
Always use sRGB/BT.709 for bitmap inputs
PiperOrigin-RevId: 533117700
This commit is contained in:
parent
fe667560d0
commit
24a4396990
4 changed files with 11 additions and 13 deletions
|
|
@ -85,8 +85,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
|
||||
|
|
|
|||
|
|
@ -377,7 +377,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);
|
||||
|
|
|
|||
|
|
@ -44,7 +44,6 @@ import androidx.media3.common.GlTextureInfo;
|
|||
import androidx.media3.common.SurfaceInfo;
|
||||
import androidx.media3.common.VideoFrameProcessingException;
|
||||
import androidx.media3.common.VideoFrameProcessor;
|
||||
import androidx.media3.common.VideoFrameProcessor.OnInputFrameProcessedListener;
|
||||
import androidx.media3.common.util.GlUtil;
|
||||
import androidx.media3.common.util.Log;
|
||||
import androidx.media3.common.util.UnstableApi;
|
||||
|
|
@ -596,7 +595,6 @@ public final class DefaultVideoFrameProcessor implements VideoFrameProcessor {
|
|||
InputSwitcher inputSwitcher =
|
||||
new InputSwitcher(
|
||||
context,
|
||||
inputColorInfo,
|
||||
/* outputColorInfo= */ linearColorInfo,
|
||||
glObjectsProvider,
|
||||
videoFrameProcessingTaskExecutor,
|
||||
|
|
@ -618,14 +616,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;
|
||||
|
|
|
|||
Loading…
Reference in a new issue