diff --git a/google3/third_party/java_src/android_libs/media/libraries/effect/src/androidTest/java/androidx/media3/effect/BitmapTestUtil.java b/google3/third_party/java_src/android_libs/media/libraries/effect/src/androidTest/java/androidx/media3/effect/BitmapTestUtil.java index 079674d05e..0c162bc98b 100644 --- a/google3/third_party/java_src/android_libs/media/libraries/effect/src/androidTest/java/androidx/media3/effect/BitmapTestUtil.java +++ b/google3/third_party/java_src/android_libs/media/libraries/effect/src/androidTest/java/androidx/media3/effect/BitmapTestUtil.java @@ -129,7 +129,7 @@ public class BitmapTestUtil { * @return The average of the maximum absolute pixel-wise differences between the expected and * actual bitmaps. */ - public static float getAveragePixelAbsoluteDifferenceArgb8888( + public static float getBitmapAveragePixelAbsoluteDifferenceArgb8888( Bitmap expected, Bitmap actual, @Nullable String testId) { int width = actual.getWidth(); int height = actual.getHeight(); diff --git a/google3/third_party/java_src/android_libs/media/libraries/effect/src/androidTest/java/androidx/media3/effect/ContrastPixelTest.java b/google3/third_party/java_src/android_libs/media/libraries/effect/src/androidTest/java/androidx/media3/effect/ContrastPixelTest.java index f866b035c4..8b07be1936 100644 --- a/google3/third_party/java_src/android_libs/media/libraries/effect/src/androidTest/java/androidx/media3/effect/ContrastPixelTest.java +++ b/google3/third_party/java_src/android_libs/media/libraries/effect/src/androidTest/java/androidx/media3/effect/ContrastPixelTest.java @@ -17,6 +17,12 @@ package androidx.media3.effect; import static androidx.media3.effect.BitmapTestUtil.MAXIMUM_AVERAGE_PIXEL_ABSOLUTE_DIFFERENCE; +import static androidx.media3.effect.BitmapTestUtil.createArgb8888BitmapFromCurrentGlFramebuffer; +import static androidx.media3.effect.BitmapTestUtil.createArgb8888BitmapWithSolidColor; +import static androidx.media3.effect.BitmapTestUtil.createGlTextureFromBitmap; +import static androidx.media3.effect.BitmapTestUtil.getBitmapAveragePixelAbsoluteDifferenceArgb8888; +import static androidx.media3.effect.BitmapTestUtil.maybeSaveTestBitmapToCacheDirectory; +import static androidx.media3.effect.BitmapTestUtil.readBitmap; import static androidx.test.core.app.ApplicationProvider.getApplicationContext; import static com.google.android.exoplayer2.util.Assertions.checkNotNull; import static com.google.common.truth.Truth.assertThat; @@ -75,13 +81,13 @@ public class ContrastPixelTest { eglDisplay = GlUtil.createEglDisplay(); eglContext = GlUtil.createEglContext(eglDisplay); - Bitmap inputBitmap = BitmapTestUtil.readBitmap(ORIGINAL_PNG_ASSET_PATH); + Bitmap inputBitmap = readBitmap(ORIGINAL_PNG_ASSET_PATH); inputWidth = inputBitmap.getWidth(); inputHeight = inputBitmap.getHeight(); placeholderEglSurface = GlUtil.createPlaceholderEglSurface(eglDisplay); GlUtil.focusEglSurface(eglDisplay, eglContext, placeholderEglSurface, inputWidth, inputHeight); - inputTexId = BitmapTestUtil.createGlTextureFromBitmap(inputBitmap); + inputTexId = createGlTextureFromBitmap(inputBitmap); } @After @@ -99,18 +105,15 @@ public class ContrastPixelTest { new Contrast(/* contrast= */ 0.0f).toGlTextureProcessor(context, /* useHdr= */ false); Pair outputSize = contrastProcessor.configure(inputWidth, inputHeight); setupOutputTexture(outputSize.first, outputSize.second); - Bitmap expectedBitmap = BitmapTestUtil.readBitmap(ORIGINAL_PNG_ASSET_PATH); + Bitmap expectedBitmap = readBitmap(ORIGINAL_PNG_ASSET_PATH); contrastProcessor.drawFrame(inputTexId, /* presentationTimeUs = */ 0); Bitmap actualBitmap = - BitmapTestUtil.createArgb8888BitmapFromCurrentGlFramebuffer( - outputSize.first, outputSize.second); + createArgb8888BitmapFromCurrentGlFramebuffer(outputSize.first, outputSize.second); - BitmapTestUtil.maybeSaveTestBitmapToCacheDirectory( - testId, /* bitmapLabel= */ "actual", actualBitmap); + maybeSaveTestBitmapToCacheDirectory(testId, /* bitmapLabel= */ "actual", actualBitmap); float averagePixelAbsoluteDifference = - BitmapTestUtil.getAveragePixelAbsoluteDifferenceArgb8888( - expectedBitmap, actualBitmap, testId); + getBitmapAveragePixelAbsoluteDifferenceArgb8888(expectedBitmap, actualBitmap, testId); assertThat(averagePixelAbsoluteDifference).isAtMost(MAXIMUM_AVERAGE_PIXEL_ABSOLUTE_DIFFERENCE); } @@ -122,7 +125,7 @@ public class ContrastPixelTest { Pair outputSize = contrastProcessor.configure(inputWidth, inputHeight); setupOutputTexture(outputSize.first, outputSize.second); Bitmap expectedBitmap = - BitmapTestUtil.createArgb8888BitmapWithSolidColor( + createArgb8888BitmapWithSolidColor( inputWidth, inputHeight, Color.rgb( @@ -130,14 +133,11 @@ public class ContrastPixelTest { contrastProcessor.drawFrame(inputTexId, /* presentationTimeUs = */ 0); Bitmap actualBitmap = - BitmapTestUtil.createArgb8888BitmapFromCurrentGlFramebuffer( - outputSize.first, outputSize.second); + createArgb8888BitmapFromCurrentGlFramebuffer(outputSize.first, outputSize.second); - BitmapTestUtil.maybeSaveTestBitmapToCacheDirectory( - testId, /* bitmapLabel= */ "actual", actualBitmap); + maybeSaveTestBitmapToCacheDirectory(testId, /* bitmapLabel= */ "actual", actualBitmap); float averagePixelAbsoluteDifference = - BitmapTestUtil.getAveragePixelAbsoluteDifferenceArgb8888( - expectedBitmap, actualBitmap, testId); + getBitmapAveragePixelAbsoluteDifferenceArgb8888(expectedBitmap, actualBitmap, testId); assertThat(averagePixelAbsoluteDifference).isAtMost(MAXIMUM_AVERAGE_PIXEL_ABSOLUTE_DIFFERENCE); } @@ -149,18 +149,15 @@ public class ContrastPixelTest { new Contrast(/* contrast= */ -0.75f).toGlTextureProcessor(context, /* useHdr= */ false); Pair outputSize = contrastProcessor.configure(inputWidth, inputHeight); setupOutputTexture(outputSize.first, outputSize.second); - Bitmap expectedBitmap = BitmapTestUtil.readBitmap(DECREASE_CONTRAST_PNG_ASSET_PATH); + Bitmap expectedBitmap = readBitmap(DECREASE_CONTRAST_PNG_ASSET_PATH); contrastProcessor.drawFrame(inputTexId, /* presentationTimeUs= */ 0); Bitmap actualBitmap = - BitmapTestUtil.createArgb8888BitmapFromCurrentGlFramebuffer( - outputSize.first, outputSize.second); + createArgb8888BitmapFromCurrentGlFramebuffer(outputSize.first, outputSize.second); - BitmapTestUtil.maybeSaveTestBitmapToCacheDirectory( - testId, /* bitmapLabel= */ "actual", actualBitmap); + maybeSaveTestBitmapToCacheDirectory(testId, /* bitmapLabel= */ "actual", actualBitmap); float averagePixelAbsoluteDifference = - BitmapTestUtil.getAveragePixelAbsoluteDifferenceArgb8888( - expectedBitmap, actualBitmap, testId); + getBitmapAveragePixelAbsoluteDifferenceArgb8888(expectedBitmap, actualBitmap, testId); assertThat(averagePixelAbsoluteDifference).isAtMost(MAXIMUM_AVERAGE_PIXEL_ABSOLUTE_DIFFERENCE); } @@ -172,18 +169,15 @@ public class ContrastPixelTest { new Contrast(/* contrast= */ 0.75f).toGlTextureProcessor(context, /* useHdr= */ false); Pair outputSize = contrastProcessor.configure(inputWidth, inputHeight); setupOutputTexture(outputSize.first, outputSize.second); - Bitmap expectedBitmap = BitmapTestUtil.readBitmap(INCREASE_CONTRAST_PNG_ASSET_PATH); + Bitmap expectedBitmap = readBitmap(INCREASE_CONTRAST_PNG_ASSET_PATH); contrastProcessor.drawFrame(inputTexId, /* presentationTimeUs= */ 0); Bitmap actualBitmap = - BitmapTestUtil.createArgb8888BitmapFromCurrentGlFramebuffer( - outputSize.first, outputSize.second); + createArgb8888BitmapFromCurrentGlFramebuffer(outputSize.first, outputSize.second); - BitmapTestUtil.maybeSaveTestBitmapToCacheDirectory( - testId, /* bitmapLabel= */ "actual", actualBitmap); + maybeSaveTestBitmapToCacheDirectory(testId, /* bitmapLabel= */ "actual", actualBitmap); float averagePixelAbsoluteDifference = - BitmapTestUtil.getAveragePixelAbsoluteDifferenceArgb8888( - expectedBitmap, actualBitmap, testId); + getBitmapAveragePixelAbsoluteDifferenceArgb8888(expectedBitmap, actualBitmap, testId); assertThat(averagePixelAbsoluteDifference).isAtMost(MAXIMUM_AVERAGE_PIXEL_ABSOLUTE_DIFFERENCE); } @@ -194,18 +188,15 @@ public class ContrastPixelTest { new Contrast(/* contrast= */ 1.0f).toGlTextureProcessor(context, /* useHdr= */ false); Pair outputSize = contrastProcessor.configure(inputWidth, inputHeight); setupOutputTexture(outputSize.first, outputSize.second); - Bitmap expectedBitmap = BitmapTestUtil.readBitmap(MAXIMUM_CONTRAST_PNG_ASSET_PATH); + Bitmap expectedBitmap = readBitmap(MAXIMUM_CONTRAST_PNG_ASSET_PATH); contrastProcessor.drawFrame(inputTexId, /* presentationTimeUs = */ 0); Bitmap actualBitmap = - BitmapTestUtil.createArgb8888BitmapFromCurrentGlFramebuffer( - outputSize.first, outputSize.second); + createArgb8888BitmapFromCurrentGlFramebuffer(outputSize.first, outputSize.second); - BitmapTestUtil.maybeSaveTestBitmapToCacheDirectory( - testId, /* bitmapLabel= */ "actual", actualBitmap); + maybeSaveTestBitmapToCacheDirectory(testId, /* bitmapLabel= */ "actual", actualBitmap); float averagePixelAbsoluteDifference = - BitmapTestUtil.getAveragePixelAbsoluteDifferenceArgb8888( - expectedBitmap, actualBitmap, testId); + getBitmapAveragePixelAbsoluteDifferenceArgb8888(expectedBitmap, actualBitmap, testId); assertThat(averagePixelAbsoluteDifference).isAtMost(MAXIMUM_AVERAGE_PIXEL_ABSOLUTE_DIFFERENCE); } diff --git a/google3/third_party/java_src/android_libs/media/libraries/effect/src/androidTest/java/androidx/media3/effect/CropPixelTest.java b/google3/third_party/java_src/android_libs/media/libraries/effect/src/androidTest/java/androidx/media3/effect/CropPixelTest.java index af6b41e357..09373a69ab 100644 --- a/google3/third_party/java_src/android_libs/media/libraries/effect/src/androidTest/java/androidx/media3/effect/CropPixelTest.java +++ b/google3/third_party/java_src/android_libs/media/libraries/effect/src/androidTest/java/androidx/media3/effect/CropPixelTest.java @@ -16,6 +16,11 @@ package androidx.media3.effect; import static androidx.media3.effect.BitmapTestUtil.MAXIMUM_AVERAGE_PIXEL_ABSOLUTE_DIFFERENCE; +import static androidx.media3.effect.BitmapTestUtil.createArgb8888BitmapFromCurrentGlFramebuffer; +import static androidx.media3.effect.BitmapTestUtil.createGlTextureFromBitmap; +import static androidx.media3.effect.BitmapTestUtil.getBitmapAveragePixelAbsoluteDifferenceArgb8888; +import static androidx.media3.effect.BitmapTestUtil.maybeSaveTestBitmapToCacheDirectory; +import static androidx.media3.effect.BitmapTestUtil.readBitmap; import static androidx.test.core.app.ApplicationProvider.getApplicationContext; import static com.google.android.exoplayer2.util.Assertions.checkNotNull; import static com.google.common.truth.Truth.assertThat; @@ -68,12 +73,12 @@ public final class CropPixelTest { public void createGlObjects() throws IOException, GlUtil.GlException { eglDisplay = GlUtil.createEglDisplay(); eglContext = GlUtil.createEglContext(eglDisplay); - Bitmap inputBitmap = BitmapTestUtil.readBitmap(ORIGINAL_PNG_ASSET_PATH); + Bitmap inputBitmap = readBitmap(ORIGINAL_PNG_ASSET_PATH); inputWidth = inputBitmap.getWidth(); inputHeight = inputBitmap.getHeight(); placeholderEglSurface = GlUtil.createPlaceholderEglSurface(eglDisplay); GlUtil.focusEglSurface(eglDisplay, eglContext, placeholderEglSurface, inputWidth, inputHeight); - inputTexId = BitmapTestUtil.createGlTextureFromBitmap(inputBitmap); + inputTexId = createGlTextureFromBitmap(inputBitmap); } @After @@ -94,19 +99,16 @@ public final class CropPixelTest { .toGlTextureProcessor(context, /* useHdr= */ false); Pair outputSize = cropTextureProcessor.configure(inputWidth, inputHeight); setupOutputTexture(outputSize.first, outputSize.second); - Bitmap expectedBitmap = BitmapTestUtil.readBitmap(ORIGINAL_PNG_ASSET_PATH); + Bitmap expectedBitmap = readBitmap(ORIGINAL_PNG_ASSET_PATH); cropTextureProcessor.drawFrame(inputTexId, /* presentationTimeUs= */ 0); Bitmap actualBitmap = - BitmapTestUtil.createArgb8888BitmapFromCurrentGlFramebuffer( - outputSize.first, outputSize.second); + createArgb8888BitmapFromCurrentGlFramebuffer(outputSize.first, outputSize.second); - BitmapTestUtil.maybeSaveTestBitmapToCacheDirectory( - testId, /* bitmapLabel= */ "actual", actualBitmap); + maybeSaveTestBitmapToCacheDirectory(testId, /* bitmapLabel= */ "actual", actualBitmap); // TODO(b/207848601): switch to using proper tooling for testing against golden data. float averagePixelAbsoluteDifference = - BitmapTestUtil.getAveragePixelAbsoluteDifferenceArgb8888( - expectedBitmap, actualBitmap, testId); + getBitmapAveragePixelAbsoluteDifferenceArgb8888(expectedBitmap, actualBitmap, testId); assertThat(averagePixelAbsoluteDifference).isAtMost(MAXIMUM_AVERAGE_PIXEL_ABSOLUTE_DIFFERENCE); } @@ -118,19 +120,16 @@ public final class CropPixelTest { .toGlTextureProcessor(context, /* useHdr= */ false); Pair outputSize = cropTextureProcessor.configure(inputWidth, inputHeight); setupOutputTexture(outputSize.first, outputSize.second); - Bitmap expectedBitmap = BitmapTestUtil.readBitmap(CROP_SMALLER_PNG_ASSET_PATH); + Bitmap expectedBitmap = readBitmap(CROP_SMALLER_PNG_ASSET_PATH); cropTextureProcessor.drawFrame(inputTexId, /* presentationTimeUs= */ 0); Bitmap actualBitmap = - BitmapTestUtil.createArgb8888BitmapFromCurrentGlFramebuffer( - outputSize.first, outputSize.second); + createArgb8888BitmapFromCurrentGlFramebuffer(outputSize.first, outputSize.second); - BitmapTestUtil.maybeSaveTestBitmapToCacheDirectory( - testId, /* bitmapLabel= */ "actual", actualBitmap); + maybeSaveTestBitmapToCacheDirectory(testId, /* bitmapLabel= */ "actual", actualBitmap); // TODO(b/207848601): switch to using proper tooling for testing against golden data. float averagePixelAbsoluteDifference = - BitmapTestUtil.getAveragePixelAbsoluteDifferenceArgb8888( - expectedBitmap, actualBitmap, testId); + getBitmapAveragePixelAbsoluteDifferenceArgb8888(expectedBitmap, actualBitmap, testId); assertThat(averagePixelAbsoluteDifference).isAtMost(MAXIMUM_AVERAGE_PIXEL_ABSOLUTE_DIFFERENCE); } @@ -142,19 +141,16 @@ public final class CropPixelTest { .toGlTextureProcessor(context, /* useHdr= */ false); Pair outputSize = cropTextureProcessor.configure(inputWidth, inputHeight); setupOutputTexture(outputSize.first, outputSize.second); - Bitmap expectedBitmap = BitmapTestUtil.readBitmap(CROP_LARGER_PNG_ASSET_PATH); + Bitmap expectedBitmap = readBitmap(CROP_LARGER_PNG_ASSET_PATH); cropTextureProcessor.drawFrame(inputTexId, /* presentationTimeUs= */ 0); Bitmap actualBitmap = - BitmapTestUtil.createArgb8888BitmapFromCurrentGlFramebuffer( - outputSize.first, outputSize.second); + createArgb8888BitmapFromCurrentGlFramebuffer(outputSize.first, outputSize.second); - BitmapTestUtil.maybeSaveTestBitmapToCacheDirectory( - testId, /* bitmapLabel= */ "actual", actualBitmap); + maybeSaveTestBitmapToCacheDirectory(testId, /* bitmapLabel= */ "actual", actualBitmap); // TODO(b/207848601): switch to using proper tooling for testing against golden data. float averagePixelAbsoluteDifference = - BitmapTestUtil.getAveragePixelAbsoluteDifferenceArgb8888( - expectedBitmap, actualBitmap, testId); + getBitmapAveragePixelAbsoluteDifferenceArgb8888(expectedBitmap, actualBitmap, testId); assertThat(averagePixelAbsoluteDifference).isAtMost(MAXIMUM_AVERAGE_PIXEL_ABSOLUTE_DIFFERENCE); } diff --git a/google3/third_party/java_src/android_libs/media/libraries/effect/src/androidTest/java/androidx/media3/effect/GlEffectsFrameProcessorPixelTest.java b/google3/third_party/java_src/android_libs/media/libraries/effect/src/androidTest/java/androidx/media3/effect/GlEffectsFrameProcessorPixelTest.java index a57c9ee63f..41f26e9959 100644 --- a/google3/third_party/java_src/android_libs/media/libraries/effect/src/androidTest/java/androidx/media3/effect/GlEffectsFrameProcessorPixelTest.java +++ b/google3/third_party/java_src/android_libs/media/libraries/effect/src/androidTest/java/androidx/media3/effect/GlEffectsFrameProcessorPixelTest.java @@ -16,6 +16,10 @@ package androidx.media3.effect; import static androidx.media3.effect.BitmapTestUtil.MAXIMUM_AVERAGE_PIXEL_ABSOLUTE_DIFFERENCE; +import static androidx.media3.effect.BitmapTestUtil.createArgb8888BitmapFromRgba8888Image; +import static androidx.media3.effect.BitmapTestUtil.getBitmapAveragePixelAbsoluteDifferenceArgb8888; +import static androidx.media3.effect.BitmapTestUtil.maybeSaveTestBitmapToCacheDirectory; +import static androidx.media3.effect.BitmapTestUtil.readBitmap; import static androidx.test.core.app.ApplicationProvider.getApplicationContext; import static com.google.android.exoplayer2.util.Assertions.checkNotNull; import static com.google.android.exoplayer2.util.Assertions.checkStateNotNull; @@ -109,16 +113,14 @@ public final class GlEffectsFrameProcessorPixelTest { public void processData_noEdits_producesExpectedOutput() throws Exception { String testId = "processData_noEdits"; setUpAndPrepareFirstFrame(DEFAULT_PIXEL_WIDTH_HEIGHT_RATIO); - Bitmap expectedBitmap = BitmapTestUtil.readBitmap(ORIGINAL_PNG_ASSET_PATH); + Bitmap expectedBitmap = readBitmap(ORIGINAL_PNG_ASSET_PATH); Bitmap actualBitmap = processFirstFrameAndEnd(); - BitmapTestUtil.maybeSaveTestBitmapToCacheDirectory( - testId, /* bitmapLabel= */ "actual", actualBitmap); + maybeSaveTestBitmapToCacheDirectory(testId, /* bitmapLabel= */ "actual", actualBitmap); // TODO(b/207848601): switch to using proper tooling for testing against golden data. float averagePixelAbsoluteDifference = - BitmapTestUtil.getAveragePixelAbsoluteDifferenceArgb8888( - expectedBitmap, actualBitmap, testId); + getBitmapAveragePixelAbsoluteDifferenceArgb8888(expectedBitmap, actualBitmap, testId); assertThat(averagePixelAbsoluteDifference).isAtMost(MAXIMUM_AVERAGE_PIXEL_ABSOLUTE_DIFFERENCE); } @@ -126,16 +128,14 @@ public final class GlEffectsFrameProcessorPixelTest { public void processData_withPixelWidthHeightRatio_producesExpectedOutput() throws Exception { String testId = "processData_withPixelWidthHeightRatio"; setUpAndPrepareFirstFrame(/* pixelWidthHeightRatio= */ 2f); - Bitmap expectedBitmap = BitmapTestUtil.readBitmap(SCALE_WIDE_PNG_ASSET_PATH); + Bitmap expectedBitmap = readBitmap(SCALE_WIDE_PNG_ASSET_PATH); Bitmap actualBitmap = processFirstFrameAndEnd(); - BitmapTestUtil.maybeSaveTestBitmapToCacheDirectory( - testId, /* bitmapLabel= */ "actual", actualBitmap); + maybeSaveTestBitmapToCacheDirectory(testId, /* bitmapLabel= */ "actual", actualBitmap); // TODO(b/207848601): switch to using proper tooling for testing against golden data. float averagePixelAbsoluteDifference = - BitmapTestUtil.getAveragePixelAbsoluteDifferenceArgb8888( - expectedBitmap, actualBitmap, testId); + getBitmapAveragePixelAbsoluteDifferenceArgb8888(expectedBitmap, actualBitmap, testId); assertThat(averagePixelAbsoluteDifference).isAtMost(MAXIMUM_AVERAGE_PIXEL_ABSOLUTE_DIFFERENCE); } @@ -148,16 +148,14 @@ public final class GlEffectsFrameProcessorPixelTest { setUpAndPrepareFirstFrame( DEFAULT_PIXEL_WIDTH_HEIGHT_RATIO, (MatrixTransformation) (long presentationTimeNs) -> translateRightMatrix); - Bitmap expectedBitmap = BitmapTestUtil.readBitmap(TRANSLATE_RIGHT_PNG_ASSET_PATH); + Bitmap expectedBitmap = readBitmap(TRANSLATE_RIGHT_PNG_ASSET_PATH); Bitmap actualBitmap = processFirstFrameAndEnd(); - BitmapTestUtil.maybeSaveTestBitmapToCacheDirectory( - testId, /* bitmapLabel= */ "actual", actualBitmap); + maybeSaveTestBitmapToCacheDirectory(testId, /* bitmapLabel= */ "actual", actualBitmap); // TODO(b/207848601): switch to using proper tooling for testing against golden data. float averagePixelAbsoluteDifference = - BitmapTestUtil.getAveragePixelAbsoluteDifferenceArgb8888( - expectedBitmap, actualBitmap, testId); + getBitmapAveragePixelAbsoluteDifferenceArgb8888(expectedBitmap, actualBitmap, testId); assertThat(averagePixelAbsoluteDifference).isAtMost(MAXIMUM_AVERAGE_PIXEL_ABSOLUTE_DIFFERENCE); } @@ -171,16 +169,14 @@ public final class GlEffectsFrameProcessorPixelTest { DEFAULT_PIXEL_WIDTH_HEIGHT_RATIO, (MatrixTransformation) (long presentationTimeUs) -> translateRightMatrix, new ScaleToFitTransformation.Builder().setRotationDegrees(45).build()); - Bitmap expectedBitmap = BitmapTestUtil.readBitmap(TRANSLATE_THEN_ROTATE_PNG_ASSET_PATH); + Bitmap expectedBitmap = readBitmap(TRANSLATE_THEN_ROTATE_PNG_ASSET_PATH); Bitmap actualBitmap = processFirstFrameAndEnd(); - BitmapTestUtil.maybeSaveTestBitmapToCacheDirectory( - testId, /* bitmapLabel= */ "actual", actualBitmap); + maybeSaveTestBitmapToCacheDirectory(testId, /* bitmapLabel= */ "actual", actualBitmap); // TODO(b/207848601): switch to using proper tooling for testing against golden data. float averagePixelAbsoluteDifference = - BitmapTestUtil.getAveragePixelAbsoluteDifferenceArgb8888( - expectedBitmap, actualBitmap, testId); + getBitmapAveragePixelAbsoluteDifferenceArgb8888(expectedBitmap, actualBitmap, testId); assertThat(averagePixelAbsoluteDifference).isAtMost(MAXIMUM_AVERAGE_PIXEL_ABSOLUTE_DIFFERENCE); } @@ -194,16 +190,14 @@ public final class GlEffectsFrameProcessorPixelTest { DEFAULT_PIXEL_WIDTH_HEIGHT_RATIO, new ScaleToFitTransformation.Builder().setRotationDegrees(45).build(), (MatrixTransformation) (long presentationTimeUs) -> translateRightMatrix); - Bitmap expectedBitmap = BitmapTestUtil.readBitmap(ROTATE_THEN_TRANSLATE_PNG_ASSET_PATH); + Bitmap expectedBitmap = readBitmap(ROTATE_THEN_TRANSLATE_PNG_ASSET_PATH); Bitmap actualBitmap = processFirstFrameAndEnd(); - BitmapTestUtil.maybeSaveTestBitmapToCacheDirectory( - testId, /* bitmapLabel= */ "actual", actualBitmap); + maybeSaveTestBitmapToCacheDirectory(testId, /* bitmapLabel= */ "actual", actualBitmap); // TODO(b/207848601): switch to using proper tooling for testing against golden data. float averagePixelAbsoluteDifference = - BitmapTestUtil.getAveragePixelAbsoluteDifferenceArgb8888( - expectedBitmap, actualBitmap, testId); + getBitmapAveragePixelAbsoluteDifferenceArgb8888(expectedBitmap, actualBitmap, testId); assertThat(averagePixelAbsoluteDifference).isAtMost(MAXIMUM_AVERAGE_PIXEL_ABSOLUTE_DIFFERENCE); } @@ -212,16 +206,14 @@ public final class GlEffectsFrameProcessorPixelTest { throws Exception { String testId = "processData_withPresentation_createForHeight"; setUpAndPrepareFirstFrame(DEFAULT_PIXEL_WIDTH_HEIGHT_RATIO, Presentation.createForHeight(480)); - Bitmap expectedBitmap = BitmapTestUtil.readBitmap(REQUEST_OUTPUT_HEIGHT_PNG_ASSET_PATH); + Bitmap expectedBitmap = readBitmap(REQUEST_OUTPUT_HEIGHT_PNG_ASSET_PATH); Bitmap actualBitmap = processFirstFrameAndEnd(); - BitmapTestUtil.maybeSaveTestBitmapToCacheDirectory( - testId, /* bitmapLabel= */ "actual", actualBitmap); + maybeSaveTestBitmapToCacheDirectory(testId, /* bitmapLabel= */ "actual", actualBitmap); // TODO(b/207848601): switch to using proper tooling for testing against golden data. float averagePixelAbsoluteDifference = - BitmapTestUtil.getAveragePixelAbsoluteDifferenceArgb8888( - expectedBitmap, actualBitmap, testId); + getBitmapAveragePixelAbsoluteDifferenceArgb8888(expectedBitmap, actualBitmap, testId); assertThat(averagePixelAbsoluteDifference).isAtMost(MAXIMUM_AVERAGE_PIXEL_ABSOLUTE_DIFFERENCE); } @@ -233,16 +225,14 @@ public final class GlEffectsFrameProcessorPixelTest { new Crop(/* left= */ -.5f, /* right= */ .5f, /* bottom= */ -.5f, /* top= */ .5f), Presentation.createForAspectRatio( /* aspectRatio= */ .5f, Presentation.LAYOUT_SCALE_TO_FIT)); - Bitmap expectedBitmap = BitmapTestUtil.readBitmap(CROP_THEN_ASPECT_RATIO_PNG_ASSET_PATH); + Bitmap expectedBitmap = readBitmap(CROP_THEN_ASPECT_RATIO_PNG_ASSET_PATH); Bitmap actualBitmap = processFirstFrameAndEnd(); - BitmapTestUtil.maybeSaveTestBitmapToCacheDirectory( - testId, /* bitmapLabel= */ "actual", actualBitmap); + maybeSaveTestBitmapToCacheDirectory(testId, /* bitmapLabel= */ "actual", actualBitmap); // TODO(b/207848601): switch to using proper tooling for testing against golden data. float averagePixelAbsoluteDifference = - BitmapTestUtil.getAveragePixelAbsoluteDifferenceArgb8888( - expectedBitmap, actualBitmap, testId); + getBitmapAveragePixelAbsoluteDifferenceArgb8888(expectedBitmap, actualBitmap, testId); assertThat(averagePixelAbsoluteDifference).isAtMost(MAXIMUM_AVERAGE_PIXEL_ABSOLUTE_DIFFERENCE); } @@ -253,16 +243,14 @@ public final class GlEffectsFrameProcessorPixelTest { setUpAndPrepareFirstFrame( DEFAULT_PIXEL_WIDTH_HEIGHT_RATIO, new ScaleToFitTransformation.Builder().setRotationDegrees(45).build()); - Bitmap expectedBitmap = BitmapTestUtil.readBitmap(ROTATE45_SCALE_TO_FIT_PNG_ASSET_PATH); + Bitmap expectedBitmap = readBitmap(ROTATE45_SCALE_TO_FIT_PNG_ASSET_PATH); Bitmap actualBitmap = processFirstFrameAndEnd(); - BitmapTestUtil.maybeSaveTestBitmapToCacheDirectory( - testId, /* bitmapLabel= */ "actual", actualBitmap); + maybeSaveTestBitmapToCacheDirectory(testId, /* bitmapLabel= */ "actual", actualBitmap); // TODO(b/207848601): switch to using proper tooling for testing against golden data. float averagePixelAbsoluteDifference = - BitmapTestUtil.getAveragePixelAbsoluteDifferenceArgb8888( - expectedBitmap, actualBitmap, testId); + getBitmapAveragePixelAbsoluteDifferenceArgb8888(expectedBitmap, actualBitmap, testId); assertThat(averagePixelAbsoluteDifference).isAtMost(MAXIMUM_AVERAGE_PIXEL_ABSOLUTE_DIFFERENCE); } @@ -277,16 +265,14 @@ public final class GlEffectsFrameProcessorPixelTest { new ScaleToFitTransformation.Builder() .setScale(/* scaleX= */ 2, /* scaleY= */ 1) .build())); - Bitmap expectedBitmap = BitmapTestUtil.readBitmap(ROTATE_THEN_SCALE_PNG_ASSET_PATH); + Bitmap expectedBitmap = readBitmap(ROTATE_THEN_SCALE_PNG_ASSET_PATH); Bitmap actualBitmap = processFirstFrameAndEnd(); - BitmapTestUtil.maybeSaveTestBitmapToCacheDirectory( - testId, /* bitmapLabel= */ "actual", actualBitmap); + maybeSaveTestBitmapToCacheDirectory(testId, /* bitmapLabel= */ "actual", actualBitmap); // TODO(b/207848601): switch to using proper tooling for testing against golden data. float averagePixelAbsoluteDifference = - BitmapTestUtil.getAveragePixelAbsoluteDifferenceArgb8888( - expectedBitmap, actualBitmap, testId); + getBitmapAveragePixelAbsoluteDifferenceArgb8888(expectedBitmap, actualBitmap, testId); assertThat(averagePixelAbsoluteDifference).isAtMost(MAXIMUM_AVERAGE_PIXEL_ABSOLUTE_DIFFERENCE); } @@ -310,15 +296,15 @@ public final class GlEffectsFrameProcessorPixelTest { DEFAULT_PIXEL_WIDTH_HEIGHT_RATIO, full10StepRotationAndCenterCrop.build()); Bitmap fullRotationAndCenterCropResultBitmap = processFirstFrameAndEnd(); - BitmapTestUtil.maybeSaveTestBitmapToCacheDirectory( + maybeSaveTestBitmapToCacheDirectory( testId, /* bitmapLabel= */ "centerCrop", centerCropResultBitmap); - BitmapTestUtil.maybeSaveTestBitmapToCacheDirectory( + maybeSaveTestBitmapToCacheDirectory( testId, /* bitmapLabel= */ "full10StepRotationAndCenterCrop", fullRotationAndCenterCropResultBitmap); // TODO(b/207848601): switch to using proper tooling for testing against golden data. float averagePixelAbsoluteDifference = - BitmapTestUtil.getAveragePixelAbsoluteDifferenceArgb8888( + getBitmapAveragePixelAbsoluteDifferenceArgb8888( centerCropResultBitmap, fullRotationAndCenterCropResultBitmap, testId); assertThat(averagePixelAbsoluteDifference).isAtMost(MAXIMUM_AVERAGE_PIXEL_ABSOLUTE_DIFFERENCE); } @@ -332,16 +318,14 @@ public final class GlEffectsFrameProcessorPixelTest { new RgbAdjustment.Builder().setGreenScale(5).build(), new RgbAdjustment.Builder().setBlueScale(5).build()); setUpAndPrepareFirstFrame(DEFAULT_PIXEL_WIDTH_HEIGHT_RATIO, increaseBrightness); - Bitmap expectedBitmap = BitmapTestUtil.readBitmap(INCREASE_BRIGHTNESS_PNG_ASSET_PATH); + Bitmap expectedBitmap = readBitmap(INCREASE_BRIGHTNESS_PNG_ASSET_PATH); Bitmap actualBitmap = processFirstFrameAndEnd(); - BitmapTestUtil.maybeSaveTestBitmapToCacheDirectory( - testId, /* bitmapLabel= */ "actual", actualBitmap); + maybeSaveTestBitmapToCacheDirectory(testId, /* bitmapLabel= */ "actual", actualBitmap); // TODO(b/207848601): switch to using proper tooling for testing against golden data. float averagePixelAbsoluteDifference = - BitmapTestUtil.getAveragePixelAbsoluteDifferenceArgb8888( - expectedBitmap, actualBitmap, testId); + getBitmapAveragePixelAbsoluteDifferenceArgb8888(expectedBitmap, actualBitmap, testId); assertThat(averagePixelAbsoluteDifference).isAtMost(MAXIMUM_AVERAGE_PIXEL_ABSOLUTE_DIFFERENCE); } @@ -372,15 +356,15 @@ public final class GlEffectsFrameProcessorPixelTest { Bitmap fullRotationBrightnessIncreaseAndCenterCropResultBitmap = processFirstFrameAndEnd(); - BitmapTestUtil.maybeSaveTestBitmapToCacheDirectory( + maybeSaveTestBitmapToCacheDirectory( testId, /* bitmapLabel= */ "centerCrop", centerCropAndBrightnessIncreaseResultBitmap); - BitmapTestUtil.maybeSaveTestBitmapToCacheDirectory( + maybeSaveTestBitmapToCacheDirectory( testId, /* bitmapLabel= */ "full4StepRotationBrightnessIncreaseAndCenterCrop", fullRotationBrightnessIncreaseAndCenterCropResultBitmap); // TODO(b/207848601): switch to using proper tooling for testing against golden data. float averagePixelAbsoluteDifference = - BitmapTestUtil.getAveragePixelAbsoluteDifferenceArgb8888( + getBitmapAveragePixelAbsoluteDifferenceArgb8888( centerCropAndBrightnessIncreaseResultBitmap, fullRotationBrightnessIncreaseAndCenterCropResultBitmap, testId); @@ -395,17 +379,14 @@ public final class GlEffectsFrameProcessorPixelTest { ImmutableList.of( RgbFilter.createGrayscaleFilter(), new RgbAdjustment.Builder().setRedScale(3).build()); setUpAndPrepareFirstFrame(DEFAULT_PIXEL_WIDTH_HEIGHT_RATIO, grayscaleThenIncreaseRed); - Bitmap expectedBitmap = - BitmapTestUtil.readBitmap(GRAYSCALE_THEN_INCREASE_RED_CHANNEL_PNG_ASSET_PATH); + Bitmap expectedBitmap = readBitmap(GRAYSCALE_THEN_INCREASE_RED_CHANNEL_PNG_ASSET_PATH); Bitmap actualBitmap = processFirstFrameAndEnd(); - BitmapTestUtil.maybeSaveTestBitmapToCacheDirectory( - testId, /* bitmapLabel= */ "actual", actualBitmap); + maybeSaveTestBitmapToCacheDirectory(testId, /* bitmapLabel= */ "actual", actualBitmap); // TODO(b/207848601): switch to using proper tooling for testing against golden data. float averagePixelAbsoluteDifference = - BitmapTestUtil.getAveragePixelAbsoluteDifferenceArgb8888( - expectedBitmap, actualBitmap, testId); + getBitmapAveragePixelAbsoluteDifferenceArgb8888(expectedBitmap, actualBitmap, testId); assertThat(averagePixelAbsoluteDifference).isAtMost(MAXIMUM_AVERAGE_PIXEL_ABSOLUTE_DIFFERENCE); } @@ -493,8 +474,7 @@ public final class GlEffectsFrameProcessorPixelTest { assertThat(frameProcessingException.get()).isNull(); Image frameProcessorOutputImage = checkNotNull(outputImageReader).acquireLatestImage(); - Bitmap actualBitmap = - BitmapTestUtil.createArgb8888BitmapFromRgba8888Image(frameProcessorOutputImage); + Bitmap actualBitmap = createArgb8888BitmapFromRgba8888Image(frameProcessorOutputImage); frameProcessorOutputImage.close(); return actualBitmap; } diff --git a/google3/third_party/java_src/android_libs/media/libraries/effect/src/androidTest/java/androidx/media3/effect/HslAdjustmentPixelTest.java b/google3/third_party/java_src/android_libs/media/libraries/effect/src/androidTest/java/androidx/media3/effect/HslAdjustmentPixelTest.java index faa81e49da..11e965cca7 100644 --- a/google3/third_party/java_src/android_libs/media/libraries/effect/src/androidTest/java/androidx/media3/effect/HslAdjustmentPixelTest.java +++ b/google3/third_party/java_src/android_libs/media/libraries/effect/src/androidTest/java/androidx/media3/effect/HslAdjustmentPixelTest.java @@ -17,6 +17,12 @@ package androidx.media3.effect; import static androidx.media3.effect.BitmapTestUtil.MAXIMUM_AVERAGE_PIXEL_ABSOLUTE_DIFFERENCE; +import static androidx.media3.effect.BitmapTestUtil.createArgb8888BitmapFromCurrentGlFramebuffer; +import static androidx.media3.effect.BitmapTestUtil.createArgb8888BitmapWithSolidColor; +import static androidx.media3.effect.BitmapTestUtil.createGlTextureFromBitmap; +import static androidx.media3.effect.BitmapTestUtil.getBitmapAveragePixelAbsoluteDifferenceArgb8888; +import static androidx.media3.effect.BitmapTestUtil.maybeSaveTestBitmapToCacheDirectory; +import static androidx.media3.effect.BitmapTestUtil.readBitmap; import static androidx.test.core.app.ApplicationProvider.getApplicationContext; import static com.google.common.truth.Truth.assertThat; @@ -79,12 +85,12 @@ public final class HslAdjustmentPixelTest { public void createGlObjects() throws IOException, GlUtil.GlException { eglDisplay = GlUtil.createEglDisplay(); eglContext = GlUtil.createEglContext(eglDisplay); - Bitmap inputBitmap = BitmapTestUtil.readBitmap(ORIGINAL_PNG_ASSET_PATH); + Bitmap inputBitmap = readBitmap(ORIGINAL_PNG_ASSET_PATH); inputWidth = inputBitmap.getWidth(); inputHeight = inputBitmap.getHeight(); placeholderEglSurface = GlUtil.createPlaceholderEglSurface(eglDisplay); GlUtil.focusEglSurface(eglDisplay, eglContext, placeholderEglSurface, inputWidth, inputHeight); - inputTexId = BitmapTestUtil.createGlTextureFromBitmap(inputBitmap); + inputTexId = createGlTextureFromBitmap(inputBitmap); outputTexId = GlUtil.createTexture(inputWidth, inputHeight, /* useHighPrecisionColorComponents= */ false); @@ -107,18 +113,15 @@ public final class HslAdjustmentPixelTest { HslAdjustment noOpAdjustment = new HslAdjustment.Builder().build(); hslProcessor = noOpAdjustment.toGlTextureProcessor(context, /* useHdr= */ false); Pair outputSize = hslProcessor.configure(inputWidth, inputHeight); - Bitmap expectedBitmap = BitmapTestUtil.readBitmap(ORIGINAL_PNG_ASSET_PATH); + Bitmap expectedBitmap = readBitmap(ORIGINAL_PNG_ASSET_PATH); hslProcessor.drawFrame(inputTexId, /* presentationTimeUs= */ 0); Bitmap actualBitmap = - BitmapTestUtil.createArgb8888BitmapFromCurrentGlFramebuffer( - outputSize.first, outputSize.second); + createArgb8888BitmapFromCurrentGlFramebuffer(outputSize.first, outputSize.second); - BitmapTestUtil.maybeSaveTestBitmapToCacheDirectory( - testId, /* bitmapLabel= */ "actual", actualBitmap); + maybeSaveTestBitmapToCacheDirectory(testId, /* bitmapLabel= */ "actual", actualBitmap); float averagePixelAbsoluteDifference = - BitmapTestUtil.getAveragePixelAbsoluteDifferenceArgb8888( - expectedBitmap, actualBitmap, testId); + getBitmapAveragePixelAbsoluteDifferenceArgb8888(expectedBitmap, actualBitmap, testId); assertThat(averagePixelAbsoluteDifference).isAtMost(MAXIMUM_AVERAGE_PIXEL_ABSOLUTE_DIFFERENCE); } @@ -128,18 +131,15 @@ public final class HslAdjustmentPixelTest { HslAdjustment minimumSaturation = new HslAdjustment.Builder().adjustSaturation(-100).build(); hslProcessor = minimumSaturation.toGlTextureProcessor(context, /* useHdr= */ false); Pair outputSize = hslProcessor.configure(inputWidth, inputHeight); - Bitmap expectedBitmap = BitmapTestUtil.readBitmap(MINIMUM_SATURATION_PNG_ASSET_PATH); + Bitmap expectedBitmap = readBitmap(MINIMUM_SATURATION_PNG_ASSET_PATH); hslProcessor.drawFrame(inputTexId, /* presentationTimeUs= */ 0); Bitmap actualBitmap = - BitmapTestUtil.createArgb8888BitmapFromCurrentGlFramebuffer( - outputSize.first, outputSize.second); + createArgb8888BitmapFromCurrentGlFramebuffer(outputSize.first, outputSize.second); - BitmapTestUtil.maybeSaveTestBitmapToCacheDirectory( - testId, /* bitmapLabel= */ "actual", actualBitmap); + maybeSaveTestBitmapToCacheDirectory(testId, /* bitmapLabel= */ "actual", actualBitmap); float averagePixelAbsoluteDifference = - BitmapTestUtil.getAveragePixelAbsoluteDifferenceArgb8888( - expectedBitmap, actualBitmap, testId); + getBitmapAveragePixelAbsoluteDifferenceArgb8888(expectedBitmap, actualBitmap, testId); assertThat(averagePixelAbsoluteDifference).isAtMost(MAXIMUM_AVERAGE_PIXEL_ABSOLUTE_DIFFERENCE); } @@ -149,18 +149,15 @@ public final class HslAdjustmentPixelTest { HslAdjustment maximumSaturation = new HslAdjustment.Builder().adjustSaturation(100).build(); hslProcessor = maximumSaturation.toGlTextureProcessor(context, /* useHdr= */ false); Pair outputSize = hslProcessor.configure(inputWidth, inputHeight); - Bitmap expectedBitmap = BitmapTestUtil.readBitmap(MAXIMUM_SATURATION_PNG_ASSET_PATH); + Bitmap expectedBitmap = readBitmap(MAXIMUM_SATURATION_PNG_ASSET_PATH); hslProcessor.drawFrame(inputTexId, /* presentationTimeUs= */ 0); Bitmap actualBitmap = - BitmapTestUtil.createArgb8888BitmapFromCurrentGlFramebuffer( - outputSize.first, outputSize.second); + createArgb8888BitmapFromCurrentGlFramebuffer(outputSize.first, outputSize.second); - BitmapTestUtil.maybeSaveTestBitmapToCacheDirectory( - testId, /* bitmapLabel= */ "actual", actualBitmap); + maybeSaveTestBitmapToCacheDirectory(testId, /* bitmapLabel= */ "actual", actualBitmap); float averagePixelAbsoluteDifference = - BitmapTestUtil.getAveragePixelAbsoluteDifferenceArgb8888( - expectedBitmap, actualBitmap, testId); + getBitmapAveragePixelAbsoluteDifferenceArgb8888(expectedBitmap, actualBitmap, testId); assertThat(averagePixelAbsoluteDifference).isAtMost(MAXIMUM_AVERAGE_PIXEL_ABSOLUTE_DIFFERENCE); } @@ -170,19 +167,15 @@ public final class HslAdjustmentPixelTest { HslAdjustment negativeHueRotation90Degrees = new HslAdjustment.Builder().adjustHue(-90).build(); hslProcessor = negativeHueRotation90Degrees.toGlTextureProcessor(context, /* useHdr= */ false); Pair outputSize = hslProcessor.configure(inputWidth, inputHeight); - Bitmap expectedBitmap = - BitmapTestUtil.readBitmap(ROTATE_HUE_BY_NEGATIVE_90_DEGREES_PNG_ASSET_PATH); + Bitmap expectedBitmap = readBitmap(ROTATE_HUE_BY_NEGATIVE_90_DEGREES_PNG_ASSET_PATH); hslProcessor.drawFrame(inputTexId, /* presentationTimeUs= */ 0); Bitmap actualBitmap = - BitmapTestUtil.createArgb8888BitmapFromCurrentGlFramebuffer( - outputSize.first, outputSize.second); + createArgb8888BitmapFromCurrentGlFramebuffer(outputSize.first, outputSize.second); - BitmapTestUtil.maybeSaveTestBitmapToCacheDirectory( - testId, /* bitmapLabel= */ "actual", actualBitmap); + maybeSaveTestBitmapToCacheDirectory(testId, /* bitmapLabel= */ "actual", actualBitmap); float averagePixelAbsoluteDifference = - BitmapTestUtil.getAveragePixelAbsoluteDifferenceArgb8888( - expectedBitmap, actualBitmap, testId); + getBitmapAveragePixelAbsoluteDifferenceArgb8888(expectedBitmap, actualBitmap, testId); assertThat(averagePixelAbsoluteDifference).isAtMost(MAXIMUM_AVERAGE_PIXEL_ABSOLUTE_DIFFERENCE); } @@ -192,18 +185,15 @@ public final class HslAdjustmentPixelTest { HslAdjustment hueRotation60Degrees = new HslAdjustment.Builder().adjustHue(60).build(); hslProcessor = hueRotation60Degrees.toGlTextureProcessor(context, /* useHdr= */ false); Pair outputSize = hslProcessor.configure(inputWidth, inputHeight); - Bitmap expectedBitmap = BitmapTestUtil.readBitmap(ROTATE_HUE_BY_60_DEGREES_PNG_ASSET_PATH); + Bitmap expectedBitmap = readBitmap(ROTATE_HUE_BY_60_DEGREES_PNG_ASSET_PATH); hslProcessor.drawFrame(inputTexId, /* presentationTimeUs= */ 0); Bitmap actualBitmap = - BitmapTestUtil.createArgb8888BitmapFromCurrentGlFramebuffer( - outputSize.first, outputSize.second); + createArgb8888BitmapFromCurrentGlFramebuffer(outputSize.first, outputSize.second); - BitmapTestUtil.maybeSaveTestBitmapToCacheDirectory( - testId, /* bitmapLabel= */ "actual", actualBitmap); + maybeSaveTestBitmapToCacheDirectory(testId, /* bitmapLabel= */ "actual", actualBitmap); float averagePixelAbsoluteDifference = - BitmapTestUtil.getAveragePixelAbsoluteDifferenceArgb8888( - expectedBitmap, actualBitmap, testId); + getBitmapAveragePixelAbsoluteDifferenceArgb8888(expectedBitmap, actualBitmap, testId); assertThat(averagePixelAbsoluteDifference).isAtMost(MAXIMUM_AVERAGE_PIXEL_ABSOLUTE_DIFFERENCE); } @@ -214,18 +204,15 @@ public final class HslAdjustmentPixelTest { HslAdjustment hueRotation420Degrees = new HslAdjustment.Builder().adjustHue(-300).build(); hslProcessor = hueRotation420Degrees.toGlTextureProcessor(context, /* useHdr= */ false); Pair outputSize = hslProcessor.configure(inputWidth, inputHeight); - Bitmap expectedBitmap = BitmapTestUtil.readBitmap(ROTATE_HUE_BY_60_DEGREES_PNG_ASSET_PATH); + Bitmap expectedBitmap = readBitmap(ROTATE_HUE_BY_60_DEGREES_PNG_ASSET_PATH); hslProcessor.drawFrame(inputTexId, /* presentationTimeUs= */ 0); Bitmap actualBitmap = - BitmapTestUtil.createArgb8888BitmapFromCurrentGlFramebuffer( - outputSize.first, outputSize.second); + createArgb8888BitmapFromCurrentGlFramebuffer(outputSize.first, outputSize.second); - BitmapTestUtil.maybeSaveTestBitmapToCacheDirectory( - testId, /* bitmapLabel= */ "actual", actualBitmap); + maybeSaveTestBitmapToCacheDirectory(testId, /* bitmapLabel= */ "actual", actualBitmap); float averagePixelAbsoluteDifference = - BitmapTestUtil.getAveragePixelAbsoluteDifferenceArgb8888( - expectedBitmap, actualBitmap, testId); + getBitmapAveragePixelAbsoluteDifferenceArgb8888(expectedBitmap, actualBitmap, testId); assertThat(averagePixelAbsoluteDifference).isAtMost(MAXIMUM_AVERAGE_PIXEL_ABSOLUTE_DIFFERENCE); } @@ -235,18 +222,15 @@ public final class HslAdjustmentPixelTest { HslAdjustment hueRotation360Degrees = new HslAdjustment.Builder().adjustHue(360).build(); hslProcessor = hueRotation360Degrees.toGlTextureProcessor(context, /* useHdr= */ false); Pair outputSize = hslProcessor.configure(inputWidth, inputHeight); - Bitmap expectedBitmap = BitmapTestUtil.readBitmap(ORIGINAL_PNG_ASSET_PATH); + Bitmap expectedBitmap = readBitmap(ORIGINAL_PNG_ASSET_PATH); hslProcessor.drawFrame(inputTexId, /* presentationTimeUs= */ 0); Bitmap actualBitmap = - BitmapTestUtil.createArgb8888BitmapFromCurrentGlFramebuffer( - outputSize.first, outputSize.second); + createArgb8888BitmapFromCurrentGlFramebuffer(outputSize.first, outputSize.second); - BitmapTestUtil.maybeSaveTestBitmapToCacheDirectory( - testId, /* bitmapLabel= */ "actual", actualBitmap); + maybeSaveTestBitmapToCacheDirectory(testId, /* bitmapLabel= */ "actual", actualBitmap); float averagePixelAbsoluteDifference = - BitmapTestUtil.getAveragePixelAbsoluteDifferenceArgb8888( - expectedBitmap, actualBitmap, testId); + getBitmapAveragePixelAbsoluteDifferenceArgb8888(expectedBitmap, actualBitmap, testId); assertThat(averagePixelAbsoluteDifference).isAtMost(MAXIMUM_AVERAGE_PIXEL_ABSOLUTE_DIFFERENCE); } @@ -257,18 +241,15 @@ public final class HslAdjustmentPixelTest { hslProcessor = minimumLightness.toGlTextureProcessor(context, /* useHdr= */ false); Pair outputSize = hslProcessor.configure(inputWidth, inputHeight); Bitmap expectedBitmap = - BitmapTestUtil.createArgb8888BitmapWithSolidColor(inputWidth, inputHeight, Color.BLACK); + createArgb8888BitmapWithSolidColor(inputWidth, inputHeight, Color.BLACK); hslProcessor.drawFrame(inputTexId, /* presentationTimeUs= */ 0); Bitmap actualBitmap = - BitmapTestUtil.createArgb8888BitmapFromCurrentGlFramebuffer( - outputSize.first, outputSize.second); + createArgb8888BitmapFromCurrentGlFramebuffer(outputSize.first, outputSize.second); - BitmapTestUtil.maybeSaveTestBitmapToCacheDirectory( - testId, /* bitmapLabel= */ "actual", actualBitmap); + maybeSaveTestBitmapToCacheDirectory(testId, /* bitmapLabel= */ "actual", actualBitmap); float averagePixelAbsoluteDifference = - BitmapTestUtil.getAveragePixelAbsoluteDifferenceArgb8888( - expectedBitmap, actualBitmap, testId); + getBitmapAveragePixelAbsoluteDifferenceArgb8888(expectedBitmap, actualBitmap, testId); assertThat(averagePixelAbsoluteDifference).isAtMost(MAXIMUM_AVERAGE_PIXEL_ABSOLUTE_DIFFERENCE); } @@ -278,18 +259,15 @@ public final class HslAdjustmentPixelTest { HslAdjustment decreasedLightness = new HslAdjustment.Builder().adjustLightness(-50).build(); hslProcessor = decreasedLightness.toGlTextureProcessor(context, /* useHdr= */ false); Pair outputSize = hslProcessor.configure(inputWidth, inputHeight); - Bitmap expectedBitmap = BitmapTestUtil.readBitmap(DECREASE_LIGHTNESS_PNG_ASSET_PATH); + Bitmap expectedBitmap = readBitmap(DECREASE_LIGHTNESS_PNG_ASSET_PATH); hslProcessor.drawFrame(inputTexId, /* presentationTimeUs= */ 0); Bitmap actualBitmap = - BitmapTestUtil.createArgb8888BitmapFromCurrentGlFramebuffer( - outputSize.first, outputSize.second); + createArgb8888BitmapFromCurrentGlFramebuffer(outputSize.first, outputSize.second); - BitmapTestUtil.maybeSaveTestBitmapToCacheDirectory( - testId, /* bitmapLabel= */ "actual", actualBitmap); + maybeSaveTestBitmapToCacheDirectory(testId, /* bitmapLabel= */ "actual", actualBitmap); float averagePixelAbsoluteDifference = - BitmapTestUtil.getAveragePixelAbsoluteDifferenceArgb8888( - expectedBitmap, actualBitmap, testId); + getBitmapAveragePixelAbsoluteDifferenceArgb8888(expectedBitmap, actualBitmap, testId); assertThat(averagePixelAbsoluteDifference).isAtMost(MAXIMUM_AVERAGE_PIXEL_ABSOLUTE_DIFFERENCE); } @@ -299,18 +277,15 @@ public final class HslAdjustmentPixelTest { HslAdjustment increasedLightness = new HslAdjustment.Builder().adjustLightness(50).build(); hslProcessor = increasedLightness.toGlTextureProcessor(context, /* useHdr= */ false); Pair outputSize = hslProcessor.configure(inputWidth, inputHeight); - Bitmap expectedBitmap = BitmapTestUtil.readBitmap(INCREASE_LIGHTNESS_PNG_ASSET_PATH); + Bitmap expectedBitmap = readBitmap(INCREASE_LIGHTNESS_PNG_ASSET_PATH); hslProcessor.drawFrame(inputTexId, /* presentationTimeUs= */ 0); Bitmap actualBitmap = - BitmapTestUtil.createArgb8888BitmapFromCurrentGlFramebuffer( - outputSize.first, outputSize.second); + createArgb8888BitmapFromCurrentGlFramebuffer(outputSize.first, outputSize.second); - BitmapTestUtil.maybeSaveTestBitmapToCacheDirectory( - testId, /* bitmapLabel= */ "actual", actualBitmap); + maybeSaveTestBitmapToCacheDirectory(testId, /* bitmapLabel= */ "actual", actualBitmap); float averagePixelAbsoluteDifference = - BitmapTestUtil.getAveragePixelAbsoluteDifferenceArgb8888( - expectedBitmap, actualBitmap, testId); + getBitmapAveragePixelAbsoluteDifferenceArgb8888(expectedBitmap, actualBitmap, testId); assertThat(averagePixelAbsoluteDifference).isAtMost(MAXIMUM_AVERAGE_PIXEL_ABSOLUTE_DIFFERENCE); } @@ -321,18 +296,15 @@ public final class HslAdjustmentPixelTest { hslProcessor = maximumLightness.toGlTextureProcessor(context, /* useHdr= */ false); Pair outputSize = hslProcessor.configure(inputWidth, inputHeight); Bitmap expectedBitmap = - BitmapTestUtil.createArgb8888BitmapWithSolidColor(inputWidth, inputHeight, Color.WHITE); + createArgb8888BitmapWithSolidColor(inputWidth, inputHeight, Color.WHITE); hslProcessor.drawFrame(inputTexId, /* presentationTimeUs= */ 0); Bitmap actualBitmap = - BitmapTestUtil.createArgb8888BitmapFromCurrentGlFramebuffer( - outputSize.first, outputSize.second); + createArgb8888BitmapFromCurrentGlFramebuffer(outputSize.first, outputSize.second); - BitmapTestUtil.maybeSaveTestBitmapToCacheDirectory( - testId, /* bitmapLabel= */ "actual", actualBitmap); + maybeSaveTestBitmapToCacheDirectory(testId, /* bitmapLabel= */ "actual", actualBitmap); float averagePixelAbsoluteDifference = - BitmapTestUtil.getAveragePixelAbsoluteDifferenceArgb8888( - expectedBitmap, actualBitmap, testId); + getBitmapAveragePixelAbsoluteDifferenceArgb8888(expectedBitmap, actualBitmap, testId); assertThat(averagePixelAbsoluteDifference).isAtMost(MAXIMUM_AVERAGE_PIXEL_ABSOLUTE_DIFFERENCE); } @@ -343,18 +315,15 @@ public final class HslAdjustmentPixelTest { new HslAdjustment.Builder().adjustHue(60).adjustSaturation(30).adjustLightness(50).build(); hslProcessor = allHslSettingsAdjusted.toGlTextureProcessor(context, /* useHdr= */ false); Pair outputSize = hslProcessor.configure(inputWidth, inputHeight); - Bitmap expectedBitmap = BitmapTestUtil.readBitmap(ADJUST_ALL_HSL_SETTINGS_PNG_ASSET_PATH); + Bitmap expectedBitmap = readBitmap(ADJUST_ALL_HSL_SETTINGS_PNG_ASSET_PATH); hslProcessor.drawFrame(inputTexId, /* presentationTimeUs= */ 0); Bitmap actualBitmap = - BitmapTestUtil.createArgb8888BitmapFromCurrentGlFramebuffer( - outputSize.first, outputSize.second); + createArgb8888BitmapFromCurrentGlFramebuffer(outputSize.first, outputSize.second); - BitmapTestUtil.maybeSaveTestBitmapToCacheDirectory( - testId, /* bitmapLabel= */ "actual", actualBitmap); + maybeSaveTestBitmapToCacheDirectory(testId, /* bitmapLabel= */ "actual", actualBitmap); float averagePixelAbsoluteDifference = - BitmapTestUtil.getAveragePixelAbsoluteDifferenceArgb8888( - expectedBitmap, actualBitmap, testId); + getBitmapAveragePixelAbsoluteDifferenceArgb8888(expectedBitmap, actualBitmap, testId); assertThat(averagePixelAbsoluteDifference).isAtMost(MAXIMUM_AVERAGE_PIXEL_ABSOLUTE_DIFFERENCE); } } diff --git a/google3/third_party/java_src/android_libs/media/libraries/effect/src/androidTest/java/androidx/media3/effect/MatrixTextureProcessorPixelTest.java b/google3/third_party/java_src/android_libs/media/libraries/effect/src/androidTest/java/androidx/media3/effect/MatrixTextureProcessorPixelTest.java index 0f6da51e2d..2b302f4ef8 100644 --- a/google3/third_party/java_src/android_libs/media/libraries/effect/src/androidTest/java/androidx/media3/effect/MatrixTextureProcessorPixelTest.java +++ b/google3/third_party/java_src/android_libs/media/libraries/effect/src/androidTest/java/androidx/media3/effect/MatrixTextureProcessorPixelTest.java @@ -16,6 +16,11 @@ package androidx.media3.effect; import static androidx.media3.effect.BitmapTestUtil.MAXIMUM_AVERAGE_PIXEL_ABSOLUTE_DIFFERENCE; +import static androidx.media3.effect.BitmapTestUtil.createArgb8888BitmapFromCurrentGlFramebuffer; +import static androidx.media3.effect.BitmapTestUtil.createGlTextureFromBitmap; +import static androidx.media3.effect.BitmapTestUtil.getBitmapAveragePixelAbsoluteDifferenceArgb8888; +import static androidx.media3.effect.BitmapTestUtil.maybeSaveTestBitmapToCacheDirectory; +import static androidx.media3.effect.BitmapTestUtil.readBitmap; import static androidx.test.core.app.ApplicationProvider.getApplicationContext; import static com.google.common.truth.Truth.assertThat; @@ -68,12 +73,12 @@ public final class MatrixTextureProcessorPixelTest { public void createGlObjects() throws IOException, GlUtil.GlException { eglDisplay = GlUtil.createEglDisplay(); eglContext = GlUtil.createEglContext(eglDisplay); - Bitmap inputBitmap = BitmapTestUtil.readBitmap(ORIGINAL_PNG_ASSET_PATH); + Bitmap inputBitmap = readBitmap(ORIGINAL_PNG_ASSET_PATH); width = inputBitmap.getWidth(); height = inputBitmap.getHeight(); EGLSurface placeholderEglSurface = GlUtil.createPlaceholderEglSurface(eglDisplay); GlUtil.focusEglSurface(eglDisplay, eglContext, placeholderEglSurface, width, height); - inputTexId = BitmapTestUtil.createGlTextureFromBitmap(inputBitmap); + inputTexId = createGlTextureFromBitmap(inputBitmap); outputTexId = GlUtil.createTexture(width, height, /* useHighPrecisionColorComponents= */ false); int frameBuffer = GlUtil.createFboForTexture(outputTexId); GlUtil.focusFramebuffer( @@ -98,18 +103,15 @@ public final class MatrixTextureProcessorPixelTest { matrixTextureProcessor = noEditsTransformation.toGlTextureProcessor(context, /* useHdr= */ false); matrixTextureProcessor.configure(width, height); - Bitmap expectedBitmap = BitmapTestUtil.readBitmap(ORIGINAL_PNG_ASSET_PATH); + Bitmap expectedBitmap = readBitmap(ORIGINAL_PNG_ASSET_PATH); matrixTextureProcessor.drawFrame(inputTexId, /* presentationTimeUs= */ 0); - Bitmap actualBitmap = - BitmapTestUtil.createArgb8888BitmapFromCurrentGlFramebuffer(width, height); + Bitmap actualBitmap = createArgb8888BitmapFromCurrentGlFramebuffer(width, height); - BitmapTestUtil.maybeSaveTestBitmapToCacheDirectory( - testId, /* bitmapLabel= */ "actual", actualBitmap); + maybeSaveTestBitmapToCacheDirectory(testId, /* bitmapLabel= */ "actual", actualBitmap); // TODO(b/207848601): switch to using proper tooling for testing against golden data. float averagePixelAbsoluteDifference = - BitmapTestUtil.getAveragePixelAbsoluteDifferenceArgb8888( - expectedBitmap, actualBitmap, testId); + getBitmapAveragePixelAbsoluteDifferenceArgb8888(expectedBitmap, actualBitmap, testId); assertThat(averagePixelAbsoluteDifference).isAtMost(MAXIMUM_AVERAGE_PIXEL_ABSOLUTE_DIFFERENCE); } @@ -123,18 +125,15 @@ public final class MatrixTextureProcessorPixelTest { matrixTextureProcessor = translateRightTransformation.toGlTextureProcessor(context, /* useHdr= */ false); matrixTextureProcessor.configure(width, height); - Bitmap expectedBitmap = BitmapTestUtil.readBitmap(TRANSLATE_RIGHT_PNG_ASSET_PATH); + Bitmap expectedBitmap = readBitmap(TRANSLATE_RIGHT_PNG_ASSET_PATH); matrixTextureProcessor.drawFrame(inputTexId, /* presentationTimeUs= */ 0); - Bitmap actualBitmap = - BitmapTestUtil.createArgb8888BitmapFromCurrentGlFramebuffer(width, height); + Bitmap actualBitmap = createArgb8888BitmapFromCurrentGlFramebuffer(width, height); - BitmapTestUtil.maybeSaveTestBitmapToCacheDirectory( - testId, /* bitmapLabel= */ "actual", actualBitmap); + maybeSaveTestBitmapToCacheDirectory(testId, /* bitmapLabel= */ "actual", actualBitmap); // TODO(b/207848601): switch to using proper tooling for testing against golden data. float averagePixelAbsoluteDifference = - BitmapTestUtil.getAveragePixelAbsoluteDifferenceArgb8888( - expectedBitmap, actualBitmap, testId); + getBitmapAveragePixelAbsoluteDifferenceArgb8888(expectedBitmap, actualBitmap, testId); assertThat(averagePixelAbsoluteDifference).isAtMost(MAXIMUM_AVERAGE_PIXEL_ABSOLUTE_DIFFERENCE); } @@ -147,18 +146,15 @@ public final class MatrixTextureProcessorPixelTest { matrixTextureProcessor = scaleNarrowTransformation.toGlTextureProcessor(context, /* useHdr= */ false); matrixTextureProcessor.configure(width, height); - Bitmap expectedBitmap = BitmapTestUtil.readBitmap(SCALE_NARROW_PNG_ASSET_PATH); + Bitmap expectedBitmap = readBitmap(SCALE_NARROW_PNG_ASSET_PATH); matrixTextureProcessor.drawFrame(inputTexId, /* presentationTimeUs= */ 0); - Bitmap actualBitmap = - BitmapTestUtil.createArgb8888BitmapFromCurrentGlFramebuffer(width, height); + Bitmap actualBitmap = createArgb8888BitmapFromCurrentGlFramebuffer(width, height); - BitmapTestUtil.maybeSaveTestBitmapToCacheDirectory( - testId, /* bitmapLabel= */ "actual", actualBitmap); + maybeSaveTestBitmapToCacheDirectory(testId, /* bitmapLabel= */ "actual", actualBitmap); // TODO(b/207848601): switch to using proper tooling for testing against golden data. float averagePixelAbsoluteDifference = - BitmapTestUtil.getAveragePixelAbsoluteDifferenceArgb8888( - expectedBitmap, actualBitmap, testId); + getBitmapAveragePixelAbsoluteDifferenceArgb8888(expectedBitmap, actualBitmap, testId); assertThat(averagePixelAbsoluteDifference).isAtMost(MAXIMUM_AVERAGE_PIXEL_ABSOLUTE_DIFFERENCE); } @@ -171,18 +167,15 @@ public final class MatrixTextureProcessorPixelTest { matrixTextureProcessor = rotate90Transformation.toGlTextureProcessor(context, /* useHdr= */ false); matrixTextureProcessor.configure(width, height); - Bitmap expectedBitmap = BitmapTestUtil.readBitmap(ROTATE_90_PNG_ASSET_PATH); + Bitmap expectedBitmap = readBitmap(ROTATE_90_PNG_ASSET_PATH); matrixTextureProcessor.drawFrame(inputTexId, /* presentationTimeUs= */ 0); - Bitmap actualBitmap = - BitmapTestUtil.createArgb8888BitmapFromCurrentGlFramebuffer(width, height); + Bitmap actualBitmap = createArgb8888BitmapFromCurrentGlFramebuffer(width, height); - BitmapTestUtil.maybeSaveTestBitmapToCacheDirectory( - testId, /* bitmapLabel= */ "actual", actualBitmap); + maybeSaveTestBitmapToCacheDirectory(testId, /* bitmapLabel= */ "actual", actualBitmap); // TODO(b/207848601): switch to using proper tooling for testing against golden data. float averagePixelAbsoluteDifference = - BitmapTestUtil.getAveragePixelAbsoluteDifferenceArgb8888( - expectedBitmap, actualBitmap, testId); + getBitmapAveragePixelAbsoluteDifferenceArgb8888(expectedBitmap, actualBitmap, testId); assertThat(averagePixelAbsoluteDifference).isAtMost(MAXIMUM_AVERAGE_PIXEL_ABSOLUTE_DIFFERENCE); } diff --git a/google3/third_party/java_src/android_libs/media/libraries/effect/src/androidTest/java/androidx/media3/effect/PresentationPixelTest.java b/google3/third_party/java_src/android_libs/media/libraries/effect/src/androidTest/java/androidx/media3/effect/PresentationPixelTest.java index 0f9b97ab8e..7380216d6e 100644 --- a/google3/third_party/java_src/android_libs/media/libraries/effect/src/androidTest/java/androidx/media3/effect/PresentationPixelTest.java +++ b/google3/third_party/java_src/android_libs/media/libraries/effect/src/androidTest/java/androidx/media3/effect/PresentationPixelTest.java @@ -16,6 +16,11 @@ package androidx.media3.effect; import static androidx.media3.effect.BitmapTestUtil.MAXIMUM_AVERAGE_PIXEL_ABSOLUTE_DIFFERENCE; +import static androidx.media3.effect.BitmapTestUtil.createArgb8888BitmapFromCurrentGlFramebuffer; +import static androidx.media3.effect.BitmapTestUtil.createGlTextureFromBitmap; +import static androidx.media3.effect.BitmapTestUtil.getBitmapAveragePixelAbsoluteDifferenceArgb8888; +import static androidx.media3.effect.BitmapTestUtil.maybeSaveTestBitmapToCacheDirectory; +import static androidx.media3.effect.BitmapTestUtil.readBitmap; import static androidx.test.core.app.ApplicationProvider.getApplicationContext; import static com.google.android.exoplayer2.util.Assertions.checkNotNull; import static com.google.common.truth.Truth.assertThat; @@ -77,12 +82,12 @@ public final class PresentationPixelTest { public void createGlObjects() throws IOException, GlUtil.GlException { eglDisplay = GlUtil.createEglDisplay(); eglContext = GlUtil.createEglContext(eglDisplay); - Bitmap inputBitmap = BitmapTestUtil.readBitmap(ORIGINAL_PNG_ASSET_PATH); + Bitmap inputBitmap = readBitmap(ORIGINAL_PNG_ASSET_PATH); inputWidth = inputBitmap.getWidth(); inputHeight = inputBitmap.getHeight(); placeholderEglSurface = GlUtil.createPlaceholderEglSurface(eglDisplay); GlUtil.focusEglSurface(eglDisplay, eglContext, placeholderEglSurface, inputWidth, inputHeight); - inputTexId = BitmapTestUtil.createGlTextureFromBitmap(inputBitmap); + inputTexId = createGlTextureFromBitmap(inputBitmap); } @After @@ -104,19 +109,16 @@ public final class PresentationPixelTest { Pair outputSize = presentationTextureProcessor.configure(inputWidth, inputHeight); setupOutputTexture(outputSize.first, outputSize.second); - Bitmap expectedBitmap = BitmapTestUtil.readBitmap(ORIGINAL_PNG_ASSET_PATH); + Bitmap expectedBitmap = readBitmap(ORIGINAL_PNG_ASSET_PATH); presentationTextureProcessor.drawFrame(inputTexId, /* presentationTimeUs= */ 0); Bitmap actualBitmap = - BitmapTestUtil.createArgb8888BitmapFromCurrentGlFramebuffer( - outputSize.first, outputSize.second); + createArgb8888BitmapFromCurrentGlFramebuffer(outputSize.first, outputSize.second); - BitmapTestUtil.maybeSaveTestBitmapToCacheDirectory( - testId, /* bitmapLabel= */ "actual", actualBitmap); + maybeSaveTestBitmapToCacheDirectory(testId, /* bitmapLabel= */ "actual", actualBitmap); // TODO(b/207848601): switch to using proper tooling for testing against golden data. float averagePixelAbsoluteDifference = - BitmapTestUtil.getAveragePixelAbsoluteDifferenceArgb8888( - expectedBitmap, actualBitmap, testId); + getBitmapAveragePixelAbsoluteDifferenceArgb8888(expectedBitmap, actualBitmap, testId); assertThat(averagePixelAbsoluteDifference).isAtMost(MAXIMUM_AVERAGE_PIXEL_ABSOLUTE_DIFFERENCE); } @@ -130,20 +132,16 @@ public final class PresentationPixelTest { Pair outputSize = presentationTextureProcessor.configure(inputWidth, inputHeight); setupOutputTexture(outputSize.first, outputSize.second); - Bitmap expectedBitmap = - BitmapTestUtil.readBitmap(ASPECT_RATIO_SCALE_TO_FIT_NARROW_PNG_ASSET_PATH); + Bitmap expectedBitmap = readBitmap(ASPECT_RATIO_SCALE_TO_FIT_NARROW_PNG_ASSET_PATH); presentationTextureProcessor.drawFrame(inputTexId, /* presentationTimeUs= */ 0); Bitmap actualBitmap = - BitmapTestUtil.createArgb8888BitmapFromCurrentGlFramebuffer( - outputSize.first, outputSize.second); + createArgb8888BitmapFromCurrentGlFramebuffer(outputSize.first, outputSize.second); - BitmapTestUtil.maybeSaveTestBitmapToCacheDirectory( - testId, /* bitmapLabel= */ "actual", actualBitmap); + maybeSaveTestBitmapToCacheDirectory(testId, /* bitmapLabel= */ "actual", actualBitmap); // TODO(b/207848601): switch to using proper tooling for testing against golden data. float averagePixelAbsoluteDifference = - BitmapTestUtil.getAveragePixelAbsoluteDifferenceArgb8888( - expectedBitmap, actualBitmap, testId); + getBitmapAveragePixelAbsoluteDifferenceArgb8888(expectedBitmap, actualBitmap, testId); assertThat(averagePixelAbsoluteDifference).isAtMost(MAXIMUM_AVERAGE_PIXEL_ABSOLUTE_DIFFERENCE); } @@ -157,20 +155,16 @@ public final class PresentationPixelTest { Pair outputSize = presentationTextureProcessor.configure(inputWidth, inputHeight); setupOutputTexture(outputSize.first, outputSize.second); - Bitmap expectedBitmap = - BitmapTestUtil.readBitmap(ASPECT_RATIO_SCALE_TO_FIT_WIDE_PNG_ASSET_PATH); + Bitmap expectedBitmap = readBitmap(ASPECT_RATIO_SCALE_TO_FIT_WIDE_PNG_ASSET_PATH); presentationTextureProcessor.drawFrame(inputTexId, /* presentationTimeUs= */ 0); Bitmap actualBitmap = - BitmapTestUtil.createArgb8888BitmapFromCurrentGlFramebuffer( - outputSize.first, outputSize.second); + createArgb8888BitmapFromCurrentGlFramebuffer(outputSize.first, outputSize.second); - BitmapTestUtil.maybeSaveTestBitmapToCacheDirectory( - testId, /* bitmapLabel= */ "actual", actualBitmap); + maybeSaveTestBitmapToCacheDirectory(testId, /* bitmapLabel= */ "actual", actualBitmap); // TODO(b/207848601): switch to using proper tooling for testing against golden data. float averagePixelAbsoluteDifference = - BitmapTestUtil.getAveragePixelAbsoluteDifferenceArgb8888( - expectedBitmap, actualBitmap, testId); + getBitmapAveragePixelAbsoluteDifferenceArgb8888(expectedBitmap, actualBitmap, testId); assertThat(averagePixelAbsoluteDifference).isAtMost(MAXIMUM_AVERAGE_PIXEL_ABSOLUTE_DIFFERENCE); } @@ -185,20 +179,16 @@ public final class PresentationPixelTest { Pair outputSize = presentationTextureProcessor.configure(inputWidth, inputHeight); setupOutputTexture(outputSize.first, outputSize.second); - Bitmap expectedBitmap = - BitmapTestUtil.readBitmap(ASPECT_RATIO_SCALE_TO_FIT_WITH_CROP_NARROW_PNG_ASSET_PATH); + Bitmap expectedBitmap = readBitmap(ASPECT_RATIO_SCALE_TO_FIT_WITH_CROP_NARROW_PNG_ASSET_PATH); presentationTextureProcessor.drawFrame(inputTexId, /* presentationTimeUs= */ 0); Bitmap actualBitmap = - BitmapTestUtil.createArgb8888BitmapFromCurrentGlFramebuffer( - outputSize.first, outputSize.second); + createArgb8888BitmapFromCurrentGlFramebuffer(outputSize.first, outputSize.second); - BitmapTestUtil.maybeSaveTestBitmapToCacheDirectory( - testId, /* bitmapLabel= */ "actual", actualBitmap); + maybeSaveTestBitmapToCacheDirectory(testId, /* bitmapLabel= */ "actual", actualBitmap); // TODO(b/207848601): switch to using proper tooling for testing against golden data. float averagePixelAbsoluteDifference = - BitmapTestUtil.getAveragePixelAbsoluteDifferenceArgb8888( - expectedBitmap, actualBitmap, testId); + getBitmapAveragePixelAbsoluteDifferenceArgb8888(expectedBitmap, actualBitmap, testId); assertThat(averagePixelAbsoluteDifference).isAtMost(MAXIMUM_AVERAGE_PIXEL_ABSOLUTE_DIFFERENCE); } @@ -213,20 +203,16 @@ public final class PresentationPixelTest { Pair outputSize = presentationTextureProcessor.configure(inputWidth, inputHeight); setupOutputTexture(outputSize.first, outputSize.second); - Bitmap expectedBitmap = - BitmapTestUtil.readBitmap(ASPECT_RATIO_SCALE_TO_FIT_WITH_CROP_WIDE_PNG_ASSET_PATH); + Bitmap expectedBitmap = readBitmap(ASPECT_RATIO_SCALE_TO_FIT_WITH_CROP_WIDE_PNG_ASSET_PATH); presentationTextureProcessor.drawFrame(inputTexId, /* presentationTimeUs= */ 0); Bitmap actualBitmap = - BitmapTestUtil.createArgb8888BitmapFromCurrentGlFramebuffer( - outputSize.first, outputSize.second); + createArgb8888BitmapFromCurrentGlFramebuffer(outputSize.first, outputSize.second); - BitmapTestUtil.maybeSaveTestBitmapToCacheDirectory( - testId, /* bitmapLabel= */ "actual", actualBitmap); + maybeSaveTestBitmapToCacheDirectory(testId, /* bitmapLabel= */ "actual", actualBitmap); // TODO(b/207848601): switch to using proper tooling for testing against golden data. float averagePixelAbsoluteDifference = - BitmapTestUtil.getAveragePixelAbsoluteDifferenceArgb8888( - expectedBitmap, actualBitmap, testId); + getBitmapAveragePixelAbsoluteDifferenceArgb8888(expectedBitmap, actualBitmap, testId); assertThat(averagePixelAbsoluteDifference).isAtMost(MAXIMUM_AVERAGE_PIXEL_ABSOLUTE_DIFFERENCE); } @@ -240,20 +226,16 @@ public final class PresentationPixelTest { Pair outputSize = presentationTextureProcessor.configure(inputWidth, inputHeight); setupOutputTexture(outputSize.first, outputSize.second); - Bitmap expectedBitmap = - BitmapTestUtil.readBitmap(ASPECT_RATIO_STRETCH_TO_FIT_NARROW_PNG_ASSET_PATH); + Bitmap expectedBitmap = readBitmap(ASPECT_RATIO_STRETCH_TO_FIT_NARROW_PNG_ASSET_PATH); presentationTextureProcessor.drawFrame(inputTexId, /* presentationTimeUs= */ 0); Bitmap actualBitmap = - BitmapTestUtil.createArgb8888BitmapFromCurrentGlFramebuffer( - outputSize.first, outputSize.second); + createArgb8888BitmapFromCurrentGlFramebuffer(outputSize.first, outputSize.second); - BitmapTestUtil.maybeSaveTestBitmapToCacheDirectory( - testId, /* bitmapLabel= */ "actual", actualBitmap); + maybeSaveTestBitmapToCacheDirectory(testId, /* bitmapLabel= */ "actual", actualBitmap); // TODO(b/207848601): switch to using proper tooling for testing against golden data. float averagePixelAbsoluteDifference = - BitmapTestUtil.getAveragePixelAbsoluteDifferenceArgb8888( - expectedBitmap, actualBitmap, testId); + getBitmapAveragePixelAbsoluteDifferenceArgb8888(expectedBitmap, actualBitmap, testId); assertThat(averagePixelAbsoluteDifference).isAtMost(MAXIMUM_AVERAGE_PIXEL_ABSOLUTE_DIFFERENCE); } @@ -267,20 +249,16 @@ public final class PresentationPixelTest { Pair outputSize = presentationTextureProcessor.configure(inputWidth, inputHeight); setupOutputTexture(outputSize.first, outputSize.second); - Bitmap expectedBitmap = - BitmapTestUtil.readBitmap(ASPECT_RATIO_STRETCH_TO_FIT_WIDE_PNG_ASSET_PATH); + Bitmap expectedBitmap = readBitmap(ASPECT_RATIO_STRETCH_TO_FIT_WIDE_PNG_ASSET_PATH); presentationTextureProcessor.drawFrame(inputTexId, /* presentationTimeUs= */ 0); Bitmap actualBitmap = - BitmapTestUtil.createArgb8888BitmapFromCurrentGlFramebuffer( - outputSize.first, outputSize.second); + createArgb8888BitmapFromCurrentGlFramebuffer(outputSize.first, outputSize.second); - BitmapTestUtil.maybeSaveTestBitmapToCacheDirectory( - testId, /* bitmapLabel= */ "actual", actualBitmap); + maybeSaveTestBitmapToCacheDirectory(testId, /* bitmapLabel= */ "actual", actualBitmap); // TODO(b/207848601): switch to using proper tooling for testing against golden data. float averagePixelAbsoluteDifference = - BitmapTestUtil.getAveragePixelAbsoluteDifferenceArgb8888( - expectedBitmap, actualBitmap, testId); + getBitmapAveragePixelAbsoluteDifferenceArgb8888(expectedBitmap, actualBitmap, testId); assertThat(averagePixelAbsoluteDifference).isAtMost(MAXIMUM_AVERAGE_PIXEL_ABSOLUTE_DIFFERENCE); } diff --git a/google3/third_party/java_src/android_libs/media/libraries/effect/src/androidTest/java/androidx/media3/effect/RgbAdjustmentPixelTest.java b/google3/third_party/java_src/android_libs/media/libraries/effect/src/androidTest/java/androidx/media3/effect/RgbAdjustmentPixelTest.java index e125089445..ded9e347f7 100644 --- a/google3/third_party/java_src/android_libs/media/libraries/effect/src/androidTest/java/androidx/media3/effect/RgbAdjustmentPixelTest.java +++ b/google3/third_party/java_src/android_libs/media/libraries/effect/src/androidTest/java/androidx/media3/effect/RgbAdjustmentPixelTest.java @@ -17,6 +17,12 @@ package androidx.media3.effect; import static androidx.media3.effect.BitmapTestUtil.MAXIMUM_AVERAGE_PIXEL_ABSOLUTE_DIFFERENCE; +import static androidx.media3.effect.BitmapTestUtil.createArgb8888BitmapFromCurrentGlFramebuffer; +import static androidx.media3.effect.BitmapTestUtil.createArgb8888BitmapWithSolidColor; +import static androidx.media3.effect.BitmapTestUtil.createGlTextureFromBitmap; +import static androidx.media3.effect.BitmapTestUtil.getBitmapAveragePixelAbsoluteDifferenceArgb8888; +import static androidx.media3.effect.BitmapTestUtil.maybeSaveTestBitmapToCacheDirectory; +import static androidx.media3.effect.BitmapTestUtil.readBitmap; import static androidx.test.core.app.ApplicationProvider.getApplicationContext; import static com.google.android.exoplayer2.util.Assertions.checkNotNull; import static com.google.common.truth.Truth.assertThat; @@ -73,12 +79,12 @@ public final class RgbAdjustmentPixelTest { public void createGlObjects() throws IOException, GlUtil.GlException { eglDisplay = GlUtil.createEglDisplay(); eglContext = GlUtil.createEglContext(eglDisplay); - Bitmap inputBitmap = BitmapTestUtil.readBitmap(ORIGINAL_PNG_ASSET_PATH); + Bitmap inputBitmap = readBitmap(ORIGINAL_PNG_ASSET_PATH); inputWidth = inputBitmap.getWidth(); inputHeight = inputBitmap.getHeight(); placeholderEglSurface = GlUtil.createPlaceholderEglSurface(eglDisplay); GlUtil.focusEglSurface(eglDisplay, eglContext, placeholderEglSurface, inputWidth, inputHeight); - inputTexId = BitmapTestUtil.createGlTextureFromBitmap(inputBitmap); + inputTexId = createGlTextureFromBitmap(inputBitmap); outputTexId = GlUtil.createTexture(inputWidth, inputHeight, /* useHighPrecisionColorComponents= */ false); @@ -106,18 +112,15 @@ public final class RgbAdjustmentPixelTest { RgbMatrix identityMatrix = new RgbAdjustment.Builder().build(); matrixTextureProcessor = identityMatrix.toGlTextureProcessor(context, /* useHdr= */ false); Pair outputSize = matrixTextureProcessor.configure(inputWidth, inputHeight); - Bitmap expectedBitmap = BitmapTestUtil.readBitmap(ORIGINAL_PNG_ASSET_PATH); + Bitmap expectedBitmap = readBitmap(ORIGINAL_PNG_ASSET_PATH); matrixTextureProcessor.drawFrame(inputTexId, /* presentationTimeUs= */ 0); Bitmap actualBitmap = - BitmapTestUtil.createArgb8888BitmapFromCurrentGlFramebuffer( - outputSize.first, outputSize.second); + createArgb8888BitmapFromCurrentGlFramebuffer(outputSize.first, outputSize.second); - BitmapTestUtil.maybeSaveTestBitmapToCacheDirectory( - testId, /* bitmapLabel= */ "actual", actualBitmap); + maybeSaveTestBitmapToCacheDirectory(testId, /* bitmapLabel= */ "actual", actualBitmap); float averagePixelAbsoluteDifference = - BitmapTestUtil.getAveragePixelAbsoluteDifferenceArgb8888( - expectedBitmap, actualBitmap, testId); + getBitmapAveragePixelAbsoluteDifferenceArgb8888(expectedBitmap, actualBitmap, testId); assertThat(averagePixelAbsoluteDifference).isAtMost(MAXIMUM_AVERAGE_PIXEL_ABSOLUTE_DIFFERENCE); } @@ -129,19 +132,15 @@ public final class RgbAdjustmentPixelTest { matrixTextureProcessor = removeColorMatrix.toGlTextureProcessor(context, /* useHdr= */ false); Pair outputSize = matrixTextureProcessor.configure(inputWidth, inputHeight); Bitmap expectedBitmap = - BitmapTestUtil.createArgb8888BitmapWithSolidColor( - outputSize.first, outputSize.second, Color.BLACK); + createArgb8888BitmapWithSolidColor(outputSize.first, outputSize.second, Color.BLACK); matrixTextureProcessor.drawFrame(inputTexId, /* presentationTimeUs= */ 0); Bitmap actualBitmap = - BitmapTestUtil.createArgb8888BitmapFromCurrentGlFramebuffer( - outputSize.first, outputSize.second); + createArgb8888BitmapFromCurrentGlFramebuffer(outputSize.first, outputSize.second); - BitmapTestUtil.maybeSaveTestBitmapToCacheDirectory( - testId, /* bitmapLabel= */ "actual", actualBitmap); + maybeSaveTestBitmapToCacheDirectory(testId, /* bitmapLabel= */ "actual", actualBitmap); float averagePixelAbsoluteDifference = - BitmapTestUtil.getAveragePixelAbsoluteDifferenceArgb8888( - expectedBitmap, actualBitmap, testId); + getBitmapAveragePixelAbsoluteDifferenceArgb8888(expectedBitmap, actualBitmap, testId); assertThat(averagePixelAbsoluteDifference).isAtMost(MAXIMUM_AVERAGE_PIXEL_ABSOLUTE_DIFFERENCE); } @@ -151,18 +150,15 @@ public final class RgbAdjustmentPixelTest { RgbMatrix redOnlyMatrix = new RgbAdjustment.Builder().setBlueScale(0).setGreenScale(0).build(); matrixTextureProcessor = redOnlyMatrix.toGlTextureProcessor(context, /* useHdr= */ false); Pair outputSize = matrixTextureProcessor.configure(inputWidth, inputHeight); - Bitmap expectedBitmap = BitmapTestUtil.readBitmap(ONLY_RED_CHANNEL_PNG_ASSET_PATH); + Bitmap expectedBitmap = readBitmap(ONLY_RED_CHANNEL_PNG_ASSET_PATH); matrixTextureProcessor.drawFrame(inputTexId, /* presentationTimeUs= */ 0); Bitmap actualBitmap = - BitmapTestUtil.createArgb8888BitmapFromCurrentGlFramebuffer( - outputSize.first, outputSize.second); + createArgb8888BitmapFromCurrentGlFramebuffer(outputSize.first, outputSize.second); - BitmapTestUtil.maybeSaveTestBitmapToCacheDirectory( - testId, /* bitmapLabel= */ "actual", actualBitmap); + maybeSaveTestBitmapToCacheDirectory(testId, /* bitmapLabel= */ "actual", actualBitmap); float averagePixelAbsoluteDifference = - BitmapTestUtil.getAveragePixelAbsoluteDifferenceArgb8888( - expectedBitmap, actualBitmap, testId); + getBitmapAveragePixelAbsoluteDifferenceArgb8888(expectedBitmap, actualBitmap, testId); assertThat(averagePixelAbsoluteDifference).isAtMost(MAXIMUM_AVERAGE_PIXEL_ABSOLUTE_DIFFERENCE); } @@ -172,18 +168,15 @@ public final class RgbAdjustmentPixelTest { RgbMatrix increaseRedMatrix = new RgbAdjustment.Builder().setRedScale(5).build(); matrixTextureProcessor = increaseRedMatrix.toGlTextureProcessor(context, /* useHdr= */ false); Pair outputSize = matrixTextureProcessor.configure(inputWidth, inputHeight); - Bitmap expectedBitmap = BitmapTestUtil.readBitmap(INCREASE_RED_CHANNEL_PNG_ASSET_PATH); + Bitmap expectedBitmap = readBitmap(INCREASE_RED_CHANNEL_PNG_ASSET_PATH); matrixTextureProcessor.drawFrame(inputTexId, /* presentationTimeUs= */ 0); Bitmap actualBitmap = - BitmapTestUtil.createArgb8888BitmapFromCurrentGlFramebuffer( - outputSize.first, outputSize.second); + createArgb8888BitmapFromCurrentGlFramebuffer(outputSize.first, outputSize.second); - BitmapTestUtil.maybeSaveTestBitmapToCacheDirectory( - testId, /* bitmapLabel= */ "actual", actualBitmap); + maybeSaveTestBitmapToCacheDirectory(testId, /* bitmapLabel= */ "actual", actualBitmap); float averagePixelAbsoluteDifference = - BitmapTestUtil.getAveragePixelAbsoluteDifferenceArgb8888( - expectedBitmap, actualBitmap, testId); + getBitmapAveragePixelAbsoluteDifferenceArgb8888(expectedBitmap, actualBitmap, testId); assertThat(averagePixelAbsoluteDifference).isAtMost(MAXIMUM_AVERAGE_PIXEL_ABSOLUTE_DIFFERENCE); } @@ -195,18 +188,15 @@ public final class RgbAdjustmentPixelTest { matrixTextureProcessor = increaseBrightnessMatrix.toGlTextureProcessor(context, /* useHdr= */ false); Pair outputSize = matrixTextureProcessor.configure(inputWidth, inputHeight); - Bitmap expectedBitmap = BitmapTestUtil.readBitmap(INCREASE_BRIGHTNESS_PNG_ASSET_PATH); + Bitmap expectedBitmap = readBitmap(INCREASE_BRIGHTNESS_PNG_ASSET_PATH); matrixTextureProcessor.drawFrame(inputTexId, /* presentationTimeUs= */ 0); Bitmap actualBitmap = - BitmapTestUtil.createArgb8888BitmapFromCurrentGlFramebuffer( - outputSize.first, outputSize.second); + createArgb8888BitmapFromCurrentGlFramebuffer(outputSize.first, outputSize.second); - BitmapTestUtil.maybeSaveTestBitmapToCacheDirectory( - testId, /* bitmapLabel= */ "actual", actualBitmap); + maybeSaveTestBitmapToCacheDirectory(testId, /* bitmapLabel= */ "actual", actualBitmap); float averagePixelAbsoluteDifference = - BitmapTestUtil.getAveragePixelAbsoluteDifferenceArgb8888( - expectedBitmap, actualBitmap, testId); + getBitmapAveragePixelAbsoluteDifferenceArgb8888(expectedBitmap, actualBitmap, testId); assertThat(averagePixelAbsoluteDifference).isAtMost(MAXIMUM_AVERAGE_PIXEL_ABSOLUTE_DIFFERENCE); } @@ -224,19 +214,15 @@ public final class RgbAdjustmentPixelTest { /* useHdr= */ false); Pair outputSize = matrixTextureProcessor.configure(inputWidth, inputHeight); Bitmap expectedBitmap = - BitmapTestUtil.createArgb8888BitmapWithSolidColor( - outputSize.first, outputSize.second, Color.BLACK); + createArgb8888BitmapWithSolidColor(outputSize.first, outputSize.second, Color.BLACK); matrixTextureProcessor.drawFrame(inputTexId, /* presentationTimeUs= */ 0); Bitmap actualBitmap = - BitmapTestUtil.createArgb8888BitmapFromCurrentGlFramebuffer( - outputSize.first, outputSize.second); + createArgb8888BitmapFromCurrentGlFramebuffer(outputSize.first, outputSize.second); - BitmapTestUtil.maybeSaveTestBitmapToCacheDirectory( - testId, /* bitmapLabel= */ "actual", actualBitmap); + maybeSaveTestBitmapToCacheDirectory(testId, /* bitmapLabel= */ "actual", actualBitmap); float averagePixelAbsoluteDifference = - BitmapTestUtil.getAveragePixelAbsoluteDifferenceArgb8888( - expectedBitmap, actualBitmap, testId); + getBitmapAveragePixelAbsoluteDifferenceArgb8888(expectedBitmap, actualBitmap, testId); assertThat(averagePixelAbsoluteDifference).isAtMost(MAXIMUM_AVERAGE_PIXEL_ABSOLUTE_DIFFERENCE); } @@ -252,18 +238,15 @@ public final class RgbAdjustmentPixelTest { /* rgbMatrices= */ ImmutableList.of(noGreen, noBlue), /* useHdr= */ false); Pair outputSize = matrixTextureProcessor.configure(inputWidth, inputHeight); - Bitmap expectedBitmap = BitmapTestUtil.readBitmap(ONLY_RED_CHANNEL_PNG_ASSET_PATH); + Bitmap expectedBitmap = readBitmap(ONLY_RED_CHANNEL_PNG_ASSET_PATH); matrixTextureProcessor.drawFrame(inputTexId, /* presentationTimeUs= */ 0); Bitmap actualBitmap = - BitmapTestUtil.createArgb8888BitmapFromCurrentGlFramebuffer( - outputSize.first, outputSize.second); + createArgb8888BitmapFromCurrentGlFramebuffer(outputSize.first, outputSize.second); - BitmapTestUtil.maybeSaveTestBitmapToCacheDirectory( - testId, /* bitmapLabel= */ "actual", actualBitmap); + maybeSaveTestBitmapToCacheDirectory(testId, /* bitmapLabel= */ "actual", actualBitmap); float averagePixelAbsoluteDifference = - BitmapTestUtil.getAveragePixelAbsoluteDifferenceArgb8888( - expectedBitmap, actualBitmap, testId); + getBitmapAveragePixelAbsoluteDifferenceArgb8888(expectedBitmap, actualBitmap, testId); assertThat(averagePixelAbsoluteDifference).isAtMost(MAXIMUM_AVERAGE_PIXEL_ABSOLUTE_DIFFERENCE); } @@ -281,18 +264,15 @@ public final class RgbAdjustmentPixelTest { /* rgbMatrices= */ ImmutableList.of(scaleRedMatrix, scaleRedByInverseMatrix), /* useHdr= */ false); Pair outputSize = matrixTextureProcessor.configure(inputWidth, inputHeight); - Bitmap expectedBitmap = BitmapTestUtil.readBitmap(ORIGINAL_PNG_ASSET_PATH); + Bitmap expectedBitmap = readBitmap(ORIGINAL_PNG_ASSET_PATH); matrixTextureProcessor.drawFrame(inputTexId, /* presentationTimeUs= */ 0); Bitmap actualBitmap = - BitmapTestUtil.createArgb8888BitmapFromCurrentGlFramebuffer( - outputSize.first, outputSize.second); + createArgb8888BitmapFromCurrentGlFramebuffer(outputSize.first, outputSize.second); - BitmapTestUtil.maybeSaveTestBitmapToCacheDirectory( - testId, /* bitmapLabel= */ "actual", actualBitmap); + maybeSaveTestBitmapToCacheDirectory(testId, /* bitmapLabel= */ "actual", actualBitmap); float averagePixelAbsoluteDifference = - BitmapTestUtil.getAveragePixelAbsoluteDifferenceArgb8888( - expectedBitmap, actualBitmap, testId); + getBitmapAveragePixelAbsoluteDifferenceArgb8888(expectedBitmap, actualBitmap, testId); assertThat(averagePixelAbsoluteDifference).isAtMost(MAXIMUM_AVERAGE_PIXEL_ABSOLUTE_DIFFERENCE); } } diff --git a/google3/third_party/java_src/android_libs/media/libraries/effect/src/androidTest/java/androidx/media3/effect/RgbFilterPixelTest.java b/google3/third_party/java_src/android_libs/media/libraries/effect/src/androidTest/java/androidx/media3/effect/RgbFilterPixelTest.java index ab30ba3842..2600f0fbb6 100644 --- a/google3/third_party/java_src/android_libs/media/libraries/effect/src/androidTest/java/androidx/media3/effect/RgbFilterPixelTest.java +++ b/google3/third_party/java_src/android_libs/media/libraries/effect/src/androidTest/java/androidx/media3/effect/RgbFilterPixelTest.java @@ -17,6 +17,11 @@ package androidx.media3.effect; import static androidx.media3.effect.BitmapTestUtil.MAXIMUM_AVERAGE_PIXEL_ABSOLUTE_DIFFERENCE; +import static androidx.media3.effect.BitmapTestUtil.createArgb8888BitmapFromCurrentGlFramebuffer; +import static androidx.media3.effect.BitmapTestUtil.createGlTextureFromBitmap; +import static androidx.media3.effect.BitmapTestUtil.getBitmapAveragePixelAbsoluteDifferenceArgb8888; +import static androidx.media3.effect.BitmapTestUtil.maybeSaveTestBitmapToCacheDirectory; +import static androidx.media3.effect.BitmapTestUtil.readBitmap; import static androidx.test.core.app.ApplicationProvider.getApplicationContext; import static com.google.android.exoplayer2.util.Assertions.checkNotNull; import static com.google.common.truth.Truth.assertThat; @@ -69,12 +74,12 @@ public final class RgbFilterPixelTest { public void createGlObjects() throws IOException, GlUtil.GlException { eglDisplay = GlUtil.createEglDisplay(); eglContext = GlUtil.createEglContext(eglDisplay); - Bitmap inputBitmap = BitmapTestUtil.readBitmap(ORIGINAL_PNG_ASSET_PATH); + Bitmap inputBitmap = readBitmap(ORIGINAL_PNG_ASSET_PATH); inputWidth = inputBitmap.getWidth(); inputHeight = inputBitmap.getHeight(); placeholderEglSurface = GlUtil.createPlaceholderEglSurface(eglDisplay); GlUtil.focusEglSurface(eglDisplay, eglContext, placeholderEglSurface, inputWidth, inputHeight); - inputTexId = BitmapTestUtil.createGlTextureFromBitmap(inputBitmap); + inputTexId = createGlTextureFromBitmap(inputBitmap); outputTexId = GlUtil.createTexture(inputWidth, inputHeight, /* useHighPrecisionColorComponents= */ false); @@ -102,18 +107,15 @@ public final class RgbFilterPixelTest { RgbMatrix grayscaleMatrix = RgbFilter.createGrayscaleFilter(); matrixTextureProcessor = grayscaleMatrix.toGlTextureProcessor(context, /* useHdr= */ false); Pair outputSize = matrixTextureProcessor.configure(inputWidth, inputHeight); - Bitmap expectedBitmap = BitmapTestUtil.readBitmap(GRAYSCALE_PNG_ASSET_PATH); + Bitmap expectedBitmap = readBitmap(GRAYSCALE_PNG_ASSET_PATH); matrixTextureProcessor.drawFrame(inputTexId, /* presentationTimeUs= */ 0); Bitmap actualBitmap = - BitmapTestUtil.createArgb8888BitmapFromCurrentGlFramebuffer( - outputSize.first, outputSize.second); + createArgb8888BitmapFromCurrentGlFramebuffer(outputSize.first, outputSize.second); - BitmapTestUtil.maybeSaveTestBitmapToCacheDirectory( - testId, /* bitmapLabel= */ "actual", actualBitmap); + maybeSaveTestBitmapToCacheDirectory(testId, /* bitmapLabel= */ "actual", actualBitmap); float averagePixelAbsoluteDifference = - BitmapTestUtil.getAveragePixelAbsoluteDifferenceArgb8888( - expectedBitmap, actualBitmap, testId); + getBitmapAveragePixelAbsoluteDifferenceArgb8888(expectedBitmap, actualBitmap, testId); assertThat(averagePixelAbsoluteDifference).isAtMost(MAXIMUM_AVERAGE_PIXEL_ABSOLUTE_DIFFERENCE); } @@ -123,18 +125,15 @@ public final class RgbFilterPixelTest { RgbMatrix invertedMatrix = RgbFilter.createInvertedFilter(); matrixTextureProcessor = invertedMatrix.toGlTextureProcessor(context, /* useHdr= */ false); Pair outputSize = matrixTextureProcessor.configure(inputWidth, inputHeight); - Bitmap expectedBitmap = BitmapTestUtil.readBitmap(INVERT_PNG_ASSET_PATH); + Bitmap expectedBitmap = readBitmap(INVERT_PNG_ASSET_PATH); matrixTextureProcessor.drawFrame(inputTexId, /* presentationTimeUs= */ 0); Bitmap actualBitmap = - BitmapTestUtil.createArgb8888BitmapFromCurrentGlFramebuffer( - outputSize.first, outputSize.second); + createArgb8888BitmapFromCurrentGlFramebuffer(outputSize.first, outputSize.second); - BitmapTestUtil.maybeSaveTestBitmapToCacheDirectory( - testId, /* bitmapLabel= */ "actual", actualBitmap); + maybeSaveTestBitmapToCacheDirectory(testId, /* bitmapLabel= */ "actual", actualBitmap); float averagePixelAbsoluteDifference = - BitmapTestUtil.getAveragePixelAbsoluteDifferenceArgb8888( - expectedBitmap, actualBitmap, testId); + getBitmapAveragePixelAbsoluteDifferenceArgb8888(expectedBitmap, actualBitmap, testId); assertThat(averagePixelAbsoluteDifference).isAtMost(MAXIMUM_AVERAGE_PIXEL_ABSOLUTE_DIFFERENCE); } } diff --git a/google3/third_party/java_src/android_libs/media/libraries/effect/src/androidTest/java/androidx/media3/effect/SingleColorLutPixelTest.java b/google3/third_party/java_src/android_libs/media/libraries/effect/src/androidTest/java/androidx/media3/effect/SingleColorLutPixelTest.java index 683bd6e269..9cd9e5029f 100644 --- a/google3/third_party/java_src/android_libs/media/libraries/effect/src/androidTest/java/androidx/media3/effect/SingleColorLutPixelTest.java +++ b/google3/third_party/java_src/android_libs/media/libraries/effect/src/androidTest/java/androidx/media3/effect/SingleColorLutPixelTest.java @@ -17,6 +17,11 @@ package androidx.media3.effect; import static androidx.media3.effect.BitmapTestUtil.MAXIMUM_AVERAGE_PIXEL_ABSOLUTE_DIFFERENCE; +import static androidx.media3.effect.BitmapTestUtil.createArgb8888BitmapFromCurrentGlFramebuffer; +import static androidx.media3.effect.BitmapTestUtil.createGlTextureFromBitmap; +import static androidx.media3.effect.BitmapTestUtil.getBitmapAveragePixelAbsoluteDifferenceArgb8888; +import static androidx.media3.effect.BitmapTestUtil.maybeSaveTestBitmapToCacheDirectory; +import static androidx.media3.effect.BitmapTestUtil.readBitmap; import static androidx.test.core.app.ApplicationProvider.getApplicationContext; import static com.google.android.exoplayer2.util.Assertions.checkNotNull; import static com.google.common.truth.Truth.assertThat; @@ -75,13 +80,13 @@ public class SingleColorLutPixelTest { eglDisplay = GlUtil.createEglDisplay(); eglContext = GlUtil.createEglContext(eglDisplay); - Bitmap inputBitmap = BitmapTestUtil.readBitmap(ORIGINAL_PNG_ASSET_PATH); + Bitmap inputBitmap = readBitmap(ORIGINAL_PNG_ASSET_PATH); inputWidth = inputBitmap.getWidth(); inputHeight = inputBitmap.getHeight(); placeholderEglSurface = GlUtil.createPlaceholderEglSurface(eglDisplay); GlUtil.focusEglSurface(eglDisplay, eglContext, placeholderEglSurface, inputWidth, inputHeight); - inputTexId = BitmapTestUtil.createGlTextureFromBitmap(inputBitmap); + inputTexId = createGlTextureFromBitmap(inputBitmap); } @After @@ -101,17 +106,15 @@ public class SingleColorLutPixelTest { .toGlTextureProcessor(context, /* useHdr= */ false); Pair outputSize = colorLutProcessor.configure(inputWidth, inputHeight); setupOutputTexture(outputSize.first, outputSize.second); - Bitmap expectedBitmap = BitmapTestUtil.readBitmap(ORIGINAL_PNG_ASSET_PATH); + Bitmap expectedBitmap = readBitmap(ORIGINAL_PNG_ASSET_PATH); colorLutProcessor.drawFrame(inputTexId, /* presentationTimeUs = */ 0); Bitmap actualBitmap = - BitmapTestUtil.createArgb8888BitmapFromCurrentGlFramebuffer( - outputSize.first, outputSize.second); + createArgb8888BitmapFromCurrentGlFramebuffer(outputSize.first, outputSize.second); - BitmapTestUtil.maybeSaveTestBitmapToCacheDirectory(testId, "actual", actualBitmap); + maybeSaveTestBitmapToCacheDirectory(testId, "actual", actualBitmap); float averagePixelAbsoluteDifference = - BitmapTestUtil.getAveragePixelAbsoluteDifferenceArgb8888( - expectedBitmap, actualBitmap, testId); + getBitmapAveragePixelAbsoluteDifferenceArgb8888(expectedBitmap, actualBitmap, testId); assertThat(averagePixelAbsoluteDifference).isAtMost(MAXIMUM_AVERAGE_PIXEL_ABSOLUTE_DIFFERENCE); } @@ -124,17 +127,15 @@ public class SingleColorLutPixelTest { .toGlTextureProcessor(context, /* useHdr= */ false); Pair outputSize = colorLutProcessor.configure(inputWidth, inputHeight); setupOutputTexture(outputSize.first, outputSize.second); - Bitmap expectedBitmap = BitmapTestUtil.readBitmap(ORIGINAL_PNG_ASSET_PATH); + Bitmap expectedBitmap = readBitmap(ORIGINAL_PNG_ASSET_PATH); colorLutProcessor.drawFrame(inputTexId, /* presentationTimeUs = */ 0); Bitmap actualBitmap = - BitmapTestUtil.createArgb8888BitmapFromCurrentGlFramebuffer( - outputSize.first, outputSize.second); + createArgb8888BitmapFromCurrentGlFramebuffer(outputSize.first, outputSize.second); - BitmapTestUtil.maybeSaveTestBitmapToCacheDirectory(testId, "actual", actualBitmap); + maybeSaveTestBitmapToCacheDirectory(testId, "actual", actualBitmap); float averagePixelAbsoluteDifference = - BitmapTestUtil.getAveragePixelAbsoluteDifferenceArgb8888( - expectedBitmap, actualBitmap, testId); + getBitmapAveragePixelAbsoluteDifferenceArgb8888(expectedBitmap, actualBitmap, testId); assertThat(averagePixelAbsoluteDifference).isAtMost(MAXIMUM_AVERAGE_PIXEL_ABSOLUTE_DIFFERENCE); } @@ -147,17 +148,15 @@ public class SingleColorLutPixelTest { .toGlTextureProcessor(context, /* useHdr= */ false); Pair outputSize = colorLutProcessor.configure(inputWidth, inputHeight); setupOutputTexture(outputSize.first, outputSize.second); - Bitmap expectedBitmap = BitmapTestUtil.readBitmap(ORIGINAL_PNG_ASSET_PATH); + Bitmap expectedBitmap = readBitmap(ORIGINAL_PNG_ASSET_PATH); colorLutProcessor.drawFrame(inputTexId, /* presentationTimeUs = */ 0); Bitmap actualBitmap = - BitmapTestUtil.createArgb8888BitmapFromCurrentGlFramebuffer( - outputSize.first, outputSize.second); + createArgb8888BitmapFromCurrentGlFramebuffer(outputSize.first, outputSize.second); - BitmapTestUtil.maybeSaveTestBitmapToCacheDirectory(testId, "actual", actualBitmap); + maybeSaveTestBitmapToCacheDirectory(testId, "actual", actualBitmap); float averagePixelAbsoluteDifference = - BitmapTestUtil.getAveragePixelAbsoluteDifferenceArgb8888( - expectedBitmap, actualBitmap, testId); + getBitmapAveragePixelAbsoluteDifferenceArgb8888(expectedBitmap, actualBitmap, testId); assertThat(averagePixelAbsoluteDifference).isAtMost(MAXIMUM_AVERAGE_PIXEL_ABSOLUTE_DIFFERENCE); } @@ -170,40 +169,36 @@ public class SingleColorLutPixelTest { .toGlTextureProcessor(context, /* useHdr= */ false); Pair outputSize = colorLutProcessor.configure(inputWidth, inputHeight); setupOutputTexture(outputSize.first, outputSize.second); - Bitmap expectedBitmap = BitmapTestUtil.readBitmap(ORIGINAL_PNG_ASSET_PATH); + Bitmap expectedBitmap = readBitmap(ORIGINAL_PNG_ASSET_PATH); colorLutProcessor.drawFrame(inputTexId, /* presentationTimeUs = */ 0); Bitmap actualBitmap = - BitmapTestUtil.createArgb8888BitmapFromCurrentGlFramebuffer( - outputSize.first, outputSize.second); + createArgb8888BitmapFromCurrentGlFramebuffer(outputSize.first, outputSize.second); - BitmapTestUtil.maybeSaveTestBitmapToCacheDirectory(testId, "actual", actualBitmap); + maybeSaveTestBitmapToCacheDirectory(testId, "actual", actualBitmap); float averagePixelAbsoluteDifference = - BitmapTestUtil.getAveragePixelAbsoluteDifferenceArgb8888( - expectedBitmap, actualBitmap, testId); + getBitmapAveragePixelAbsoluteDifferenceArgb8888(expectedBitmap, actualBitmap, testId); assertThat(averagePixelAbsoluteDifference).isAtMost(MAXIMUM_AVERAGE_PIXEL_ABSOLUTE_DIFFERENCE); } @Test public void drawFrame_identityLutFromHaldImage_leavesFrameUnchanged() throws Exception { String testId = "drawFrame_identityLutFromHaldImage"; - Bitmap bitmapLut = BitmapTestUtil.readBitmap(VERTICAL_HALD_IDENTITY_LUT); + Bitmap bitmapLut = readBitmap(VERTICAL_HALD_IDENTITY_LUT); colorLutProcessor = SingleColorLut.createFromBitmap(bitmapLut) .toGlTextureProcessor(context, /* useHdr= */ false); Pair outputSize = colorLutProcessor.configure(inputWidth, inputHeight); setupOutputTexture(outputSize.first, outputSize.second); - Bitmap expectedBitmap = BitmapTestUtil.readBitmap(ORIGINAL_PNG_ASSET_PATH); + Bitmap expectedBitmap = readBitmap(ORIGINAL_PNG_ASSET_PATH); colorLutProcessor.drawFrame(inputTexId, /* presentationTimeUs = */ 0); Bitmap actualBitmap = - BitmapTestUtil.createArgb8888BitmapFromCurrentGlFramebuffer( - outputSize.first, outputSize.second); + createArgb8888BitmapFromCurrentGlFramebuffer(outputSize.first, outputSize.second); - BitmapTestUtil.maybeSaveTestBitmapToCacheDirectory(testId, "actual", actualBitmap); + maybeSaveTestBitmapToCacheDirectory(testId, "actual", actualBitmap); float averagePixelAbsoluteDifference = - BitmapTestUtil.getAveragePixelAbsoluteDifferenceArgb8888( - expectedBitmap, actualBitmap, testId); + getBitmapAveragePixelAbsoluteDifferenceArgb8888(expectedBitmap, actualBitmap, testId); assertThat(averagePixelAbsoluteDifference).isAtMost(MAXIMUM_AVERAGE_PIXEL_ABSOLUTE_DIFFERENCE); } @@ -218,63 +213,57 @@ public class SingleColorLutPixelTest { .toGlTextureProcessor(context, /* useHdr= */ false); Pair outputSize = colorLutProcessor.configure(inputWidth, inputHeight); setupOutputTexture(outputSize.first, outputSize.second); - Bitmap expectedBitmap = BitmapTestUtil.readBitmap(LUT_MAP_WHITE_TO_GREEN_ASSET_PATH); + Bitmap expectedBitmap = readBitmap(LUT_MAP_WHITE_TO_GREEN_ASSET_PATH); colorLutProcessor.drawFrame(inputTexId, /* presentationTimeUs = */ 0); Bitmap actualBitmap = - BitmapTestUtil.createArgb8888BitmapFromCurrentGlFramebuffer( - outputSize.first, outputSize.second); + createArgb8888BitmapFromCurrentGlFramebuffer(outputSize.first, outputSize.second); - BitmapTestUtil.maybeSaveTestBitmapToCacheDirectory(testId, "actual", actualBitmap); + maybeSaveTestBitmapToCacheDirectory(testId, "actual", actualBitmap); float averagePixelAbsoluteDifference = - BitmapTestUtil.getAveragePixelAbsoluteDifferenceArgb8888( - expectedBitmap, actualBitmap, testId); + getBitmapAveragePixelAbsoluteDifferenceArgb8888(expectedBitmap, actualBitmap, testId); assertThat(averagePixelAbsoluteDifference).isAtMost(MAXIMUM_AVERAGE_PIXEL_ABSOLUTE_DIFFERENCE); } @Test public void drawFrame_applyInvertedLut_producesInvertedFrame() throws Exception { String testId = "drawFrame_applyInvertedLut"; - Bitmap invertedLutBitmap = BitmapTestUtil.readBitmap(VERTICAL_HALD_INVERTED_LUT); + Bitmap invertedLutBitmap = readBitmap(VERTICAL_HALD_INVERTED_LUT); colorLutProcessor = SingleColorLut.createFromBitmap(invertedLutBitmap) .toGlTextureProcessor(context, /* useHdr= */ false); Pair outputSize = colorLutProcessor.configure(inputWidth, inputHeight); setupOutputTexture(outputSize.first, outputSize.second); - Bitmap expectedBitmap = BitmapTestUtil.readBitmap(INVERT_PNG_ASSET_PATH); + Bitmap expectedBitmap = readBitmap(INVERT_PNG_ASSET_PATH); colorLutProcessor.drawFrame(inputTexId, /* presentationTimeUs = */ 0); Bitmap actualBitmap = - BitmapTestUtil.createArgb8888BitmapFromCurrentGlFramebuffer( - outputSize.first, outputSize.second); + createArgb8888BitmapFromCurrentGlFramebuffer(outputSize.first, outputSize.second); - BitmapTestUtil.maybeSaveTestBitmapToCacheDirectory(testId, "actual", actualBitmap); + maybeSaveTestBitmapToCacheDirectory(testId, "actual", actualBitmap); float averagePixelAbsoluteDifference = - BitmapTestUtil.getAveragePixelAbsoluteDifferenceArgb8888( - expectedBitmap, actualBitmap, testId); + getBitmapAveragePixelAbsoluteDifferenceArgb8888(expectedBitmap, actualBitmap, testId); assertThat(averagePixelAbsoluteDifference).isAtMost(MAXIMUM_AVERAGE_PIXEL_ABSOLUTE_DIFFERENCE); } @Test public void drawFrame_applyGrayscaleLut_producesGrayscaleFrame() throws Exception { String testId = "drawFrame_applyGrayscaleLut"; - Bitmap grayscaleLutBitmap = BitmapTestUtil.readBitmap(VERTICAL_HALD_GRAYSCALE_LUT); + Bitmap grayscaleLutBitmap = readBitmap(VERTICAL_HALD_GRAYSCALE_LUT); colorLutProcessor = SingleColorLut.createFromBitmap(grayscaleLutBitmap) .toGlTextureProcessor(context, /* useHdr= */ false); Pair outputSize = colorLutProcessor.configure(inputWidth, inputHeight); setupOutputTexture(outputSize.first, outputSize.second); - Bitmap expectedBitmap = BitmapTestUtil.readBitmap(GRAYSCALE_PNG_ASSET_PATH); + Bitmap expectedBitmap = readBitmap(GRAYSCALE_PNG_ASSET_PATH); colorLutProcessor.drawFrame(inputTexId, /* presentationTimeUs = */ 0); Bitmap actualBitmap = - BitmapTestUtil.createArgb8888BitmapFromCurrentGlFramebuffer( - outputSize.first, outputSize.second); + createArgb8888BitmapFromCurrentGlFramebuffer(outputSize.first, outputSize.second); - BitmapTestUtil.maybeSaveTestBitmapToCacheDirectory(testId, "actual", actualBitmap); + maybeSaveTestBitmapToCacheDirectory(testId, "actual", actualBitmap); float averagePixelAbsoluteDifference = - BitmapTestUtil.getAveragePixelAbsoluteDifferenceArgb8888( - expectedBitmap, actualBitmap, testId); + getBitmapAveragePixelAbsoluteDifferenceArgb8888(expectedBitmap, actualBitmap, testId); assertThat(averagePixelAbsoluteDifference).isAtMost(MAXIMUM_AVERAGE_PIXEL_ABSOLUTE_DIFFERENCE); }