mirror of
https://github.com/androidx/media.git
synced 2025-04-30 06:46:50 +08:00
Tests for disabled color transfers
#minor-release PiperOrigin-RevId: 538466615 (cherry picked from commit c3b9328d74e21a05ff463ea8250510663233b79c)
This commit is contained in:
parent
295eb06145
commit
f7245a5ff2
@ -87,6 +87,11 @@ public final class DefaultVideoFrameProcessorPixelTest {
|
|||||||
/** Input video of which we only use the first frame. */
|
/** Input video of which we only use the first frame. */
|
||||||
private static final String INPUT_SDR_MP4_ASSET_STRING = "media/mp4/sample.mp4";
|
private static final String INPUT_SDR_MP4_ASSET_STRING = "media/mp4/sample.mp4";
|
||||||
|
|
||||||
|
// A passthrough effect allows for testing having an intermediate effect injected, which uses
|
||||||
|
// different OpenGL shaders from having no effects.
|
||||||
|
private static final GlEffect NO_OP_EFFECT =
|
||||||
|
new GlEffectWrapper(new ScaleAndRotateTransformation.Builder().build());
|
||||||
|
|
||||||
private @MonotonicNonNull VideoFrameProcessorTestRunner videoFrameProcessorTestRunner;
|
private @MonotonicNonNull VideoFrameProcessorTestRunner videoFrameProcessorTestRunner;
|
||||||
|
|
||||||
@After
|
@After
|
||||||
@ -109,6 +114,45 @@ public final class DefaultVideoFrameProcessorPixelTest {
|
|||||||
assertThat(averagePixelAbsoluteDifference).isAtMost(MAXIMUM_AVERAGE_PIXEL_ABSOLUTE_DIFFERENCE);
|
assertThat(averagePixelAbsoluteDifference).isAtMost(MAXIMUM_AVERAGE_PIXEL_ABSOLUTE_DIFFERENCE);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Test
|
||||||
|
public void noEffects_withFrameCache_matchesGoldenFile() throws Exception {
|
||||||
|
String testId = "noEffects_withFrameCache_matchesGoldenFile";
|
||||||
|
videoFrameProcessorTestRunner =
|
||||||
|
getDefaultFrameProcessorTestRunnerBuilder(testId)
|
||||||
|
.setEffects(new FrameCache(/* capacity= */ 5))
|
||||||
|
.build();
|
||||||
|
Bitmap expectedBitmap = readBitmap(ORIGINAL_PNG_ASSET_PATH);
|
||||||
|
|
||||||
|
videoFrameProcessorTestRunner.processFirstFrameAndEnd();
|
||||||
|
Bitmap actualBitmap = videoFrameProcessorTestRunner.getOutputBitmap();
|
||||||
|
|
||||||
|
// TODO(b/207848601): Switch to using proper tooling for testing against golden data.
|
||||||
|
float averagePixelAbsoluteDifference =
|
||||||
|
getBitmapAveragePixelAbsoluteDifferenceArgb8888(expectedBitmap, actualBitmap, testId);
|
||||||
|
assertThat(averagePixelAbsoluteDifference).isAtMost(MAXIMUM_AVERAGE_PIXEL_ABSOLUTE_DIFFERENCE);
|
||||||
|
}
|
||||||
|
|
||||||
|
@Test
|
||||||
|
public void noEffects_withDisabledColorTransfers_matchesGoldenFile() throws Exception {
|
||||||
|
String testId = "noEffects_withDisabledColorTransfers_matchesGoldenFile";
|
||||||
|
videoFrameProcessorTestRunner =
|
||||||
|
getDefaultFrameProcessorTestRunnerBuilder(testId)
|
||||||
|
.setVideoFrameProcessorFactory(
|
||||||
|
new DefaultVideoFrameProcessor.Factory.Builder()
|
||||||
|
.setEnableColorTransfers(false)
|
||||||
|
.build())
|
||||||
|
.build();
|
||||||
|
Bitmap expectedBitmap = readBitmap(ORIGINAL_PNG_ASSET_PATH);
|
||||||
|
|
||||||
|
videoFrameProcessorTestRunner.processFirstFrameAndEnd();
|
||||||
|
Bitmap actualBitmap = videoFrameProcessorTestRunner.getOutputBitmap();
|
||||||
|
|
||||||
|
// TODO(b/207848601): Switch to using proper tooling for testing against golden data.
|
||||||
|
float averagePixelAbsoluteDifference =
|
||||||
|
getBitmapAveragePixelAbsoluteDifferenceArgb8888(expectedBitmap, actualBitmap, testId);
|
||||||
|
assertThat(averagePixelAbsoluteDifference).isAtMost(MAXIMUM_AVERAGE_PIXEL_ABSOLUTE_DIFFERENCE);
|
||||||
|
}
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
public void noEffects_withImageInput_matchesGoldenFile() throws Exception {
|
public void noEffects_withImageInput_matchesGoldenFile() throws Exception {
|
||||||
String testId = "noEffects_withImageInput_matchesGoldenFile";
|
String testId = "noEffects_withImageInput_matchesGoldenFile";
|
||||||
@ -161,20 +205,29 @@ public final class DefaultVideoFrameProcessorPixelTest {
|
|||||||
}
|
}
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
public void noEffects_withFrameCache_matchesGoldenFile() throws Exception {
|
public void noOpEffect_withImageInputAndDisabledColorTransfers_matchesGoldenFile()
|
||||||
String testId = "noEffects_withFrameCache_matchesGoldenFile";
|
throws Exception {
|
||||||
|
String testId = "noOpEffect_withImageInputAndDisabledColorTransfers_matchesGoldenFile";
|
||||||
videoFrameProcessorTestRunner =
|
videoFrameProcessorTestRunner =
|
||||||
getDefaultFrameProcessorTestRunnerBuilder(testId)
|
getDefaultFrameProcessorTestRunnerBuilder(testId)
|
||||||
.setEffects(new FrameCache(/* capacity= */ 5))
|
.setVideoFrameProcessorFactory(
|
||||||
|
new DefaultVideoFrameProcessor.Factory.Builder()
|
||||||
|
.setEnableColorTransfers(false)
|
||||||
|
.build())
|
||||||
|
.setInputType(INPUT_TYPE_BITMAP)
|
||||||
|
.setInputColorInfo(ColorInfo.SRGB_BT709_FULL)
|
||||||
|
.setEffects(NO_OP_EFFECT)
|
||||||
.build();
|
.build();
|
||||||
Bitmap expectedBitmap = readBitmap(ORIGINAL_PNG_ASSET_PATH);
|
Bitmap originalBitmap = readBitmap(IMAGE_PNG_ASSET_PATH);
|
||||||
|
|
||||||
videoFrameProcessorTestRunner.processFirstFrameAndEnd();
|
videoFrameProcessorTestRunner.queueInputBitmap(
|
||||||
|
originalBitmap, C.MICROS_PER_SECOND, /* offsetToAddUs= */ 0L, /* frameRate= */ 1);
|
||||||
|
videoFrameProcessorTestRunner.endFrameProcessing();
|
||||||
Bitmap actualBitmap = videoFrameProcessorTestRunner.getOutputBitmap();
|
Bitmap actualBitmap = videoFrameProcessorTestRunner.getOutputBitmap();
|
||||||
|
|
||||||
// TODO(b/207848601): Switch to using proper tooling for testing against golden data.
|
// TODO(b/207848601): Switch to using proper tooling for testing against golden data.
|
||||||
float averagePixelAbsoluteDifference =
|
float averagePixelAbsoluteDifference =
|
||||||
getBitmapAveragePixelAbsoluteDifferenceArgb8888(expectedBitmap, actualBitmap, testId);
|
getBitmapAveragePixelAbsoluteDifferenceArgb8888(originalBitmap, actualBitmap, testId);
|
||||||
assertThat(averagePixelAbsoluteDifference).isAtMost(MAXIMUM_AVERAGE_PIXEL_ABSOLUTE_DIFFERENCE);
|
assertThat(averagePixelAbsoluteDifference).isAtMost(MAXIMUM_AVERAGE_PIXEL_ABSOLUTE_DIFFERENCE);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Loading…
x
Reference in New Issue
Block a user