Reset the simple frame dropping logic on flush or EOS.

#minor-release

PiperOrigin-RevId: 540633875
This commit is contained in:
tofunmi 2023-06-15 19:07:48 +01:00 committed by Marc Baechinger
parent be9b057dda
commit 251fb013c3
3 changed files with 29 additions and 2 deletions

View File

@ -97,12 +97,13 @@ public class FrameDropTest {
/* expectedFrameRate= */ 6, /* targetFrameRate= */ 2))
.build();
videoFrameProcessorTestRunner.registerAndQueueInputBitmap(
videoFrameProcessorTestRunner.registerInputStream(INPUT_TYPE_BITMAP);
videoFrameProcessorTestRunner.queueInputBitmap(
readBitmap(ORIGINAL_PNG_ASSET_PATH),
/* durationUs= */ C.MICROS_PER_SECOND,
/* offsetToAddUs= */ 0L,
/* frameRate= */ 4);
videoFrameProcessorTestRunner.registerAndQueueInputBitmap(
videoFrameProcessorTestRunner.queueInputBitmap(
readBitmap(SCALE_WIDE_PNG_ASSET_PATH),
/* durationUs= */ C.MICROS_PER_SECOND,
/* offsetToAddUs= */ C.MICROS_PER_SECOND,

View File

@ -63,4 +63,16 @@ import androidx.media3.common.VideoFrameProcessingException;
inputListener.onReadyToAcceptInputFrame();
}
}
@Override
public void signalEndOfCurrentInputStream() {
super.signalEndOfCurrentInputStream();
framesReceived = 0;
}
@Override
public void flush() {
super.flush();
framesReceived = 0;
}
}

View File

@ -342,6 +342,20 @@ public final class VideoFrameProcessorTestRunner {
endFrameProcessing();
}
public void registerInputStream(@InputType int inputType) {
videoFrameProcessor.registerInputStream(inputType, ImmutableList.of());
}
public void queueInputBitmap(
Bitmap inputBitmap, long durationUs, long offsetToAddUs, float frameRate) {
videoFrameProcessor.setInputFrameInfo(
new FrameInfo.Builder(inputBitmap.getWidth(), inputBitmap.getHeight())
.setPixelWidthHeightRatio(pixelWidthHeightRatio)
.setOffsetToAddUs(offsetToAddUs)
.build());
videoFrameProcessor.queueInputBitmap(inputBitmap, durationUs, frameRate);
}
public void registerAndQueueInputBitmap(
Bitmap inputBitmap, long durationUs, long offsetToAddUs, float frameRate) {
videoFrameProcessor.setInputFrameInfo(