Fix some minor nits

PiperOrigin-RevId: 509879029
This commit is contained in:
andrewlewis 2023-02-15 18:53:46 +00:00 committed by christosts
parent 482871fed4
commit 3e5ae92bc6
17 changed files with 83 additions and 83 deletions

View File

@ -136,6 +136,7 @@ public interface FrameProcessor {
* @param inputBitmap The {@link Bitmap} queued to the {@link FrameProcessor}. * @param inputBitmap The {@link Bitmap} queued to the {@link FrameProcessor}.
* @param durationUs The duration for which to display the {@code inputBitmap}, in microseconds. * @param durationUs The duration for which to display the {@code inputBitmap}, in microseconds.
* @param frameRate The frame rate at which to display the {@code inputBitmap}, in frames per * @param frameRate The frame rate at which to display the {@code inputBitmap}, in frames per
* second.
*/ */
// TODO(b/262693274): Remove duration and frameRate parameters when EditedMediaItem can be // TODO(b/262693274): Remove duration and frameRate parameters when EditedMediaItem can be
// signalled down to the processors. // signalled down to the processors.

View File

@ -106,7 +106,7 @@ public final class CropPixelTest {
createArgb8888BitmapFromCurrentGlFramebuffer(outputSize.getWidth(), outputSize.getHeight()); createArgb8888BitmapFromCurrentGlFramebuffer(outputSize.getWidth(), outputSize.getHeight());
maybeSaveTestBitmapToCacheDirectory(testId, /* bitmapLabel= */ "actual", actualBitmap); maybeSaveTestBitmapToCacheDirectory(testId, /* bitmapLabel= */ "actual", actualBitmap);
// TODO(b/207848601): switch to using proper tooling for testing against golden data. // TODO(b/207848601): Switch to using proper tooling for testing against golden data.
float averagePixelAbsoluteDifference = float averagePixelAbsoluteDifference =
getBitmapAveragePixelAbsoluteDifferenceArgb8888(expectedBitmap, actualBitmap, testId); getBitmapAveragePixelAbsoluteDifferenceArgb8888(expectedBitmap, actualBitmap, testId);
assertThat(averagePixelAbsoluteDifference).isAtMost(MAXIMUM_AVERAGE_PIXEL_ABSOLUTE_DIFFERENCE); assertThat(averagePixelAbsoluteDifference).isAtMost(MAXIMUM_AVERAGE_PIXEL_ABSOLUTE_DIFFERENCE);
@ -127,7 +127,7 @@ public final class CropPixelTest {
createArgb8888BitmapFromCurrentGlFramebuffer(outputSize.getWidth(), outputSize.getHeight()); createArgb8888BitmapFromCurrentGlFramebuffer(outputSize.getWidth(), outputSize.getHeight());
maybeSaveTestBitmapToCacheDirectory(testId, /* bitmapLabel= */ "actual", actualBitmap); maybeSaveTestBitmapToCacheDirectory(testId, /* bitmapLabel= */ "actual", actualBitmap);
// TODO(b/207848601): switch to using proper tooling for testing against golden data. // TODO(b/207848601): Switch to using proper tooling for testing against golden data.
float averagePixelAbsoluteDifference = float averagePixelAbsoluteDifference =
getBitmapAveragePixelAbsoluteDifferenceArgb8888(expectedBitmap, actualBitmap, testId); getBitmapAveragePixelAbsoluteDifferenceArgb8888(expectedBitmap, actualBitmap, testId);
assertThat(averagePixelAbsoluteDifference).isAtMost(MAXIMUM_AVERAGE_PIXEL_ABSOLUTE_DIFFERENCE); assertThat(averagePixelAbsoluteDifference).isAtMost(MAXIMUM_AVERAGE_PIXEL_ABSOLUTE_DIFFERENCE);
@ -148,7 +148,7 @@ public final class CropPixelTest {
createArgb8888BitmapFromCurrentGlFramebuffer(outputSize.getWidth(), outputSize.getHeight()); createArgb8888BitmapFromCurrentGlFramebuffer(outputSize.getWidth(), outputSize.getHeight());
maybeSaveTestBitmapToCacheDirectory(testId, /* bitmapLabel= */ "actual", actualBitmap); maybeSaveTestBitmapToCacheDirectory(testId, /* bitmapLabel= */ "actual", actualBitmap);
// TODO(b/207848601): switch to using proper tooling for testing against golden data. // TODO(b/207848601): Switch to using proper tooling for testing against golden data.
float averagePixelAbsoluteDifference = float averagePixelAbsoluteDifference =
getBitmapAveragePixelAbsoluteDifferenceArgb8888(expectedBitmap, actualBitmap, testId); getBitmapAveragePixelAbsoluteDifferenceArgb8888(expectedBitmap, actualBitmap, testId);
assertThat(averagePixelAbsoluteDifference).isAtMost(MAXIMUM_AVERAGE_PIXEL_ABSOLUTE_DIFFERENCE); assertThat(averagePixelAbsoluteDifference).isAtMost(MAXIMUM_AVERAGE_PIXEL_ABSOLUTE_DIFFERENCE);

View File

@ -96,7 +96,7 @@ public final class GlEffectsFrameProcessorPixelTest {
Bitmap actualBitmap = frameProcessorTestRunner.processFirstFrameAndEnd(); Bitmap actualBitmap = frameProcessorTestRunner.processFirstFrameAndEnd();
// TODO(b/207848601): switch to using proper tooling for testing against golden data. // TODO(b/207848601): Switch to using proper tooling for testing against golden data.
float averagePixelAbsoluteDifference = float averagePixelAbsoluteDifference =
getBitmapAveragePixelAbsoluteDifferenceArgb8888(expectedBitmap, actualBitmap, testId); getBitmapAveragePixelAbsoluteDifferenceArgb8888(expectedBitmap, actualBitmap, testId);
assertThat(averagePixelAbsoluteDifference).isAtMost(MAXIMUM_AVERAGE_PIXEL_ABSOLUTE_DIFFERENCE); assertThat(averagePixelAbsoluteDifference).isAtMost(MAXIMUM_AVERAGE_PIXEL_ABSOLUTE_DIFFERENCE);
@ -111,7 +111,7 @@ public final class GlEffectsFrameProcessorPixelTest {
Bitmap actualBitmap = frameProcessorTestRunner.processImageFrameAndEnd(expectedBitmap); Bitmap actualBitmap = frameProcessorTestRunner.processImageFrameAndEnd(expectedBitmap);
// TODO(b/207848601): switch to using proper tooling for testing against golden data. // TODO(b/207848601): Switch to using proper tooling for testing against golden data.
float averagePixelAbsoluteDifference = float averagePixelAbsoluteDifference =
getBitmapAveragePixelAbsoluteDifferenceArgb8888(expectedBitmap, actualBitmap, testId); getBitmapAveragePixelAbsoluteDifferenceArgb8888(expectedBitmap, actualBitmap, testId);
assertThat(averagePixelAbsoluteDifference).isAtMost(MAXIMUM_AVERAGE_PIXEL_ABSOLUTE_DIFFERENCE); assertThat(averagePixelAbsoluteDifference).isAtMost(MAXIMUM_AVERAGE_PIXEL_ABSOLUTE_DIFFERENCE);
@ -136,14 +136,14 @@ public final class GlEffectsFrameProcessorPixelTest {
Bitmap actualBitmap = frameProcessorTestRunner.processImageFrameAndEnd(originalBitmap); Bitmap actualBitmap = frameProcessorTestRunner.processImageFrameAndEnd(originalBitmap);
// TODO(b/207848601): switch to using proper tooling for testing against golden data. // TODO(b/207848601): Switch to using proper tooling for testing against golden data.
float averagePixelAbsoluteDifference = float averagePixelAbsoluteDifference =
getBitmapAveragePixelAbsoluteDifferenceArgb8888(expectedBitmap, actualBitmap, testId); getBitmapAveragePixelAbsoluteDifferenceArgb8888(expectedBitmap, actualBitmap, testId);
assertThat(averagePixelAbsoluteDifference).isAtMost(MAXIMUM_AVERAGE_PIXEL_ABSOLUTE_DIFFERENCE); assertThat(averagePixelAbsoluteDifference).isAtMost(MAXIMUM_AVERAGE_PIXEL_ABSOLUTE_DIFFERENCE);
} }
// TODO(b/262693274): Once texture deletion is added to InternalTextureManager.java, add a test // TODO(b/262693274): Once texture deletion is added to InternalTextureManager.java, add a test
// queuing multiple input bitmaps to ensure successfully completion without errors, ensuring the // queuing multiple input bitmaps to ensure the operation successfully completes and that the
// correct number of frames haas been queued. // correct number of frames has been queued.
@Test @Test
public void noEffects_withFrameCache_matchesGoldenFile() throws Exception { public void noEffects_withFrameCache_matchesGoldenFile() throws Exception {
@ -156,7 +156,7 @@ public final class GlEffectsFrameProcessorPixelTest {
Bitmap actualBitmap = frameProcessorTestRunner.processFirstFrameAndEnd(); Bitmap actualBitmap = frameProcessorTestRunner.processFirstFrameAndEnd();
// TODO(b/207848601): switch to using proper tooling for testing against golden data. // TODO(b/207848601): Switch to using proper tooling for testing against golden data.
float averagePixelAbsoluteDifference = float averagePixelAbsoluteDifference =
getBitmapAveragePixelAbsoluteDifferenceArgb8888(expectedBitmap, actualBitmap, testId); getBitmapAveragePixelAbsoluteDifferenceArgb8888(expectedBitmap, actualBitmap, testId);
assertThat(averagePixelAbsoluteDifference).isAtMost(MAXIMUM_AVERAGE_PIXEL_ABSOLUTE_DIFFERENCE); assertThat(averagePixelAbsoluteDifference).isAtMost(MAXIMUM_AVERAGE_PIXEL_ABSOLUTE_DIFFERENCE);
@ -171,7 +171,7 @@ public final class GlEffectsFrameProcessorPixelTest {
Bitmap actualBitmap = frameProcessorTestRunner.processFirstFrameAndEnd(); Bitmap actualBitmap = frameProcessorTestRunner.processFirstFrameAndEnd();
// TODO(b/207848601): switch to using proper tooling for testing against golden data. // TODO(b/207848601): Switch to using proper tooling for testing against golden data.
float averagePixelAbsoluteDifference = float averagePixelAbsoluteDifference =
getBitmapAveragePixelAbsoluteDifferenceArgb8888(expectedBitmap, actualBitmap, testId); getBitmapAveragePixelAbsoluteDifferenceArgb8888(expectedBitmap, actualBitmap, testId);
assertThat(averagePixelAbsoluteDifference).isAtMost(MAXIMUM_AVERAGE_PIXEL_ABSOLUTE_DIFFERENCE); assertThat(averagePixelAbsoluteDifference).isAtMost(MAXIMUM_AVERAGE_PIXEL_ABSOLUTE_DIFFERENCE);
@ -190,7 +190,7 @@ public final class GlEffectsFrameProcessorPixelTest {
Bitmap actualBitmap = frameProcessorTestRunner.processFirstFrameAndEnd(); Bitmap actualBitmap = frameProcessorTestRunner.processFirstFrameAndEnd();
// TODO(b/207848601): switch to using proper tooling for testing against golden data. // TODO(b/207848601): Switch to using proper tooling for testing against golden data.
float averagePixelAbsoluteDifference = float averagePixelAbsoluteDifference =
getBitmapAveragePixelAbsoluteDifferenceArgb8888(expectedBitmap, actualBitmap, testId); getBitmapAveragePixelAbsoluteDifferenceArgb8888(expectedBitmap, actualBitmap, testId);
assertThat(averagePixelAbsoluteDifference).isAtMost(MAXIMUM_AVERAGE_PIXEL_ABSOLUTE_DIFFERENCE); assertThat(averagePixelAbsoluteDifference).isAtMost(MAXIMUM_AVERAGE_PIXEL_ABSOLUTE_DIFFERENCE);
@ -211,7 +211,7 @@ public final class GlEffectsFrameProcessorPixelTest {
Bitmap actualBitmap = frameProcessorTestRunner.processFirstFrameAndEnd(); Bitmap actualBitmap = frameProcessorTestRunner.processFirstFrameAndEnd();
// TODO(b/207848601): switch to using proper tooling for testing against golden data. // TODO(b/207848601): Switch to using proper tooling for testing against golden data.
float averagePixelAbsoluteDifference = float averagePixelAbsoluteDifference =
getBitmapAveragePixelAbsoluteDifferenceArgb8888(expectedBitmap, actualBitmap, testId); getBitmapAveragePixelAbsoluteDifferenceArgb8888(expectedBitmap, actualBitmap, testId);
assertThat(averagePixelAbsoluteDifference).isAtMost(MAXIMUM_AVERAGE_PIXEL_ABSOLUTE_DIFFERENCE); assertThat(averagePixelAbsoluteDifference).isAtMost(MAXIMUM_AVERAGE_PIXEL_ABSOLUTE_DIFFERENCE);
@ -230,7 +230,7 @@ public final class GlEffectsFrameProcessorPixelTest {
Bitmap actualBitmap = frameProcessorTestRunner.processFirstFrameAndEnd(); Bitmap actualBitmap = frameProcessorTestRunner.processFirstFrameAndEnd();
// TODO(b/207848601): switch to using proper tooling for testing against golden data. // TODO(b/207848601): Switch to using proper tooling for testing against golden data.
float averagePixelAbsoluteDifference = float averagePixelAbsoluteDifference =
getBitmapAveragePixelAbsoluteDifferenceArgb8888(expectedBitmap, actualBitmap, testId); getBitmapAveragePixelAbsoluteDifferenceArgb8888(expectedBitmap, actualBitmap, testId);
assertThat(averagePixelAbsoluteDifference).isAtMost(MAXIMUM_AVERAGE_PIXEL_ABSOLUTE_DIFFERENCE); assertThat(averagePixelAbsoluteDifference).isAtMost(MAXIMUM_AVERAGE_PIXEL_ABSOLUTE_DIFFERENCE);
@ -251,7 +251,7 @@ public final class GlEffectsFrameProcessorPixelTest {
Bitmap actualBitmap = frameProcessorTestRunner.processFirstFrameAndEnd(); Bitmap actualBitmap = frameProcessorTestRunner.processFirstFrameAndEnd();
// TODO(b/207848601): switch to using proper tooling for testing against golden data. // TODO(b/207848601): Switch to using proper tooling for testing against golden data.
float averagePixelAbsoluteDifference = float averagePixelAbsoluteDifference =
getBitmapAveragePixelAbsoluteDifferenceArgb8888(expectedBitmap, actualBitmap, testId); getBitmapAveragePixelAbsoluteDifferenceArgb8888(expectedBitmap, actualBitmap, testId);
assertThat(averagePixelAbsoluteDifference).isAtMost(MAXIMUM_AVERAGE_PIXEL_ABSOLUTE_DIFFERENCE); assertThat(averagePixelAbsoluteDifference).isAtMost(MAXIMUM_AVERAGE_PIXEL_ABSOLUTE_DIFFERENCE);
@ -268,7 +268,7 @@ public final class GlEffectsFrameProcessorPixelTest {
Bitmap actualBitmap = frameProcessorTestRunner.processFirstFrameAndEnd(); Bitmap actualBitmap = frameProcessorTestRunner.processFirstFrameAndEnd();
// TODO(b/207848601): switch to using proper tooling for testing against golden data. // TODO(b/207848601): Switch to using proper tooling for testing against golden data.
float averagePixelAbsoluteDifference = float averagePixelAbsoluteDifference =
getBitmapAveragePixelAbsoluteDifferenceArgb8888(expectedBitmap, actualBitmap, testId); getBitmapAveragePixelAbsoluteDifferenceArgb8888(expectedBitmap, actualBitmap, testId);
assertThat(averagePixelAbsoluteDifference).isAtMost(MAXIMUM_AVERAGE_PIXEL_ABSOLUTE_DIFFERENCE); assertThat(averagePixelAbsoluteDifference).isAtMost(MAXIMUM_AVERAGE_PIXEL_ABSOLUTE_DIFFERENCE);
@ -289,7 +289,7 @@ public final class GlEffectsFrameProcessorPixelTest {
Bitmap actualBitmap = frameProcessorTestRunner.processFirstFrameAndEnd(); Bitmap actualBitmap = frameProcessorTestRunner.processFirstFrameAndEnd();
// TODO(b/207848601): switch to using proper tooling for testing against golden data. // TODO(b/207848601): Switch to using proper tooling for testing against golden data.
float averagePixelAbsoluteDifference = float averagePixelAbsoluteDifference =
getBitmapAveragePixelAbsoluteDifferenceArgb8888(expectedBitmap, actualBitmap, testId); getBitmapAveragePixelAbsoluteDifferenceArgb8888(expectedBitmap, actualBitmap, testId);
assertThat(averagePixelAbsoluteDifference).isAtMost(MAXIMUM_AVERAGE_PIXEL_ABSOLUTE_DIFFERENCE); assertThat(averagePixelAbsoluteDifference).isAtMost(MAXIMUM_AVERAGE_PIXEL_ABSOLUTE_DIFFERENCE);
@ -306,7 +306,7 @@ public final class GlEffectsFrameProcessorPixelTest {
Bitmap actualBitmap = frameProcessorTestRunner.processFirstFrameAndEnd(); Bitmap actualBitmap = frameProcessorTestRunner.processFirstFrameAndEnd();
// TODO(b/207848601): switch to using proper tooling for testing against golden data. // TODO(b/207848601): Switch to using proper tooling for testing against golden data.
float averagePixelAbsoluteDifference = float averagePixelAbsoluteDifference =
getBitmapAveragePixelAbsoluteDifferenceArgb8888(expectedBitmap, actualBitmap, testId); getBitmapAveragePixelAbsoluteDifferenceArgb8888(expectedBitmap, actualBitmap, testId);
assertThat(averagePixelAbsoluteDifference).isAtMost(MAXIMUM_AVERAGE_PIXEL_ABSOLUTE_DIFFERENCE); assertThat(averagePixelAbsoluteDifference).isAtMost(MAXIMUM_AVERAGE_PIXEL_ABSOLUTE_DIFFERENCE);
@ -329,7 +329,7 @@ public final class GlEffectsFrameProcessorPixelTest {
Bitmap actualBitmap = frameProcessorTestRunner.processFirstFrameAndEnd(); Bitmap actualBitmap = frameProcessorTestRunner.processFirstFrameAndEnd();
// TODO(b/207848601): switch to using proper tooling for testing against golden data. // TODO(b/207848601): Switch to using proper tooling for testing against golden data.
float averagePixelAbsoluteDifference = float averagePixelAbsoluteDifference =
getBitmapAveragePixelAbsoluteDifferenceArgb8888(expectedBitmap, actualBitmap, testId); getBitmapAveragePixelAbsoluteDifferenceArgb8888(expectedBitmap, actualBitmap, testId);
assertThat(averagePixelAbsoluteDifference).isAtMost(MAXIMUM_AVERAGE_PIXEL_ABSOLUTE_DIFFERENCE); assertThat(averagePixelAbsoluteDifference).isAtMost(MAXIMUM_AVERAGE_PIXEL_ABSOLUTE_DIFFERENCE);
@ -361,7 +361,7 @@ public final class GlEffectsFrameProcessorPixelTest {
Bitmap fullRotationAndCenterCropResultBitmap = Bitmap fullRotationAndCenterCropResultBitmap =
frameProcessorTestRunner.processFirstFrameAndEnd(); frameProcessorTestRunner.processFirstFrameAndEnd();
// TODO(b/207848601): switch to using proper tooling for testing against golden data. // TODO(b/207848601): Switch to using proper tooling for testing against golden data.
float averagePixelAbsoluteDifference = float averagePixelAbsoluteDifference =
getBitmapAveragePixelAbsoluteDifferenceArgb8888( getBitmapAveragePixelAbsoluteDifferenceArgb8888(
centerCropResultBitmap, fullRotationAndCenterCropResultBitmap, testId); centerCropResultBitmap, fullRotationAndCenterCropResultBitmap, testId);
@ -377,7 +377,7 @@ public final class GlEffectsFrameProcessorPixelTest {
Bitmap actualBitmap = frameProcessorTestRunner.processFirstFrameAndEnd(); Bitmap actualBitmap = frameProcessorTestRunner.processFirstFrameAndEnd();
// TODO(b/207848601): switch to using proper tooling for testing against golden data. // TODO(b/207848601): Switch to using proper tooling for testing against golden data.
float averagePixelAbsoluteDifference = float averagePixelAbsoluteDifference =
getBitmapAveragePixelAbsoluteDifferenceArgb8888(expectedBitmap, actualBitmap, testId); getBitmapAveragePixelAbsoluteDifferenceArgb8888(expectedBitmap, actualBitmap, testId);
assertThat(averagePixelAbsoluteDifference).isAtMost(MAXIMUM_AVERAGE_PIXEL_ABSOLUTE_DIFFERENCE); assertThat(averagePixelAbsoluteDifference).isAtMost(MAXIMUM_AVERAGE_PIXEL_ABSOLUTE_DIFFERENCE);
@ -418,7 +418,7 @@ public final class GlEffectsFrameProcessorPixelTest {
Bitmap fullRotationBrightnessIncreaseAndCenterCropResultBitmap = Bitmap fullRotationBrightnessIncreaseAndCenterCropResultBitmap =
frameProcessorTestRunner.processFirstFrameAndEnd(); frameProcessorTestRunner.processFirstFrameAndEnd();
// TODO(b/207848601): switch to using proper tooling for testing against golden data. // TODO(b/207848601): Switch to using proper tooling for testing against golden data.
float averagePixelAbsoluteDifference = float averagePixelAbsoluteDifference =
getBitmapAveragePixelAbsoluteDifferenceArgb8888( getBitmapAveragePixelAbsoluteDifferenceArgb8888(
centerCropAndBrightnessIncreaseResultBitmap, centerCropAndBrightnessIncreaseResultBitmap,
@ -465,7 +465,7 @@ public final class GlEffectsFrameProcessorPixelTest {
Bitmap fullRotationBrightnessIncreaseAndCenterCropResultBitmap = Bitmap fullRotationBrightnessIncreaseAndCenterCropResultBitmap =
frameProcessorTestRunner.processFirstFrameAndEnd(); frameProcessorTestRunner.processFirstFrameAndEnd();
// TODO(b/207848601): switch to using proper tooling for testing against golden data. // TODO(b/207848601): Switch to using proper tooling for testing against golden data.
float averagePixelAbsoluteDifference = float averagePixelAbsoluteDifference =
getBitmapAveragePixelAbsoluteDifferenceArgb8888( getBitmapAveragePixelAbsoluteDifferenceArgb8888(
centerCropAndBrightnessIncreaseResultBitmap, centerCropAndBrightnessIncreaseResultBitmap,
@ -487,7 +487,7 @@ public final class GlEffectsFrameProcessorPixelTest {
Bitmap actualBitmap = frameProcessorTestRunner.processFirstFrameAndEnd(); Bitmap actualBitmap = frameProcessorTestRunner.processFirstFrameAndEnd();
// TODO(b/207848601): switch to using proper tooling for testing against golden data. // TODO(b/207848601): Switch to using proper tooling for testing against golden data.
float averagePixelAbsoluteDifference = float averagePixelAbsoluteDifference =
getBitmapAveragePixelAbsoluteDifferenceArgb8888(expectedBitmap, actualBitmap, testId); getBitmapAveragePixelAbsoluteDifferenceArgb8888(expectedBitmap, actualBitmap, testId);
assertThat(averagePixelAbsoluteDifference).isAtMost(MAXIMUM_AVERAGE_PIXEL_ABSOLUTE_DIFFERENCE); assertThat(averagePixelAbsoluteDifference).isAtMost(MAXIMUM_AVERAGE_PIXEL_ABSOLUTE_DIFFERENCE);

View File

@ -109,7 +109,7 @@ public final class MatrixShaderProgramPixelTest {
Bitmap actualBitmap = createArgb8888BitmapFromCurrentGlFramebuffer(inputWidth, inputHeight); Bitmap actualBitmap = createArgb8888BitmapFromCurrentGlFramebuffer(inputWidth, inputHeight);
maybeSaveTestBitmapToCacheDirectory(testId, /* bitmapLabel= */ "actual", actualBitmap); maybeSaveTestBitmapToCacheDirectory(testId, /* bitmapLabel= */ "actual", actualBitmap);
// TODO(b/207848601): switch to using proper tooling for testing against golden data. // TODO(b/207848601): Switch to using proper tooling for testing against golden data.
float averagePixelAbsoluteDifference = float averagePixelAbsoluteDifference =
getBitmapAveragePixelAbsoluteDifferenceArgb8888(expectedBitmap, actualBitmap, testId); getBitmapAveragePixelAbsoluteDifferenceArgb8888(expectedBitmap, actualBitmap, testId);
assertThat(averagePixelAbsoluteDifference).isAtMost(MAXIMUM_AVERAGE_PIXEL_ABSOLUTE_DIFFERENCE); assertThat(averagePixelAbsoluteDifference).isAtMost(MAXIMUM_AVERAGE_PIXEL_ABSOLUTE_DIFFERENCE);
@ -131,7 +131,7 @@ public final class MatrixShaderProgramPixelTest {
Bitmap actualBitmap = createArgb8888BitmapFromCurrentGlFramebuffer(inputWidth, inputHeight); Bitmap actualBitmap = createArgb8888BitmapFromCurrentGlFramebuffer(inputWidth, inputHeight);
maybeSaveTestBitmapToCacheDirectory(testId, /* bitmapLabel= */ "actual", actualBitmap); maybeSaveTestBitmapToCacheDirectory(testId, /* bitmapLabel= */ "actual", actualBitmap);
// TODO(b/207848601): switch to using proper tooling for testing against golden data. // TODO(b/207848601): Switch to using proper tooling for testing against golden data.
float averagePixelAbsoluteDifference = float averagePixelAbsoluteDifference =
getBitmapAveragePixelAbsoluteDifferenceArgb8888(expectedBitmap, actualBitmap, testId); getBitmapAveragePixelAbsoluteDifferenceArgb8888(expectedBitmap, actualBitmap, testId);
assertThat(averagePixelAbsoluteDifference).isAtMost(MAXIMUM_AVERAGE_PIXEL_ABSOLUTE_DIFFERENCE); assertThat(averagePixelAbsoluteDifference).isAtMost(MAXIMUM_AVERAGE_PIXEL_ABSOLUTE_DIFFERENCE);
@ -151,7 +151,7 @@ public final class MatrixShaderProgramPixelTest {
Bitmap actualBitmap = createArgb8888BitmapFromCurrentGlFramebuffer(inputWidth, inputHeight); Bitmap actualBitmap = createArgb8888BitmapFromCurrentGlFramebuffer(inputWidth, inputHeight);
maybeSaveTestBitmapToCacheDirectory(testId, /* bitmapLabel= */ "actual", actualBitmap); maybeSaveTestBitmapToCacheDirectory(testId, /* bitmapLabel= */ "actual", actualBitmap);
// TODO(b/207848601): switch to using proper tooling for testing against golden data. // TODO(b/207848601): Switch to using proper tooling for testing against golden data.
float averagePixelAbsoluteDifference = float averagePixelAbsoluteDifference =
getBitmapAveragePixelAbsoluteDifferenceArgb8888(expectedBitmap, actualBitmap, testId); getBitmapAveragePixelAbsoluteDifferenceArgb8888(expectedBitmap, actualBitmap, testId);
assertThat(averagePixelAbsoluteDifference).isAtMost(MAXIMUM_AVERAGE_PIXEL_ABSOLUTE_DIFFERENCE); assertThat(averagePixelAbsoluteDifference).isAtMost(MAXIMUM_AVERAGE_PIXEL_ABSOLUTE_DIFFERENCE);
@ -171,7 +171,7 @@ public final class MatrixShaderProgramPixelTest {
Bitmap actualBitmap = createArgb8888BitmapFromCurrentGlFramebuffer(inputWidth, inputHeight); Bitmap actualBitmap = createArgb8888BitmapFromCurrentGlFramebuffer(inputWidth, inputHeight);
maybeSaveTestBitmapToCacheDirectory(testId, /* bitmapLabel= */ "actual", actualBitmap); maybeSaveTestBitmapToCacheDirectory(testId, /* bitmapLabel= */ "actual", actualBitmap);
// TODO(b/207848601): switch to using proper tooling for testing against golden data. // TODO(b/207848601): Switch to using proper tooling for testing against golden data.
float averagePixelAbsoluteDifference = float averagePixelAbsoluteDifference =
getBitmapAveragePixelAbsoluteDifferenceArgb8888(expectedBitmap, actualBitmap, testId); getBitmapAveragePixelAbsoluteDifferenceArgb8888(expectedBitmap, actualBitmap, testId);
assertThat(averagePixelAbsoluteDifference).isAtMost(MAXIMUM_AVERAGE_PIXEL_ABSOLUTE_DIFFERENCE); assertThat(averagePixelAbsoluteDifference).isAtMost(MAXIMUM_AVERAGE_PIXEL_ABSOLUTE_DIFFERENCE);

View File

@ -115,7 +115,7 @@ public final class PresentationPixelTest {
createArgb8888BitmapFromCurrentGlFramebuffer(outputSize.getWidth(), outputSize.getHeight()); createArgb8888BitmapFromCurrentGlFramebuffer(outputSize.getWidth(), outputSize.getHeight());
maybeSaveTestBitmapToCacheDirectory(testId, /* bitmapLabel= */ "actual", actualBitmap); maybeSaveTestBitmapToCacheDirectory(testId, /* bitmapLabel= */ "actual", actualBitmap);
// TODO(b/207848601): switch to using proper tooling for testing against golden data. // TODO(b/207848601): Switch to using proper tooling for testing against golden data.
float averagePixelAbsoluteDifference = float averagePixelAbsoluteDifference =
getBitmapAveragePixelAbsoluteDifferenceArgb8888(expectedBitmap, actualBitmap, testId); getBitmapAveragePixelAbsoluteDifferenceArgb8888(expectedBitmap, actualBitmap, testId);
assertThat(averagePixelAbsoluteDifference).isAtMost(MAXIMUM_AVERAGE_PIXEL_ABSOLUTE_DIFFERENCE); assertThat(averagePixelAbsoluteDifference).isAtMost(MAXIMUM_AVERAGE_PIXEL_ABSOLUTE_DIFFERENCE);
@ -136,7 +136,7 @@ public final class PresentationPixelTest {
createArgb8888BitmapFromCurrentGlFramebuffer(outputSize.getWidth(), outputSize.getHeight()); createArgb8888BitmapFromCurrentGlFramebuffer(outputSize.getWidth(), outputSize.getHeight());
maybeSaveTestBitmapToCacheDirectory(testId, /* bitmapLabel= */ "actual", actualBitmap); maybeSaveTestBitmapToCacheDirectory(testId, /* bitmapLabel= */ "actual", actualBitmap);
// TODO(b/207848601): switch to using proper tooling for testing against golden data. // TODO(b/207848601): Switch to using proper tooling for testing against golden data.
float averagePixelAbsoluteDifference = float averagePixelAbsoluteDifference =
getBitmapAveragePixelAbsoluteDifferenceArgb8888(expectedBitmap, actualBitmap, testId); getBitmapAveragePixelAbsoluteDifferenceArgb8888(expectedBitmap, actualBitmap, testId);
assertThat(averagePixelAbsoluteDifference).isAtMost(MAXIMUM_AVERAGE_PIXEL_ABSOLUTE_DIFFERENCE); assertThat(averagePixelAbsoluteDifference).isAtMost(MAXIMUM_AVERAGE_PIXEL_ABSOLUTE_DIFFERENCE);
@ -157,7 +157,7 @@ public final class PresentationPixelTest {
createArgb8888BitmapFromCurrentGlFramebuffer(outputSize.getWidth(), outputSize.getHeight()); createArgb8888BitmapFromCurrentGlFramebuffer(outputSize.getWidth(), outputSize.getHeight());
maybeSaveTestBitmapToCacheDirectory(testId, /* bitmapLabel= */ "actual", actualBitmap); maybeSaveTestBitmapToCacheDirectory(testId, /* bitmapLabel= */ "actual", actualBitmap);
// TODO(b/207848601): switch to using proper tooling for testing against golden data. // TODO(b/207848601): Switch to using proper tooling for testing against golden data.
float averagePixelAbsoluteDifference = float averagePixelAbsoluteDifference =
getBitmapAveragePixelAbsoluteDifferenceArgb8888(expectedBitmap, actualBitmap, testId); getBitmapAveragePixelAbsoluteDifferenceArgb8888(expectedBitmap, actualBitmap, testId);
assertThat(averagePixelAbsoluteDifference).isAtMost(MAXIMUM_AVERAGE_PIXEL_ABSOLUTE_DIFFERENCE); assertThat(averagePixelAbsoluteDifference).isAtMost(MAXIMUM_AVERAGE_PIXEL_ABSOLUTE_DIFFERENCE);
@ -180,7 +180,7 @@ public final class PresentationPixelTest {
createArgb8888BitmapFromCurrentGlFramebuffer(outputSize.getWidth(), outputSize.getHeight()); createArgb8888BitmapFromCurrentGlFramebuffer(outputSize.getWidth(), outputSize.getHeight());
maybeSaveTestBitmapToCacheDirectory(testId, /* bitmapLabel= */ "actual", actualBitmap); maybeSaveTestBitmapToCacheDirectory(testId, /* bitmapLabel= */ "actual", actualBitmap);
// TODO(b/207848601): switch to using proper tooling for testing against golden data. // TODO(b/207848601): Switch to using proper tooling for testing against golden data.
float averagePixelAbsoluteDifference = float averagePixelAbsoluteDifference =
getBitmapAveragePixelAbsoluteDifferenceArgb8888(expectedBitmap, actualBitmap, testId); getBitmapAveragePixelAbsoluteDifferenceArgb8888(expectedBitmap, actualBitmap, testId);
assertThat(averagePixelAbsoluteDifference).isAtMost(MAXIMUM_AVERAGE_PIXEL_ABSOLUTE_DIFFERENCE); assertThat(averagePixelAbsoluteDifference).isAtMost(MAXIMUM_AVERAGE_PIXEL_ABSOLUTE_DIFFERENCE);
@ -203,7 +203,7 @@ public final class PresentationPixelTest {
createArgb8888BitmapFromCurrentGlFramebuffer(outputSize.getWidth(), outputSize.getHeight()); createArgb8888BitmapFromCurrentGlFramebuffer(outputSize.getWidth(), outputSize.getHeight());
maybeSaveTestBitmapToCacheDirectory(testId, /* bitmapLabel= */ "actual", actualBitmap); maybeSaveTestBitmapToCacheDirectory(testId, /* bitmapLabel= */ "actual", actualBitmap);
// TODO(b/207848601): switch to using proper tooling for testing against golden data. // TODO(b/207848601): Switch to using proper tooling for testing against golden data.
float averagePixelAbsoluteDifference = float averagePixelAbsoluteDifference =
getBitmapAveragePixelAbsoluteDifferenceArgb8888(expectedBitmap, actualBitmap, testId); getBitmapAveragePixelAbsoluteDifferenceArgb8888(expectedBitmap, actualBitmap, testId);
assertThat(averagePixelAbsoluteDifference).isAtMost(MAXIMUM_AVERAGE_PIXEL_ABSOLUTE_DIFFERENCE); assertThat(averagePixelAbsoluteDifference).isAtMost(MAXIMUM_AVERAGE_PIXEL_ABSOLUTE_DIFFERENCE);
@ -224,7 +224,7 @@ public final class PresentationPixelTest {
createArgb8888BitmapFromCurrentGlFramebuffer(outputSize.getWidth(), outputSize.getHeight()); createArgb8888BitmapFromCurrentGlFramebuffer(outputSize.getWidth(), outputSize.getHeight());
maybeSaveTestBitmapToCacheDirectory(testId, /* bitmapLabel= */ "actual", actualBitmap); maybeSaveTestBitmapToCacheDirectory(testId, /* bitmapLabel= */ "actual", actualBitmap);
// TODO(b/207848601): switch to using proper tooling for testing against golden data. // TODO(b/207848601): Switch to using proper tooling for testing against golden data.
float averagePixelAbsoluteDifference = float averagePixelAbsoluteDifference =
getBitmapAveragePixelAbsoluteDifferenceArgb8888(expectedBitmap, actualBitmap, testId); getBitmapAveragePixelAbsoluteDifferenceArgb8888(expectedBitmap, actualBitmap, testId);
assertThat(averagePixelAbsoluteDifference).isAtMost(MAXIMUM_AVERAGE_PIXEL_ABSOLUTE_DIFFERENCE); assertThat(averagePixelAbsoluteDifference).isAtMost(MAXIMUM_AVERAGE_PIXEL_ABSOLUTE_DIFFERENCE);
@ -245,7 +245,7 @@ public final class PresentationPixelTest {
createArgb8888BitmapFromCurrentGlFramebuffer(outputSize.getWidth(), outputSize.getHeight()); createArgb8888BitmapFromCurrentGlFramebuffer(outputSize.getWidth(), outputSize.getHeight());
maybeSaveTestBitmapToCacheDirectory(testId, /* bitmapLabel= */ "actual", actualBitmap); maybeSaveTestBitmapToCacheDirectory(testId, /* bitmapLabel= */ "actual", actualBitmap);
// TODO(b/207848601): switch to using proper tooling for testing against golden data. // TODO(b/207848601): Switch to using proper tooling for testing against golden data.
float averagePixelAbsoluteDifference = float averagePixelAbsoluteDifference =
getBitmapAveragePixelAbsoluteDifferenceArgb8888(expectedBitmap, actualBitmap, testId); getBitmapAveragePixelAbsoluteDifferenceArgb8888(expectedBitmap, actualBitmap, testId);
assertThat(averagePixelAbsoluteDifference).isAtMost(MAXIMUM_AVERAGE_PIXEL_ABSOLUTE_DIFFERENCE); assertThat(averagePixelAbsoluteDifference).isAtMost(MAXIMUM_AVERAGE_PIXEL_ABSOLUTE_DIFFERENCE);

View File

@ -35,7 +35,7 @@ import java.util.concurrent.atomic.AtomicInteger;
* Forwards externally produced frames that become available via a {@link SurfaceTexture} to an * Forwards externally produced frames that become available via a {@link SurfaceTexture} to an
* {@link ExternalShaderProgram} for consumption. * {@link ExternalShaderProgram} for consumption.
*/ */
/* package */ class ExternalTextureManager implements InputListener { /* package */ final class ExternalTextureManager implements InputListener {
private final FrameProcessingTaskExecutor frameProcessingTaskExecutor; private final FrameProcessingTaskExecutor frameProcessingTaskExecutor;
private final ExternalShaderProgram externalShaderProgram; private final ExternalShaderProgram externalShaderProgram;

View File

@ -27,7 +27,7 @@ import com.google.android.exoplayer2.util.FrameProcessingException;
* <p>Example usage: cache the processed frames when presenting them on screen, to accommodate for * <p>Example usage: cache the processed frames when presenting them on screen, to accommodate for
* the possible fluctuation in frame processing time between frames. * the possible fluctuation in frame processing time between frames.
*/ */
public class FrameCache implements GlEffect { public final class FrameCache implements GlEffect {
/** The capacity of the frame cache. */ /** The capacity of the frame cache. */
public final int capacity; public final int capacity;

View File

@ -35,7 +35,7 @@ import java.util.concurrent.Executor;
* *
* <p>Implements {@link FrameCache}. * <p>Implements {@link FrameCache}.
*/ */
/* package */ class FrameCacheShaderProgram implements GlShaderProgram { /* package */ final class FrameCacheShaderProgram implements GlShaderProgram {
private static final String VERTEX_SHADER_TRANSFORMATION_ES2_PATH = private static final String VERTEX_SHADER_TRANSFORMATION_ES2_PATH =
"shaders/vertex_shader_transformation_es2.glsl"; "shaders/vertex_shader_transformation_es2.glsl";
private static final String FRAGMENT_SHADER_TRANSFORMATION_ES2_PATH = private static final String FRAGMENT_SHADER_TRANSFORMATION_ES2_PATH =

View File

@ -30,11 +30,11 @@ import java.util.Queue;
import java.util.concurrent.LinkedBlockingQueue; import java.util.concurrent.LinkedBlockingQueue;
/** /**
* Forwards a frame produced from a {@link Bitmap} to a {@link GlShaderProgram} for consumption * Forwards a frame produced from a {@link Bitmap} to a {@link GlShaderProgram} for consumption.
* *
* <p>Methods in this class can be called from any thread. * <p>Methods in this class can be called from any thread.
*/ */
/* package */ class InternalTextureManager implements GlShaderProgram.InputListener { /* package */ final class InternalTextureManager implements GlShaderProgram.InputListener {
private final GlShaderProgram shaderProgram; private final GlShaderProgram shaderProgram;
private final FrameProcessingTaskExecutor frameProcessingTaskExecutor; private final FrameProcessingTaskExecutor frameProcessingTaskExecutor;
// The queue holds all bitmaps with one or more frames pending to be sent downstream. // The queue holds all bitmaps with one or more frames pending to be sent downstream.
@ -94,7 +94,7 @@ import java.util.concurrent.LinkedBlockingQueue;
frameProcessingTaskExecutor.submit( frameProcessingTaskExecutor.submit(
() -> { () -> {
inputEnded = true; inputEnded = true;
signalEndOfOutput(); maybeSignalEndOfOutput();
}); });
} }
@ -145,12 +145,12 @@ import java.util.concurrent.LinkedBlockingQueue;
currentPresentationTimeUs += currentBitmap.frameDurationUs; currentPresentationTimeUs += currentBitmap.frameDurationUs;
if (framesToQueueForCurrentBitmap == 0) { if (framesToQueueForCurrentBitmap == 0) {
pendingBitmaps.remove(); pendingBitmaps.remove();
signalEndOfOutput(); maybeSignalEndOfOutput();
} }
} }
@WorkerThread @WorkerThread
private void signalEndOfOutput() { private void maybeSignalEndOfOutput() {
if (framesToQueueForCurrentBitmap == 0 if (framesToQueueForCurrentBitmap == 0
&& pendingBitmaps.isEmpty() && pendingBitmaps.isEmpty()
&& inputEnded && inputEnded
@ -160,10 +160,7 @@ import java.util.concurrent.LinkedBlockingQueue;
} }
} }
/** /** Information to generate all the frames associated with a specific {@link Bitmap}. */
* Value class specifying information to generate all the frames associated with a specific {@link
* Bitmap}.
*/
private static final class BitmapFrameSequenceInfo { private static final class BitmapFrameSequenceInfo {
public final TextureInfo textureInfo; public final TextureInfo textureInfo;
public final long frameDurationUs; public final long frameDurationUs;

View File

@ -38,12 +38,13 @@ public final class OverlaySettings {
/** A builder for {@link OverlaySettings} instances. */ /** A builder for {@link OverlaySettings} instances. */
public static final class Builder { public static final class Builder {
private boolean useHdr; private boolean useHdr;
private float alpha = 1; private float alpha;
private float[] matrix; private float[] matrix;
private Pair<Float, Float> anchor; private Pair<Float, Float> anchor;
/** Creates a new {@link Builder}. */ /** Creates a new {@link Builder}. */
public Builder() { public Builder() {
alpha = 1f;
matrix = GlUtil.create4x4IdentityMatrix(); matrix = GlUtil.create4x4IdentityMatrix();
anchor = Pair.create(0f, 0f); anchor = Pair.create(0f, 0f);
} }
@ -94,18 +95,14 @@ public final class OverlaySettings {
* <p>The coordinates are specified in Normalised Device Coordinates (NDCs). Set to always * <p>The coordinates are specified in Normalised Device Coordinates (NDCs). Set to always
* return {@code (0,0)} (the center) by default. * return {@code (0,0)} (the center) by default.
* *
* @param x the NDC x-coordinate. * @param x The NDC x-coordinate in the range [-1, 1].
* @param y the NDC y-coordinate. * @param y The NDC y-coordinate in the range [-1, 1].
*/ */
@CanIgnoreReturnValue @CanIgnoreReturnValue
public Builder setAnchor( public Builder setAnchor(
@FloatRange(from = -1, to = 1) float x, @FloatRange(from = -1, to = 1) float y) { @FloatRange(from = -1, to = 1) float x, @FloatRange(from = -1, to = 1) float y) {
checkArgument( checkArgument(-1 <= x && x <= 1);
-1 <= x && x <= 1, checkArgument(-1 <= y && y <= 1);
"x needs to be specified in terms of NDCs which lie in the interval [-1, 1].");
checkArgument(
-1 <= y && y <= 1,
"y needs to be specified in terms of NDCs which lie in the interval [-1, 1].");
this.anchor = Pair.create(x, y); this.anchor = Pair.create(x, y);
return this; return this;
} }

View File

@ -139,7 +139,7 @@ public final class ToneMapHdrToSdrUsingOpenGlPixelTest {
} }
Log.i(TAG, "Successfully tone mapped."); Log.i(TAG, "Successfully tone mapped.");
// TODO(b/207848601): switch to using proper tooling for testing against golden data. // TODO(b/207848601): Switch to using proper tooling for testing against golden data.
float averagePixelAbsoluteDifference = float averagePixelAbsoluteDifference =
getBitmapAveragePixelAbsoluteDifferenceArgb8888(expectedBitmap, actualBitmap, testId); getBitmapAveragePixelAbsoluteDifferenceArgb8888(expectedBitmap, actualBitmap, testId);
assertThat(averagePixelAbsoluteDifference) assertThat(averagePixelAbsoluteDifference)
@ -202,7 +202,7 @@ public final class ToneMapHdrToSdrUsingOpenGlPixelTest {
} }
Log.i(TAG, "Successfully tone mapped."); Log.i(TAG, "Successfully tone mapped.");
// TODO(b/207848601): switch to using proper tooling for testing against golden data. // TODO(b/207848601): Switch to using proper tooling for testing against golden data.
float averagePixelAbsoluteDifference = float averagePixelAbsoluteDifference =
getBitmapAveragePixelAbsoluteDifferenceArgb8888(expectedBitmap, actualBitmap, testId); getBitmapAveragePixelAbsoluteDifferenceArgb8888(expectedBitmap, actualBitmap, testId);
assertThat(averagePixelAbsoluteDifference) assertThat(averagePixelAbsoluteDifference)

View File

@ -22,7 +22,6 @@ import static com.google.android.exoplayer2.transformer.AndroidTestUtil.MP4_ASSE
import static com.google.android.exoplayer2.transformer.AndroidTestUtil.MP4_ASSET_1080P_5_SECOND_HLG10_FORMAT; import static com.google.android.exoplayer2.transformer.AndroidTestUtil.MP4_ASSET_1080P_5_SECOND_HLG10_FORMAT;
import static com.google.android.exoplayer2.transformer.AndroidTestUtil.recordTestSkipped; import static com.google.android.exoplayer2.transformer.AndroidTestUtil.recordTestSkipped;
import static com.google.android.exoplayer2.transformer.mh.FileUtil.assertFileHasColorTransfer; import static com.google.android.exoplayer2.transformer.mh.FileUtil.assertFileHasColorTransfer;
import static com.google.android.exoplayer2.util.Assertions.checkNotNull;
import android.content.Context; import android.content.Context;
import android.net.Uri; import android.net.Uri;
@ -91,10 +90,9 @@ public class ToneMapHdrToSdrUsingOpenGlTest {
new TransformerAndroidTestRunner.Builder(context, transformer) new TransformerAndroidTestRunner.Builder(context, transformer)
.build() .build()
.run(testId, mediaItem); .run(testId, mediaItem);
Log.i(TAG, "Tone mapped.");
assertFileHasColorTransfer(exportTestResult.filePath, C.COLOR_TRANSFER_SDR); assertFileHasColorTransfer(exportTestResult.filePath, C.COLOR_TRANSFER_SDR);
} catch (TransformationException exception) { } catch (TransformationException exception) {
Log.i(TAG, checkNotNull(exception.getCause()).toString()); Log.e(TAG, "Error during transformation.", exception);
if (exception.errorCode != TransformationException.ERROR_CODE_DECODING_FORMAT_UNSUPPORTED) { if (exception.errorCode != TransformationException.ERROR_CODE_DECODING_FORMAT_UNSUPPORTED) {
throw exception; throw exception;
} }
@ -142,10 +140,9 @@ public class ToneMapHdrToSdrUsingOpenGlTest {
new TransformerAndroidTestRunner.Builder(context, transformer) new TransformerAndroidTestRunner.Builder(context, transformer)
.build() .build()
.run(testId, mediaItem); .run(testId, mediaItem);
Log.i(TAG, "Tone mapped.");
assertFileHasColorTransfer(exportTestResult.filePath, C.COLOR_TRANSFER_SDR); assertFileHasColorTransfer(exportTestResult.filePath, C.COLOR_TRANSFER_SDR);
} catch (TransformationException exception) { } catch (TransformationException exception) {
Log.i(TAG, checkNotNull(exception.getCause()).toString()); Log.e(TAG, "Error during transformation.", exception);
if (exception.errorCode != TransformationException.ERROR_CODE_DECODING_FORMAT_UNSUPPORTED) { if (exception.errorCode != TransformationException.ERROR_CODE_DECODING_FORMAT_UNSUPPORTED) {
throw exception; throw exception;
} }

View File

@ -299,18 +299,18 @@ public final class ExoPlayerAssetLoader implements AssetLoader {
if (tracks.isTypeSelected(C.TRACK_TYPE_VIDEO)) { if (tracks.isTypeSelected(C.TRACK_TYPE_VIDEO)) {
trackCount++; trackCount++;
} }
if (trackCount == 0) {
if (trackCount > 0) {
assetLoaderListener.onTrackCount(trackCount);
// Start the renderers after having registered all the tracks to make sure the AssetLoader
// listener callbacks are called in the right order.
player.play();
} else {
assetLoaderListener.onError( assetLoaderListener.onError(
TransformationException.createForAssetLoader( TransformationException.createForAssetLoader(
new IllegalStateException("The asset loader has no track to output."), new IllegalStateException("The asset loader has no track to output."),
ERROR_CODE_FAILED_RUNTIME_CHECK)); ERROR_CODE_FAILED_RUNTIME_CHECK));
return;
} else {
assetLoaderListener.onTrackCount(trackCount);
} }
// Start the renderers after having registered all the tracks to make sure the AssetLoader
// listener callbacks are called in the right order.
player.play();
} }
@Override @Override

View File

@ -399,7 +399,7 @@ public final class Transformer {
* <li>Duration will match duration of the input media. * <li>Duration will match duration of the input media.
* <li>Sample mime type will match {@link TransformationRequest#audioMimeType}, or {@link * <li>Sample mime type will match {@link TransformationRequest#audioMimeType}, or {@link
* MimeTypes#AUDIO_AAC} if {@code null}. * MimeTypes#AUDIO_AAC} if {@code null}.
* <li>Sample rate will be {@code 44100} hz. This can be modified by creating a {@link * <li>Sample rate will be {@code 44100} Hz. This can be modified by creating a {@link
* SonicAudioProcessor}, setting its {@linkplain * SonicAudioProcessor}, setting its {@linkplain
* SonicAudioProcessor#setOutputSampleRateHz(int) sample rate}, and passing it to the * SonicAudioProcessor#setOutputSampleRateHz(int) sample rate}, and passing it to the
* {@link EditedMediaItem} used to start the export. * {@link EditedMediaItem} used to start the export.
@ -422,8 +422,8 @@ public final class Transformer {
* *
* @throws IllegalStateException If both audio and video have been removed (otherwise the output * @throws IllegalStateException If both audio and video have been removed (otherwise the output
* would not contain any samples). * would not contain any samples).
* @throws IllegalStateException If the muxer doesn't support the requested audio MIME type. * @throws IllegalStateException If the muxer doesn't support the requested audio/video MIME
* @throws IllegalStateException If the muxer doesn't support the requested video MIME type. * type.
*/ */
public Transformer build() { public Transformer build() {
if (transformationRequest.audioMimeType != null) { if (transformationRequest.audioMimeType != null) {

View File

@ -55,6 +55,9 @@ import org.checkerframework.dataflow.qual.Pure;
/** Pipeline to process, re-encode and mux raw video frames. */ /** Pipeline to process, re-encode and mux raw video frames. */
/* package */ final class VideoSamplePipeline extends SamplePipeline { /* package */ final class VideoSamplePipeline extends SamplePipeline {
/** MIME type to use for output video if the input type is not a video. */
private static final String DEFAULT_OUTPUT_MIME_TYPE = MimeTypes.VIDEO_H265;
private final FrameProcessor frameProcessor; private final FrameProcessor frameProcessor;
private final ColorInfo frameProcessorInputColor; private final ColorInfo frameProcessorInputColor;
private final FrameInfo firstFrameInfo; private final FrameInfo firstFrameInfo;
@ -364,7 +367,7 @@ import org.checkerframework.dataflow.qual.Pure;
if (transformationRequest.videoMimeType != null) { if (transformationRequest.videoMimeType != null) {
requestedOutputMimeType = transformationRequest.videoMimeType; requestedOutputMimeType = transformationRequest.videoMimeType;
} else if (MimeTypes.isImage(inputSampleMimeType)) { } else if (MimeTypes.isImage(inputSampleMimeType)) {
requestedOutputMimeType = MimeTypes.VIDEO_H265; requestedOutputMimeType = DEFAULT_OUTPUT_MIME_TYPE;
} else { } else {
requestedOutputMimeType = inputSampleMimeType; requestedOutputMimeType = inputSampleMimeType;
} }

View File

@ -84,7 +84,8 @@ public class EncoderUtilTest {
@Nullable @Nullable
Size closestSupportedResolution = Size closestSupportedResolution =
EncoderUtil.getSupportedResolution(encoderInfo, VIDEO_H264, 1920, 1080); EncoderUtil.getSupportedResolution(
encoderInfo, VIDEO_H264, /* width= */ 1920, /* height= */ 1080);
assertThat(closestSupportedResolution).isNotNull(); assertThat(closestSupportedResolution).isNotNull();
assertThat(closestSupportedResolution.getWidth()).isEqualTo(1920); assertThat(closestSupportedResolution.getWidth()).isEqualTo(1920);
@ -98,7 +99,8 @@ public class EncoderUtilTest {
@Nullable @Nullable
Size closestSupportedResolution = Size closestSupportedResolution =
EncoderUtil.getSupportedResolution(encoderInfo, VIDEO_H264, 1919, 1081); EncoderUtil.getSupportedResolution(
encoderInfo, VIDEO_H264, /* width= */ 1919, /* height= */ 1081);
assertThat(closestSupportedResolution).isNotNull(); assertThat(closestSupportedResolution).isNotNull();
assertThat(closestSupportedResolution.getWidth()).isEqualTo(1920); assertThat(closestSupportedResolution.getWidth()).isEqualTo(1920);
@ -113,7 +115,8 @@ public class EncoderUtilTest {
@Nullable @Nullable
Size closestSupportedResolution = Size closestSupportedResolution =
EncoderUtil.getSupportedResolution(encoderInfo, VIDEO_H264, 1920, 1920); EncoderUtil.getSupportedResolution(
encoderInfo, VIDEO_H264, /* width= */ 1920, /* height= */ 1920);
assertThat(closestSupportedResolution).isNotNull(); assertThat(closestSupportedResolution).isNotNull();
assertThat(closestSupportedResolution.getWidth()).isEqualTo(1440); assertThat(closestSupportedResolution.getWidth()).isEqualTo(1440);
@ -127,7 +130,8 @@ public class EncoderUtilTest {
@Nullable @Nullable
Size closestSupportedResolution = Size closestSupportedResolution =
EncoderUtil.getSupportedResolution(encoderInfo, VIDEO_H264, 2880, 1620); EncoderUtil.getSupportedResolution(
encoderInfo, VIDEO_H264, /* width= */ 2880, /* height= */ 1620);
assertThat(closestSupportedResolution).isNotNull(); assertThat(closestSupportedResolution).isNotNull();
assertThat(closestSupportedResolution.getWidth()).isEqualTo(1920); assertThat(closestSupportedResolution.getWidth()).isEqualTo(1920);
@ -141,7 +145,8 @@ public class EncoderUtilTest {
@Nullable @Nullable
Size closestSupportedResolution = Size closestSupportedResolution =
EncoderUtil.getSupportedResolution(encoderInfo, VIDEO_H264, 2160, 3840); EncoderUtil.getSupportedResolution(
encoderInfo, VIDEO_H264, /* width= */ 2160, /* height= */ 3840);
assertThat(closestSupportedResolution).isNotNull(); assertThat(closestSupportedResolution).isNotNull();
assertThat(closestSupportedResolution.getWidth()).isEqualTo(1080); assertThat(closestSupportedResolution.getWidth()).isEqualTo(1080);
@ -155,7 +160,8 @@ public class EncoderUtilTest {
@Nullable @Nullable
Size closestSupportedResolution = Size closestSupportedResolution =
EncoderUtil.getSupportedResolution(encoderInfo, VIDEO_H264, 7680, 4320); EncoderUtil.getSupportedResolution(
encoderInfo, VIDEO_H264, /* width= */ 7680, /* height= */ 4320);
assertThat(closestSupportedResolution).isNotNull(); assertThat(closestSupportedResolution).isNotNull();
assertThat(closestSupportedResolution.getWidth()).isEqualTo(1920); assertThat(closestSupportedResolution.getWidth()).isEqualTo(1920);
@ -167,16 +173,15 @@ public class EncoderUtilTest {
ImmutableList<MediaCodecInfo> supportedEncoders = EncoderUtil.getSupportedEncoders(VIDEO_H264); ImmutableList<MediaCodecInfo> supportedEncoders = EncoderUtil.getSupportedEncoders(VIDEO_H264);
MediaCodecInfo encoderInfo = supportedEncoders.get(0); MediaCodecInfo encoderInfo = supportedEncoders.get(0);
double aspectRatio = 1.5;
@Nullable @Nullable
Size closestSupportedResolution = Size closestSupportedResolution =
EncoderUtil.getSupportedResolution( EncoderUtil.getSupportedResolution(
encoderInfo, VIDEO_H264, (int) (aspectRatio * 5000), 5000); encoderInfo, VIDEO_H264, /* width= */ 7500, /* height= */ 5000);
assertThat(closestSupportedResolution).isNotNull(); assertThat(closestSupportedResolution).isNotNull();
assertThat( assertThat(
(double) closestSupportedResolution.getWidth() / closestSupportedResolution.getHeight()) (double) closestSupportedResolution.getWidth() / closestSupportedResolution.getHeight())
.isEqualTo(aspectRatio); .isEqualTo(7500.0 / 5000);
} }
/** /**

View File

@ -38,7 +38,7 @@ import java.nio.ByteBuffer;
import org.checkerframework.checker.nullness.qual.Nullable; import org.checkerframework.checker.nullness.qual.Nullable;
/** Utilities for decoding a frame for tests. */ /** Utilities for decoding a frame for tests. */
public class DecodeOneFrameUtil { public final class DecodeOneFrameUtil {
public static final String NO_DECODER_SUPPORT_ERROR_STRING = public static final String NO_DECODER_SUPPORT_ERROR_STRING =
"No MediaCodec decoders on this device support this value."; "No MediaCodec decoders on this device support this value.";