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;
|
||||
}
|
||||
|
||||
@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,
|
||||
|
@ -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
|
||||
|