diff --git a/libraries/effect/src/main/java/androidx/media3/effect/InternalTextureManager.java b/libraries/effect/src/main/java/androidx/media3/effect/InternalTextureManager.java index 4e2fd45d87..416ef447fb 100644 --- a/libraries/effect/src/main/java/androidx/media3/effect/InternalTextureManager.java +++ b/libraries/effect/src/main/java/androidx/media3/effect/InternalTextureManager.java @@ -16,7 +16,7 @@ package androidx.media3.effect; import static androidx.media3.common.util.Assertions.checkNotNull; -import static java.lang.Math.floor; +import static java.lang.Math.round; import android.graphics.Bitmap; import android.opengl.GLES20; @@ -47,7 +47,7 @@ import org.checkerframework.checker.nullness.qual.MonotonicNonNull; private @MonotonicNonNull GlTextureInfo currentGlTextureInfo; private int downstreamShaderProgramCapacity; private int framesToQueueForCurrentBitmap; - private long currentPresentationTimeUs; + private double currentPresentationTimeUs; private boolean inputEnded; private boolean useHdr; private boolean outputEnded; @@ -109,8 +109,8 @@ import org.checkerframework.checker.nullness.qual.MonotonicNonNull; if (inputEnded) { return; } - int framesToAdd = (int) floor(frameRate * (durationUs / (float) C.MICROS_PER_SECOND)); - long frameDurationUs = (long) floor(C.MICROS_PER_SECOND / frameRate); + int framesToAdd = round(frameRate * (durationUs / (float) C.MICROS_PER_SECOND)); + double frameDurationUs = C.MICROS_PER_SECOND / frameRate; pendingBitmaps.add(new BitmapFrameSequenceInfo(bitmap, frameDurationUs, framesToAdd)); maybeQueueToShaderProgram(); @@ -153,7 +153,8 @@ import org.checkerframework.checker.nullness.qual.MonotonicNonNull; framesToQueueForCurrentBitmap--; downstreamShaderProgramCapacity--; - shaderProgram.queueInputFrame(checkNotNull(currentGlTextureInfo), currentPresentationTimeUs); + shaderProgram.queueInputFrame( + checkNotNull(currentGlTextureInfo), round(currentPresentationTimeUs)); currentPresentationTimeUs += currentBitmapInfo.frameDurationUs; if (framesToQueueForCurrentBitmap == 0) { @@ -175,10 +176,10 @@ import org.checkerframework.checker.nullness.qual.MonotonicNonNull; /** Information to generate all the frames associated with a specific {@link Bitmap}. */ private static final class BitmapFrameSequenceInfo { public final Bitmap bitmap; - public final long frameDurationUs; + public final double frameDurationUs; public final int numberOfFrames; - public BitmapFrameSequenceInfo(Bitmap bitmap, long frameDurationUs, int numberOfFrames) { + public BitmapFrameSequenceInfo(Bitmap bitmap, double frameDurationUs, int numberOfFrames) { this.bitmap = bitmap; this.frameDurationUs = frameDurationUs; this.numberOfFrames = numberOfFrames;