Remove possibly retained bitmap reference
PiperOrigin-RevId: 580579054
This commit is contained in:
parent
508582d56c
commit
f172923f0d
@ -229,6 +229,8 @@ public final class DefaultVideoFrameProcessorPixelTest {
|
|||||||
.setEffects(NO_OP_EFFECT)
|
.setEffects(NO_OP_EFFECT)
|
||||||
.build();
|
.build();
|
||||||
Bitmap originalBitmap = readBitmap(IMAGE_JPG_ASSET_PATH);
|
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(
|
videoFrameProcessorTestRunner.queueInputBitmap(
|
||||||
originalBitmap, C.MICROS_PER_SECOND, /* offsetToAddUs= */ 0L, /* frameRate= */ 1);
|
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.
|
// TODO(b/207848601): Switch to using proper tooling for testing against golden data.
|
||||||
float averagePixelAbsoluteDifference =
|
float averagePixelAbsoluteDifference =
|
||||||
getBitmapAveragePixelAbsoluteDifferenceArgb8888(originalBitmap, actualBitmap, testId);
|
getBitmapAveragePixelAbsoluteDifferenceArgb8888(expectedBitmap, actualBitmap, testId);
|
||||||
assertThat(averagePixelAbsoluteDifference).isAtMost(MAXIMUM_AVERAGE_PIXEL_ABSOLUTE_DIFFERENCE);
|
assertThat(averagePixelAbsoluteDifference).isAtMost(MAXIMUM_AVERAGE_PIXEL_ABSOLUTE_DIFFERENCE);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -53,9 +53,11 @@ import org.checkerframework.checker.nullness.qual.MonotonicNonNull;
|
|||||||
|
|
||||||
private @MonotonicNonNull GlTextureInfo currentGlTextureInfo;
|
private @MonotonicNonNull GlTextureInfo currentGlTextureInfo;
|
||||||
private int downstreamShaderProgramCapacity;
|
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 useHdr;
|
||||||
|
|
||||||
private boolean currentInputStreamEnded;
|
private boolean currentInputStreamEnded;
|
||||||
private boolean isNextFrameInTexture;
|
private boolean isNextFrameInTexture;
|
||||||
|
|
||||||
@ -127,6 +129,7 @@ import org.checkerframework.checker.nullness.qual.MonotonicNonNull;
|
|||||||
if (currentGlTextureInfo != null) {
|
if (currentGlTextureInfo != null) {
|
||||||
currentGlTextureInfo.release();
|
currentGlTextureInfo.release();
|
||||||
}
|
}
|
||||||
|
pendingBitmaps.clear();
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -174,7 +177,8 @@ import org.checkerframework.checker.nullness.qual.MonotonicNonNull;
|
|||||||
|
|
||||||
if (!currentBitmapInfo.inStreamOffsetsUs.hasNext()) {
|
if (!currentBitmapInfo.inStreamOffsetsUs.hasNext()) {
|
||||||
isNextFrameInTexture = false;
|
isNextFrameInTexture = false;
|
||||||
pendingBitmaps.remove();
|
BitmapFrameSequenceInfo finishedBitmapInfo = pendingBitmaps.remove();
|
||||||
|
finishedBitmapInfo.bitmap.recycle();
|
||||||
if (pendingBitmaps.isEmpty() && currentInputStreamEnded) {
|
if (pendingBitmaps.isEmpty() && currentInputStreamEnded) {
|
||||||
// Only signal end of stream after all pending bitmaps are processed.
|
// Only signal end of stream after all pending bitmaps are processed.
|
||||||
shaderProgram.signalEndOfCurrentInputStream();
|
shaderProgram.signalEndOfCurrentInputStream();
|
||||||
|
Loading…
x
Reference in New Issue
Block a user