mirror of
https://github.com/samsonjs/media.git
synced 2026-04-09 11:55:46 +00:00
Compositor: Add 10 frame test.
This serves as a sort of test with more frames for the compositor for now (before more varied video system tests come later when integrating with Transformer), showing it doesn't error out and outputs the right amount of frames. Due to the VFPTestRunner having a 5s timeout, and mostly due to presubmit emulators being very slow with OpenGL, there is a sort of limitation to how many frames this type of test can have, depending on the test target PiperOrigin-RevId: 548159762
This commit is contained in:
parent
2261756d3a
commit
8c4aa6b75d
1 changed files with 55 additions and 11 deletions
|
|
@ -44,10 +44,10 @@ import androidx.media3.test.utils.VideoFrameProcessorTestRunner;
|
|||
import com.google.common.collect.ImmutableList;
|
||||
import java.io.IOException;
|
||||
import java.util.List;
|
||||
import java.util.Set;
|
||||
import java.util.concurrent.CopyOnWriteArrayList;
|
||||
import java.util.concurrent.CountDownLatch;
|
||||
import java.util.concurrent.ExecutorService;
|
||||
import java.util.concurrent.atomic.AtomicInteger;
|
||||
import java.util.concurrent.atomic.AtomicReference;
|
||||
import org.checkerframework.checker.nullness.qual.MonotonicNonNull;
|
||||
import org.checkerframework.checker.nullness.qual.Nullable;
|
||||
|
|
@ -114,16 +114,14 @@ public final class VideoCompositorPixelTest {
|
|||
|
||||
videoCompositorTestRunner.queueBitmapsToBothInputs(/* count= */ 1);
|
||||
|
||||
Bitmap actualCompositorInputBitmap1 = videoCompositorTestRunner.inputBitmapReader1.getBitmap();
|
||||
saveAndAssertBitmapMatchesExpected(
|
||||
testId,
|
||||
actualCompositorInputBitmap1,
|
||||
videoCompositorTestRunner.inputBitmapReader1.getBitmap(),
|
||||
/* actualBitmapLabel= */ "actualCompositorInputBitmap1",
|
||||
GRAYSCALE_PNG_ASSET_PATH);
|
||||
Bitmap actualCompositorInputBitmap2 = videoCompositorTestRunner.inputBitmapReader2.getBitmap();
|
||||
saveAndAssertBitmapMatchesExpected(
|
||||
testId,
|
||||
actualCompositorInputBitmap2,
|
||||
videoCompositorTestRunner.inputBitmapReader2.getBitmap(),
|
||||
/* actualBitmapLabel= */ "actualCompositorInputBitmap2",
|
||||
ROTATE180_PNG_ASSET_PATH);
|
||||
saveAndAssertBitmapMatchesExpected(
|
||||
|
|
@ -176,12 +174,12 @@ public final class VideoCompositorPixelTest {
|
|||
2L * C.MICROS_PER_SECOND,
|
||||
3L * C.MICROS_PER_SECOND,
|
||||
4L * C.MICROS_PER_SECOND);
|
||||
Set<Long> inputTimestampsSource1 =
|
||||
videoCompositorTestRunner.inputBitmapReader1.getOutputTimestamps();
|
||||
assertThat(inputTimestampsSource1).containsExactlyElementsIn(expectedTimestamps).inOrder();
|
||||
Set<Long> inputTimestampsSource2 =
|
||||
videoCompositorTestRunner.inputBitmapReader2.getOutputTimestamps();
|
||||
assertThat(inputTimestampsSource2).containsExactlyElementsIn(expectedTimestamps).inOrder();
|
||||
assertThat(videoCompositorTestRunner.inputBitmapReader1.getOutputTimestamps())
|
||||
.containsExactlyElementsIn(expectedTimestamps)
|
||||
.inOrder();
|
||||
assertThat(videoCompositorTestRunner.inputBitmapReader2.getOutputTimestamps())
|
||||
.containsExactlyElementsIn(expectedTimestamps)
|
||||
.inOrder();
|
||||
assertThat(compositorTimestamps).containsExactlyElementsIn(expectedTimestamps).inOrder();
|
||||
saveAndAssertBitmapMatchesExpected(
|
||||
testId,
|
||||
|
|
@ -190,6 +188,52 @@ public final class VideoCompositorPixelTest {
|
|||
GRAYSCALE_AND_ROTATE180_COMPOSITE_PNG_ASSET_PATH);
|
||||
}
|
||||
|
||||
@Test
|
||||
public void compositeTwoInputs_withTenFramesFromEach_matchesExpectedFrameCount()
|
||||
throws Exception {
|
||||
String testId =
|
||||
"compositeTwoInputs_withTenFramesFromEach_matchesExpectedFrameCount[useSharedExecutor="
|
||||
+ useSharedExecutor
|
||||
+ "]";
|
||||
AtomicInteger compositedFrameCount = new AtomicInteger();
|
||||
AtomicReference<Bitmap> compositedFirstOutputBitmap = new AtomicReference<>();
|
||||
videoCompositorTestRunner =
|
||||
new VideoCompositorTestRunner(
|
||||
testId,
|
||||
(outputTexture, presentationTimeUs, releaseOutputTextureCallback, syncObject) -> {
|
||||
try {
|
||||
if (!useSharedExecutor) {
|
||||
GlUtil.awaitSyncObject(syncObject);
|
||||
}
|
||||
if (compositedFirstOutputBitmap.get() == null) {
|
||||
compositedFirstOutputBitmap.set(
|
||||
BitmapPixelTestUtil.createArgb8888BitmapFromFocusedGlFramebuffer(
|
||||
outputTexture.width, outputTexture.height));
|
||||
}
|
||||
compositedFrameCount.incrementAndGet();
|
||||
} catch (GlUtil.GlException e) {
|
||||
throw VideoFrameProcessingException.from(e);
|
||||
} finally {
|
||||
releaseOutputTextureCallback.release(presentationTimeUs);
|
||||
}
|
||||
},
|
||||
useSharedExecutor);
|
||||
int numberOfFramesToQueue = 10;
|
||||
|
||||
videoCompositorTestRunner.queueBitmapsToBothInputs(numberOfFramesToQueue);
|
||||
|
||||
assertThat(videoCompositorTestRunner.inputBitmapReader1.getOutputTimestamps())
|
||||
.hasSize(numberOfFramesToQueue);
|
||||
assertThat(videoCompositorTestRunner.inputBitmapReader2.getOutputTimestamps())
|
||||
.hasSize(numberOfFramesToQueue);
|
||||
assertThat(compositedFrameCount.get()).isEqualTo(numberOfFramesToQueue);
|
||||
saveAndAssertBitmapMatchesExpected(
|
||||
testId,
|
||||
compositedFirstOutputBitmap.get(),
|
||||
/* actualBitmapLabel= */ "compositorOutputBitmap",
|
||||
GRAYSCALE_AND_ROTATE180_COMPOSITE_PNG_ASSET_PATH);
|
||||
}
|
||||
|
||||
/**
|
||||
* A test runner for {@link VideoCompositor tests} tests.
|
||||
*
|
||||
|
|
|
|||
Loading…
Reference in a new issue