mirror of
https://github.com/samsonjs/media.git
synced 2026-04-27 15:07:40 +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
|
* @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
|
||||||
|
|
|
||||||
|
|
@ -377,7 +377,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);
|
||||||
|
|
|
||||||
|
|
@ -44,7 +44,6 @@ import androidx.media3.common.GlTextureInfo;
|
||||||
import androidx.media3.common.SurfaceInfo;
|
import androidx.media3.common.SurfaceInfo;
|
||||||
import androidx.media3.common.VideoFrameProcessingException;
|
import androidx.media3.common.VideoFrameProcessingException;
|
||||||
import androidx.media3.common.VideoFrameProcessor;
|
import androidx.media3.common.VideoFrameProcessor;
|
||||||
import androidx.media3.common.VideoFrameProcessor.OnInputFrameProcessedListener;
|
|
||||||
import androidx.media3.common.util.GlUtil;
|
import androidx.media3.common.util.GlUtil;
|
||||||
import androidx.media3.common.util.Log;
|
import androidx.media3.common.util.Log;
|
||||||
import androidx.media3.common.util.UnstableApi;
|
import androidx.media3.common.util.UnstableApi;
|
||||||
|
|
@ -596,7 +595,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,
|
||||||
|
|
@ -618,14 +616,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;
|
||||||
*/
|
*/
|
||||||
/* 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;
|
||||||
|
|
||||||
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;
|
||||||
*
|
*
|
||||||
* <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;
|
||||||
|
|
|
||||||
Loading…
Reference in a new issue