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
Before Width: | Height: | Size: 1.4 MiB After Width: | Height: | Size: 1.8 MiB |
Before Width: | Height: | Size: 1.3 MiB After Width: | Height: | Size: 1.6 MiB |
Before Width: | Height: | Size: 1.7 MiB After Width: | Height: | Size: 2.0 MiB |
Before Width: | Height: | Size: 1.7 MiB After Width: | Height: | Size: 1.5 MiB |
@ -328,6 +328,7 @@ public final class VideoFrameProcessorTestRunner {
|
|||||||
this.effects = effects;
|
this.effects = effects;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@SuppressLint("InlinedApi") // Inlined MediaFormat keys.
|
||||||
public void processFirstFrameAndEnd() throws Exception {
|
public void processFirstFrameAndEnd() throws Exception {
|
||||||
DecodeOneFrameUtil.decodeOneAssetFileFrame(
|
DecodeOneFrameUtil.decodeOneAssetFileFrame(
|
||||||
checkNotNull(videoAssetPath),
|
checkNotNull(videoAssetPath),
|
||||||
@ -336,12 +337,22 @@ public final class VideoFrameProcessorTestRunner {
|
|||||||
public void onContainerExtracted(MediaFormat mediaFormat) {
|
public void onContainerExtracted(MediaFormat mediaFormat) {
|
||||||
videoFrameProcessorReadyCondition.close();
|
videoFrameProcessorReadyCondition.close();
|
||||||
@Nullable ColorInfo colorInfo = MediaFormatUtil.getColorInfo(mediaFormat);
|
@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(
|
videoFrameProcessor.registerInputStream(
|
||||||
INPUT_TYPE_SURFACE,
|
INPUT_TYPE_SURFACE,
|
||||||
new Format.Builder()
|
new Format.Builder()
|
||||||
.setColorInfo(colorInfo == null ? ColorInfo.SDR_BT709_LIMITED : colorInfo)
|
.setColorInfo(colorInfo == null ? ColorInfo.SDR_BT709_LIMITED : colorInfo)
|
||||||
.setWidth(mediaFormat.getInteger(MediaFormat.KEY_WIDTH))
|
.setWidth(width)
|
||||||
.setHeight(mediaFormat.getInteger(MediaFormat.KEY_HEIGHT))
|
.setHeight(height)
|
||||||
.setPixelWidthHeightRatio(pixelWidthHeightRatio)
|
.setPixelWidthHeightRatio(pixelWidthHeightRatio)
|
||||||
.build(),
|
.build(),
|
||||||
effects,
|
effects,
|
||||||
|
@ -389,9 +389,7 @@ public final class DefaultVideoFrameProcessorTextureOutputPixelTest {
|
|||||||
videoFrameProcessorTestRunner.processFirstFrameAndEnd();
|
videoFrameProcessorTestRunner.processFirstFrameAndEnd();
|
||||||
Bitmap actualBitmap = videoFrameProcessorTestRunner.getOutputBitmap();
|
Bitmap actualBitmap = videoFrameProcessorTestRunner.getOutputBitmap();
|
||||||
|
|
||||||
// TODO: b/376016540 - use HDR_PSNR_THRESHOLD when HDR videos are processed with high floating
|
assertBitmapsAreSimilar(expectedBitmap, actualBitmap, HDR_PSNR_THRESHOLD);
|
||||||
// point precision.
|
|
||||||
assertBitmapsAreSimilar(expectedBitmap, actualBitmap, /* psnrThresholdDb= */ 42.5);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
|