mirror of
https://github.com/androidx/media.git
synced 2025-05-09 16:40:55 +08:00
Previewing: Allow inputColorInfo to change, from SDR to HDR.
This also fixes issue introduced by frames being released from a prior version of a GlShaderProgram Tested by seeking within a playlist with one SDR then one HDR video. PiperOrigin-RevId: 599475959
This commit is contained in:
parent
0e66197419
commit
616cb943f0
@ -165,6 +165,14 @@ public abstract class BaseGlShaderProgram implements GlShaderProgram {
|
||||
|
||||
@Override
|
||||
public void releaseOutputFrame(GlTextureInfo outputTexture) {
|
||||
if (!outputTexturePool.isUsingTexture(outputTexture)) {
|
||||
// This allows us to ignore outputTexture instances not associated with this
|
||||
// BaseGlShaderProgram instance. This may happen if a BaseGlShaderProgram is introduced into
|
||||
// the GlShaderProgram chain after frames already exist in the pipeline.
|
||||
// TODO - b/320481157: Consider removing this if condition and disallowing disconnecting a
|
||||
// GlShaderProgram while it still has in-use frames.
|
||||
return;
|
||||
}
|
||||
outputTexturePool.freeTexture(outputTexture);
|
||||
inputListener.onReadyToAcceptInputFrame();
|
||||
}
|
||||
|
@ -76,6 +76,7 @@ import org.checkerframework.checker.nullness.qual.MonotonicNonNull;
|
||||
|
||||
@Override
|
||||
public void setSamplingGlShaderProgram(GlShaderProgram samplingGlShaderProgram) {
|
||||
downstreamShaderProgramCapacity = 0;
|
||||
this.shaderProgram = samplingGlShaderProgram;
|
||||
}
|
||||
|
||||
|
@ -447,12 +447,7 @@ public final class DefaultVideoFrameProcessor implements VideoFrameProcessor {
|
||||
* <p>If either {@link FrameInfo#colorInfo} or {@code outputColorInfo} {@linkplain
|
||||
* ColorInfo#isTransferHdr} are HDR}, color transfers must {@linkplain
|
||||
* Factory.Builder#setEnableColorTransfers be enabled}.
|
||||
*
|
||||
* <p>The {@link FrameInfo}'s {@link ColorInfo} must not change between different calls to this
|
||||
* method.
|
||||
*/
|
||||
// TODO: b/307952514: After updating frameInfo.colorInfo works with flushing, remove relevant
|
||||
// javadoc.
|
||||
@Override
|
||||
public void registerInputStream(
|
||||
@InputType int inputType, List<Effect> effects, FrameInfo frameInfo) {
|
||||
|
@ -140,6 +140,7 @@ import org.checkerframework.checker.nullness.qual.MonotonicNonNull;
|
||||
@Override
|
||||
public void setSamplingGlShaderProgram(GlShaderProgram samplingGlShaderProgram) {
|
||||
checkState(samplingGlShaderProgram instanceof ExternalShaderProgram);
|
||||
externalShaderProgramInputCapacity.set(0);
|
||||
this.externalShaderProgram = (ExternalShaderProgram) samplingGlShaderProgram;
|
||||
}
|
||||
|
||||
|
@ -69,8 +69,6 @@ import androidx.media3.common.util.TimestampIterator;
|
||||
*
|
||||
* <p>Must be called before any method that queues input or {@link
|
||||
* #signalEndOfCurrentInputStream()}.
|
||||
*
|
||||
* <p>This must only be called once.
|
||||
*/
|
||||
public abstract void setSamplingGlShaderProgram(GlShaderProgram samplingGlShaderProgram);
|
||||
|
||||
|
@ -105,6 +105,11 @@ import java.util.Queue;
|
||||
freeTextures.add(textureInfo);
|
||||
}
|
||||
|
||||
/** Returns whether the texture represented by {@code textureInfo} is in use. */
|
||||
public boolean isUsingTexture(GlTextureInfo textureInfo) {
|
||||
return inUseTextures.contains(textureInfo);
|
||||
}
|
||||
|
||||
/**
|
||||
* Frees the oldest in-use texture.
|
||||
*
|
||||
|
@ -560,7 +560,6 @@ public final class CompositingVideoSinkProvider
|
||||
@Nullable private Effect rotationEffect;
|
||||
|
||||
@Nullable private Format inputFormat;
|
||||
private @MonotonicNonNull ColorInfo firstInputColorInfo;
|
||||
private @InputType int inputType;
|
||||
private long inputStreamOffsetUs;
|
||||
private boolean pendingInputStreamOffsetChange;
|
||||
@ -778,15 +777,13 @@ public final class CompositingVideoSinkProvider
|
||||
}
|
||||
effects.addAll(videoEffects);
|
||||
Format inputFormat = checkNotNull(this.inputFormat);
|
||||
if (firstInputColorInfo == null) {
|
||||
// TODO: b/307952514 - Get inputColorInfo from inputFormat for each stream, after this value
|
||||
// can change per-stream.
|
||||
firstInputColorInfo = getAdjustedInputColorInfo(inputFormat.colorInfo);
|
||||
}
|
||||
videoFrameProcessor.registerInputStream(
|
||||
inputType,
|
||||
effects,
|
||||
new FrameInfo.Builder(firstInputColorInfo, inputFormat.width, inputFormat.height)
|
||||
new FrameInfo.Builder(
|
||||
getAdjustedInputColorInfo(inputFormat.colorInfo),
|
||||
inputFormat.width,
|
||||
inputFormat.height)
|
||||
.setPixelWidthHeightRatio(inputFormat.pixelWidthHeightRatio)
|
||||
.build());
|
||||
}
|
||||
|
Loading…
x
Reference in New Issue
Block a user