VideoFrameProcessorTestRunner add support for portrait video

Fixes test failures due to differences test util bug that introduced
a crop in external texture sampling

PiperOrigin-RevId: 705061267
This commit is contained in:
dancho 2024-12-11 04:42:01 -08:00 committed by Copybara-Service
parent 8d2f531470
commit f55e0f3a3f
6 changed files with 14 additions and 5 deletions

Binary file not shown.

Before

Width:  |  Height:  |  Size: 1.4 MiB

After

Width:  |  Height:  |  Size: 1.8 MiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 1.3 MiB

After

Width:  |  Height:  |  Size: 1.6 MiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 1.7 MiB

After

Width:  |  Height:  |  Size: 2.0 MiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 1.7 MiB

After

Width:  |  Height:  |  Size: 1.5 MiB

View File

@ -328,6 +328,7 @@ public final class VideoFrameProcessorTestRunner {
this.effects = effects;
}
@SuppressLint("InlinedApi") // Inlined MediaFormat keys.
public void processFirstFrameAndEnd() throws Exception {
DecodeOneFrameUtil.decodeOneAssetFileFrame(
checkNotNull(videoAssetPath),
@ -336,12 +337,22 @@ public final class VideoFrameProcessorTestRunner {
public void onContainerExtracted(MediaFormat mediaFormat) {
videoFrameProcessorReadyCondition.close();
@Nullable ColorInfo colorInfo = MediaFormatUtil.getColorInfo(mediaFormat);
int rotationDegrees =
MediaFormatUtil.getInteger(
mediaFormat, MediaFormat.KEY_ROTATION, /* defaultValue= */ 0);
int width = mediaFormat.getInteger(MediaFormat.KEY_WIDTH);
int height = mediaFormat.getInteger(MediaFormat.KEY_HEIGHT);
if (rotationDegrees % 180 == 90) {
int tmp = width;
width = height;
height = tmp;
}
videoFrameProcessor.registerInputStream(
INPUT_TYPE_SURFACE,
new Format.Builder()
.setColorInfo(colorInfo == null ? ColorInfo.SDR_BT709_LIMITED : colorInfo)
.setWidth(mediaFormat.getInteger(MediaFormat.KEY_WIDTH))
.setHeight(mediaFormat.getInteger(MediaFormat.KEY_HEIGHT))
.setWidth(width)
.setHeight(height)
.setPixelWidthHeightRatio(pixelWidthHeightRatio)
.build(),
effects,

View File

@ -389,9 +389,7 @@ public final class DefaultVideoFrameProcessorTextureOutputPixelTest {
videoFrameProcessorTestRunner.processFirstFrameAndEnd();
Bitmap actualBitmap = videoFrameProcessorTestRunner.getOutputBitmap();
// TODO: b/376016540 - use HDR_PSNR_THRESHOLD when HDR videos are processed with high floating
// point precision.
assertBitmapsAreSimilar(expectedBitmap, actualBitmap, /* psnrThresholdDb= */ 42.5);
assertBitmapsAreSimilar(expectedBitmap, actualBitmap, HDR_PSNR_THRESHOLD);
}
@Test