From 444cb3fb3a62483df433924fcf33bf08f8e9c179 Mon Sep 17 00:00:00 2001 From: huangdarwin Date: Fri, 22 Sep 2023 12:04:27 -0700 Subject: [PATCH] Test: Rename getBitmap to getBitmapAtPresentationTimeUs PiperOrigin-RevId: 567683139 --- .../java/androidx/media3/effect/FrameDropTest.java | 2 +- .../androidx/media3/test/utils/TextureBitmapReader.java | 8 +++++--- ...VideoFrameProcessorMultipleTextureOutputPixelTest.java | 6 +++--- 3 files changed, 9 insertions(+), 7 deletions(-) diff --git a/libraries/effect/src/androidTest/java/androidx/media3/effect/FrameDropTest.java b/libraries/effect/src/androidTest/java/androidx/media3/effect/FrameDropTest.java index 740c4f1325..47466d8bfe 100644 --- a/libraries/effect/src/androidTest/java/androidx/media3/effect/FrameDropTest.java +++ b/libraries/effect/src/androidTest/java/androidx/media3/effect/FrameDropTest.java @@ -135,7 +135,7 @@ public class FrameDropTest { throws IOException { for (int i = 0; i < presentationTimesUs.size(); i++) { long presentationTimeUs = presentationTimesUs.get(i); - Bitmap actualBitmap = textureBitmapReader.getBitmap(presentationTimeUs); + Bitmap actualBitmap = textureBitmapReader.getBitmapAtPresentationTimeUs(presentationTimeUs); Bitmap expectedBitmap = readBitmap(Util.formatInvariant("%s/pts_%d.png", ASSET_PATH, presentationTimeUs)); maybeSaveTestBitmap( diff --git a/libraries/test_utils/src/main/java/androidx/media3/test/utils/TextureBitmapReader.java b/libraries/test_utils/src/main/java/androidx/media3/test/utils/TextureBitmapReader.java index 87060fd2b8..3ff86df499 100644 --- a/libraries/test_utils/src/main/java/androidx/media3/test/utils/TextureBitmapReader.java +++ b/libraries/test_utils/src/main/java/androidx/media3/test/utils/TextureBitmapReader.java @@ -69,7 +69,7 @@ public final class TextureBitmapReader implements VideoFrameProcessorTestRunner. * @return The output {@link Bitmap} at a given {@code presentationTimeUs}. * @throws IllegalStateException If no such bitmap is produced. */ - public Bitmap getBitmap(long presentationTimeUs) { + public Bitmap getBitmapAtPresentationTimeUs(long presentationTimeUs) { return checkStateNotNull(outputTimestampsToBitmaps.get(presentationTimeUs)); } @@ -81,7 +81,8 @@ public final class TextureBitmapReader implements VideoFrameProcessorTestRunner. /** * Reads the given {@code outputTexture}. * - *

The read result can be fetched by calling one of the {@link #getBitmap} methods. + *

The read result can be fetched by calling {@link #getBitmapAtPresentationTimeUs} or {@link + * #getBitmap}. * *

This implementation incorrectly marks the output Bitmap as {@link Bitmap#isPremultiplied() * premultiplied}, even though OpenGL typically outputs only non-premultiplied alpha. Use {@link @@ -110,7 +111,8 @@ public final class TextureBitmapReader implements VideoFrameProcessorTestRunner. /** * Reads the given {@code outputTexture} as one with unpremultiplied alpha. * - *

The read result can be fetched by calling one of the {@link #getBitmap} methods. + *

The read result can be fetched by calling {@link #getBitmapAtPresentationTimeUs} or {@link + * #getBitmap}. */ @RequiresApi(19) // BitmapPixelTestUtil#createArgb8888BitmapFromFocusedGlFramebuffer. public void readBitmapUnpremultipliedAlpha(GlTextureInfo outputTexture, long presentationTimeUs) diff --git a/libraries/transformer/src/androidTest/java/androidx/media3/transformer/mh/DefaultVideoFrameProcessorMultipleTextureOutputPixelTest.java b/libraries/transformer/src/androidTest/java/androidx/media3/transformer/mh/DefaultVideoFrameProcessorMultipleTextureOutputPixelTest.java index 4547d308e7..65cb33dcee 100644 --- a/libraries/transformer/src/androidTest/java/androidx/media3/transformer/mh/DefaultVideoFrameProcessorMultipleTextureOutputPixelTest.java +++ b/libraries/transformer/src/androidTest/java/androidx/media3/transformer/mh/DefaultVideoFrameProcessorMultipleTextureOutputPixelTest.java @@ -78,7 +78,7 @@ public class DefaultVideoFrameProcessorMultipleTextureOutputPixelTest { TextureBitmapReader textureBitmapReader = checkNotNull(this.textureBitmapReader); Set outputTimestamps = textureBitmapReader.getOutputTimestamps(); assertThat(outputTimestamps).containsExactlyElementsIn(inputTimestamps).inOrder(); - Bitmap actualBitmap = textureBitmapReader.getBitmap(/* presentationTimeUs= */ 1_000_000L); + Bitmap actualBitmap = textureBitmapReader.getBitmapAtPresentationTimeUs(1_000_000L); maybeSaveTestBitmap(testId, /* bitmapLabel= */ "actual", actualBitmap, /* path= */ null); float averagePixelAbsoluteDifference = BitmapPixelTestUtil.getBitmapAveragePixelAbsoluteDifferenceArgb8888( @@ -103,9 +103,9 @@ public class DefaultVideoFrameProcessorMultipleTextureOutputPixelTest { TextureBitmapReader textureBitmapReader = checkNotNull(this.textureBitmapReader); Set actualOutputTimestamps = textureBitmapReader.getOutputTimestamps(); assertThat(actualOutputTimestamps).containsExactlyElementsIn(outputTimestamps).inOrder(); - Bitmap actualBitmap1 = textureBitmapReader.getBitmap(/* presentationTimeUs= */ 1_000_000L); + Bitmap actualBitmap1 = textureBitmapReader.getBitmapAtPresentationTimeUs(1_000_000L); maybeSaveTestBitmap(testId, /* bitmapLabel= */ "actual1", actualBitmap1, /* path= */ null); - Bitmap actualBitmap2 = textureBitmapReader.getBitmap(/* presentationTimeUs= */ 2_000_000L); + Bitmap actualBitmap2 = textureBitmapReader.getBitmapAtPresentationTimeUs(2_000_000L); maybeSaveTestBitmap(testId, /* bitmapLabel= */ "actual2", actualBitmap2, /* path= */ null); float averagePixelAbsoluteDifference1 = BitmapPixelTestUtil.getBitmapAveragePixelAbsoluteDifferenceArgb8888(