Remove possibly retained bitmap reference

PiperOrigin-RevId: 580579054
This commit is contained in:
claincly 2023-11-08 10:37:02 -08:00 committed by Copybara-Service
parent 508582d56c
commit f172923f0d
2 changed files with 10 additions and 4 deletions

View File

@ -229,6 +229,8 @@ public final class DefaultVideoFrameProcessorPixelTest {
.setEffects(NO_OP_EFFECT)
.build();
Bitmap originalBitmap = readBitmap(IMAGE_JPG_ASSET_PATH);
// VideoFrameProcessor recycles the original bitmap so it cannot be used for comparison.
Bitmap expectedBitmap = originalBitmap.copy(Bitmap.Config.ARGB_8888, /* isMutable= */ false);
videoFrameProcessorTestRunner.queueInputBitmap(
originalBitmap, C.MICROS_PER_SECOND, /* offsetToAddUs= */ 0L, /* frameRate= */ 1);
@ -237,7 +239,7 @@ public final class DefaultVideoFrameProcessorPixelTest {
// TODO(b/207848601): Switch to using proper tooling for testing against golden data.
float averagePixelAbsoluteDifference =
getBitmapAveragePixelAbsoluteDifferenceArgb8888(originalBitmap, actualBitmap, testId);
getBitmapAveragePixelAbsoluteDifferenceArgb8888(expectedBitmap, actualBitmap, testId);
assertThat(averagePixelAbsoluteDifference).isAtMost(MAXIMUM_AVERAGE_PIXEL_ABSOLUTE_DIFFERENCE);
}

View File

@ -53,9 +53,11 @@ import org.checkerframework.checker.nullness.qual.MonotonicNonNull;
private @MonotonicNonNull GlTextureInfo currentGlTextureInfo;
private int downstreamShaderProgramCapacity;
// TODO - b/262693274: Support HDR. Currently this variable is not used and will trigger error
// prone warning.
// TODO - b/262693274: Support HDR.
@SuppressWarnings({"UnusedVariable", "FieldCanBeLocal"})
private boolean useHdr;
private boolean currentInputStreamEnded;
private boolean isNextFrameInTexture;
@ -127,6 +129,7 @@ import org.checkerframework.checker.nullness.qual.MonotonicNonNull;
if (currentGlTextureInfo != null) {
currentGlTextureInfo.release();
}
pendingBitmaps.clear();
});
}
@ -174,7 +177,8 @@ import org.checkerframework.checker.nullness.qual.MonotonicNonNull;
if (!currentBitmapInfo.inStreamOffsetsUs.hasNext()) {
isNextFrameInTexture = false;
pendingBitmaps.remove();
BitmapFrameSequenceInfo finishedBitmapInfo = pendingBitmaps.remove();
finishedBitmapInfo.bitmap.recycle();
if (pendingBitmaps.isEmpty() && currentInputStreamEnded) {
// Only signal end of stream after all pending bitmaps are processed.
shaderProgram.signalEndOfCurrentInputStream();