mirror of
https://github.com/androidx/media.git
synced 2025-04-30 06:46:50 +08:00
Fix a bug that video effects are added twice
The tests passed because of an issue in chaining. The chaining listener allows self-looping, i.e. the producer and the consumer of a frame could be the same instance. Like an effect chain of `a -> a -> b` This didn't fail any test before, because the chaining is rectified when connecting a to b, but it should have failed when connecting a to a. PiperOrigin-RevId: 742215700
This commit is contained in:
parent
73fa820828
commit
ff6537d69b
@ -15,6 +15,8 @@
|
|||||||
*/
|
*/
|
||||||
package androidx.media3.effect;
|
package androidx.media3.effect;
|
||||||
|
|
||||||
|
import static androidx.media3.common.util.Assertions.checkArgument;
|
||||||
|
|
||||||
import androidx.media3.common.GlObjectsProvider;
|
import androidx.media3.common.GlObjectsProvider;
|
||||||
import androidx.media3.common.GlTextureInfo;
|
import androidx.media3.common.GlTextureInfo;
|
||||||
import androidx.media3.effect.GlShaderProgram.InputListener;
|
import androidx.media3.effect.GlShaderProgram.InputListener;
|
||||||
@ -51,6 +53,9 @@ import androidx.media3.effect.GlShaderProgram.OutputListener;
|
|||||||
GlShaderProgram producingGlShaderProgram,
|
GlShaderProgram producingGlShaderProgram,
|
||||||
GlShaderProgram consumingGlShaderProgram,
|
GlShaderProgram consumingGlShaderProgram,
|
||||||
VideoFrameProcessingTaskExecutor videoFrameProcessingTaskExecutor) {
|
VideoFrameProcessingTaskExecutor videoFrameProcessingTaskExecutor) {
|
||||||
|
checkArgument(
|
||||||
|
producingGlShaderProgram != consumingGlShaderProgram,
|
||||||
|
"Creating a self loop in the chain: " + producingGlShaderProgram);
|
||||||
this.producingGlShaderProgram = producingGlShaderProgram;
|
this.producingGlShaderProgram = producingGlShaderProgram;
|
||||||
frameConsumptionManager =
|
frameConsumptionManager =
|
||||||
new FrameConsumptionManager(
|
new FrameConsumptionManager(
|
||||||
|
@ -782,7 +782,7 @@ public final class PlaybackVideoGraphWrapper implements VideoSinkProvider, Video
|
|||||||
@FirstFrameReleaseInstruction int firstFrameReleaseInstruction,
|
@FirstFrameReleaseInstruction int firstFrameReleaseInstruction,
|
||||||
List<Effect> videoEffects) {
|
List<Effect> videoEffects) {
|
||||||
checkState(isInitialized());
|
checkState(isInitialized());
|
||||||
setPendingVideoEffects(videoEffects);
|
this.videoEffects = ImmutableList.copyOf(videoEffects);
|
||||||
this.inputType = inputType;
|
this.inputType = inputType;
|
||||||
this.inputFormat = format;
|
this.inputFormat = format;
|
||||||
finalBufferPresentationTimeUs = C.TIME_UNSET;
|
finalBufferPresentationTimeUs = C.TIME_UNSET;
|
||||||
@ -863,7 +863,7 @@ public final class PlaybackVideoGraphWrapper implements VideoSinkProvider, Video
|
|||||||
if (this.videoEffects.equals(videoEffects)) {
|
if (this.videoEffects.equals(videoEffects)) {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
setPendingVideoEffects(videoEffects);
|
this.videoEffects = ImmutableList.copyOf(videoEffects);
|
||||||
if (inputFormat != null) {
|
if (inputFormat != null) {
|
||||||
registerInputStream(inputFormat);
|
registerInputStream(inputFormat);
|
||||||
}
|
}
|
||||||
@ -999,23 +999,6 @@ public final class PlaybackVideoGraphWrapper implements VideoSinkProvider, Video
|
|||||||
|
|
||||||
// Private methods
|
// Private methods
|
||||||
|
|
||||||
/**
|
|
||||||
* Sets the pending video effects.
|
|
||||||
*
|
|
||||||
* <p>Effects are pending until a new input stream is registered.
|
|
||||||
*/
|
|
||||||
private void setPendingVideoEffects(List<Effect> newVideoEffects) {
|
|
||||||
if (videoGraphFactory.supportsMultipleInputs()) {
|
|
||||||
this.videoEffects = ImmutableList.copyOf(newVideoEffects);
|
|
||||||
} else {
|
|
||||||
this.videoEffects =
|
|
||||||
new ImmutableList.Builder<Effect>()
|
|
||||||
.addAll(newVideoEffects)
|
|
||||||
.addAll(compositionEffects)
|
|
||||||
.build();
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
private void registerInputStream(Format inputFormat) {
|
private void registerInputStream(Format inputFormat) {
|
||||||
Format adjustedInputFormat =
|
Format adjustedInputFormat =
|
||||||
inputFormat
|
inputFormat
|
||||||
|
Loading…
x
Reference in New Issue
Block a user