mirror of
https://github.com/androidx/media.git
synced 2025-05-05 06:30:24 +08:00
Tests: Statically import BitmapTestUtil methods.
Per go/java-practices/imports#static No functional changes intended. PiperOrigin-RevId: 477974779
This commit is contained in:
parent
9786802527
commit
da2c6376cd
@ -129,7 +129,7 @@ public class BitmapTestUtil {
|
|||||||
* @return The average of the maximum absolute pixel-wise differences between the expected and
|
* @return The average of the maximum absolute pixel-wise differences between the expected and
|
||||||
* actual bitmaps.
|
* actual bitmaps.
|
||||||
*/
|
*/
|
||||||
public static float getAveragePixelAbsoluteDifferenceArgb8888(
|
public static float getBitmapAveragePixelAbsoluteDifferenceArgb8888(
|
||||||
Bitmap expected, Bitmap actual, @Nullable String testId) {
|
Bitmap expected, Bitmap actual, @Nullable String testId) {
|
||||||
int width = actual.getWidth();
|
int width = actual.getWidth();
|
||||||
int height = actual.getHeight();
|
int height = actual.getHeight();
|
||||||
|
@ -17,6 +17,12 @@
|
|||||||
package androidx.media3.effect;
|
package androidx.media3.effect;
|
||||||
|
|
||||||
import static androidx.media3.effect.BitmapTestUtil.MAXIMUM_AVERAGE_PIXEL_ABSOLUTE_DIFFERENCE;
|
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 androidx.test.core.app.ApplicationProvider.getApplicationContext;
|
||||||
import static com.google.android.exoplayer2.util.Assertions.checkNotNull;
|
import static com.google.android.exoplayer2.util.Assertions.checkNotNull;
|
||||||
import static com.google.common.truth.Truth.assertThat;
|
import static com.google.common.truth.Truth.assertThat;
|
||||||
@ -75,13 +81,13 @@ public class ContrastPixelTest {
|
|||||||
eglDisplay = GlUtil.createEglDisplay();
|
eglDisplay = GlUtil.createEglDisplay();
|
||||||
eglContext = GlUtil.createEglContext(eglDisplay);
|
eglContext = GlUtil.createEglContext(eglDisplay);
|
||||||
|
|
||||||
Bitmap inputBitmap = BitmapTestUtil.readBitmap(ORIGINAL_PNG_ASSET_PATH);
|
Bitmap inputBitmap = readBitmap(ORIGINAL_PNG_ASSET_PATH);
|
||||||
inputWidth = inputBitmap.getWidth();
|
inputWidth = inputBitmap.getWidth();
|
||||||
inputHeight = inputBitmap.getHeight();
|
inputHeight = inputBitmap.getHeight();
|
||||||
|
|
||||||
placeholderEglSurface = GlUtil.createPlaceholderEglSurface(eglDisplay);
|
placeholderEglSurface = GlUtil.createPlaceholderEglSurface(eglDisplay);
|
||||||
GlUtil.focusEglSurface(eglDisplay, eglContext, placeholderEglSurface, inputWidth, inputHeight);
|
GlUtil.focusEglSurface(eglDisplay, eglContext, placeholderEglSurface, inputWidth, inputHeight);
|
||||||
inputTexId = BitmapTestUtil.createGlTextureFromBitmap(inputBitmap);
|
inputTexId = createGlTextureFromBitmap(inputBitmap);
|
||||||
}
|
}
|
||||||
|
|
||||||
@After
|
@After
|
||||||
@ -99,18 +105,15 @@ public class ContrastPixelTest {
|
|||||||
new Contrast(/* contrast= */ 0.0f).toGlTextureProcessor(context, /* useHdr= */ false);
|
new Contrast(/* contrast= */ 0.0f).toGlTextureProcessor(context, /* useHdr= */ false);
|
||||||
Pair<Integer, Integer> outputSize = contrastProcessor.configure(inputWidth, inputHeight);
|
Pair<Integer, Integer> outputSize = contrastProcessor.configure(inputWidth, inputHeight);
|
||||||
setupOutputTexture(outputSize.first, outputSize.second);
|
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);
|
contrastProcessor.drawFrame(inputTexId, /* presentationTimeUs = */ 0);
|
||||||
Bitmap actualBitmap =
|
Bitmap actualBitmap =
|
||||||
BitmapTestUtil.createArgb8888BitmapFromCurrentGlFramebuffer(
|
createArgb8888BitmapFromCurrentGlFramebuffer(outputSize.first, outputSize.second);
|
||||||
outputSize.first, outputSize.second);
|
|
||||||
|
|
||||||
BitmapTestUtil.maybeSaveTestBitmapToCacheDirectory(
|
maybeSaveTestBitmapToCacheDirectory(testId, /* bitmapLabel= */ "actual", actualBitmap);
|
||||||
testId, /* bitmapLabel= */ "actual", actualBitmap);
|
|
||||||
float averagePixelAbsoluteDifference =
|
float averagePixelAbsoluteDifference =
|
||||||
BitmapTestUtil.getAveragePixelAbsoluteDifferenceArgb8888(
|
getBitmapAveragePixelAbsoluteDifferenceArgb8888(expectedBitmap, actualBitmap, testId);
|
||||||
expectedBitmap, actualBitmap, testId);
|
|
||||||
assertThat(averagePixelAbsoluteDifference).isAtMost(MAXIMUM_AVERAGE_PIXEL_ABSOLUTE_DIFFERENCE);
|
assertThat(averagePixelAbsoluteDifference).isAtMost(MAXIMUM_AVERAGE_PIXEL_ABSOLUTE_DIFFERENCE);
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -122,7 +125,7 @@ public class ContrastPixelTest {
|
|||||||
Pair<Integer, Integer> outputSize = contrastProcessor.configure(inputWidth, inputHeight);
|
Pair<Integer, Integer> outputSize = contrastProcessor.configure(inputWidth, inputHeight);
|
||||||
setupOutputTexture(outputSize.first, outputSize.second);
|
setupOutputTexture(outputSize.first, outputSize.second);
|
||||||
Bitmap expectedBitmap =
|
Bitmap expectedBitmap =
|
||||||
BitmapTestUtil.createArgb8888BitmapWithSolidColor(
|
createArgb8888BitmapWithSolidColor(
|
||||||
inputWidth,
|
inputWidth,
|
||||||
inputHeight,
|
inputHeight,
|
||||||
Color.rgb(
|
Color.rgb(
|
||||||
@ -130,14 +133,11 @@ public class ContrastPixelTest {
|
|||||||
|
|
||||||
contrastProcessor.drawFrame(inputTexId, /* presentationTimeUs = */ 0);
|
contrastProcessor.drawFrame(inputTexId, /* presentationTimeUs = */ 0);
|
||||||
Bitmap actualBitmap =
|
Bitmap actualBitmap =
|
||||||
BitmapTestUtil.createArgb8888BitmapFromCurrentGlFramebuffer(
|
createArgb8888BitmapFromCurrentGlFramebuffer(outputSize.first, outputSize.second);
|
||||||
outputSize.first, outputSize.second);
|
|
||||||
|
|
||||||
BitmapTestUtil.maybeSaveTestBitmapToCacheDirectory(
|
maybeSaveTestBitmapToCacheDirectory(testId, /* bitmapLabel= */ "actual", actualBitmap);
|
||||||
testId, /* bitmapLabel= */ "actual", actualBitmap);
|
|
||||||
float averagePixelAbsoluteDifference =
|
float averagePixelAbsoluteDifference =
|
||||||
BitmapTestUtil.getAveragePixelAbsoluteDifferenceArgb8888(
|
getBitmapAveragePixelAbsoluteDifferenceArgb8888(expectedBitmap, actualBitmap, testId);
|
||||||
expectedBitmap, actualBitmap, testId);
|
|
||||||
assertThat(averagePixelAbsoluteDifference).isAtMost(MAXIMUM_AVERAGE_PIXEL_ABSOLUTE_DIFFERENCE);
|
assertThat(averagePixelAbsoluteDifference).isAtMost(MAXIMUM_AVERAGE_PIXEL_ABSOLUTE_DIFFERENCE);
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -149,18 +149,15 @@ public class ContrastPixelTest {
|
|||||||
new Contrast(/* contrast= */ -0.75f).toGlTextureProcessor(context, /* useHdr= */ false);
|
new Contrast(/* contrast= */ -0.75f).toGlTextureProcessor(context, /* useHdr= */ false);
|
||||||
Pair<Integer, Integer> outputSize = contrastProcessor.configure(inputWidth, inputHeight);
|
Pair<Integer, Integer> outputSize = contrastProcessor.configure(inputWidth, inputHeight);
|
||||||
setupOutputTexture(outputSize.first, outputSize.second);
|
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);
|
contrastProcessor.drawFrame(inputTexId, /* presentationTimeUs= */ 0);
|
||||||
Bitmap actualBitmap =
|
Bitmap actualBitmap =
|
||||||
BitmapTestUtil.createArgb8888BitmapFromCurrentGlFramebuffer(
|
createArgb8888BitmapFromCurrentGlFramebuffer(outputSize.first, outputSize.second);
|
||||||
outputSize.first, outputSize.second);
|
|
||||||
|
|
||||||
BitmapTestUtil.maybeSaveTestBitmapToCacheDirectory(
|
maybeSaveTestBitmapToCacheDirectory(testId, /* bitmapLabel= */ "actual", actualBitmap);
|
||||||
testId, /* bitmapLabel= */ "actual", actualBitmap);
|
|
||||||
float averagePixelAbsoluteDifference =
|
float averagePixelAbsoluteDifference =
|
||||||
BitmapTestUtil.getAveragePixelAbsoluteDifferenceArgb8888(
|
getBitmapAveragePixelAbsoluteDifferenceArgb8888(expectedBitmap, actualBitmap, testId);
|
||||||
expectedBitmap, actualBitmap, testId);
|
|
||||||
assertThat(averagePixelAbsoluteDifference).isAtMost(MAXIMUM_AVERAGE_PIXEL_ABSOLUTE_DIFFERENCE);
|
assertThat(averagePixelAbsoluteDifference).isAtMost(MAXIMUM_AVERAGE_PIXEL_ABSOLUTE_DIFFERENCE);
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -172,18 +169,15 @@ public class ContrastPixelTest {
|
|||||||
new Contrast(/* contrast= */ 0.75f).toGlTextureProcessor(context, /* useHdr= */ false);
|
new Contrast(/* contrast= */ 0.75f).toGlTextureProcessor(context, /* useHdr= */ false);
|
||||||
Pair<Integer, Integer> outputSize = contrastProcessor.configure(inputWidth, inputHeight);
|
Pair<Integer, Integer> outputSize = contrastProcessor.configure(inputWidth, inputHeight);
|
||||||
setupOutputTexture(outputSize.first, outputSize.second);
|
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);
|
contrastProcessor.drawFrame(inputTexId, /* presentationTimeUs= */ 0);
|
||||||
Bitmap actualBitmap =
|
Bitmap actualBitmap =
|
||||||
BitmapTestUtil.createArgb8888BitmapFromCurrentGlFramebuffer(
|
createArgb8888BitmapFromCurrentGlFramebuffer(outputSize.first, outputSize.second);
|
||||||
outputSize.first, outputSize.second);
|
|
||||||
|
|
||||||
BitmapTestUtil.maybeSaveTestBitmapToCacheDirectory(
|
maybeSaveTestBitmapToCacheDirectory(testId, /* bitmapLabel= */ "actual", actualBitmap);
|
||||||
testId, /* bitmapLabel= */ "actual", actualBitmap);
|
|
||||||
float averagePixelAbsoluteDifference =
|
float averagePixelAbsoluteDifference =
|
||||||
BitmapTestUtil.getAveragePixelAbsoluteDifferenceArgb8888(
|
getBitmapAveragePixelAbsoluteDifferenceArgb8888(expectedBitmap, actualBitmap, testId);
|
||||||
expectedBitmap, actualBitmap, testId);
|
|
||||||
assertThat(averagePixelAbsoluteDifference).isAtMost(MAXIMUM_AVERAGE_PIXEL_ABSOLUTE_DIFFERENCE);
|
assertThat(averagePixelAbsoluteDifference).isAtMost(MAXIMUM_AVERAGE_PIXEL_ABSOLUTE_DIFFERENCE);
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -194,18 +188,15 @@ public class ContrastPixelTest {
|
|||||||
new Contrast(/* contrast= */ 1.0f).toGlTextureProcessor(context, /* useHdr= */ false);
|
new Contrast(/* contrast= */ 1.0f).toGlTextureProcessor(context, /* useHdr= */ false);
|
||||||
Pair<Integer, Integer> outputSize = contrastProcessor.configure(inputWidth, inputHeight);
|
Pair<Integer, Integer> outputSize = contrastProcessor.configure(inputWidth, inputHeight);
|
||||||
setupOutputTexture(outputSize.first, outputSize.second);
|
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);
|
contrastProcessor.drawFrame(inputTexId, /* presentationTimeUs = */ 0);
|
||||||
Bitmap actualBitmap =
|
Bitmap actualBitmap =
|
||||||
BitmapTestUtil.createArgb8888BitmapFromCurrentGlFramebuffer(
|
createArgb8888BitmapFromCurrentGlFramebuffer(outputSize.first, outputSize.second);
|
||||||
outputSize.first, outputSize.second);
|
|
||||||
|
|
||||||
BitmapTestUtil.maybeSaveTestBitmapToCacheDirectory(
|
maybeSaveTestBitmapToCacheDirectory(testId, /* bitmapLabel= */ "actual", actualBitmap);
|
||||||
testId, /* bitmapLabel= */ "actual", actualBitmap);
|
|
||||||
float averagePixelAbsoluteDifference =
|
float averagePixelAbsoluteDifference =
|
||||||
BitmapTestUtil.getAveragePixelAbsoluteDifferenceArgb8888(
|
getBitmapAveragePixelAbsoluteDifferenceArgb8888(expectedBitmap, actualBitmap, testId);
|
||||||
expectedBitmap, actualBitmap, testId);
|
|
||||||
assertThat(averagePixelAbsoluteDifference).isAtMost(MAXIMUM_AVERAGE_PIXEL_ABSOLUTE_DIFFERENCE);
|
assertThat(averagePixelAbsoluteDifference).isAtMost(MAXIMUM_AVERAGE_PIXEL_ABSOLUTE_DIFFERENCE);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -16,6 +16,11 @@
|
|||||||
package androidx.media3.effect;
|
package androidx.media3.effect;
|
||||||
|
|
||||||
import static androidx.media3.effect.BitmapTestUtil.MAXIMUM_AVERAGE_PIXEL_ABSOLUTE_DIFFERENCE;
|
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 androidx.test.core.app.ApplicationProvider.getApplicationContext;
|
||||||
import static com.google.android.exoplayer2.util.Assertions.checkNotNull;
|
import static com.google.android.exoplayer2.util.Assertions.checkNotNull;
|
||||||
import static com.google.common.truth.Truth.assertThat;
|
import static com.google.common.truth.Truth.assertThat;
|
||||||
@ -68,12 +73,12 @@ public final class CropPixelTest {
|
|||||||
public void createGlObjects() throws IOException, GlUtil.GlException {
|
public void createGlObjects() throws IOException, GlUtil.GlException {
|
||||||
eglDisplay = GlUtil.createEglDisplay();
|
eglDisplay = GlUtil.createEglDisplay();
|
||||||
eglContext = GlUtil.createEglContext(eglDisplay);
|
eglContext = GlUtil.createEglContext(eglDisplay);
|
||||||
Bitmap inputBitmap = BitmapTestUtil.readBitmap(ORIGINAL_PNG_ASSET_PATH);
|
Bitmap inputBitmap = readBitmap(ORIGINAL_PNG_ASSET_PATH);
|
||||||
inputWidth = inputBitmap.getWidth();
|
inputWidth = inputBitmap.getWidth();
|
||||||
inputHeight = inputBitmap.getHeight();
|
inputHeight = inputBitmap.getHeight();
|
||||||
placeholderEglSurface = GlUtil.createPlaceholderEglSurface(eglDisplay);
|
placeholderEglSurface = GlUtil.createPlaceholderEglSurface(eglDisplay);
|
||||||
GlUtil.focusEglSurface(eglDisplay, eglContext, placeholderEglSurface, inputWidth, inputHeight);
|
GlUtil.focusEglSurface(eglDisplay, eglContext, placeholderEglSurface, inputWidth, inputHeight);
|
||||||
inputTexId = BitmapTestUtil.createGlTextureFromBitmap(inputBitmap);
|
inputTexId = createGlTextureFromBitmap(inputBitmap);
|
||||||
}
|
}
|
||||||
|
|
||||||
@After
|
@After
|
||||||
@ -94,19 +99,16 @@ public final class CropPixelTest {
|
|||||||
.toGlTextureProcessor(context, /* useHdr= */ false);
|
.toGlTextureProcessor(context, /* useHdr= */ false);
|
||||||
Pair<Integer, Integer> outputSize = cropTextureProcessor.configure(inputWidth, inputHeight);
|
Pair<Integer, Integer> outputSize = cropTextureProcessor.configure(inputWidth, inputHeight);
|
||||||
setupOutputTexture(outputSize.first, outputSize.second);
|
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);
|
cropTextureProcessor.drawFrame(inputTexId, /* presentationTimeUs= */ 0);
|
||||||
Bitmap actualBitmap =
|
Bitmap actualBitmap =
|
||||||
BitmapTestUtil.createArgb8888BitmapFromCurrentGlFramebuffer(
|
createArgb8888BitmapFromCurrentGlFramebuffer(outputSize.first, outputSize.second);
|
||||||
outputSize.first, outputSize.second);
|
|
||||||
|
|
||||||
BitmapTestUtil.maybeSaveTestBitmapToCacheDirectory(
|
maybeSaveTestBitmapToCacheDirectory(testId, /* bitmapLabel= */ "actual", actualBitmap);
|
||||||
testId, /* bitmapLabel= */ "actual", actualBitmap);
|
|
||||||
// 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 =
|
||||||
BitmapTestUtil.getAveragePixelAbsoluteDifferenceArgb8888(
|
getBitmapAveragePixelAbsoluteDifferenceArgb8888(expectedBitmap, actualBitmap, testId);
|
||||||
expectedBitmap, actualBitmap, testId);
|
|
||||||
assertThat(averagePixelAbsoluteDifference).isAtMost(MAXIMUM_AVERAGE_PIXEL_ABSOLUTE_DIFFERENCE);
|
assertThat(averagePixelAbsoluteDifference).isAtMost(MAXIMUM_AVERAGE_PIXEL_ABSOLUTE_DIFFERENCE);
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -118,19 +120,16 @@ public final class CropPixelTest {
|
|||||||
.toGlTextureProcessor(context, /* useHdr= */ false);
|
.toGlTextureProcessor(context, /* useHdr= */ false);
|
||||||
Pair<Integer, Integer> outputSize = cropTextureProcessor.configure(inputWidth, inputHeight);
|
Pair<Integer, Integer> outputSize = cropTextureProcessor.configure(inputWidth, inputHeight);
|
||||||
setupOutputTexture(outputSize.first, outputSize.second);
|
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);
|
cropTextureProcessor.drawFrame(inputTexId, /* presentationTimeUs= */ 0);
|
||||||
Bitmap actualBitmap =
|
Bitmap actualBitmap =
|
||||||
BitmapTestUtil.createArgb8888BitmapFromCurrentGlFramebuffer(
|
createArgb8888BitmapFromCurrentGlFramebuffer(outputSize.first, outputSize.second);
|
||||||
outputSize.first, outputSize.second);
|
|
||||||
|
|
||||||
BitmapTestUtil.maybeSaveTestBitmapToCacheDirectory(
|
maybeSaveTestBitmapToCacheDirectory(testId, /* bitmapLabel= */ "actual", actualBitmap);
|
||||||
testId, /* bitmapLabel= */ "actual", actualBitmap);
|
|
||||||
// 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 =
|
||||||
BitmapTestUtil.getAveragePixelAbsoluteDifferenceArgb8888(
|
getBitmapAveragePixelAbsoluteDifferenceArgb8888(expectedBitmap, actualBitmap, testId);
|
||||||
expectedBitmap, actualBitmap, testId);
|
|
||||||
assertThat(averagePixelAbsoluteDifference).isAtMost(MAXIMUM_AVERAGE_PIXEL_ABSOLUTE_DIFFERENCE);
|
assertThat(averagePixelAbsoluteDifference).isAtMost(MAXIMUM_AVERAGE_PIXEL_ABSOLUTE_DIFFERENCE);
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -142,19 +141,16 @@ public final class CropPixelTest {
|
|||||||
.toGlTextureProcessor(context, /* useHdr= */ false);
|
.toGlTextureProcessor(context, /* useHdr= */ false);
|
||||||
Pair<Integer, Integer> outputSize = cropTextureProcessor.configure(inputWidth, inputHeight);
|
Pair<Integer, Integer> outputSize = cropTextureProcessor.configure(inputWidth, inputHeight);
|
||||||
setupOutputTexture(outputSize.first, outputSize.second);
|
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);
|
cropTextureProcessor.drawFrame(inputTexId, /* presentationTimeUs= */ 0);
|
||||||
Bitmap actualBitmap =
|
Bitmap actualBitmap =
|
||||||
BitmapTestUtil.createArgb8888BitmapFromCurrentGlFramebuffer(
|
createArgb8888BitmapFromCurrentGlFramebuffer(outputSize.first, outputSize.second);
|
||||||
outputSize.first, outputSize.second);
|
|
||||||
|
|
||||||
BitmapTestUtil.maybeSaveTestBitmapToCacheDirectory(
|
maybeSaveTestBitmapToCacheDirectory(testId, /* bitmapLabel= */ "actual", actualBitmap);
|
||||||
testId, /* bitmapLabel= */ "actual", actualBitmap);
|
|
||||||
// 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 =
|
||||||
BitmapTestUtil.getAveragePixelAbsoluteDifferenceArgb8888(
|
getBitmapAveragePixelAbsoluteDifferenceArgb8888(expectedBitmap, actualBitmap, testId);
|
||||||
expectedBitmap, actualBitmap, testId);
|
|
||||||
assertThat(averagePixelAbsoluteDifference).isAtMost(MAXIMUM_AVERAGE_PIXEL_ABSOLUTE_DIFFERENCE);
|
assertThat(averagePixelAbsoluteDifference).isAtMost(MAXIMUM_AVERAGE_PIXEL_ABSOLUTE_DIFFERENCE);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -16,6 +16,10 @@
|
|||||||
package androidx.media3.effect;
|
package androidx.media3.effect;
|
||||||
|
|
||||||
import static androidx.media3.effect.BitmapTestUtil.MAXIMUM_AVERAGE_PIXEL_ABSOLUTE_DIFFERENCE;
|
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 androidx.test.core.app.ApplicationProvider.getApplicationContext;
|
||||||
import static com.google.android.exoplayer2.util.Assertions.checkNotNull;
|
import static com.google.android.exoplayer2.util.Assertions.checkNotNull;
|
||||||
import static com.google.android.exoplayer2.util.Assertions.checkStateNotNull;
|
import static com.google.android.exoplayer2.util.Assertions.checkStateNotNull;
|
||||||
@ -109,16 +113,14 @@ public final class GlEffectsFrameProcessorPixelTest {
|
|||||||
public void processData_noEdits_producesExpectedOutput() throws Exception {
|
public void processData_noEdits_producesExpectedOutput() throws Exception {
|
||||||
String testId = "processData_noEdits";
|
String testId = "processData_noEdits";
|
||||||
setUpAndPrepareFirstFrame(DEFAULT_PIXEL_WIDTH_HEIGHT_RATIO);
|
setUpAndPrepareFirstFrame(DEFAULT_PIXEL_WIDTH_HEIGHT_RATIO);
|
||||||
Bitmap expectedBitmap = BitmapTestUtil.readBitmap(ORIGINAL_PNG_ASSET_PATH);
|
Bitmap expectedBitmap = readBitmap(ORIGINAL_PNG_ASSET_PATH);
|
||||||
|
|
||||||
Bitmap actualBitmap = processFirstFrameAndEnd();
|
Bitmap actualBitmap = processFirstFrameAndEnd();
|
||||||
|
|
||||||
BitmapTestUtil.maybeSaveTestBitmapToCacheDirectory(
|
maybeSaveTestBitmapToCacheDirectory(testId, /* bitmapLabel= */ "actual", actualBitmap);
|
||||||
testId, /* bitmapLabel= */ "actual", actualBitmap);
|
|
||||||
// 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 =
|
||||||
BitmapTestUtil.getAveragePixelAbsoluteDifferenceArgb8888(
|
getBitmapAveragePixelAbsoluteDifferenceArgb8888(expectedBitmap, actualBitmap, testId);
|
||||||
expectedBitmap, actualBitmap, testId);
|
|
||||||
assertThat(averagePixelAbsoluteDifference).isAtMost(MAXIMUM_AVERAGE_PIXEL_ABSOLUTE_DIFFERENCE);
|
assertThat(averagePixelAbsoluteDifference).isAtMost(MAXIMUM_AVERAGE_PIXEL_ABSOLUTE_DIFFERENCE);
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -126,16 +128,14 @@ public final class GlEffectsFrameProcessorPixelTest {
|
|||||||
public void processData_withPixelWidthHeightRatio_producesExpectedOutput() throws Exception {
|
public void processData_withPixelWidthHeightRatio_producesExpectedOutput() throws Exception {
|
||||||
String testId = "processData_withPixelWidthHeightRatio";
|
String testId = "processData_withPixelWidthHeightRatio";
|
||||||
setUpAndPrepareFirstFrame(/* pixelWidthHeightRatio= */ 2f);
|
setUpAndPrepareFirstFrame(/* pixelWidthHeightRatio= */ 2f);
|
||||||
Bitmap expectedBitmap = BitmapTestUtil.readBitmap(SCALE_WIDE_PNG_ASSET_PATH);
|
Bitmap expectedBitmap = readBitmap(SCALE_WIDE_PNG_ASSET_PATH);
|
||||||
|
|
||||||
Bitmap actualBitmap = processFirstFrameAndEnd();
|
Bitmap actualBitmap = processFirstFrameAndEnd();
|
||||||
|
|
||||||
BitmapTestUtil.maybeSaveTestBitmapToCacheDirectory(
|
maybeSaveTestBitmapToCacheDirectory(testId, /* bitmapLabel= */ "actual", actualBitmap);
|
||||||
testId, /* bitmapLabel= */ "actual", actualBitmap);
|
|
||||||
// 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 =
|
||||||
BitmapTestUtil.getAveragePixelAbsoluteDifferenceArgb8888(
|
getBitmapAveragePixelAbsoluteDifferenceArgb8888(expectedBitmap, actualBitmap, testId);
|
||||||
expectedBitmap, actualBitmap, testId);
|
|
||||||
assertThat(averagePixelAbsoluteDifference).isAtMost(MAXIMUM_AVERAGE_PIXEL_ABSOLUTE_DIFFERENCE);
|
assertThat(averagePixelAbsoluteDifference).isAtMost(MAXIMUM_AVERAGE_PIXEL_ABSOLUTE_DIFFERENCE);
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -148,16 +148,14 @@ public final class GlEffectsFrameProcessorPixelTest {
|
|||||||
setUpAndPrepareFirstFrame(
|
setUpAndPrepareFirstFrame(
|
||||||
DEFAULT_PIXEL_WIDTH_HEIGHT_RATIO,
|
DEFAULT_PIXEL_WIDTH_HEIGHT_RATIO,
|
||||||
(MatrixTransformation) (long presentationTimeNs) -> translateRightMatrix);
|
(MatrixTransformation) (long presentationTimeNs) -> translateRightMatrix);
|
||||||
Bitmap expectedBitmap = BitmapTestUtil.readBitmap(TRANSLATE_RIGHT_PNG_ASSET_PATH);
|
Bitmap expectedBitmap = readBitmap(TRANSLATE_RIGHT_PNG_ASSET_PATH);
|
||||||
|
|
||||||
Bitmap actualBitmap = processFirstFrameAndEnd();
|
Bitmap actualBitmap = processFirstFrameAndEnd();
|
||||||
|
|
||||||
BitmapTestUtil.maybeSaveTestBitmapToCacheDirectory(
|
maybeSaveTestBitmapToCacheDirectory(testId, /* bitmapLabel= */ "actual", actualBitmap);
|
||||||
testId, /* bitmapLabel= */ "actual", actualBitmap);
|
|
||||||
// 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 =
|
||||||
BitmapTestUtil.getAveragePixelAbsoluteDifferenceArgb8888(
|
getBitmapAveragePixelAbsoluteDifferenceArgb8888(expectedBitmap, actualBitmap, testId);
|
||||||
expectedBitmap, actualBitmap, testId);
|
|
||||||
assertThat(averagePixelAbsoluteDifference).isAtMost(MAXIMUM_AVERAGE_PIXEL_ABSOLUTE_DIFFERENCE);
|
assertThat(averagePixelAbsoluteDifference).isAtMost(MAXIMUM_AVERAGE_PIXEL_ABSOLUTE_DIFFERENCE);
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -171,16 +169,14 @@ public final class GlEffectsFrameProcessorPixelTest {
|
|||||||
DEFAULT_PIXEL_WIDTH_HEIGHT_RATIO,
|
DEFAULT_PIXEL_WIDTH_HEIGHT_RATIO,
|
||||||
(MatrixTransformation) (long presentationTimeUs) -> translateRightMatrix,
|
(MatrixTransformation) (long presentationTimeUs) -> translateRightMatrix,
|
||||||
new ScaleToFitTransformation.Builder().setRotationDegrees(45).build());
|
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();
|
Bitmap actualBitmap = processFirstFrameAndEnd();
|
||||||
|
|
||||||
BitmapTestUtil.maybeSaveTestBitmapToCacheDirectory(
|
maybeSaveTestBitmapToCacheDirectory(testId, /* bitmapLabel= */ "actual", actualBitmap);
|
||||||
testId, /* bitmapLabel= */ "actual", actualBitmap);
|
|
||||||
// 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 =
|
||||||
BitmapTestUtil.getAveragePixelAbsoluteDifferenceArgb8888(
|
getBitmapAveragePixelAbsoluteDifferenceArgb8888(expectedBitmap, actualBitmap, testId);
|
||||||
expectedBitmap, actualBitmap, testId);
|
|
||||||
assertThat(averagePixelAbsoluteDifference).isAtMost(MAXIMUM_AVERAGE_PIXEL_ABSOLUTE_DIFFERENCE);
|
assertThat(averagePixelAbsoluteDifference).isAtMost(MAXIMUM_AVERAGE_PIXEL_ABSOLUTE_DIFFERENCE);
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -194,16 +190,14 @@ public final class GlEffectsFrameProcessorPixelTest {
|
|||||||
DEFAULT_PIXEL_WIDTH_HEIGHT_RATIO,
|
DEFAULT_PIXEL_WIDTH_HEIGHT_RATIO,
|
||||||
new ScaleToFitTransformation.Builder().setRotationDegrees(45).build(),
|
new ScaleToFitTransformation.Builder().setRotationDegrees(45).build(),
|
||||||
(MatrixTransformation) (long presentationTimeUs) -> translateRightMatrix);
|
(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();
|
Bitmap actualBitmap = processFirstFrameAndEnd();
|
||||||
|
|
||||||
BitmapTestUtil.maybeSaveTestBitmapToCacheDirectory(
|
maybeSaveTestBitmapToCacheDirectory(testId, /* bitmapLabel= */ "actual", actualBitmap);
|
||||||
testId, /* bitmapLabel= */ "actual", actualBitmap);
|
|
||||||
// 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 =
|
||||||
BitmapTestUtil.getAveragePixelAbsoluteDifferenceArgb8888(
|
getBitmapAveragePixelAbsoluteDifferenceArgb8888(expectedBitmap, actualBitmap, testId);
|
||||||
expectedBitmap, actualBitmap, testId);
|
|
||||||
assertThat(averagePixelAbsoluteDifference).isAtMost(MAXIMUM_AVERAGE_PIXEL_ABSOLUTE_DIFFERENCE);
|
assertThat(averagePixelAbsoluteDifference).isAtMost(MAXIMUM_AVERAGE_PIXEL_ABSOLUTE_DIFFERENCE);
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -212,16 +206,14 @@ public final class GlEffectsFrameProcessorPixelTest {
|
|||||||
throws Exception {
|
throws Exception {
|
||||||
String testId = "processData_withPresentation_createForHeight";
|
String testId = "processData_withPresentation_createForHeight";
|
||||||
setUpAndPrepareFirstFrame(DEFAULT_PIXEL_WIDTH_HEIGHT_RATIO, Presentation.createForHeight(480));
|
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();
|
Bitmap actualBitmap = processFirstFrameAndEnd();
|
||||||
|
|
||||||
BitmapTestUtil.maybeSaveTestBitmapToCacheDirectory(
|
maybeSaveTestBitmapToCacheDirectory(testId, /* bitmapLabel= */ "actual", actualBitmap);
|
||||||
testId, /* bitmapLabel= */ "actual", actualBitmap);
|
|
||||||
// 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 =
|
||||||
BitmapTestUtil.getAveragePixelAbsoluteDifferenceArgb8888(
|
getBitmapAveragePixelAbsoluteDifferenceArgb8888(expectedBitmap, actualBitmap, testId);
|
||||||
expectedBitmap, actualBitmap, testId);
|
|
||||||
assertThat(averagePixelAbsoluteDifference).isAtMost(MAXIMUM_AVERAGE_PIXEL_ABSOLUTE_DIFFERENCE);
|
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),
|
new Crop(/* left= */ -.5f, /* right= */ .5f, /* bottom= */ -.5f, /* top= */ .5f),
|
||||||
Presentation.createForAspectRatio(
|
Presentation.createForAspectRatio(
|
||||||
/* aspectRatio= */ .5f, Presentation.LAYOUT_SCALE_TO_FIT));
|
/* 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();
|
Bitmap actualBitmap = processFirstFrameAndEnd();
|
||||||
|
|
||||||
BitmapTestUtil.maybeSaveTestBitmapToCacheDirectory(
|
maybeSaveTestBitmapToCacheDirectory(testId, /* bitmapLabel= */ "actual", actualBitmap);
|
||||||
testId, /* bitmapLabel= */ "actual", actualBitmap);
|
|
||||||
// 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 =
|
||||||
BitmapTestUtil.getAveragePixelAbsoluteDifferenceArgb8888(
|
getBitmapAveragePixelAbsoluteDifferenceArgb8888(expectedBitmap, actualBitmap, testId);
|
||||||
expectedBitmap, actualBitmap, testId);
|
|
||||||
assertThat(averagePixelAbsoluteDifference).isAtMost(MAXIMUM_AVERAGE_PIXEL_ABSOLUTE_DIFFERENCE);
|
assertThat(averagePixelAbsoluteDifference).isAtMost(MAXIMUM_AVERAGE_PIXEL_ABSOLUTE_DIFFERENCE);
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -253,16 +243,14 @@ public final class GlEffectsFrameProcessorPixelTest {
|
|||||||
setUpAndPrepareFirstFrame(
|
setUpAndPrepareFirstFrame(
|
||||||
DEFAULT_PIXEL_WIDTH_HEIGHT_RATIO,
|
DEFAULT_PIXEL_WIDTH_HEIGHT_RATIO,
|
||||||
new ScaleToFitTransformation.Builder().setRotationDegrees(45).build());
|
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();
|
Bitmap actualBitmap = processFirstFrameAndEnd();
|
||||||
|
|
||||||
BitmapTestUtil.maybeSaveTestBitmapToCacheDirectory(
|
maybeSaveTestBitmapToCacheDirectory(testId, /* bitmapLabel= */ "actual", actualBitmap);
|
||||||
testId, /* bitmapLabel= */ "actual", actualBitmap);
|
|
||||||
// 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 =
|
||||||
BitmapTestUtil.getAveragePixelAbsoluteDifferenceArgb8888(
|
getBitmapAveragePixelAbsoluteDifferenceArgb8888(expectedBitmap, actualBitmap, testId);
|
||||||
expectedBitmap, actualBitmap, testId);
|
|
||||||
assertThat(averagePixelAbsoluteDifference).isAtMost(MAXIMUM_AVERAGE_PIXEL_ABSOLUTE_DIFFERENCE);
|
assertThat(averagePixelAbsoluteDifference).isAtMost(MAXIMUM_AVERAGE_PIXEL_ABSOLUTE_DIFFERENCE);
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -277,16 +265,14 @@ public final class GlEffectsFrameProcessorPixelTest {
|
|||||||
new ScaleToFitTransformation.Builder()
|
new ScaleToFitTransformation.Builder()
|
||||||
.setScale(/* scaleX= */ 2, /* scaleY= */ 1)
|
.setScale(/* scaleX= */ 2, /* scaleY= */ 1)
|
||||||
.build()));
|
.build()));
|
||||||
Bitmap expectedBitmap = BitmapTestUtil.readBitmap(ROTATE_THEN_SCALE_PNG_ASSET_PATH);
|
Bitmap expectedBitmap = readBitmap(ROTATE_THEN_SCALE_PNG_ASSET_PATH);
|
||||||
|
|
||||||
Bitmap actualBitmap = processFirstFrameAndEnd();
|
Bitmap actualBitmap = processFirstFrameAndEnd();
|
||||||
|
|
||||||
BitmapTestUtil.maybeSaveTestBitmapToCacheDirectory(
|
maybeSaveTestBitmapToCacheDirectory(testId, /* bitmapLabel= */ "actual", actualBitmap);
|
||||||
testId, /* bitmapLabel= */ "actual", actualBitmap);
|
|
||||||
// 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 =
|
||||||
BitmapTestUtil.getAveragePixelAbsoluteDifferenceArgb8888(
|
getBitmapAveragePixelAbsoluteDifferenceArgb8888(expectedBitmap, actualBitmap, testId);
|
||||||
expectedBitmap, actualBitmap, testId);
|
|
||||||
assertThat(averagePixelAbsoluteDifference).isAtMost(MAXIMUM_AVERAGE_PIXEL_ABSOLUTE_DIFFERENCE);
|
assertThat(averagePixelAbsoluteDifference).isAtMost(MAXIMUM_AVERAGE_PIXEL_ABSOLUTE_DIFFERENCE);
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -310,15 +296,15 @@ public final class GlEffectsFrameProcessorPixelTest {
|
|||||||
DEFAULT_PIXEL_WIDTH_HEIGHT_RATIO, full10StepRotationAndCenterCrop.build());
|
DEFAULT_PIXEL_WIDTH_HEIGHT_RATIO, full10StepRotationAndCenterCrop.build());
|
||||||
Bitmap fullRotationAndCenterCropResultBitmap = processFirstFrameAndEnd();
|
Bitmap fullRotationAndCenterCropResultBitmap = processFirstFrameAndEnd();
|
||||||
|
|
||||||
BitmapTestUtil.maybeSaveTestBitmapToCacheDirectory(
|
maybeSaveTestBitmapToCacheDirectory(
|
||||||
testId, /* bitmapLabel= */ "centerCrop", centerCropResultBitmap);
|
testId, /* bitmapLabel= */ "centerCrop", centerCropResultBitmap);
|
||||||
BitmapTestUtil.maybeSaveTestBitmapToCacheDirectory(
|
maybeSaveTestBitmapToCacheDirectory(
|
||||||
testId,
|
testId,
|
||||||
/* bitmapLabel= */ "full10StepRotationAndCenterCrop",
|
/* bitmapLabel= */ "full10StepRotationAndCenterCrop",
|
||||||
fullRotationAndCenterCropResultBitmap);
|
fullRotationAndCenterCropResultBitmap);
|
||||||
// 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 =
|
||||||
BitmapTestUtil.getAveragePixelAbsoluteDifferenceArgb8888(
|
getBitmapAveragePixelAbsoluteDifferenceArgb8888(
|
||||||
centerCropResultBitmap, fullRotationAndCenterCropResultBitmap, testId);
|
centerCropResultBitmap, fullRotationAndCenterCropResultBitmap, testId);
|
||||||
assertThat(averagePixelAbsoluteDifference).isAtMost(MAXIMUM_AVERAGE_PIXEL_ABSOLUTE_DIFFERENCE);
|
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().setGreenScale(5).build(),
|
||||||
new RgbAdjustment.Builder().setBlueScale(5).build());
|
new RgbAdjustment.Builder().setBlueScale(5).build());
|
||||||
setUpAndPrepareFirstFrame(DEFAULT_PIXEL_WIDTH_HEIGHT_RATIO, increaseBrightness);
|
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();
|
Bitmap actualBitmap = processFirstFrameAndEnd();
|
||||||
|
|
||||||
BitmapTestUtil.maybeSaveTestBitmapToCacheDirectory(
|
maybeSaveTestBitmapToCacheDirectory(testId, /* bitmapLabel= */ "actual", actualBitmap);
|
||||||
testId, /* bitmapLabel= */ "actual", actualBitmap);
|
|
||||||
// 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 =
|
||||||
BitmapTestUtil.getAveragePixelAbsoluteDifferenceArgb8888(
|
getBitmapAveragePixelAbsoluteDifferenceArgb8888(expectedBitmap, actualBitmap, testId);
|
||||||
expectedBitmap, actualBitmap, testId);
|
|
||||||
assertThat(averagePixelAbsoluteDifference).isAtMost(MAXIMUM_AVERAGE_PIXEL_ABSOLUTE_DIFFERENCE);
|
assertThat(averagePixelAbsoluteDifference).isAtMost(MAXIMUM_AVERAGE_PIXEL_ABSOLUTE_DIFFERENCE);
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -372,15 +356,15 @@ public final class GlEffectsFrameProcessorPixelTest {
|
|||||||
|
|
||||||
Bitmap fullRotationBrightnessIncreaseAndCenterCropResultBitmap = processFirstFrameAndEnd();
|
Bitmap fullRotationBrightnessIncreaseAndCenterCropResultBitmap = processFirstFrameAndEnd();
|
||||||
|
|
||||||
BitmapTestUtil.maybeSaveTestBitmapToCacheDirectory(
|
maybeSaveTestBitmapToCacheDirectory(
|
||||||
testId, /* bitmapLabel= */ "centerCrop", centerCropAndBrightnessIncreaseResultBitmap);
|
testId, /* bitmapLabel= */ "centerCrop", centerCropAndBrightnessIncreaseResultBitmap);
|
||||||
BitmapTestUtil.maybeSaveTestBitmapToCacheDirectory(
|
maybeSaveTestBitmapToCacheDirectory(
|
||||||
testId,
|
testId,
|
||||||
/* bitmapLabel= */ "full4StepRotationBrightnessIncreaseAndCenterCrop",
|
/* bitmapLabel= */ "full4StepRotationBrightnessIncreaseAndCenterCrop",
|
||||||
fullRotationBrightnessIncreaseAndCenterCropResultBitmap);
|
fullRotationBrightnessIncreaseAndCenterCropResultBitmap);
|
||||||
// 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 =
|
||||||
BitmapTestUtil.getAveragePixelAbsoluteDifferenceArgb8888(
|
getBitmapAveragePixelAbsoluteDifferenceArgb8888(
|
||||||
centerCropAndBrightnessIncreaseResultBitmap,
|
centerCropAndBrightnessIncreaseResultBitmap,
|
||||||
fullRotationBrightnessIncreaseAndCenterCropResultBitmap,
|
fullRotationBrightnessIncreaseAndCenterCropResultBitmap,
|
||||||
testId);
|
testId);
|
||||||
@ -395,17 +379,14 @@ public final class GlEffectsFrameProcessorPixelTest {
|
|||||||
ImmutableList.of(
|
ImmutableList.of(
|
||||||
RgbFilter.createGrayscaleFilter(), new RgbAdjustment.Builder().setRedScale(3).build());
|
RgbFilter.createGrayscaleFilter(), new RgbAdjustment.Builder().setRedScale(3).build());
|
||||||
setUpAndPrepareFirstFrame(DEFAULT_PIXEL_WIDTH_HEIGHT_RATIO, grayscaleThenIncreaseRed);
|
setUpAndPrepareFirstFrame(DEFAULT_PIXEL_WIDTH_HEIGHT_RATIO, grayscaleThenIncreaseRed);
|
||||||
Bitmap expectedBitmap =
|
Bitmap expectedBitmap = readBitmap(GRAYSCALE_THEN_INCREASE_RED_CHANNEL_PNG_ASSET_PATH);
|
||||||
BitmapTestUtil.readBitmap(GRAYSCALE_THEN_INCREASE_RED_CHANNEL_PNG_ASSET_PATH);
|
|
||||||
|
|
||||||
Bitmap actualBitmap = processFirstFrameAndEnd();
|
Bitmap actualBitmap = processFirstFrameAndEnd();
|
||||||
|
|
||||||
BitmapTestUtil.maybeSaveTestBitmapToCacheDirectory(
|
maybeSaveTestBitmapToCacheDirectory(testId, /* bitmapLabel= */ "actual", actualBitmap);
|
||||||
testId, /* bitmapLabel= */ "actual", actualBitmap);
|
|
||||||
// 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 =
|
||||||
BitmapTestUtil.getAveragePixelAbsoluteDifferenceArgb8888(
|
getBitmapAveragePixelAbsoluteDifferenceArgb8888(expectedBitmap, actualBitmap, testId);
|
||||||
expectedBitmap, actualBitmap, testId);
|
|
||||||
assertThat(averagePixelAbsoluteDifference).isAtMost(MAXIMUM_AVERAGE_PIXEL_ABSOLUTE_DIFFERENCE);
|
assertThat(averagePixelAbsoluteDifference).isAtMost(MAXIMUM_AVERAGE_PIXEL_ABSOLUTE_DIFFERENCE);
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -493,8 +474,7 @@ public final class GlEffectsFrameProcessorPixelTest {
|
|||||||
assertThat(frameProcessingException.get()).isNull();
|
assertThat(frameProcessingException.get()).isNull();
|
||||||
|
|
||||||
Image frameProcessorOutputImage = checkNotNull(outputImageReader).acquireLatestImage();
|
Image frameProcessorOutputImage = checkNotNull(outputImageReader).acquireLatestImage();
|
||||||
Bitmap actualBitmap =
|
Bitmap actualBitmap = createArgb8888BitmapFromRgba8888Image(frameProcessorOutputImage);
|
||||||
BitmapTestUtil.createArgb8888BitmapFromRgba8888Image(frameProcessorOutputImage);
|
|
||||||
frameProcessorOutputImage.close();
|
frameProcessorOutputImage.close();
|
||||||
return actualBitmap;
|
return actualBitmap;
|
||||||
}
|
}
|
||||||
|
@ -17,6 +17,12 @@
|
|||||||
package androidx.media3.effect;
|
package androidx.media3.effect;
|
||||||
|
|
||||||
import static androidx.media3.effect.BitmapTestUtil.MAXIMUM_AVERAGE_PIXEL_ABSOLUTE_DIFFERENCE;
|
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 androidx.test.core.app.ApplicationProvider.getApplicationContext;
|
||||||
import static com.google.common.truth.Truth.assertThat;
|
import static com.google.common.truth.Truth.assertThat;
|
||||||
|
|
||||||
@ -79,12 +85,12 @@ public final class HslAdjustmentPixelTest {
|
|||||||
public void createGlObjects() throws IOException, GlUtil.GlException {
|
public void createGlObjects() throws IOException, GlUtil.GlException {
|
||||||
eglDisplay = GlUtil.createEglDisplay();
|
eglDisplay = GlUtil.createEglDisplay();
|
||||||
eglContext = GlUtil.createEglContext(eglDisplay);
|
eglContext = GlUtil.createEglContext(eglDisplay);
|
||||||
Bitmap inputBitmap = BitmapTestUtil.readBitmap(ORIGINAL_PNG_ASSET_PATH);
|
Bitmap inputBitmap = readBitmap(ORIGINAL_PNG_ASSET_PATH);
|
||||||
inputWidth = inputBitmap.getWidth();
|
inputWidth = inputBitmap.getWidth();
|
||||||
inputHeight = inputBitmap.getHeight();
|
inputHeight = inputBitmap.getHeight();
|
||||||
placeholderEglSurface = GlUtil.createPlaceholderEglSurface(eglDisplay);
|
placeholderEglSurface = GlUtil.createPlaceholderEglSurface(eglDisplay);
|
||||||
GlUtil.focusEglSurface(eglDisplay, eglContext, placeholderEglSurface, inputWidth, inputHeight);
|
GlUtil.focusEglSurface(eglDisplay, eglContext, placeholderEglSurface, inputWidth, inputHeight);
|
||||||
inputTexId = BitmapTestUtil.createGlTextureFromBitmap(inputBitmap);
|
inputTexId = createGlTextureFromBitmap(inputBitmap);
|
||||||
|
|
||||||
outputTexId =
|
outputTexId =
|
||||||
GlUtil.createTexture(inputWidth, inputHeight, /* useHighPrecisionColorComponents= */ false);
|
GlUtil.createTexture(inputWidth, inputHeight, /* useHighPrecisionColorComponents= */ false);
|
||||||
@ -107,18 +113,15 @@ public final class HslAdjustmentPixelTest {
|
|||||||
HslAdjustment noOpAdjustment = new HslAdjustment.Builder().build();
|
HslAdjustment noOpAdjustment = new HslAdjustment.Builder().build();
|
||||||
hslProcessor = noOpAdjustment.toGlTextureProcessor(context, /* useHdr= */ false);
|
hslProcessor = noOpAdjustment.toGlTextureProcessor(context, /* useHdr= */ false);
|
||||||
Pair<Integer, Integer> outputSize = hslProcessor.configure(inputWidth, inputHeight);
|
Pair<Integer, Integer> 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);
|
hslProcessor.drawFrame(inputTexId, /* presentationTimeUs= */ 0);
|
||||||
Bitmap actualBitmap =
|
Bitmap actualBitmap =
|
||||||
BitmapTestUtil.createArgb8888BitmapFromCurrentGlFramebuffer(
|
createArgb8888BitmapFromCurrentGlFramebuffer(outputSize.first, outputSize.second);
|
||||||
outputSize.first, outputSize.second);
|
|
||||||
|
|
||||||
BitmapTestUtil.maybeSaveTestBitmapToCacheDirectory(
|
maybeSaveTestBitmapToCacheDirectory(testId, /* bitmapLabel= */ "actual", actualBitmap);
|
||||||
testId, /* bitmapLabel= */ "actual", actualBitmap);
|
|
||||||
float averagePixelAbsoluteDifference =
|
float averagePixelAbsoluteDifference =
|
||||||
BitmapTestUtil.getAveragePixelAbsoluteDifferenceArgb8888(
|
getBitmapAveragePixelAbsoluteDifferenceArgb8888(expectedBitmap, actualBitmap, testId);
|
||||||
expectedBitmap, actualBitmap, testId);
|
|
||||||
assertThat(averagePixelAbsoluteDifference).isAtMost(MAXIMUM_AVERAGE_PIXEL_ABSOLUTE_DIFFERENCE);
|
assertThat(averagePixelAbsoluteDifference).isAtMost(MAXIMUM_AVERAGE_PIXEL_ABSOLUTE_DIFFERENCE);
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -128,18 +131,15 @@ public final class HslAdjustmentPixelTest {
|
|||||||
HslAdjustment minimumSaturation = new HslAdjustment.Builder().adjustSaturation(-100).build();
|
HslAdjustment minimumSaturation = new HslAdjustment.Builder().adjustSaturation(-100).build();
|
||||||
hslProcessor = minimumSaturation.toGlTextureProcessor(context, /* useHdr= */ false);
|
hslProcessor = minimumSaturation.toGlTextureProcessor(context, /* useHdr= */ false);
|
||||||
Pair<Integer, Integer> outputSize = hslProcessor.configure(inputWidth, inputHeight);
|
Pair<Integer, Integer> 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);
|
hslProcessor.drawFrame(inputTexId, /* presentationTimeUs= */ 0);
|
||||||
Bitmap actualBitmap =
|
Bitmap actualBitmap =
|
||||||
BitmapTestUtil.createArgb8888BitmapFromCurrentGlFramebuffer(
|
createArgb8888BitmapFromCurrentGlFramebuffer(outputSize.first, outputSize.second);
|
||||||
outputSize.first, outputSize.second);
|
|
||||||
|
|
||||||
BitmapTestUtil.maybeSaveTestBitmapToCacheDirectory(
|
maybeSaveTestBitmapToCacheDirectory(testId, /* bitmapLabel= */ "actual", actualBitmap);
|
||||||
testId, /* bitmapLabel= */ "actual", actualBitmap);
|
|
||||||
float averagePixelAbsoluteDifference =
|
float averagePixelAbsoluteDifference =
|
||||||
BitmapTestUtil.getAveragePixelAbsoluteDifferenceArgb8888(
|
getBitmapAveragePixelAbsoluteDifferenceArgb8888(expectedBitmap, actualBitmap, testId);
|
||||||
expectedBitmap, actualBitmap, testId);
|
|
||||||
assertThat(averagePixelAbsoluteDifference).isAtMost(MAXIMUM_AVERAGE_PIXEL_ABSOLUTE_DIFFERENCE);
|
assertThat(averagePixelAbsoluteDifference).isAtMost(MAXIMUM_AVERAGE_PIXEL_ABSOLUTE_DIFFERENCE);
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -149,18 +149,15 @@ public final class HslAdjustmentPixelTest {
|
|||||||
HslAdjustment maximumSaturation = new HslAdjustment.Builder().adjustSaturation(100).build();
|
HslAdjustment maximumSaturation = new HslAdjustment.Builder().adjustSaturation(100).build();
|
||||||
hslProcessor = maximumSaturation.toGlTextureProcessor(context, /* useHdr= */ false);
|
hslProcessor = maximumSaturation.toGlTextureProcessor(context, /* useHdr= */ false);
|
||||||
Pair<Integer, Integer> outputSize = hslProcessor.configure(inputWidth, inputHeight);
|
Pair<Integer, Integer> 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);
|
hslProcessor.drawFrame(inputTexId, /* presentationTimeUs= */ 0);
|
||||||
Bitmap actualBitmap =
|
Bitmap actualBitmap =
|
||||||
BitmapTestUtil.createArgb8888BitmapFromCurrentGlFramebuffer(
|
createArgb8888BitmapFromCurrentGlFramebuffer(outputSize.first, outputSize.second);
|
||||||
outputSize.first, outputSize.second);
|
|
||||||
|
|
||||||
BitmapTestUtil.maybeSaveTestBitmapToCacheDirectory(
|
maybeSaveTestBitmapToCacheDirectory(testId, /* bitmapLabel= */ "actual", actualBitmap);
|
||||||
testId, /* bitmapLabel= */ "actual", actualBitmap);
|
|
||||||
float averagePixelAbsoluteDifference =
|
float averagePixelAbsoluteDifference =
|
||||||
BitmapTestUtil.getAveragePixelAbsoluteDifferenceArgb8888(
|
getBitmapAveragePixelAbsoluteDifferenceArgb8888(expectedBitmap, actualBitmap, testId);
|
||||||
expectedBitmap, actualBitmap, testId);
|
|
||||||
assertThat(averagePixelAbsoluteDifference).isAtMost(MAXIMUM_AVERAGE_PIXEL_ABSOLUTE_DIFFERENCE);
|
assertThat(averagePixelAbsoluteDifference).isAtMost(MAXIMUM_AVERAGE_PIXEL_ABSOLUTE_DIFFERENCE);
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -170,19 +167,15 @@ public final class HslAdjustmentPixelTest {
|
|||||||
HslAdjustment negativeHueRotation90Degrees = new HslAdjustment.Builder().adjustHue(-90).build();
|
HslAdjustment negativeHueRotation90Degrees = new HslAdjustment.Builder().adjustHue(-90).build();
|
||||||
hslProcessor = negativeHueRotation90Degrees.toGlTextureProcessor(context, /* useHdr= */ false);
|
hslProcessor = negativeHueRotation90Degrees.toGlTextureProcessor(context, /* useHdr= */ false);
|
||||||
Pair<Integer, Integer> outputSize = hslProcessor.configure(inputWidth, inputHeight);
|
Pair<Integer, Integer> outputSize = hslProcessor.configure(inputWidth, inputHeight);
|
||||||
Bitmap expectedBitmap =
|
Bitmap expectedBitmap = readBitmap(ROTATE_HUE_BY_NEGATIVE_90_DEGREES_PNG_ASSET_PATH);
|
||||||
BitmapTestUtil.readBitmap(ROTATE_HUE_BY_NEGATIVE_90_DEGREES_PNG_ASSET_PATH);
|
|
||||||
|
|
||||||
hslProcessor.drawFrame(inputTexId, /* presentationTimeUs= */ 0);
|
hslProcessor.drawFrame(inputTexId, /* presentationTimeUs= */ 0);
|
||||||
Bitmap actualBitmap =
|
Bitmap actualBitmap =
|
||||||
BitmapTestUtil.createArgb8888BitmapFromCurrentGlFramebuffer(
|
createArgb8888BitmapFromCurrentGlFramebuffer(outputSize.first, outputSize.second);
|
||||||
outputSize.first, outputSize.second);
|
|
||||||
|
|
||||||
BitmapTestUtil.maybeSaveTestBitmapToCacheDirectory(
|
maybeSaveTestBitmapToCacheDirectory(testId, /* bitmapLabel= */ "actual", actualBitmap);
|
||||||
testId, /* bitmapLabel= */ "actual", actualBitmap);
|
|
||||||
float averagePixelAbsoluteDifference =
|
float averagePixelAbsoluteDifference =
|
||||||
BitmapTestUtil.getAveragePixelAbsoluteDifferenceArgb8888(
|
getBitmapAveragePixelAbsoluteDifferenceArgb8888(expectedBitmap, actualBitmap, testId);
|
||||||
expectedBitmap, actualBitmap, testId);
|
|
||||||
assertThat(averagePixelAbsoluteDifference).isAtMost(MAXIMUM_AVERAGE_PIXEL_ABSOLUTE_DIFFERENCE);
|
assertThat(averagePixelAbsoluteDifference).isAtMost(MAXIMUM_AVERAGE_PIXEL_ABSOLUTE_DIFFERENCE);
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -192,18 +185,15 @@ public final class HslAdjustmentPixelTest {
|
|||||||
HslAdjustment hueRotation60Degrees = new HslAdjustment.Builder().adjustHue(60).build();
|
HslAdjustment hueRotation60Degrees = new HslAdjustment.Builder().adjustHue(60).build();
|
||||||
hslProcessor = hueRotation60Degrees.toGlTextureProcessor(context, /* useHdr= */ false);
|
hslProcessor = hueRotation60Degrees.toGlTextureProcessor(context, /* useHdr= */ false);
|
||||||
Pair<Integer, Integer> outputSize = hslProcessor.configure(inputWidth, inputHeight);
|
Pair<Integer, Integer> 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);
|
hslProcessor.drawFrame(inputTexId, /* presentationTimeUs= */ 0);
|
||||||
Bitmap actualBitmap =
|
Bitmap actualBitmap =
|
||||||
BitmapTestUtil.createArgb8888BitmapFromCurrentGlFramebuffer(
|
createArgb8888BitmapFromCurrentGlFramebuffer(outputSize.first, outputSize.second);
|
||||||
outputSize.first, outputSize.second);
|
|
||||||
|
|
||||||
BitmapTestUtil.maybeSaveTestBitmapToCacheDirectory(
|
maybeSaveTestBitmapToCacheDirectory(testId, /* bitmapLabel= */ "actual", actualBitmap);
|
||||||
testId, /* bitmapLabel= */ "actual", actualBitmap);
|
|
||||||
float averagePixelAbsoluteDifference =
|
float averagePixelAbsoluteDifference =
|
||||||
BitmapTestUtil.getAveragePixelAbsoluteDifferenceArgb8888(
|
getBitmapAveragePixelAbsoluteDifferenceArgb8888(expectedBitmap, actualBitmap, testId);
|
||||||
expectedBitmap, actualBitmap, testId);
|
|
||||||
assertThat(averagePixelAbsoluteDifference).isAtMost(MAXIMUM_AVERAGE_PIXEL_ABSOLUTE_DIFFERENCE);
|
assertThat(averagePixelAbsoluteDifference).isAtMost(MAXIMUM_AVERAGE_PIXEL_ABSOLUTE_DIFFERENCE);
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -214,18 +204,15 @@ public final class HslAdjustmentPixelTest {
|
|||||||
HslAdjustment hueRotation420Degrees = new HslAdjustment.Builder().adjustHue(-300).build();
|
HslAdjustment hueRotation420Degrees = new HslAdjustment.Builder().adjustHue(-300).build();
|
||||||
hslProcessor = hueRotation420Degrees.toGlTextureProcessor(context, /* useHdr= */ false);
|
hslProcessor = hueRotation420Degrees.toGlTextureProcessor(context, /* useHdr= */ false);
|
||||||
Pair<Integer, Integer> outputSize = hslProcessor.configure(inputWidth, inputHeight);
|
Pair<Integer, Integer> 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);
|
hslProcessor.drawFrame(inputTexId, /* presentationTimeUs= */ 0);
|
||||||
Bitmap actualBitmap =
|
Bitmap actualBitmap =
|
||||||
BitmapTestUtil.createArgb8888BitmapFromCurrentGlFramebuffer(
|
createArgb8888BitmapFromCurrentGlFramebuffer(outputSize.first, outputSize.second);
|
||||||
outputSize.first, outputSize.second);
|
|
||||||
|
|
||||||
BitmapTestUtil.maybeSaveTestBitmapToCacheDirectory(
|
maybeSaveTestBitmapToCacheDirectory(testId, /* bitmapLabel= */ "actual", actualBitmap);
|
||||||
testId, /* bitmapLabel= */ "actual", actualBitmap);
|
|
||||||
float averagePixelAbsoluteDifference =
|
float averagePixelAbsoluteDifference =
|
||||||
BitmapTestUtil.getAveragePixelAbsoluteDifferenceArgb8888(
|
getBitmapAveragePixelAbsoluteDifferenceArgb8888(expectedBitmap, actualBitmap, testId);
|
||||||
expectedBitmap, actualBitmap, testId);
|
|
||||||
assertThat(averagePixelAbsoluteDifference).isAtMost(MAXIMUM_AVERAGE_PIXEL_ABSOLUTE_DIFFERENCE);
|
assertThat(averagePixelAbsoluteDifference).isAtMost(MAXIMUM_AVERAGE_PIXEL_ABSOLUTE_DIFFERENCE);
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -235,18 +222,15 @@ public final class HslAdjustmentPixelTest {
|
|||||||
HslAdjustment hueRotation360Degrees = new HslAdjustment.Builder().adjustHue(360).build();
|
HslAdjustment hueRotation360Degrees = new HslAdjustment.Builder().adjustHue(360).build();
|
||||||
hslProcessor = hueRotation360Degrees.toGlTextureProcessor(context, /* useHdr= */ false);
|
hslProcessor = hueRotation360Degrees.toGlTextureProcessor(context, /* useHdr= */ false);
|
||||||
Pair<Integer, Integer> outputSize = hslProcessor.configure(inputWidth, inputHeight);
|
Pair<Integer, Integer> 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);
|
hslProcessor.drawFrame(inputTexId, /* presentationTimeUs= */ 0);
|
||||||
Bitmap actualBitmap =
|
Bitmap actualBitmap =
|
||||||
BitmapTestUtil.createArgb8888BitmapFromCurrentGlFramebuffer(
|
createArgb8888BitmapFromCurrentGlFramebuffer(outputSize.first, outputSize.second);
|
||||||
outputSize.first, outputSize.second);
|
|
||||||
|
|
||||||
BitmapTestUtil.maybeSaveTestBitmapToCacheDirectory(
|
maybeSaveTestBitmapToCacheDirectory(testId, /* bitmapLabel= */ "actual", actualBitmap);
|
||||||
testId, /* bitmapLabel= */ "actual", actualBitmap);
|
|
||||||
float averagePixelAbsoluteDifference =
|
float averagePixelAbsoluteDifference =
|
||||||
BitmapTestUtil.getAveragePixelAbsoluteDifferenceArgb8888(
|
getBitmapAveragePixelAbsoluteDifferenceArgb8888(expectedBitmap, actualBitmap, testId);
|
||||||
expectedBitmap, actualBitmap, testId);
|
|
||||||
assertThat(averagePixelAbsoluteDifference).isAtMost(MAXIMUM_AVERAGE_PIXEL_ABSOLUTE_DIFFERENCE);
|
assertThat(averagePixelAbsoluteDifference).isAtMost(MAXIMUM_AVERAGE_PIXEL_ABSOLUTE_DIFFERENCE);
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -257,18 +241,15 @@ public final class HslAdjustmentPixelTest {
|
|||||||
hslProcessor = minimumLightness.toGlTextureProcessor(context, /* useHdr= */ false);
|
hslProcessor = minimumLightness.toGlTextureProcessor(context, /* useHdr= */ false);
|
||||||
Pair<Integer, Integer> outputSize = hslProcessor.configure(inputWidth, inputHeight);
|
Pair<Integer, Integer> outputSize = hslProcessor.configure(inputWidth, inputHeight);
|
||||||
Bitmap expectedBitmap =
|
Bitmap expectedBitmap =
|
||||||
BitmapTestUtil.createArgb8888BitmapWithSolidColor(inputWidth, inputHeight, Color.BLACK);
|
createArgb8888BitmapWithSolidColor(inputWidth, inputHeight, Color.BLACK);
|
||||||
|
|
||||||
hslProcessor.drawFrame(inputTexId, /* presentationTimeUs= */ 0);
|
hslProcessor.drawFrame(inputTexId, /* presentationTimeUs= */ 0);
|
||||||
Bitmap actualBitmap =
|
Bitmap actualBitmap =
|
||||||
BitmapTestUtil.createArgb8888BitmapFromCurrentGlFramebuffer(
|
createArgb8888BitmapFromCurrentGlFramebuffer(outputSize.first, outputSize.second);
|
||||||
outputSize.first, outputSize.second);
|
|
||||||
|
|
||||||
BitmapTestUtil.maybeSaveTestBitmapToCacheDirectory(
|
maybeSaveTestBitmapToCacheDirectory(testId, /* bitmapLabel= */ "actual", actualBitmap);
|
||||||
testId, /* bitmapLabel= */ "actual", actualBitmap);
|
|
||||||
float averagePixelAbsoluteDifference =
|
float averagePixelAbsoluteDifference =
|
||||||
BitmapTestUtil.getAveragePixelAbsoluteDifferenceArgb8888(
|
getBitmapAveragePixelAbsoluteDifferenceArgb8888(expectedBitmap, actualBitmap, testId);
|
||||||
expectedBitmap, actualBitmap, testId);
|
|
||||||
assertThat(averagePixelAbsoluteDifference).isAtMost(MAXIMUM_AVERAGE_PIXEL_ABSOLUTE_DIFFERENCE);
|
assertThat(averagePixelAbsoluteDifference).isAtMost(MAXIMUM_AVERAGE_PIXEL_ABSOLUTE_DIFFERENCE);
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -278,18 +259,15 @@ public final class HslAdjustmentPixelTest {
|
|||||||
HslAdjustment decreasedLightness = new HslAdjustment.Builder().adjustLightness(-50).build();
|
HslAdjustment decreasedLightness = new HslAdjustment.Builder().adjustLightness(-50).build();
|
||||||
hslProcessor = decreasedLightness.toGlTextureProcessor(context, /* useHdr= */ false);
|
hslProcessor = decreasedLightness.toGlTextureProcessor(context, /* useHdr= */ false);
|
||||||
Pair<Integer, Integer> outputSize = hslProcessor.configure(inputWidth, inputHeight);
|
Pair<Integer, Integer> 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);
|
hslProcessor.drawFrame(inputTexId, /* presentationTimeUs= */ 0);
|
||||||
Bitmap actualBitmap =
|
Bitmap actualBitmap =
|
||||||
BitmapTestUtil.createArgb8888BitmapFromCurrentGlFramebuffer(
|
createArgb8888BitmapFromCurrentGlFramebuffer(outputSize.first, outputSize.second);
|
||||||
outputSize.first, outputSize.second);
|
|
||||||
|
|
||||||
BitmapTestUtil.maybeSaveTestBitmapToCacheDirectory(
|
maybeSaveTestBitmapToCacheDirectory(testId, /* bitmapLabel= */ "actual", actualBitmap);
|
||||||
testId, /* bitmapLabel= */ "actual", actualBitmap);
|
|
||||||
float averagePixelAbsoluteDifference =
|
float averagePixelAbsoluteDifference =
|
||||||
BitmapTestUtil.getAveragePixelAbsoluteDifferenceArgb8888(
|
getBitmapAveragePixelAbsoluteDifferenceArgb8888(expectedBitmap, actualBitmap, testId);
|
||||||
expectedBitmap, actualBitmap, testId);
|
|
||||||
assertThat(averagePixelAbsoluteDifference).isAtMost(MAXIMUM_AVERAGE_PIXEL_ABSOLUTE_DIFFERENCE);
|
assertThat(averagePixelAbsoluteDifference).isAtMost(MAXIMUM_AVERAGE_PIXEL_ABSOLUTE_DIFFERENCE);
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -299,18 +277,15 @@ public final class HslAdjustmentPixelTest {
|
|||||||
HslAdjustment increasedLightness = new HslAdjustment.Builder().adjustLightness(50).build();
|
HslAdjustment increasedLightness = new HslAdjustment.Builder().adjustLightness(50).build();
|
||||||
hslProcessor = increasedLightness.toGlTextureProcessor(context, /* useHdr= */ false);
|
hslProcessor = increasedLightness.toGlTextureProcessor(context, /* useHdr= */ false);
|
||||||
Pair<Integer, Integer> outputSize = hslProcessor.configure(inputWidth, inputHeight);
|
Pair<Integer, Integer> 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);
|
hslProcessor.drawFrame(inputTexId, /* presentationTimeUs= */ 0);
|
||||||
Bitmap actualBitmap =
|
Bitmap actualBitmap =
|
||||||
BitmapTestUtil.createArgb8888BitmapFromCurrentGlFramebuffer(
|
createArgb8888BitmapFromCurrentGlFramebuffer(outputSize.first, outputSize.second);
|
||||||
outputSize.first, outputSize.second);
|
|
||||||
|
|
||||||
BitmapTestUtil.maybeSaveTestBitmapToCacheDirectory(
|
maybeSaveTestBitmapToCacheDirectory(testId, /* bitmapLabel= */ "actual", actualBitmap);
|
||||||
testId, /* bitmapLabel= */ "actual", actualBitmap);
|
|
||||||
float averagePixelAbsoluteDifference =
|
float averagePixelAbsoluteDifference =
|
||||||
BitmapTestUtil.getAveragePixelAbsoluteDifferenceArgb8888(
|
getBitmapAveragePixelAbsoluteDifferenceArgb8888(expectedBitmap, actualBitmap, testId);
|
||||||
expectedBitmap, actualBitmap, testId);
|
|
||||||
assertThat(averagePixelAbsoluteDifference).isAtMost(MAXIMUM_AVERAGE_PIXEL_ABSOLUTE_DIFFERENCE);
|
assertThat(averagePixelAbsoluteDifference).isAtMost(MAXIMUM_AVERAGE_PIXEL_ABSOLUTE_DIFFERENCE);
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -321,18 +296,15 @@ public final class HslAdjustmentPixelTest {
|
|||||||
hslProcessor = maximumLightness.toGlTextureProcessor(context, /* useHdr= */ false);
|
hslProcessor = maximumLightness.toGlTextureProcessor(context, /* useHdr= */ false);
|
||||||
Pair<Integer, Integer> outputSize = hslProcessor.configure(inputWidth, inputHeight);
|
Pair<Integer, Integer> outputSize = hslProcessor.configure(inputWidth, inputHeight);
|
||||||
Bitmap expectedBitmap =
|
Bitmap expectedBitmap =
|
||||||
BitmapTestUtil.createArgb8888BitmapWithSolidColor(inputWidth, inputHeight, Color.WHITE);
|
createArgb8888BitmapWithSolidColor(inputWidth, inputHeight, Color.WHITE);
|
||||||
|
|
||||||
hslProcessor.drawFrame(inputTexId, /* presentationTimeUs= */ 0);
|
hslProcessor.drawFrame(inputTexId, /* presentationTimeUs= */ 0);
|
||||||
Bitmap actualBitmap =
|
Bitmap actualBitmap =
|
||||||
BitmapTestUtil.createArgb8888BitmapFromCurrentGlFramebuffer(
|
createArgb8888BitmapFromCurrentGlFramebuffer(outputSize.first, outputSize.second);
|
||||||
outputSize.first, outputSize.second);
|
|
||||||
|
|
||||||
BitmapTestUtil.maybeSaveTestBitmapToCacheDirectory(
|
maybeSaveTestBitmapToCacheDirectory(testId, /* bitmapLabel= */ "actual", actualBitmap);
|
||||||
testId, /* bitmapLabel= */ "actual", actualBitmap);
|
|
||||||
float averagePixelAbsoluteDifference =
|
float averagePixelAbsoluteDifference =
|
||||||
BitmapTestUtil.getAveragePixelAbsoluteDifferenceArgb8888(
|
getBitmapAveragePixelAbsoluteDifferenceArgb8888(expectedBitmap, actualBitmap, testId);
|
||||||
expectedBitmap, actualBitmap, testId);
|
|
||||||
assertThat(averagePixelAbsoluteDifference).isAtMost(MAXIMUM_AVERAGE_PIXEL_ABSOLUTE_DIFFERENCE);
|
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();
|
new HslAdjustment.Builder().adjustHue(60).adjustSaturation(30).adjustLightness(50).build();
|
||||||
hslProcessor = allHslSettingsAdjusted.toGlTextureProcessor(context, /* useHdr= */ false);
|
hslProcessor = allHslSettingsAdjusted.toGlTextureProcessor(context, /* useHdr= */ false);
|
||||||
Pair<Integer, Integer> outputSize = hslProcessor.configure(inputWidth, inputHeight);
|
Pair<Integer, Integer> 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);
|
hslProcessor.drawFrame(inputTexId, /* presentationTimeUs= */ 0);
|
||||||
Bitmap actualBitmap =
|
Bitmap actualBitmap =
|
||||||
BitmapTestUtil.createArgb8888BitmapFromCurrentGlFramebuffer(
|
createArgb8888BitmapFromCurrentGlFramebuffer(outputSize.first, outputSize.second);
|
||||||
outputSize.first, outputSize.second);
|
|
||||||
|
|
||||||
BitmapTestUtil.maybeSaveTestBitmapToCacheDirectory(
|
maybeSaveTestBitmapToCacheDirectory(testId, /* bitmapLabel= */ "actual", actualBitmap);
|
||||||
testId, /* bitmapLabel= */ "actual", actualBitmap);
|
|
||||||
float averagePixelAbsoluteDifference =
|
float averagePixelAbsoluteDifference =
|
||||||
BitmapTestUtil.getAveragePixelAbsoluteDifferenceArgb8888(
|
getBitmapAveragePixelAbsoluteDifferenceArgb8888(expectedBitmap, actualBitmap, testId);
|
||||||
expectedBitmap, actualBitmap, testId);
|
|
||||||
assertThat(averagePixelAbsoluteDifference).isAtMost(MAXIMUM_AVERAGE_PIXEL_ABSOLUTE_DIFFERENCE);
|
assertThat(averagePixelAbsoluteDifference).isAtMost(MAXIMUM_AVERAGE_PIXEL_ABSOLUTE_DIFFERENCE);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -16,6 +16,11 @@
|
|||||||
package androidx.media3.effect;
|
package androidx.media3.effect;
|
||||||
|
|
||||||
import static androidx.media3.effect.BitmapTestUtil.MAXIMUM_AVERAGE_PIXEL_ABSOLUTE_DIFFERENCE;
|
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 androidx.test.core.app.ApplicationProvider.getApplicationContext;
|
||||||
import static com.google.common.truth.Truth.assertThat;
|
import static com.google.common.truth.Truth.assertThat;
|
||||||
|
|
||||||
@ -68,12 +73,12 @@ public final class MatrixTextureProcessorPixelTest {
|
|||||||
public void createGlObjects() throws IOException, GlUtil.GlException {
|
public void createGlObjects() throws IOException, GlUtil.GlException {
|
||||||
eglDisplay = GlUtil.createEglDisplay();
|
eglDisplay = GlUtil.createEglDisplay();
|
||||||
eglContext = GlUtil.createEglContext(eglDisplay);
|
eglContext = GlUtil.createEglContext(eglDisplay);
|
||||||
Bitmap inputBitmap = BitmapTestUtil.readBitmap(ORIGINAL_PNG_ASSET_PATH);
|
Bitmap inputBitmap = readBitmap(ORIGINAL_PNG_ASSET_PATH);
|
||||||
width = inputBitmap.getWidth();
|
width = inputBitmap.getWidth();
|
||||||
height = inputBitmap.getHeight();
|
height = inputBitmap.getHeight();
|
||||||
EGLSurface placeholderEglSurface = GlUtil.createPlaceholderEglSurface(eglDisplay);
|
EGLSurface placeholderEglSurface = GlUtil.createPlaceholderEglSurface(eglDisplay);
|
||||||
GlUtil.focusEglSurface(eglDisplay, eglContext, placeholderEglSurface, width, height);
|
GlUtil.focusEglSurface(eglDisplay, eglContext, placeholderEglSurface, width, height);
|
||||||
inputTexId = BitmapTestUtil.createGlTextureFromBitmap(inputBitmap);
|
inputTexId = createGlTextureFromBitmap(inputBitmap);
|
||||||
outputTexId = GlUtil.createTexture(width, height, /* useHighPrecisionColorComponents= */ false);
|
outputTexId = GlUtil.createTexture(width, height, /* useHighPrecisionColorComponents= */ false);
|
||||||
int frameBuffer = GlUtil.createFboForTexture(outputTexId);
|
int frameBuffer = GlUtil.createFboForTexture(outputTexId);
|
||||||
GlUtil.focusFramebuffer(
|
GlUtil.focusFramebuffer(
|
||||||
@ -98,18 +103,15 @@ public final class MatrixTextureProcessorPixelTest {
|
|||||||
matrixTextureProcessor =
|
matrixTextureProcessor =
|
||||||
noEditsTransformation.toGlTextureProcessor(context, /* useHdr= */ false);
|
noEditsTransformation.toGlTextureProcessor(context, /* useHdr= */ false);
|
||||||
matrixTextureProcessor.configure(width, height);
|
matrixTextureProcessor.configure(width, height);
|
||||||
Bitmap expectedBitmap = BitmapTestUtil.readBitmap(ORIGINAL_PNG_ASSET_PATH);
|
Bitmap expectedBitmap = readBitmap(ORIGINAL_PNG_ASSET_PATH);
|
||||||
|
|
||||||
matrixTextureProcessor.drawFrame(inputTexId, /* presentationTimeUs= */ 0);
|
matrixTextureProcessor.drawFrame(inputTexId, /* presentationTimeUs= */ 0);
|
||||||
Bitmap actualBitmap =
|
Bitmap actualBitmap = createArgb8888BitmapFromCurrentGlFramebuffer(width, height);
|
||||||
BitmapTestUtil.createArgb8888BitmapFromCurrentGlFramebuffer(width, height);
|
|
||||||
|
|
||||||
BitmapTestUtil.maybeSaveTestBitmapToCacheDirectory(
|
maybeSaveTestBitmapToCacheDirectory(testId, /* bitmapLabel= */ "actual", actualBitmap);
|
||||||
testId, /* bitmapLabel= */ "actual", actualBitmap);
|
|
||||||
// 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 =
|
||||||
BitmapTestUtil.getAveragePixelAbsoluteDifferenceArgb8888(
|
getBitmapAveragePixelAbsoluteDifferenceArgb8888(expectedBitmap, actualBitmap, testId);
|
||||||
expectedBitmap, actualBitmap, testId);
|
|
||||||
assertThat(averagePixelAbsoluteDifference).isAtMost(MAXIMUM_AVERAGE_PIXEL_ABSOLUTE_DIFFERENCE);
|
assertThat(averagePixelAbsoluteDifference).isAtMost(MAXIMUM_AVERAGE_PIXEL_ABSOLUTE_DIFFERENCE);
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -123,18 +125,15 @@ public final class MatrixTextureProcessorPixelTest {
|
|||||||
matrixTextureProcessor =
|
matrixTextureProcessor =
|
||||||
translateRightTransformation.toGlTextureProcessor(context, /* useHdr= */ false);
|
translateRightTransformation.toGlTextureProcessor(context, /* useHdr= */ false);
|
||||||
matrixTextureProcessor.configure(width, height);
|
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);
|
matrixTextureProcessor.drawFrame(inputTexId, /* presentationTimeUs= */ 0);
|
||||||
Bitmap actualBitmap =
|
Bitmap actualBitmap = createArgb8888BitmapFromCurrentGlFramebuffer(width, height);
|
||||||
BitmapTestUtil.createArgb8888BitmapFromCurrentGlFramebuffer(width, height);
|
|
||||||
|
|
||||||
BitmapTestUtil.maybeSaveTestBitmapToCacheDirectory(
|
maybeSaveTestBitmapToCacheDirectory(testId, /* bitmapLabel= */ "actual", actualBitmap);
|
||||||
testId, /* bitmapLabel= */ "actual", actualBitmap);
|
|
||||||
// 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 =
|
||||||
BitmapTestUtil.getAveragePixelAbsoluteDifferenceArgb8888(
|
getBitmapAveragePixelAbsoluteDifferenceArgb8888(expectedBitmap, actualBitmap, testId);
|
||||||
expectedBitmap, actualBitmap, testId);
|
|
||||||
assertThat(averagePixelAbsoluteDifference).isAtMost(MAXIMUM_AVERAGE_PIXEL_ABSOLUTE_DIFFERENCE);
|
assertThat(averagePixelAbsoluteDifference).isAtMost(MAXIMUM_AVERAGE_PIXEL_ABSOLUTE_DIFFERENCE);
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -147,18 +146,15 @@ public final class MatrixTextureProcessorPixelTest {
|
|||||||
matrixTextureProcessor =
|
matrixTextureProcessor =
|
||||||
scaleNarrowTransformation.toGlTextureProcessor(context, /* useHdr= */ false);
|
scaleNarrowTransformation.toGlTextureProcessor(context, /* useHdr= */ false);
|
||||||
matrixTextureProcessor.configure(width, height);
|
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);
|
matrixTextureProcessor.drawFrame(inputTexId, /* presentationTimeUs= */ 0);
|
||||||
Bitmap actualBitmap =
|
Bitmap actualBitmap = createArgb8888BitmapFromCurrentGlFramebuffer(width, height);
|
||||||
BitmapTestUtil.createArgb8888BitmapFromCurrentGlFramebuffer(width, height);
|
|
||||||
|
|
||||||
BitmapTestUtil.maybeSaveTestBitmapToCacheDirectory(
|
maybeSaveTestBitmapToCacheDirectory(testId, /* bitmapLabel= */ "actual", actualBitmap);
|
||||||
testId, /* bitmapLabel= */ "actual", actualBitmap);
|
|
||||||
// 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 =
|
||||||
BitmapTestUtil.getAveragePixelAbsoluteDifferenceArgb8888(
|
getBitmapAveragePixelAbsoluteDifferenceArgb8888(expectedBitmap, actualBitmap, testId);
|
||||||
expectedBitmap, actualBitmap, testId);
|
|
||||||
assertThat(averagePixelAbsoluteDifference).isAtMost(MAXIMUM_AVERAGE_PIXEL_ABSOLUTE_DIFFERENCE);
|
assertThat(averagePixelAbsoluteDifference).isAtMost(MAXIMUM_AVERAGE_PIXEL_ABSOLUTE_DIFFERENCE);
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -171,18 +167,15 @@ public final class MatrixTextureProcessorPixelTest {
|
|||||||
matrixTextureProcessor =
|
matrixTextureProcessor =
|
||||||
rotate90Transformation.toGlTextureProcessor(context, /* useHdr= */ false);
|
rotate90Transformation.toGlTextureProcessor(context, /* useHdr= */ false);
|
||||||
matrixTextureProcessor.configure(width, height);
|
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);
|
matrixTextureProcessor.drawFrame(inputTexId, /* presentationTimeUs= */ 0);
|
||||||
Bitmap actualBitmap =
|
Bitmap actualBitmap = createArgb8888BitmapFromCurrentGlFramebuffer(width, height);
|
||||||
BitmapTestUtil.createArgb8888BitmapFromCurrentGlFramebuffer(width, height);
|
|
||||||
|
|
||||||
BitmapTestUtil.maybeSaveTestBitmapToCacheDirectory(
|
maybeSaveTestBitmapToCacheDirectory(testId, /* bitmapLabel= */ "actual", actualBitmap);
|
||||||
testId, /* bitmapLabel= */ "actual", actualBitmap);
|
|
||||||
// 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 =
|
||||||
BitmapTestUtil.getAveragePixelAbsoluteDifferenceArgb8888(
|
getBitmapAveragePixelAbsoluteDifferenceArgb8888(expectedBitmap, actualBitmap, testId);
|
||||||
expectedBitmap, actualBitmap, testId);
|
|
||||||
assertThat(averagePixelAbsoluteDifference).isAtMost(MAXIMUM_AVERAGE_PIXEL_ABSOLUTE_DIFFERENCE);
|
assertThat(averagePixelAbsoluteDifference).isAtMost(MAXIMUM_AVERAGE_PIXEL_ABSOLUTE_DIFFERENCE);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -16,6 +16,11 @@
|
|||||||
package androidx.media3.effect;
|
package androidx.media3.effect;
|
||||||
|
|
||||||
import static androidx.media3.effect.BitmapTestUtil.MAXIMUM_AVERAGE_PIXEL_ABSOLUTE_DIFFERENCE;
|
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 androidx.test.core.app.ApplicationProvider.getApplicationContext;
|
||||||
import static com.google.android.exoplayer2.util.Assertions.checkNotNull;
|
import static com.google.android.exoplayer2.util.Assertions.checkNotNull;
|
||||||
import static com.google.common.truth.Truth.assertThat;
|
import static com.google.common.truth.Truth.assertThat;
|
||||||
@ -77,12 +82,12 @@ public final class PresentationPixelTest {
|
|||||||
public void createGlObjects() throws IOException, GlUtil.GlException {
|
public void createGlObjects() throws IOException, GlUtil.GlException {
|
||||||
eglDisplay = GlUtil.createEglDisplay();
|
eglDisplay = GlUtil.createEglDisplay();
|
||||||
eglContext = GlUtil.createEglContext(eglDisplay);
|
eglContext = GlUtil.createEglContext(eglDisplay);
|
||||||
Bitmap inputBitmap = BitmapTestUtil.readBitmap(ORIGINAL_PNG_ASSET_PATH);
|
Bitmap inputBitmap = readBitmap(ORIGINAL_PNG_ASSET_PATH);
|
||||||
inputWidth = inputBitmap.getWidth();
|
inputWidth = inputBitmap.getWidth();
|
||||||
inputHeight = inputBitmap.getHeight();
|
inputHeight = inputBitmap.getHeight();
|
||||||
placeholderEglSurface = GlUtil.createPlaceholderEglSurface(eglDisplay);
|
placeholderEglSurface = GlUtil.createPlaceholderEglSurface(eglDisplay);
|
||||||
GlUtil.focusEglSurface(eglDisplay, eglContext, placeholderEglSurface, inputWidth, inputHeight);
|
GlUtil.focusEglSurface(eglDisplay, eglContext, placeholderEglSurface, inputWidth, inputHeight);
|
||||||
inputTexId = BitmapTestUtil.createGlTextureFromBitmap(inputBitmap);
|
inputTexId = createGlTextureFromBitmap(inputBitmap);
|
||||||
}
|
}
|
||||||
|
|
||||||
@After
|
@After
|
||||||
@ -104,19 +109,16 @@ public final class PresentationPixelTest {
|
|||||||
Pair<Integer, Integer> outputSize =
|
Pair<Integer, Integer> outputSize =
|
||||||
presentationTextureProcessor.configure(inputWidth, inputHeight);
|
presentationTextureProcessor.configure(inputWidth, inputHeight);
|
||||||
setupOutputTexture(outputSize.first, outputSize.second);
|
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);
|
presentationTextureProcessor.drawFrame(inputTexId, /* presentationTimeUs= */ 0);
|
||||||
Bitmap actualBitmap =
|
Bitmap actualBitmap =
|
||||||
BitmapTestUtil.createArgb8888BitmapFromCurrentGlFramebuffer(
|
createArgb8888BitmapFromCurrentGlFramebuffer(outputSize.first, outputSize.second);
|
||||||
outputSize.first, outputSize.second);
|
|
||||||
|
|
||||||
BitmapTestUtil.maybeSaveTestBitmapToCacheDirectory(
|
maybeSaveTestBitmapToCacheDirectory(testId, /* bitmapLabel= */ "actual", actualBitmap);
|
||||||
testId, /* bitmapLabel= */ "actual", actualBitmap);
|
|
||||||
// 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 =
|
||||||
BitmapTestUtil.getAveragePixelAbsoluteDifferenceArgb8888(
|
getBitmapAveragePixelAbsoluteDifferenceArgb8888(expectedBitmap, actualBitmap, testId);
|
||||||
expectedBitmap, actualBitmap, testId);
|
|
||||||
assertThat(averagePixelAbsoluteDifference).isAtMost(MAXIMUM_AVERAGE_PIXEL_ABSOLUTE_DIFFERENCE);
|
assertThat(averagePixelAbsoluteDifference).isAtMost(MAXIMUM_AVERAGE_PIXEL_ABSOLUTE_DIFFERENCE);
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -130,20 +132,16 @@ public final class PresentationPixelTest {
|
|||||||
Pair<Integer, Integer> outputSize =
|
Pair<Integer, Integer> outputSize =
|
||||||
presentationTextureProcessor.configure(inputWidth, inputHeight);
|
presentationTextureProcessor.configure(inputWidth, inputHeight);
|
||||||
setupOutputTexture(outputSize.first, outputSize.second);
|
setupOutputTexture(outputSize.first, outputSize.second);
|
||||||
Bitmap expectedBitmap =
|
Bitmap expectedBitmap = readBitmap(ASPECT_RATIO_SCALE_TO_FIT_NARROW_PNG_ASSET_PATH);
|
||||||
BitmapTestUtil.readBitmap(ASPECT_RATIO_SCALE_TO_FIT_NARROW_PNG_ASSET_PATH);
|
|
||||||
|
|
||||||
presentationTextureProcessor.drawFrame(inputTexId, /* presentationTimeUs= */ 0);
|
presentationTextureProcessor.drawFrame(inputTexId, /* presentationTimeUs= */ 0);
|
||||||
Bitmap actualBitmap =
|
Bitmap actualBitmap =
|
||||||
BitmapTestUtil.createArgb8888BitmapFromCurrentGlFramebuffer(
|
createArgb8888BitmapFromCurrentGlFramebuffer(outputSize.first, outputSize.second);
|
||||||
outputSize.first, outputSize.second);
|
|
||||||
|
|
||||||
BitmapTestUtil.maybeSaveTestBitmapToCacheDirectory(
|
maybeSaveTestBitmapToCacheDirectory(testId, /* bitmapLabel= */ "actual", actualBitmap);
|
||||||
testId, /* bitmapLabel= */ "actual", actualBitmap);
|
|
||||||
// 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 =
|
||||||
BitmapTestUtil.getAveragePixelAbsoluteDifferenceArgb8888(
|
getBitmapAveragePixelAbsoluteDifferenceArgb8888(expectedBitmap, actualBitmap, testId);
|
||||||
expectedBitmap, actualBitmap, testId);
|
|
||||||
assertThat(averagePixelAbsoluteDifference).isAtMost(MAXIMUM_AVERAGE_PIXEL_ABSOLUTE_DIFFERENCE);
|
assertThat(averagePixelAbsoluteDifference).isAtMost(MAXIMUM_AVERAGE_PIXEL_ABSOLUTE_DIFFERENCE);
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -157,20 +155,16 @@ public final class PresentationPixelTest {
|
|||||||
Pair<Integer, Integer> outputSize =
|
Pair<Integer, Integer> outputSize =
|
||||||
presentationTextureProcessor.configure(inputWidth, inputHeight);
|
presentationTextureProcessor.configure(inputWidth, inputHeight);
|
||||||
setupOutputTexture(outputSize.first, outputSize.second);
|
setupOutputTexture(outputSize.first, outputSize.second);
|
||||||
Bitmap expectedBitmap =
|
Bitmap expectedBitmap = readBitmap(ASPECT_RATIO_SCALE_TO_FIT_WIDE_PNG_ASSET_PATH);
|
||||||
BitmapTestUtil.readBitmap(ASPECT_RATIO_SCALE_TO_FIT_WIDE_PNG_ASSET_PATH);
|
|
||||||
|
|
||||||
presentationTextureProcessor.drawFrame(inputTexId, /* presentationTimeUs= */ 0);
|
presentationTextureProcessor.drawFrame(inputTexId, /* presentationTimeUs= */ 0);
|
||||||
Bitmap actualBitmap =
|
Bitmap actualBitmap =
|
||||||
BitmapTestUtil.createArgb8888BitmapFromCurrentGlFramebuffer(
|
createArgb8888BitmapFromCurrentGlFramebuffer(outputSize.first, outputSize.second);
|
||||||
outputSize.first, outputSize.second);
|
|
||||||
|
|
||||||
BitmapTestUtil.maybeSaveTestBitmapToCacheDirectory(
|
maybeSaveTestBitmapToCacheDirectory(testId, /* bitmapLabel= */ "actual", actualBitmap);
|
||||||
testId, /* bitmapLabel= */ "actual", actualBitmap);
|
|
||||||
// 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 =
|
||||||
BitmapTestUtil.getAveragePixelAbsoluteDifferenceArgb8888(
|
getBitmapAveragePixelAbsoluteDifferenceArgb8888(expectedBitmap, actualBitmap, testId);
|
||||||
expectedBitmap, actualBitmap, testId);
|
|
||||||
assertThat(averagePixelAbsoluteDifference).isAtMost(MAXIMUM_AVERAGE_PIXEL_ABSOLUTE_DIFFERENCE);
|
assertThat(averagePixelAbsoluteDifference).isAtMost(MAXIMUM_AVERAGE_PIXEL_ABSOLUTE_DIFFERENCE);
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -185,20 +179,16 @@ public final class PresentationPixelTest {
|
|||||||
Pair<Integer, Integer> outputSize =
|
Pair<Integer, Integer> outputSize =
|
||||||
presentationTextureProcessor.configure(inputWidth, inputHeight);
|
presentationTextureProcessor.configure(inputWidth, inputHeight);
|
||||||
setupOutputTexture(outputSize.first, outputSize.second);
|
setupOutputTexture(outputSize.first, outputSize.second);
|
||||||
Bitmap expectedBitmap =
|
Bitmap expectedBitmap = readBitmap(ASPECT_RATIO_SCALE_TO_FIT_WITH_CROP_NARROW_PNG_ASSET_PATH);
|
||||||
BitmapTestUtil.readBitmap(ASPECT_RATIO_SCALE_TO_FIT_WITH_CROP_NARROW_PNG_ASSET_PATH);
|
|
||||||
|
|
||||||
presentationTextureProcessor.drawFrame(inputTexId, /* presentationTimeUs= */ 0);
|
presentationTextureProcessor.drawFrame(inputTexId, /* presentationTimeUs= */ 0);
|
||||||
Bitmap actualBitmap =
|
Bitmap actualBitmap =
|
||||||
BitmapTestUtil.createArgb8888BitmapFromCurrentGlFramebuffer(
|
createArgb8888BitmapFromCurrentGlFramebuffer(outputSize.first, outputSize.second);
|
||||||
outputSize.first, outputSize.second);
|
|
||||||
|
|
||||||
BitmapTestUtil.maybeSaveTestBitmapToCacheDirectory(
|
maybeSaveTestBitmapToCacheDirectory(testId, /* bitmapLabel= */ "actual", actualBitmap);
|
||||||
testId, /* bitmapLabel= */ "actual", actualBitmap);
|
|
||||||
// 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 =
|
||||||
BitmapTestUtil.getAveragePixelAbsoluteDifferenceArgb8888(
|
getBitmapAveragePixelAbsoluteDifferenceArgb8888(expectedBitmap, actualBitmap, testId);
|
||||||
expectedBitmap, actualBitmap, testId);
|
|
||||||
assertThat(averagePixelAbsoluteDifference).isAtMost(MAXIMUM_AVERAGE_PIXEL_ABSOLUTE_DIFFERENCE);
|
assertThat(averagePixelAbsoluteDifference).isAtMost(MAXIMUM_AVERAGE_PIXEL_ABSOLUTE_DIFFERENCE);
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -213,20 +203,16 @@ public final class PresentationPixelTest {
|
|||||||
Pair<Integer, Integer> outputSize =
|
Pair<Integer, Integer> outputSize =
|
||||||
presentationTextureProcessor.configure(inputWidth, inputHeight);
|
presentationTextureProcessor.configure(inputWidth, inputHeight);
|
||||||
setupOutputTexture(outputSize.first, outputSize.second);
|
setupOutputTexture(outputSize.first, outputSize.second);
|
||||||
Bitmap expectedBitmap =
|
Bitmap expectedBitmap = readBitmap(ASPECT_RATIO_SCALE_TO_FIT_WITH_CROP_WIDE_PNG_ASSET_PATH);
|
||||||
BitmapTestUtil.readBitmap(ASPECT_RATIO_SCALE_TO_FIT_WITH_CROP_WIDE_PNG_ASSET_PATH);
|
|
||||||
|
|
||||||
presentationTextureProcessor.drawFrame(inputTexId, /* presentationTimeUs= */ 0);
|
presentationTextureProcessor.drawFrame(inputTexId, /* presentationTimeUs= */ 0);
|
||||||
Bitmap actualBitmap =
|
Bitmap actualBitmap =
|
||||||
BitmapTestUtil.createArgb8888BitmapFromCurrentGlFramebuffer(
|
createArgb8888BitmapFromCurrentGlFramebuffer(outputSize.first, outputSize.second);
|
||||||
outputSize.first, outputSize.second);
|
|
||||||
|
|
||||||
BitmapTestUtil.maybeSaveTestBitmapToCacheDirectory(
|
maybeSaveTestBitmapToCacheDirectory(testId, /* bitmapLabel= */ "actual", actualBitmap);
|
||||||
testId, /* bitmapLabel= */ "actual", actualBitmap);
|
|
||||||
// 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 =
|
||||||
BitmapTestUtil.getAveragePixelAbsoluteDifferenceArgb8888(
|
getBitmapAveragePixelAbsoluteDifferenceArgb8888(expectedBitmap, actualBitmap, testId);
|
||||||
expectedBitmap, actualBitmap, testId);
|
|
||||||
assertThat(averagePixelAbsoluteDifference).isAtMost(MAXIMUM_AVERAGE_PIXEL_ABSOLUTE_DIFFERENCE);
|
assertThat(averagePixelAbsoluteDifference).isAtMost(MAXIMUM_AVERAGE_PIXEL_ABSOLUTE_DIFFERENCE);
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -240,20 +226,16 @@ public final class PresentationPixelTest {
|
|||||||
Pair<Integer, Integer> outputSize =
|
Pair<Integer, Integer> outputSize =
|
||||||
presentationTextureProcessor.configure(inputWidth, inputHeight);
|
presentationTextureProcessor.configure(inputWidth, inputHeight);
|
||||||
setupOutputTexture(outputSize.first, outputSize.second);
|
setupOutputTexture(outputSize.first, outputSize.second);
|
||||||
Bitmap expectedBitmap =
|
Bitmap expectedBitmap = readBitmap(ASPECT_RATIO_STRETCH_TO_FIT_NARROW_PNG_ASSET_PATH);
|
||||||
BitmapTestUtil.readBitmap(ASPECT_RATIO_STRETCH_TO_FIT_NARROW_PNG_ASSET_PATH);
|
|
||||||
|
|
||||||
presentationTextureProcessor.drawFrame(inputTexId, /* presentationTimeUs= */ 0);
|
presentationTextureProcessor.drawFrame(inputTexId, /* presentationTimeUs= */ 0);
|
||||||
Bitmap actualBitmap =
|
Bitmap actualBitmap =
|
||||||
BitmapTestUtil.createArgb8888BitmapFromCurrentGlFramebuffer(
|
createArgb8888BitmapFromCurrentGlFramebuffer(outputSize.first, outputSize.second);
|
||||||
outputSize.first, outputSize.second);
|
|
||||||
|
|
||||||
BitmapTestUtil.maybeSaveTestBitmapToCacheDirectory(
|
maybeSaveTestBitmapToCacheDirectory(testId, /* bitmapLabel= */ "actual", actualBitmap);
|
||||||
testId, /* bitmapLabel= */ "actual", actualBitmap);
|
|
||||||
// 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 =
|
||||||
BitmapTestUtil.getAveragePixelAbsoluteDifferenceArgb8888(
|
getBitmapAveragePixelAbsoluteDifferenceArgb8888(expectedBitmap, actualBitmap, testId);
|
||||||
expectedBitmap, actualBitmap, testId);
|
|
||||||
assertThat(averagePixelAbsoluteDifference).isAtMost(MAXIMUM_AVERAGE_PIXEL_ABSOLUTE_DIFFERENCE);
|
assertThat(averagePixelAbsoluteDifference).isAtMost(MAXIMUM_AVERAGE_PIXEL_ABSOLUTE_DIFFERENCE);
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -267,20 +249,16 @@ public final class PresentationPixelTest {
|
|||||||
Pair<Integer, Integer> outputSize =
|
Pair<Integer, Integer> outputSize =
|
||||||
presentationTextureProcessor.configure(inputWidth, inputHeight);
|
presentationTextureProcessor.configure(inputWidth, inputHeight);
|
||||||
setupOutputTexture(outputSize.first, outputSize.second);
|
setupOutputTexture(outputSize.first, outputSize.second);
|
||||||
Bitmap expectedBitmap =
|
Bitmap expectedBitmap = readBitmap(ASPECT_RATIO_STRETCH_TO_FIT_WIDE_PNG_ASSET_PATH);
|
||||||
BitmapTestUtil.readBitmap(ASPECT_RATIO_STRETCH_TO_FIT_WIDE_PNG_ASSET_PATH);
|
|
||||||
|
|
||||||
presentationTextureProcessor.drawFrame(inputTexId, /* presentationTimeUs= */ 0);
|
presentationTextureProcessor.drawFrame(inputTexId, /* presentationTimeUs= */ 0);
|
||||||
Bitmap actualBitmap =
|
Bitmap actualBitmap =
|
||||||
BitmapTestUtil.createArgb8888BitmapFromCurrentGlFramebuffer(
|
createArgb8888BitmapFromCurrentGlFramebuffer(outputSize.first, outputSize.second);
|
||||||
outputSize.first, outputSize.second);
|
|
||||||
|
|
||||||
BitmapTestUtil.maybeSaveTestBitmapToCacheDirectory(
|
maybeSaveTestBitmapToCacheDirectory(testId, /* bitmapLabel= */ "actual", actualBitmap);
|
||||||
testId, /* bitmapLabel= */ "actual", actualBitmap);
|
|
||||||
// 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 =
|
||||||
BitmapTestUtil.getAveragePixelAbsoluteDifferenceArgb8888(
|
getBitmapAveragePixelAbsoluteDifferenceArgb8888(expectedBitmap, actualBitmap, testId);
|
||||||
expectedBitmap, actualBitmap, testId);
|
|
||||||
assertThat(averagePixelAbsoluteDifference).isAtMost(MAXIMUM_AVERAGE_PIXEL_ABSOLUTE_DIFFERENCE);
|
assertThat(averagePixelAbsoluteDifference).isAtMost(MAXIMUM_AVERAGE_PIXEL_ABSOLUTE_DIFFERENCE);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -17,6 +17,12 @@
|
|||||||
package androidx.media3.effect;
|
package androidx.media3.effect;
|
||||||
|
|
||||||
import static androidx.media3.effect.BitmapTestUtil.MAXIMUM_AVERAGE_PIXEL_ABSOLUTE_DIFFERENCE;
|
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 androidx.test.core.app.ApplicationProvider.getApplicationContext;
|
||||||
import static com.google.android.exoplayer2.util.Assertions.checkNotNull;
|
import static com.google.android.exoplayer2.util.Assertions.checkNotNull;
|
||||||
import static com.google.common.truth.Truth.assertThat;
|
import static com.google.common.truth.Truth.assertThat;
|
||||||
@ -73,12 +79,12 @@ public final class RgbAdjustmentPixelTest {
|
|||||||
public void createGlObjects() throws IOException, GlUtil.GlException {
|
public void createGlObjects() throws IOException, GlUtil.GlException {
|
||||||
eglDisplay = GlUtil.createEglDisplay();
|
eglDisplay = GlUtil.createEglDisplay();
|
||||||
eglContext = GlUtil.createEglContext(eglDisplay);
|
eglContext = GlUtil.createEglContext(eglDisplay);
|
||||||
Bitmap inputBitmap = BitmapTestUtil.readBitmap(ORIGINAL_PNG_ASSET_PATH);
|
Bitmap inputBitmap = readBitmap(ORIGINAL_PNG_ASSET_PATH);
|
||||||
inputWidth = inputBitmap.getWidth();
|
inputWidth = inputBitmap.getWidth();
|
||||||
inputHeight = inputBitmap.getHeight();
|
inputHeight = inputBitmap.getHeight();
|
||||||
placeholderEglSurface = GlUtil.createPlaceholderEglSurface(eglDisplay);
|
placeholderEglSurface = GlUtil.createPlaceholderEglSurface(eglDisplay);
|
||||||
GlUtil.focusEglSurface(eglDisplay, eglContext, placeholderEglSurface, inputWidth, inputHeight);
|
GlUtil.focusEglSurface(eglDisplay, eglContext, placeholderEglSurface, inputWidth, inputHeight);
|
||||||
inputTexId = BitmapTestUtil.createGlTextureFromBitmap(inputBitmap);
|
inputTexId = createGlTextureFromBitmap(inputBitmap);
|
||||||
|
|
||||||
outputTexId =
|
outputTexId =
|
||||||
GlUtil.createTexture(inputWidth, inputHeight, /* useHighPrecisionColorComponents= */ false);
|
GlUtil.createTexture(inputWidth, inputHeight, /* useHighPrecisionColorComponents= */ false);
|
||||||
@ -106,18 +112,15 @@ public final class RgbAdjustmentPixelTest {
|
|||||||
RgbMatrix identityMatrix = new RgbAdjustment.Builder().build();
|
RgbMatrix identityMatrix = new RgbAdjustment.Builder().build();
|
||||||
matrixTextureProcessor = identityMatrix.toGlTextureProcessor(context, /* useHdr= */ false);
|
matrixTextureProcessor = identityMatrix.toGlTextureProcessor(context, /* useHdr= */ false);
|
||||||
Pair<Integer, Integer> outputSize = matrixTextureProcessor.configure(inputWidth, inputHeight);
|
Pair<Integer, Integer> 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);
|
matrixTextureProcessor.drawFrame(inputTexId, /* presentationTimeUs= */ 0);
|
||||||
Bitmap actualBitmap =
|
Bitmap actualBitmap =
|
||||||
BitmapTestUtil.createArgb8888BitmapFromCurrentGlFramebuffer(
|
createArgb8888BitmapFromCurrentGlFramebuffer(outputSize.first, outputSize.second);
|
||||||
outputSize.first, outputSize.second);
|
|
||||||
|
|
||||||
BitmapTestUtil.maybeSaveTestBitmapToCacheDirectory(
|
maybeSaveTestBitmapToCacheDirectory(testId, /* bitmapLabel= */ "actual", actualBitmap);
|
||||||
testId, /* bitmapLabel= */ "actual", actualBitmap);
|
|
||||||
float averagePixelAbsoluteDifference =
|
float averagePixelAbsoluteDifference =
|
||||||
BitmapTestUtil.getAveragePixelAbsoluteDifferenceArgb8888(
|
getBitmapAveragePixelAbsoluteDifferenceArgb8888(expectedBitmap, actualBitmap, testId);
|
||||||
expectedBitmap, actualBitmap, testId);
|
|
||||||
assertThat(averagePixelAbsoluteDifference).isAtMost(MAXIMUM_AVERAGE_PIXEL_ABSOLUTE_DIFFERENCE);
|
assertThat(averagePixelAbsoluteDifference).isAtMost(MAXIMUM_AVERAGE_PIXEL_ABSOLUTE_DIFFERENCE);
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -129,19 +132,15 @@ public final class RgbAdjustmentPixelTest {
|
|||||||
matrixTextureProcessor = removeColorMatrix.toGlTextureProcessor(context, /* useHdr= */ false);
|
matrixTextureProcessor = removeColorMatrix.toGlTextureProcessor(context, /* useHdr= */ false);
|
||||||
Pair<Integer, Integer> outputSize = matrixTextureProcessor.configure(inputWidth, inputHeight);
|
Pair<Integer, Integer> outputSize = matrixTextureProcessor.configure(inputWidth, inputHeight);
|
||||||
Bitmap expectedBitmap =
|
Bitmap expectedBitmap =
|
||||||
BitmapTestUtil.createArgb8888BitmapWithSolidColor(
|
createArgb8888BitmapWithSolidColor(outputSize.first, outputSize.second, Color.BLACK);
|
||||||
outputSize.first, outputSize.second, Color.BLACK);
|
|
||||||
|
|
||||||
matrixTextureProcessor.drawFrame(inputTexId, /* presentationTimeUs= */ 0);
|
matrixTextureProcessor.drawFrame(inputTexId, /* presentationTimeUs= */ 0);
|
||||||
Bitmap actualBitmap =
|
Bitmap actualBitmap =
|
||||||
BitmapTestUtil.createArgb8888BitmapFromCurrentGlFramebuffer(
|
createArgb8888BitmapFromCurrentGlFramebuffer(outputSize.first, outputSize.second);
|
||||||
outputSize.first, outputSize.second);
|
|
||||||
|
|
||||||
BitmapTestUtil.maybeSaveTestBitmapToCacheDirectory(
|
maybeSaveTestBitmapToCacheDirectory(testId, /* bitmapLabel= */ "actual", actualBitmap);
|
||||||
testId, /* bitmapLabel= */ "actual", actualBitmap);
|
|
||||||
float averagePixelAbsoluteDifference =
|
float averagePixelAbsoluteDifference =
|
||||||
BitmapTestUtil.getAveragePixelAbsoluteDifferenceArgb8888(
|
getBitmapAveragePixelAbsoluteDifferenceArgb8888(expectedBitmap, actualBitmap, testId);
|
||||||
expectedBitmap, actualBitmap, testId);
|
|
||||||
assertThat(averagePixelAbsoluteDifference).isAtMost(MAXIMUM_AVERAGE_PIXEL_ABSOLUTE_DIFFERENCE);
|
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();
|
RgbMatrix redOnlyMatrix = new RgbAdjustment.Builder().setBlueScale(0).setGreenScale(0).build();
|
||||||
matrixTextureProcessor = redOnlyMatrix.toGlTextureProcessor(context, /* useHdr= */ false);
|
matrixTextureProcessor = redOnlyMatrix.toGlTextureProcessor(context, /* useHdr= */ false);
|
||||||
Pair<Integer, Integer> outputSize = matrixTextureProcessor.configure(inputWidth, inputHeight);
|
Pair<Integer, Integer> 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);
|
matrixTextureProcessor.drawFrame(inputTexId, /* presentationTimeUs= */ 0);
|
||||||
Bitmap actualBitmap =
|
Bitmap actualBitmap =
|
||||||
BitmapTestUtil.createArgb8888BitmapFromCurrentGlFramebuffer(
|
createArgb8888BitmapFromCurrentGlFramebuffer(outputSize.first, outputSize.second);
|
||||||
outputSize.first, outputSize.second);
|
|
||||||
|
|
||||||
BitmapTestUtil.maybeSaveTestBitmapToCacheDirectory(
|
maybeSaveTestBitmapToCacheDirectory(testId, /* bitmapLabel= */ "actual", actualBitmap);
|
||||||
testId, /* bitmapLabel= */ "actual", actualBitmap);
|
|
||||||
float averagePixelAbsoluteDifference =
|
float averagePixelAbsoluteDifference =
|
||||||
BitmapTestUtil.getAveragePixelAbsoluteDifferenceArgb8888(
|
getBitmapAveragePixelAbsoluteDifferenceArgb8888(expectedBitmap, actualBitmap, testId);
|
||||||
expectedBitmap, actualBitmap, testId);
|
|
||||||
assertThat(averagePixelAbsoluteDifference).isAtMost(MAXIMUM_AVERAGE_PIXEL_ABSOLUTE_DIFFERENCE);
|
assertThat(averagePixelAbsoluteDifference).isAtMost(MAXIMUM_AVERAGE_PIXEL_ABSOLUTE_DIFFERENCE);
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -172,18 +168,15 @@ public final class RgbAdjustmentPixelTest {
|
|||||||
RgbMatrix increaseRedMatrix = new RgbAdjustment.Builder().setRedScale(5).build();
|
RgbMatrix increaseRedMatrix = new RgbAdjustment.Builder().setRedScale(5).build();
|
||||||
matrixTextureProcessor = increaseRedMatrix.toGlTextureProcessor(context, /* useHdr= */ false);
|
matrixTextureProcessor = increaseRedMatrix.toGlTextureProcessor(context, /* useHdr= */ false);
|
||||||
Pair<Integer, Integer> outputSize = matrixTextureProcessor.configure(inputWidth, inputHeight);
|
Pair<Integer, Integer> 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);
|
matrixTextureProcessor.drawFrame(inputTexId, /* presentationTimeUs= */ 0);
|
||||||
Bitmap actualBitmap =
|
Bitmap actualBitmap =
|
||||||
BitmapTestUtil.createArgb8888BitmapFromCurrentGlFramebuffer(
|
createArgb8888BitmapFromCurrentGlFramebuffer(outputSize.first, outputSize.second);
|
||||||
outputSize.first, outputSize.second);
|
|
||||||
|
|
||||||
BitmapTestUtil.maybeSaveTestBitmapToCacheDirectory(
|
maybeSaveTestBitmapToCacheDirectory(testId, /* bitmapLabel= */ "actual", actualBitmap);
|
||||||
testId, /* bitmapLabel= */ "actual", actualBitmap);
|
|
||||||
float averagePixelAbsoluteDifference =
|
float averagePixelAbsoluteDifference =
|
||||||
BitmapTestUtil.getAveragePixelAbsoluteDifferenceArgb8888(
|
getBitmapAveragePixelAbsoluteDifferenceArgb8888(expectedBitmap, actualBitmap, testId);
|
||||||
expectedBitmap, actualBitmap, testId);
|
|
||||||
assertThat(averagePixelAbsoluteDifference).isAtMost(MAXIMUM_AVERAGE_PIXEL_ABSOLUTE_DIFFERENCE);
|
assertThat(averagePixelAbsoluteDifference).isAtMost(MAXIMUM_AVERAGE_PIXEL_ABSOLUTE_DIFFERENCE);
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -195,18 +188,15 @@ public final class RgbAdjustmentPixelTest {
|
|||||||
matrixTextureProcessor =
|
matrixTextureProcessor =
|
||||||
increaseBrightnessMatrix.toGlTextureProcessor(context, /* useHdr= */ false);
|
increaseBrightnessMatrix.toGlTextureProcessor(context, /* useHdr= */ false);
|
||||||
Pair<Integer, Integer> outputSize = matrixTextureProcessor.configure(inputWidth, inputHeight);
|
Pair<Integer, Integer> 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);
|
matrixTextureProcessor.drawFrame(inputTexId, /* presentationTimeUs= */ 0);
|
||||||
Bitmap actualBitmap =
|
Bitmap actualBitmap =
|
||||||
BitmapTestUtil.createArgb8888BitmapFromCurrentGlFramebuffer(
|
createArgb8888BitmapFromCurrentGlFramebuffer(outputSize.first, outputSize.second);
|
||||||
outputSize.first, outputSize.second);
|
|
||||||
|
|
||||||
BitmapTestUtil.maybeSaveTestBitmapToCacheDirectory(
|
maybeSaveTestBitmapToCacheDirectory(testId, /* bitmapLabel= */ "actual", actualBitmap);
|
||||||
testId, /* bitmapLabel= */ "actual", actualBitmap);
|
|
||||||
float averagePixelAbsoluteDifference =
|
float averagePixelAbsoluteDifference =
|
||||||
BitmapTestUtil.getAveragePixelAbsoluteDifferenceArgb8888(
|
getBitmapAveragePixelAbsoluteDifferenceArgb8888(expectedBitmap, actualBitmap, testId);
|
||||||
expectedBitmap, actualBitmap, testId);
|
|
||||||
assertThat(averagePixelAbsoluteDifference).isAtMost(MAXIMUM_AVERAGE_PIXEL_ABSOLUTE_DIFFERENCE);
|
assertThat(averagePixelAbsoluteDifference).isAtMost(MAXIMUM_AVERAGE_PIXEL_ABSOLUTE_DIFFERENCE);
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -224,19 +214,15 @@ public final class RgbAdjustmentPixelTest {
|
|||||||
/* useHdr= */ false);
|
/* useHdr= */ false);
|
||||||
Pair<Integer, Integer> outputSize = matrixTextureProcessor.configure(inputWidth, inputHeight);
|
Pair<Integer, Integer> outputSize = matrixTextureProcessor.configure(inputWidth, inputHeight);
|
||||||
Bitmap expectedBitmap =
|
Bitmap expectedBitmap =
|
||||||
BitmapTestUtil.createArgb8888BitmapWithSolidColor(
|
createArgb8888BitmapWithSolidColor(outputSize.first, outputSize.second, Color.BLACK);
|
||||||
outputSize.first, outputSize.second, Color.BLACK);
|
|
||||||
|
|
||||||
matrixTextureProcessor.drawFrame(inputTexId, /* presentationTimeUs= */ 0);
|
matrixTextureProcessor.drawFrame(inputTexId, /* presentationTimeUs= */ 0);
|
||||||
Bitmap actualBitmap =
|
Bitmap actualBitmap =
|
||||||
BitmapTestUtil.createArgb8888BitmapFromCurrentGlFramebuffer(
|
createArgb8888BitmapFromCurrentGlFramebuffer(outputSize.first, outputSize.second);
|
||||||
outputSize.first, outputSize.second);
|
|
||||||
|
|
||||||
BitmapTestUtil.maybeSaveTestBitmapToCacheDirectory(
|
maybeSaveTestBitmapToCacheDirectory(testId, /* bitmapLabel= */ "actual", actualBitmap);
|
||||||
testId, /* bitmapLabel= */ "actual", actualBitmap);
|
|
||||||
float averagePixelAbsoluteDifference =
|
float averagePixelAbsoluteDifference =
|
||||||
BitmapTestUtil.getAveragePixelAbsoluteDifferenceArgb8888(
|
getBitmapAveragePixelAbsoluteDifferenceArgb8888(expectedBitmap, actualBitmap, testId);
|
||||||
expectedBitmap, actualBitmap, testId);
|
|
||||||
assertThat(averagePixelAbsoluteDifference).isAtMost(MAXIMUM_AVERAGE_PIXEL_ABSOLUTE_DIFFERENCE);
|
assertThat(averagePixelAbsoluteDifference).isAtMost(MAXIMUM_AVERAGE_PIXEL_ABSOLUTE_DIFFERENCE);
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -252,18 +238,15 @@ public final class RgbAdjustmentPixelTest {
|
|||||||
/* rgbMatrices= */ ImmutableList.of(noGreen, noBlue),
|
/* rgbMatrices= */ ImmutableList.of(noGreen, noBlue),
|
||||||
/* useHdr= */ false);
|
/* useHdr= */ false);
|
||||||
Pair<Integer, Integer> outputSize = matrixTextureProcessor.configure(inputWidth, inputHeight);
|
Pair<Integer, Integer> 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);
|
matrixTextureProcessor.drawFrame(inputTexId, /* presentationTimeUs= */ 0);
|
||||||
Bitmap actualBitmap =
|
Bitmap actualBitmap =
|
||||||
BitmapTestUtil.createArgb8888BitmapFromCurrentGlFramebuffer(
|
createArgb8888BitmapFromCurrentGlFramebuffer(outputSize.first, outputSize.second);
|
||||||
outputSize.first, outputSize.second);
|
|
||||||
|
|
||||||
BitmapTestUtil.maybeSaveTestBitmapToCacheDirectory(
|
maybeSaveTestBitmapToCacheDirectory(testId, /* bitmapLabel= */ "actual", actualBitmap);
|
||||||
testId, /* bitmapLabel= */ "actual", actualBitmap);
|
|
||||||
float averagePixelAbsoluteDifference =
|
float averagePixelAbsoluteDifference =
|
||||||
BitmapTestUtil.getAveragePixelAbsoluteDifferenceArgb8888(
|
getBitmapAveragePixelAbsoluteDifferenceArgb8888(expectedBitmap, actualBitmap, testId);
|
||||||
expectedBitmap, actualBitmap, testId);
|
|
||||||
assertThat(averagePixelAbsoluteDifference).isAtMost(MAXIMUM_AVERAGE_PIXEL_ABSOLUTE_DIFFERENCE);
|
assertThat(averagePixelAbsoluteDifference).isAtMost(MAXIMUM_AVERAGE_PIXEL_ABSOLUTE_DIFFERENCE);
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -281,18 +264,15 @@ public final class RgbAdjustmentPixelTest {
|
|||||||
/* rgbMatrices= */ ImmutableList.of(scaleRedMatrix, scaleRedByInverseMatrix),
|
/* rgbMatrices= */ ImmutableList.of(scaleRedMatrix, scaleRedByInverseMatrix),
|
||||||
/* useHdr= */ false);
|
/* useHdr= */ false);
|
||||||
Pair<Integer, Integer> outputSize = matrixTextureProcessor.configure(inputWidth, inputHeight);
|
Pair<Integer, Integer> 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);
|
matrixTextureProcessor.drawFrame(inputTexId, /* presentationTimeUs= */ 0);
|
||||||
Bitmap actualBitmap =
|
Bitmap actualBitmap =
|
||||||
BitmapTestUtil.createArgb8888BitmapFromCurrentGlFramebuffer(
|
createArgb8888BitmapFromCurrentGlFramebuffer(outputSize.first, outputSize.second);
|
||||||
outputSize.first, outputSize.second);
|
|
||||||
|
|
||||||
BitmapTestUtil.maybeSaveTestBitmapToCacheDirectory(
|
maybeSaveTestBitmapToCacheDirectory(testId, /* bitmapLabel= */ "actual", actualBitmap);
|
||||||
testId, /* bitmapLabel= */ "actual", actualBitmap);
|
|
||||||
float averagePixelAbsoluteDifference =
|
float averagePixelAbsoluteDifference =
|
||||||
BitmapTestUtil.getAveragePixelAbsoluteDifferenceArgb8888(
|
getBitmapAveragePixelAbsoluteDifferenceArgb8888(expectedBitmap, actualBitmap, testId);
|
||||||
expectedBitmap, actualBitmap, testId);
|
|
||||||
assertThat(averagePixelAbsoluteDifference).isAtMost(MAXIMUM_AVERAGE_PIXEL_ABSOLUTE_DIFFERENCE);
|
assertThat(averagePixelAbsoluteDifference).isAtMost(MAXIMUM_AVERAGE_PIXEL_ABSOLUTE_DIFFERENCE);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -17,6 +17,11 @@
|
|||||||
package androidx.media3.effect;
|
package androidx.media3.effect;
|
||||||
|
|
||||||
import static androidx.media3.effect.BitmapTestUtil.MAXIMUM_AVERAGE_PIXEL_ABSOLUTE_DIFFERENCE;
|
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 androidx.test.core.app.ApplicationProvider.getApplicationContext;
|
||||||
import static com.google.android.exoplayer2.util.Assertions.checkNotNull;
|
import static com.google.android.exoplayer2.util.Assertions.checkNotNull;
|
||||||
import static com.google.common.truth.Truth.assertThat;
|
import static com.google.common.truth.Truth.assertThat;
|
||||||
@ -69,12 +74,12 @@ public final class RgbFilterPixelTest {
|
|||||||
public void createGlObjects() throws IOException, GlUtil.GlException {
|
public void createGlObjects() throws IOException, GlUtil.GlException {
|
||||||
eglDisplay = GlUtil.createEglDisplay();
|
eglDisplay = GlUtil.createEglDisplay();
|
||||||
eglContext = GlUtil.createEglContext(eglDisplay);
|
eglContext = GlUtil.createEglContext(eglDisplay);
|
||||||
Bitmap inputBitmap = BitmapTestUtil.readBitmap(ORIGINAL_PNG_ASSET_PATH);
|
Bitmap inputBitmap = readBitmap(ORIGINAL_PNG_ASSET_PATH);
|
||||||
inputWidth = inputBitmap.getWidth();
|
inputWidth = inputBitmap.getWidth();
|
||||||
inputHeight = inputBitmap.getHeight();
|
inputHeight = inputBitmap.getHeight();
|
||||||
placeholderEglSurface = GlUtil.createPlaceholderEglSurface(eglDisplay);
|
placeholderEglSurface = GlUtil.createPlaceholderEglSurface(eglDisplay);
|
||||||
GlUtil.focusEglSurface(eglDisplay, eglContext, placeholderEglSurface, inputWidth, inputHeight);
|
GlUtil.focusEglSurface(eglDisplay, eglContext, placeholderEglSurface, inputWidth, inputHeight);
|
||||||
inputTexId = BitmapTestUtil.createGlTextureFromBitmap(inputBitmap);
|
inputTexId = createGlTextureFromBitmap(inputBitmap);
|
||||||
|
|
||||||
outputTexId =
|
outputTexId =
|
||||||
GlUtil.createTexture(inputWidth, inputHeight, /* useHighPrecisionColorComponents= */ false);
|
GlUtil.createTexture(inputWidth, inputHeight, /* useHighPrecisionColorComponents= */ false);
|
||||||
@ -102,18 +107,15 @@ public final class RgbFilterPixelTest {
|
|||||||
RgbMatrix grayscaleMatrix = RgbFilter.createGrayscaleFilter();
|
RgbMatrix grayscaleMatrix = RgbFilter.createGrayscaleFilter();
|
||||||
matrixTextureProcessor = grayscaleMatrix.toGlTextureProcessor(context, /* useHdr= */ false);
|
matrixTextureProcessor = grayscaleMatrix.toGlTextureProcessor(context, /* useHdr= */ false);
|
||||||
Pair<Integer, Integer> outputSize = matrixTextureProcessor.configure(inputWidth, inputHeight);
|
Pair<Integer, Integer> 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);
|
matrixTextureProcessor.drawFrame(inputTexId, /* presentationTimeUs= */ 0);
|
||||||
Bitmap actualBitmap =
|
Bitmap actualBitmap =
|
||||||
BitmapTestUtil.createArgb8888BitmapFromCurrentGlFramebuffer(
|
createArgb8888BitmapFromCurrentGlFramebuffer(outputSize.first, outputSize.second);
|
||||||
outputSize.first, outputSize.second);
|
|
||||||
|
|
||||||
BitmapTestUtil.maybeSaveTestBitmapToCacheDirectory(
|
maybeSaveTestBitmapToCacheDirectory(testId, /* bitmapLabel= */ "actual", actualBitmap);
|
||||||
testId, /* bitmapLabel= */ "actual", actualBitmap);
|
|
||||||
float averagePixelAbsoluteDifference =
|
float averagePixelAbsoluteDifference =
|
||||||
BitmapTestUtil.getAveragePixelAbsoluteDifferenceArgb8888(
|
getBitmapAveragePixelAbsoluteDifferenceArgb8888(expectedBitmap, actualBitmap, testId);
|
||||||
expectedBitmap, actualBitmap, testId);
|
|
||||||
assertThat(averagePixelAbsoluteDifference).isAtMost(MAXIMUM_AVERAGE_PIXEL_ABSOLUTE_DIFFERENCE);
|
assertThat(averagePixelAbsoluteDifference).isAtMost(MAXIMUM_AVERAGE_PIXEL_ABSOLUTE_DIFFERENCE);
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -123,18 +125,15 @@ public final class RgbFilterPixelTest {
|
|||||||
RgbMatrix invertedMatrix = RgbFilter.createInvertedFilter();
|
RgbMatrix invertedMatrix = RgbFilter.createInvertedFilter();
|
||||||
matrixTextureProcessor = invertedMatrix.toGlTextureProcessor(context, /* useHdr= */ false);
|
matrixTextureProcessor = invertedMatrix.toGlTextureProcessor(context, /* useHdr= */ false);
|
||||||
Pair<Integer, Integer> outputSize = matrixTextureProcessor.configure(inputWidth, inputHeight);
|
Pair<Integer, Integer> 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);
|
matrixTextureProcessor.drawFrame(inputTexId, /* presentationTimeUs= */ 0);
|
||||||
Bitmap actualBitmap =
|
Bitmap actualBitmap =
|
||||||
BitmapTestUtil.createArgb8888BitmapFromCurrentGlFramebuffer(
|
createArgb8888BitmapFromCurrentGlFramebuffer(outputSize.first, outputSize.second);
|
||||||
outputSize.first, outputSize.second);
|
|
||||||
|
|
||||||
BitmapTestUtil.maybeSaveTestBitmapToCacheDirectory(
|
maybeSaveTestBitmapToCacheDirectory(testId, /* bitmapLabel= */ "actual", actualBitmap);
|
||||||
testId, /* bitmapLabel= */ "actual", actualBitmap);
|
|
||||||
float averagePixelAbsoluteDifference =
|
float averagePixelAbsoluteDifference =
|
||||||
BitmapTestUtil.getAveragePixelAbsoluteDifferenceArgb8888(
|
getBitmapAveragePixelAbsoluteDifferenceArgb8888(expectedBitmap, actualBitmap, testId);
|
||||||
expectedBitmap, actualBitmap, testId);
|
|
||||||
assertThat(averagePixelAbsoluteDifference).isAtMost(MAXIMUM_AVERAGE_PIXEL_ABSOLUTE_DIFFERENCE);
|
assertThat(averagePixelAbsoluteDifference).isAtMost(MAXIMUM_AVERAGE_PIXEL_ABSOLUTE_DIFFERENCE);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -17,6 +17,11 @@
|
|||||||
package androidx.media3.effect;
|
package androidx.media3.effect;
|
||||||
|
|
||||||
import static androidx.media3.effect.BitmapTestUtil.MAXIMUM_AVERAGE_PIXEL_ABSOLUTE_DIFFERENCE;
|
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 androidx.test.core.app.ApplicationProvider.getApplicationContext;
|
||||||
import static com.google.android.exoplayer2.util.Assertions.checkNotNull;
|
import static com.google.android.exoplayer2.util.Assertions.checkNotNull;
|
||||||
import static com.google.common.truth.Truth.assertThat;
|
import static com.google.common.truth.Truth.assertThat;
|
||||||
@ -75,13 +80,13 @@ public class SingleColorLutPixelTest {
|
|||||||
eglDisplay = GlUtil.createEglDisplay();
|
eglDisplay = GlUtil.createEglDisplay();
|
||||||
eglContext = GlUtil.createEglContext(eglDisplay);
|
eglContext = GlUtil.createEglContext(eglDisplay);
|
||||||
|
|
||||||
Bitmap inputBitmap = BitmapTestUtil.readBitmap(ORIGINAL_PNG_ASSET_PATH);
|
Bitmap inputBitmap = readBitmap(ORIGINAL_PNG_ASSET_PATH);
|
||||||
inputWidth = inputBitmap.getWidth();
|
inputWidth = inputBitmap.getWidth();
|
||||||
inputHeight = inputBitmap.getHeight();
|
inputHeight = inputBitmap.getHeight();
|
||||||
|
|
||||||
placeholderEglSurface = GlUtil.createPlaceholderEglSurface(eglDisplay);
|
placeholderEglSurface = GlUtil.createPlaceholderEglSurface(eglDisplay);
|
||||||
GlUtil.focusEglSurface(eglDisplay, eglContext, placeholderEglSurface, inputWidth, inputHeight);
|
GlUtil.focusEglSurface(eglDisplay, eglContext, placeholderEglSurface, inputWidth, inputHeight);
|
||||||
inputTexId = BitmapTestUtil.createGlTextureFromBitmap(inputBitmap);
|
inputTexId = createGlTextureFromBitmap(inputBitmap);
|
||||||
}
|
}
|
||||||
|
|
||||||
@After
|
@After
|
||||||
@ -101,17 +106,15 @@ public class SingleColorLutPixelTest {
|
|||||||
.toGlTextureProcessor(context, /* useHdr= */ false);
|
.toGlTextureProcessor(context, /* useHdr= */ false);
|
||||||
Pair<Integer, Integer> outputSize = colorLutProcessor.configure(inputWidth, inputHeight);
|
Pair<Integer, Integer> outputSize = colorLutProcessor.configure(inputWidth, inputHeight);
|
||||||
setupOutputTexture(outputSize.first, outputSize.second);
|
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);
|
colorLutProcessor.drawFrame(inputTexId, /* presentationTimeUs = */ 0);
|
||||||
Bitmap actualBitmap =
|
Bitmap actualBitmap =
|
||||||
BitmapTestUtil.createArgb8888BitmapFromCurrentGlFramebuffer(
|
createArgb8888BitmapFromCurrentGlFramebuffer(outputSize.first, outputSize.second);
|
||||||
outputSize.first, outputSize.second);
|
|
||||||
|
|
||||||
BitmapTestUtil.maybeSaveTestBitmapToCacheDirectory(testId, "actual", actualBitmap);
|
maybeSaveTestBitmapToCacheDirectory(testId, "actual", actualBitmap);
|
||||||
float averagePixelAbsoluteDifference =
|
float averagePixelAbsoluteDifference =
|
||||||
BitmapTestUtil.getAveragePixelAbsoluteDifferenceArgb8888(
|
getBitmapAveragePixelAbsoluteDifferenceArgb8888(expectedBitmap, actualBitmap, testId);
|
||||||
expectedBitmap, actualBitmap, testId);
|
|
||||||
assertThat(averagePixelAbsoluteDifference).isAtMost(MAXIMUM_AVERAGE_PIXEL_ABSOLUTE_DIFFERENCE);
|
assertThat(averagePixelAbsoluteDifference).isAtMost(MAXIMUM_AVERAGE_PIXEL_ABSOLUTE_DIFFERENCE);
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -124,17 +127,15 @@ public class SingleColorLutPixelTest {
|
|||||||
.toGlTextureProcessor(context, /* useHdr= */ false);
|
.toGlTextureProcessor(context, /* useHdr= */ false);
|
||||||
Pair<Integer, Integer> outputSize = colorLutProcessor.configure(inputWidth, inputHeight);
|
Pair<Integer, Integer> outputSize = colorLutProcessor.configure(inputWidth, inputHeight);
|
||||||
setupOutputTexture(outputSize.first, outputSize.second);
|
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);
|
colorLutProcessor.drawFrame(inputTexId, /* presentationTimeUs = */ 0);
|
||||||
Bitmap actualBitmap =
|
Bitmap actualBitmap =
|
||||||
BitmapTestUtil.createArgb8888BitmapFromCurrentGlFramebuffer(
|
createArgb8888BitmapFromCurrentGlFramebuffer(outputSize.first, outputSize.second);
|
||||||
outputSize.first, outputSize.second);
|
|
||||||
|
|
||||||
BitmapTestUtil.maybeSaveTestBitmapToCacheDirectory(testId, "actual", actualBitmap);
|
maybeSaveTestBitmapToCacheDirectory(testId, "actual", actualBitmap);
|
||||||
float averagePixelAbsoluteDifference =
|
float averagePixelAbsoluteDifference =
|
||||||
BitmapTestUtil.getAveragePixelAbsoluteDifferenceArgb8888(
|
getBitmapAveragePixelAbsoluteDifferenceArgb8888(expectedBitmap, actualBitmap, testId);
|
||||||
expectedBitmap, actualBitmap, testId);
|
|
||||||
assertThat(averagePixelAbsoluteDifference).isAtMost(MAXIMUM_AVERAGE_PIXEL_ABSOLUTE_DIFFERENCE);
|
assertThat(averagePixelAbsoluteDifference).isAtMost(MAXIMUM_AVERAGE_PIXEL_ABSOLUTE_DIFFERENCE);
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -147,17 +148,15 @@ public class SingleColorLutPixelTest {
|
|||||||
.toGlTextureProcessor(context, /* useHdr= */ false);
|
.toGlTextureProcessor(context, /* useHdr= */ false);
|
||||||
Pair<Integer, Integer> outputSize = colorLutProcessor.configure(inputWidth, inputHeight);
|
Pair<Integer, Integer> outputSize = colorLutProcessor.configure(inputWidth, inputHeight);
|
||||||
setupOutputTexture(outputSize.first, outputSize.second);
|
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);
|
colorLutProcessor.drawFrame(inputTexId, /* presentationTimeUs = */ 0);
|
||||||
Bitmap actualBitmap =
|
Bitmap actualBitmap =
|
||||||
BitmapTestUtil.createArgb8888BitmapFromCurrentGlFramebuffer(
|
createArgb8888BitmapFromCurrentGlFramebuffer(outputSize.first, outputSize.second);
|
||||||
outputSize.first, outputSize.second);
|
|
||||||
|
|
||||||
BitmapTestUtil.maybeSaveTestBitmapToCacheDirectory(testId, "actual", actualBitmap);
|
maybeSaveTestBitmapToCacheDirectory(testId, "actual", actualBitmap);
|
||||||
float averagePixelAbsoluteDifference =
|
float averagePixelAbsoluteDifference =
|
||||||
BitmapTestUtil.getAveragePixelAbsoluteDifferenceArgb8888(
|
getBitmapAveragePixelAbsoluteDifferenceArgb8888(expectedBitmap, actualBitmap, testId);
|
||||||
expectedBitmap, actualBitmap, testId);
|
|
||||||
assertThat(averagePixelAbsoluteDifference).isAtMost(MAXIMUM_AVERAGE_PIXEL_ABSOLUTE_DIFFERENCE);
|
assertThat(averagePixelAbsoluteDifference).isAtMost(MAXIMUM_AVERAGE_PIXEL_ABSOLUTE_DIFFERENCE);
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -170,40 +169,36 @@ public class SingleColorLutPixelTest {
|
|||||||
.toGlTextureProcessor(context, /* useHdr= */ false);
|
.toGlTextureProcessor(context, /* useHdr= */ false);
|
||||||
Pair<Integer, Integer> outputSize = colorLutProcessor.configure(inputWidth, inputHeight);
|
Pair<Integer, Integer> outputSize = colorLutProcessor.configure(inputWidth, inputHeight);
|
||||||
setupOutputTexture(outputSize.first, outputSize.second);
|
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);
|
colorLutProcessor.drawFrame(inputTexId, /* presentationTimeUs = */ 0);
|
||||||
Bitmap actualBitmap =
|
Bitmap actualBitmap =
|
||||||
BitmapTestUtil.createArgb8888BitmapFromCurrentGlFramebuffer(
|
createArgb8888BitmapFromCurrentGlFramebuffer(outputSize.first, outputSize.second);
|
||||||
outputSize.first, outputSize.second);
|
|
||||||
|
|
||||||
BitmapTestUtil.maybeSaveTestBitmapToCacheDirectory(testId, "actual", actualBitmap);
|
maybeSaveTestBitmapToCacheDirectory(testId, "actual", actualBitmap);
|
||||||
float averagePixelAbsoluteDifference =
|
float averagePixelAbsoluteDifference =
|
||||||
BitmapTestUtil.getAveragePixelAbsoluteDifferenceArgb8888(
|
getBitmapAveragePixelAbsoluteDifferenceArgb8888(expectedBitmap, actualBitmap, testId);
|
||||||
expectedBitmap, actualBitmap, testId);
|
|
||||||
assertThat(averagePixelAbsoluteDifference).isAtMost(MAXIMUM_AVERAGE_PIXEL_ABSOLUTE_DIFFERENCE);
|
assertThat(averagePixelAbsoluteDifference).isAtMost(MAXIMUM_AVERAGE_PIXEL_ABSOLUTE_DIFFERENCE);
|
||||||
}
|
}
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
public void drawFrame_identityLutFromHaldImage_leavesFrameUnchanged() throws Exception {
|
public void drawFrame_identityLutFromHaldImage_leavesFrameUnchanged() throws Exception {
|
||||||
String testId = "drawFrame_identityLutFromHaldImage";
|
String testId = "drawFrame_identityLutFromHaldImage";
|
||||||
Bitmap bitmapLut = BitmapTestUtil.readBitmap(VERTICAL_HALD_IDENTITY_LUT);
|
Bitmap bitmapLut = readBitmap(VERTICAL_HALD_IDENTITY_LUT);
|
||||||
colorLutProcessor =
|
colorLutProcessor =
|
||||||
SingleColorLut.createFromBitmap(bitmapLut)
|
SingleColorLut.createFromBitmap(bitmapLut)
|
||||||
.toGlTextureProcessor(context, /* useHdr= */ false);
|
.toGlTextureProcessor(context, /* useHdr= */ false);
|
||||||
Pair<Integer, Integer> outputSize = colorLutProcessor.configure(inputWidth, inputHeight);
|
Pair<Integer, Integer> outputSize = colorLutProcessor.configure(inputWidth, inputHeight);
|
||||||
setupOutputTexture(outputSize.first, outputSize.second);
|
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);
|
colorLutProcessor.drawFrame(inputTexId, /* presentationTimeUs = */ 0);
|
||||||
Bitmap actualBitmap =
|
Bitmap actualBitmap =
|
||||||
BitmapTestUtil.createArgb8888BitmapFromCurrentGlFramebuffer(
|
createArgb8888BitmapFromCurrentGlFramebuffer(outputSize.first, outputSize.second);
|
||||||
outputSize.first, outputSize.second);
|
|
||||||
|
|
||||||
BitmapTestUtil.maybeSaveTestBitmapToCacheDirectory(testId, "actual", actualBitmap);
|
maybeSaveTestBitmapToCacheDirectory(testId, "actual", actualBitmap);
|
||||||
float averagePixelAbsoluteDifference =
|
float averagePixelAbsoluteDifference =
|
||||||
BitmapTestUtil.getAveragePixelAbsoluteDifferenceArgb8888(
|
getBitmapAveragePixelAbsoluteDifferenceArgb8888(expectedBitmap, actualBitmap, testId);
|
||||||
expectedBitmap, actualBitmap, testId);
|
|
||||||
assertThat(averagePixelAbsoluteDifference).isAtMost(MAXIMUM_AVERAGE_PIXEL_ABSOLUTE_DIFFERENCE);
|
assertThat(averagePixelAbsoluteDifference).isAtMost(MAXIMUM_AVERAGE_PIXEL_ABSOLUTE_DIFFERENCE);
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -218,63 +213,57 @@ public class SingleColorLutPixelTest {
|
|||||||
.toGlTextureProcessor(context, /* useHdr= */ false);
|
.toGlTextureProcessor(context, /* useHdr= */ false);
|
||||||
Pair<Integer, Integer> outputSize = colorLutProcessor.configure(inputWidth, inputHeight);
|
Pair<Integer, Integer> outputSize = colorLutProcessor.configure(inputWidth, inputHeight);
|
||||||
setupOutputTexture(outputSize.first, outputSize.second);
|
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);
|
colorLutProcessor.drawFrame(inputTexId, /* presentationTimeUs = */ 0);
|
||||||
Bitmap actualBitmap =
|
Bitmap actualBitmap =
|
||||||
BitmapTestUtil.createArgb8888BitmapFromCurrentGlFramebuffer(
|
createArgb8888BitmapFromCurrentGlFramebuffer(outputSize.first, outputSize.second);
|
||||||
outputSize.first, outputSize.second);
|
|
||||||
|
|
||||||
BitmapTestUtil.maybeSaveTestBitmapToCacheDirectory(testId, "actual", actualBitmap);
|
maybeSaveTestBitmapToCacheDirectory(testId, "actual", actualBitmap);
|
||||||
float averagePixelAbsoluteDifference =
|
float averagePixelAbsoluteDifference =
|
||||||
BitmapTestUtil.getAveragePixelAbsoluteDifferenceArgb8888(
|
getBitmapAveragePixelAbsoluteDifferenceArgb8888(expectedBitmap, actualBitmap, testId);
|
||||||
expectedBitmap, actualBitmap, testId);
|
|
||||||
assertThat(averagePixelAbsoluteDifference).isAtMost(MAXIMUM_AVERAGE_PIXEL_ABSOLUTE_DIFFERENCE);
|
assertThat(averagePixelAbsoluteDifference).isAtMost(MAXIMUM_AVERAGE_PIXEL_ABSOLUTE_DIFFERENCE);
|
||||||
}
|
}
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
public void drawFrame_applyInvertedLut_producesInvertedFrame() throws Exception {
|
public void drawFrame_applyInvertedLut_producesInvertedFrame() throws Exception {
|
||||||
String testId = "drawFrame_applyInvertedLut";
|
String testId = "drawFrame_applyInvertedLut";
|
||||||
Bitmap invertedLutBitmap = BitmapTestUtil.readBitmap(VERTICAL_HALD_INVERTED_LUT);
|
Bitmap invertedLutBitmap = readBitmap(VERTICAL_HALD_INVERTED_LUT);
|
||||||
colorLutProcessor =
|
colorLutProcessor =
|
||||||
SingleColorLut.createFromBitmap(invertedLutBitmap)
|
SingleColorLut.createFromBitmap(invertedLutBitmap)
|
||||||
.toGlTextureProcessor(context, /* useHdr= */ false);
|
.toGlTextureProcessor(context, /* useHdr= */ false);
|
||||||
Pair<Integer, Integer> outputSize = colorLutProcessor.configure(inputWidth, inputHeight);
|
Pair<Integer, Integer> outputSize = colorLutProcessor.configure(inputWidth, inputHeight);
|
||||||
setupOutputTexture(outputSize.first, outputSize.second);
|
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);
|
colorLutProcessor.drawFrame(inputTexId, /* presentationTimeUs = */ 0);
|
||||||
Bitmap actualBitmap =
|
Bitmap actualBitmap =
|
||||||
BitmapTestUtil.createArgb8888BitmapFromCurrentGlFramebuffer(
|
createArgb8888BitmapFromCurrentGlFramebuffer(outputSize.first, outputSize.second);
|
||||||
outputSize.first, outputSize.second);
|
|
||||||
|
|
||||||
BitmapTestUtil.maybeSaveTestBitmapToCacheDirectory(testId, "actual", actualBitmap);
|
maybeSaveTestBitmapToCacheDirectory(testId, "actual", actualBitmap);
|
||||||
float averagePixelAbsoluteDifference =
|
float averagePixelAbsoluteDifference =
|
||||||
BitmapTestUtil.getAveragePixelAbsoluteDifferenceArgb8888(
|
getBitmapAveragePixelAbsoluteDifferenceArgb8888(expectedBitmap, actualBitmap, testId);
|
||||||
expectedBitmap, actualBitmap, testId);
|
|
||||||
assertThat(averagePixelAbsoluteDifference).isAtMost(MAXIMUM_AVERAGE_PIXEL_ABSOLUTE_DIFFERENCE);
|
assertThat(averagePixelAbsoluteDifference).isAtMost(MAXIMUM_AVERAGE_PIXEL_ABSOLUTE_DIFFERENCE);
|
||||||
}
|
}
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
public void drawFrame_applyGrayscaleLut_producesGrayscaleFrame() throws Exception {
|
public void drawFrame_applyGrayscaleLut_producesGrayscaleFrame() throws Exception {
|
||||||
String testId = "drawFrame_applyGrayscaleLut";
|
String testId = "drawFrame_applyGrayscaleLut";
|
||||||
Bitmap grayscaleLutBitmap = BitmapTestUtil.readBitmap(VERTICAL_HALD_GRAYSCALE_LUT);
|
Bitmap grayscaleLutBitmap = readBitmap(VERTICAL_HALD_GRAYSCALE_LUT);
|
||||||
colorLutProcessor =
|
colorLutProcessor =
|
||||||
SingleColorLut.createFromBitmap(grayscaleLutBitmap)
|
SingleColorLut.createFromBitmap(grayscaleLutBitmap)
|
||||||
.toGlTextureProcessor(context, /* useHdr= */ false);
|
.toGlTextureProcessor(context, /* useHdr= */ false);
|
||||||
Pair<Integer, Integer> outputSize = colorLutProcessor.configure(inputWidth, inputHeight);
|
Pair<Integer, Integer> outputSize = colorLutProcessor.configure(inputWidth, inputHeight);
|
||||||
setupOutputTexture(outputSize.first, outputSize.second);
|
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);
|
colorLutProcessor.drawFrame(inputTexId, /* presentationTimeUs = */ 0);
|
||||||
Bitmap actualBitmap =
|
Bitmap actualBitmap =
|
||||||
BitmapTestUtil.createArgb8888BitmapFromCurrentGlFramebuffer(
|
createArgb8888BitmapFromCurrentGlFramebuffer(outputSize.first, outputSize.second);
|
||||||
outputSize.first, outputSize.second);
|
|
||||||
|
|
||||||
BitmapTestUtil.maybeSaveTestBitmapToCacheDirectory(testId, "actual", actualBitmap);
|
maybeSaveTestBitmapToCacheDirectory(testId, "actual", actualBitmap);
|
||||||
float averagePixelAbsoluteDifference =
|
float averagePixelAbsoluteDifference =
|
||||||
BitmapTestUtil.getAveragePixelAbsoluteDifferenceArgb8888(
|
getBitmapAveragePixelAbsoluteDifferenceArgb8888(expectedBitmap, actualBitmap, testId);
|
||||||
expectedBitmap, 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