Skip to content

Commit

Permalink
rename videoFrameProcessorTestRunner.queueInputBitmap
Browse files Browse the repository at this point in the history
This methods currently registers and queues the bitmaps Will need to have a method that just queues bitmaps in future CLs.

#minor-release

PiperOrigin-RevId: 539605628
  • Loading branch information
tof-tof committed Jun 12, 2023
1 parent 5f43180 commit 219212d
Show file tree
Hide file tree
Showing 5 changed files with 24 additions and 23 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -65,17 +65,17 @@ public void imageInput_queueThreeBitmaps_outputsCorrectNumberOfFrames() throws E
String testId = "imageInput_queueThreeBitmaps_outputsCorrectNumberOfFrames";
videoFrameProcessorTestRunner = getDefaultFrameProcessorTestRunnerBuilder(testId).build();

videoFrameProcessorTestRunner.queueInputBitmap(
videoFrameProcessorTestRunner.registerAndQueueInputBitmap(
readBitmap(ORIGINAL_PNG_ASSET_PATH),
C.MICROS_PER_SECOND,
/* offsetToAddUs= */ 0L,
/* frameRate= */ 2);
videoFrameProcessorTestRunner.queueInputBitmap(
videoFrameProcessorTestRunner.registerAndQueueInputBitmap(
readBitmap(SCALE_WIDE_PNG_ASSET_PATH),
2 * C.MICROS_PER_SECOND,
/* offsetToAddUs= */ 0L,
/* frameRate= */ 3);
videoFrameProcessorTestRunner.queueInputBitmap(
videoFrameProcessorTestRunner.registerAndQueueInputBitmap(
readBitmap(BITMAP_OVERLAY_PNG_ASSET_PATH),
3 * C.MICROS_PER_SECOND,
/* offsetToAddUs= */ 0L,
Expand All @@ -93,7 +93,7 @@ public void imageInput_queueTwentyBitmaps_outputsCorrectNumberOfFrames() throws
videoFrameProcessorTestRunner = getDefaultFrameProcessorTestRunnerBuilder(testId).build();

for (int i = 0; i < 20; i++) {
videoFrameProcessorTestRunner.queueInputBitmap(
videoFrameProcessorTestRunner.registerAndQueueInputBitmap(
readBitmap(ORIGINAL_PNG_ASSET_PATH),
/* durationUs= */ C.MICROS_PER_SECOND,
/* offsetToAddUs= */ 0L,
Expand All @@ -118,7 +118,7 @@ public void imageInput_queueOneWithStartOffset_outputsFramesAtTheCorrectPresenta
.build();

long offsetUs = 1_000_000L;
videoFrameProcessorTestRunner.queueInputBitmap(
videoFrameProcessorTestRunner.registerAndQueueInputBitmap(
readBitmap(ORIGINAL_PNG_ASSET_PATH),
/* durationUs= */ C.MICROS_PER_SECOND,
/* offsetToAddUs= */ offsetUs,
Expand All @@ -141,13 +141,13 @@ public void imageInput_queueWithStartOffsets_outputsFramesAtTheCorrectPresentati
.build();

long offsetUs1 = 1_000_000L;
videoFrameProcessorTestRunner.queueInputBitmap(
videoFrameProcessorTestRunner.registerAndQueueInputBitmap(
readBitmap(ORIGINAL_PNG_ASSET_PATH),
/* durationUs= */ C.MICROS_PER_SECOND,
/* offsetToAddUs= */ offsetUs1,
/* frameRate= */ 2);
long offsetUs2 = 2_000_000L;
videoFrameProcessorTestRunner.queueInputBitmap(
videoFrameProcessorTestRunner.registerAndQueueInputBitmap(
readBitmap(SCALE_WIDE_PNG_ASSET_PATH),
/* durationUs= */ C.MICROS_PER_SECOND,
/* offsetToAddUs= */ offsetUs2,
Expand Down Expand Up @@ -175,13 +175,13 @@ public void imageInput_queueWithStartOffsets_outputsFramesAtTheCorrectPresentati
.setOnOutputFrameAvailableForRenderingListener(actualPresentationTimesUs::add)
.build();

videoFrameProcessorTestRunner.queueInputBitmap(
videoFrameProcessorTestRunner.registerAndQueueInputBitmap(
readBitmap(ORIGINAL_PNG_ASSET_PATH),
/* durationUs= */ C.MICROS_PER_SECOND,
/* offsetToAddUs= */ 0L,
/* frameRate= */ 2);
videoFrameProcessorTestRunner.endFrameProcessing();
videoFrameProcessorTestRunner.queueInputBitmap(
videoFrameProcessorTestRunner.registerAndQueueInputBitmap(
readBitmap(ORIGINAL_PNG_ASSET_PATH),
/* durationUs= */ 2 * C.MICROS_PER_SECOND,
/* offsetToAddUs= */ 0L,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -164,7 +164,7 @@ public void noEffects_withImageInput_matchesGoldenFile() throws Exception {
Bitmap originalBitmap = readBitmap(IMAGE_PNG_ASSET_PATH);
Bitmap expectedBitmap = readBitmap(IMAGE_TO_VIDEO_PNG_ASSET_PATH);

videoFrameProcessorTestRunner.queueInputBitmap(
videoFrameProcessorTestRunner.registerAndQueueInputBitmap(
originalBitmap, C.MICROS_PER_SECOND, /* offsetToAddUs= */ 0L, /* frameRate= */ 1);
videoFrameProcessorTestRunner.endFrameProcessing();
Bitmap actualBitmap = videoFrameProcessorTestRunner.getOutputBitmap();
Expand Down Expand Up @@ -193,7 +193,7 @@ public void wrappedCrop_withImageInput_matchesGoldenFile() throws Exception {
Bitmap originalBitmap = readBitmap(IMAGE_PNG_ASSET_PATH);
Bitmap expectedBitmap = readBitmap(IMAGE_TO_CROPPED_VIDEO_PNG_ASSET_PATH);

videoFrameProcessorTestRunner.queueInputBitmap(
videoFrameProcessorTestRunner.registerAndQueueInputBitmap(
originalBitmap, C.MICROS_PER_SECOND, /* offsetToAddUs= */ 0L, /* frameRate= */ 1);
videoFrameProcessorTestRunner.endFrameProcessing();
Bitmap actualBitmap = videoFrameProcessorTestRunner.getOutputBitmap();
Expand All @@ -220,7 +220,7 @@ public void noOpEffect_withImageInputAndDisabledColorTransfers_matchesGoldenFile
.build();
Bitmap originalBitmap = readBitmap(IMAGE_PNG_ASSET_PATH);

videoFrameProcessorTestRunner.queueInputBitmap(
videoFrameProcessorTestRunner.registerAndQueueInputBitmap(
originalBitmap, C.MICROS_PER_SECOND, /* offsetToAddUs= */ 0L, /* frameRate= */ 1);
videoFrameProcessorTestRunner.endFrameProcessing();
Bitmap actualBitmap = videoFrameProcessorTestRunner.getOutputBitmap();
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -74,7 +74,7 @@ public void frameDrop_withDefaultStrategy_outputsFramesAtTheCorrectPresentationT

ImmutableList<Integer> timestampsMs = ImmutableList.of(0, 16, 32, 48, 58, 71, 86);
for (int timestampMs : timestampsMs) {
videoFrameProcessorTestRunner.queueInputBitmap(
videoFrameProcessorTestRunner.registerAndQueueInputBitmap(
readBitmap(ORIGINAL_PNG_ASSET_PATH),
/* durationUs= */ C.MICROS_PER_SECOND,
/* offsetToAddUs= */ timestampMs * 1000L,
Expand All @@ -97,12 +97,12 @@ public void frameDrop_withSimpleStrategy_outputsFramesAtTheCorrectPresentationTi
/* expectedFrameRate= */ 6, /* targetFrameRate= */ 2))
.build();

videoFrameProcessorTestRunner.queueInputBitmap(
videoFrameProcessorTestRunner.registerAndQueueInputBitmap(
readBitmap(ORIGINAL_PNG_ASSET_PATH),
/* durationUs= */ C.MICROS_PER_SECOND,
/* offsetToAddUs= */ 0L,
/* frameRate= */ 4);
videoFrameProcessorTestRunner.queueInputBitmap(
videoFrameProcessorTestRunner.registerAndQueueInputBitmap(
readBitmap(SCALE_WIDE_PNG_ASSET_PATH),
/* durationUs= */ C.MICROS_PER_SECOND,
/* offsetToAddUs= */ C.MICROS_PER_SECOND,
Expand All @@ -123,7 +123,7 @@ public void frameDrop_withSimpleStrategy_outputsAllFrames() throws Exception {
/* expectedFrameRate= */ 3, /* targetFrameRate= */ 3))
.build();

videoFrameProcessorTestRunner.queueInputBitmap(
videoFrameProcessorTestRunner.registerAndQueueInputBitmap(
readBitmap(ORIGINAL_PNG_ASSET_PATH),
/* durationUs= */ C.MICROS_PER_SECOND,
/* offsetToAddUs= */ 0L,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -42,6 +42,7 @@
import androidx.media3.common.SurfaceInfo;
import androidx.media3.common.VideoFrameProcessingException;
import androidx.media3.common.VideoFrameProcessor;
import androidx.media3.common.VideoFrameProcessor.InputType;
import androidx.media3.common.util.GlUtil;
import androidx.media3.common.util.UnstableApi;
import com.google.common.collect.ImmutableList;
Expand Down Expand Up @@ -70,7 +71,7 @@ public static final class Builder {
private float pixelWidthHeightRatio;
private @MonotonicNonNull ColorInfo inputColorInfo;
private @MonotonicNonNull ColorInfo outputColorInfo;
private @VideoFrameProcessor.InputType int inputType;
private @InputType int inputType;
private OnOutputFrameAvailableForRenderingListener onOutputFrameAvailableListener;

/** Creates a new instance with default values. */
Expand Down Expand Up @@ -199,7 +200,7 @@ public Builder setOutputColorInfo(ColorInfo outputColorInfo) {
* <p>The default value is {@link VideoFrameProcessor#INPUT_TYPE_SURFACE}.
*/
@CanIgnoreReturnValue
public Builder setInputType(@VideoFrameProcessor.InputType int inputType) {
public Builder setInputType(@InputType int inputType) {
this.inputType = inputType;
return this;
}
Expand Down Expand Up @@ -263,7 +264,7 @@ private VideoFrameProcessorTestRunner(
float pixelWidthHeightRatio,
ColorInfo inputColorInfo,
ColorInfo outputColorInfo,
@VideoFrameProcessor.InputType int inputType,
@InputType int inputType,
OnOutputFrameAvailableForRenderingListener onOutputFrameAvailableForRenderingListener)
throws VideoFrameProcessingException {
this.testId = testId;
Expand Down Expand Up @@ -341,7 +342,7 @@ public void onFrameDecoded(MediaFormat mediaFormat) {
endFrameProcessing();
}

public void queueInputBitmap(
public void registerAndQueueInputBitmap(
Bitmap inputBitmap, long durationUs, long offsetToAddUs, float frameRate) {
videoFrameProcessor.setInputFrameInfo(
new FrameInfo.Builder(inputBitmap.getWidth(), inputBitmap.getHeight())
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -68,7 +68,7 @@ public void textureOutput_queueBitmap_matchesGoldenFile() throws Exception {
videoFrameProcessorTestRunner = getFrameProcessorTestRunnerBuilder(testId).build();

long offsetUs = 1_000_000L;
videoFrameProcessorTestRunner.queueInputBitmap(
videoFrameProcessorTestRunner.registerAndQueueInputBitmap(
readBitmap(ORIGINAL_PNG_ASSET_PATH),
/* durationUs= */ 3 * C.MICROS_PER_SECOND,
/* offsetToAddUs= */ offsetUs,
Expand All @@ -95,13 +95,13 @@ public void textureOutput_queueTwoBitmaps_matchesGoldenFiles() throws Exception
videoFrameProcessorTestRunner = getFrameProcessorTestRunnerBuilder(testId).build();

long offsetUs1 = 1_000_000L;
videoFrameProcessorTestRunner.queueInputBitmap(
videoFrameProcessorTestRunner.registerAndQueueInputBitmap(
readBitmap(ORIGINAL_PNG_ASSET_PATH),
/* durationUs= */ C.MICROS_PER_SECOND,
/* offsetToAddUs= */ offsetUs1,
/* frameRate= */ 2);
long offsetUs2 = 2_000_000L;
videoFrameProcessorTestRunner.queueInputBitmap(
videoFrameProcessorTestRunner.registerAndQueueInputBitmap(
readBitmap(MEDIA3_TEST_PNG_ASSET_PATH),
/* durationUs= */ 3 * C.MICROS_PER_SECOND,
/* offsetToAddUs= */ offsetUs2,
Expand Down

0 comments on commit 219212d

Please sign in to comment.