From 3e5ae92bc6f4f0cf2a82e5150b51c0c63ddefcf7 Mon Sep 17 00:00:00 2001 From: andrewlewis Date: Wed, 15 Feb 2023 18:53:46 +0000 Subject: [PATCH] Fix some minor nits PiperOrigin-RevId: 509879029 --- .../exoplayer2/util/FrameProcessor.java | 1 + .../exoplayer2/effect/CropPixelTest.java | 6 +-- .../GlEffectsFrameProcessorPixelTest.java | 40 +++++++++---------- .../effect/MatrixShaderProgramPixelTest.java | 8 ++-- .../effect/PresentationPixelTest.java | 14 +++---- .../effect/ExternalTextureManager.java | 2 +- .../android/exoplayer2/effect/FrameCache.java | 2 +- .../effect/FrameCacheShaderProgram.java | 2 +- .../effect/InternalTextureManager.java | 15 +++---- .../exoplayer2/effect/OverlaySettings.java | 15 +++---- .../ToneMapHdrToSdrUsingOpenGlPixelTest.java | 4 +- .../mh/ToneMapHdrToSdrUsingOpenGlTest.java | 7 +--- .../transformer/ExoPlayerAssetLoader.java | 14 +++---- .../exoplayer2/transformer/Transformer.java | 6 +-- .../transformer/VideoSamplePipeline.java | 5 ++- .../transformer/EncoderUtilTest.java | 23 ++++++----- .../testutil/DecodeOneFrameUtil.java | 2 +- 17 files changed, 83 insertions(+), 83 deletions(-) diff --git a/library/common/src/main/java/com/google/android/exoplayer2/util/FrameProcessor.java b/library/common/src/main/java/com/google/android/exoplayer2/util/FrameProcessor.java index 133b5de38e..e883b2ec14 100644 --- a/library/common/src/main/java/com/google/android/exoplayer2/util/FrameProcessor.java +++ b/library/common/src/main/java/com/google/android/exoplayer2/util/FrameProcessor.java @@ -136,6 +136,7 @@ public interface 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 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 // signalled down to the processors. diff --git a/library/effect/src/androidTest/java/com/google/android/exoplayer2/effect/CropPixelTest.java b/library/effect/src/androidTest/java/com/google/android/exoplayer2/effect/CropPixelTest.java index 173ee666b4..f0c23cf348 100644 --- a/library/effect/src/androidTest/java/com/google/android/exoplayer2/effect/CropPixelTest.java +++ b/library/effect/src/androidTest/java/com/google/android/exoplayer2/effect/CropPixelTest.java @@ -106,7 +106,7 @@ public final class CropPixelTest { createArgb8888BitmapFromCurrentGlFramebuffer(outputSize.getWidth(), outputSize.getHeight()); 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 = getBitmapAveragePixelAbsoluteDifferenceArgb8888(expectedBitmap, actualBitmap, testId); assertThat(averagePixelAbsoluteDifference).isAtMost(MAXIMUM_AVERAGE_PIXEL_ABSOLUTE_DIFFERENCE); @@ -127,7 +127,7 @@ public final class CropPixelTest { createArgb8888BitmapFromCurrentGlFramebuffer(outputSize.getWidth(), outputSize.getHeight()); 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 = getBitmapAveragePixelAbsoluteDifferenceArgb8888(expectedBitmap, actualBitmap, testId); assertThat(averagePixelAbsoluteDifference).isAtMost(MAXIMUM_AVERAGE_PIXEL_ABSOLUTE_DIFFERENCE); @@ -148,7 +148,7 @@ public final class CropPixelTest { createArgb8888BitmapFromCurrentGlFramebuffer(outputSize.getWidth(), outputSize.getHeight()); 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 = getBitmapAveragePixelAbsoluteDifferenceArgb8888(expectedBitmap, actualBitmap, testId); assertThat(averagePixelAbsoluteDifference).isAtMost(MAXIMUM_AVERAGE_PIXEL_ABSOLUTE_DIFFERENCE); diff --git a/library/effect/src/androidTest/java/com/google/android/exoplayer2/effect/GlEffectsFrameProcessorPixelTest.java b/library/effect/src/androidTest/java/com/google/android/exoplayer2/effect/GlEffectsFrameProcessorPixelTest.java index c26c0b1ac4..1d19843281 100644 --- a/library/effect/src/androidTest/java/com/google/android/exoplayer2/effect/GlEffectsFrameProcessorPixelTest.java +++ b/library/effect/src/androidTest/java/com/google/android/exoplayer2/effect/GlEffectsFrameProcessorPixelTest.java @@ -96,7 +96,7 @@ public final class GlEffectsFrameProcessorPixelTest { 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 = getBitmapAveragePixelAbsoluteDifferenceArgb8888(expectedBitmap, actualBitmap, testId); assertThat(averagePixelAbsoluteDifference).isAtMost(MAXIMUM_AVERAGE_PIXEL_ABSOLUTE_DIFFERENCE); @@ -111,7 +111,7 @@ public final class GlEffectsFrameProcessorPixelTest { 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 = getBitmapAveragePixelAbsoluteDifferenceArgb8888(expectedBitmap, actualBitmap, testId); assertThat(averagePixelAbsoluteDifference).isAtMost(MAXIMUM_AVERAGE_PIXEL_ABSOLUTE_DIFFERENCE); @@ -136,14 +136,14 @@ public final class GlEffectsFrameProcessorPixelTest { 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 = getBitmapAveragePixelAbsoluteDifferenceArgb8888(expectedBitmap, actualBitmap, testId); assertThat(averagePixelAbsoluteDifference).isAtMost(MAXIMUM_AVERAGE_PIXEL_ABSOLUTE_DIFFERENCE); } // 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 - // correct number of frames haas been queued. + // queuing multiple input bitmaps to ensure the operation successfully completes and that the + // correct number of frames has been queued. @Test public void noEffects_withFrameCache_matchesGoldenFile() throws Exception { @@ -156,7 +156,7 @@ public final class GlEffectsFrameProcessorPixelTest { 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 = getBitmapAveragePixelAbsoluteDifferenceArgb8888(expectedBitmap, actualBitmap, testId); assertThat(averagePixelAbsoluteDifference).isAtMost(MAXIMUM_AVERAGE_PIXEL_ABSOLUTE_DIFFERENCE); @@ -171,7 +171,7 @@ public final class GlEffectsFrameProcessorPixelTest { 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 = getBitmapAveragePixelAbsoluteDifferenceArgb8888(expectedBitmap, actualBitmap, testId); assertThat(averagePixelAbsoluteDifference).isAtMost(MAXIMUM_AVERAGE_PIXEL_ABSOLUTE_DIFFERENCE); @@ -190,7 +190,7 @@ public final class GlEffectsFrameProcessorPixelTest { 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 = getBitmapAveragePixelAbsoluteDifferenceArgb8888(expectedBitmap, actualBitmap, testId); assertThat(averagePixelAbsoluteDifference).isAtMost(MAXIMUM_AVERAGE_PIXEL_ABSOLUTE_DIFFERENCE); @@ -211,7 +211,7 @@ public final class GlEffectsFrameProcessorPixelTest { 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 = getBitmapAveragePixelAbsoluteDifferenceArgb8888(expectedBitmap, actualBitmap, testId); assertThat(averagePixelAbsoluteDifference).isAtMost(MAXIMUM_AVERAGE_PIXEL_ABSOLUTE_DIFFERENCE); @@ -230,7 +230,7 @@ public final class GlEffectsFrameProcessorPixelTest { 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 = getBitmapAveragePixelAbsoluteDifferenceArgb8888(expectedBitmap, actualBitmap, testId); assertThat(averagePixelAbsoluteDifference).isAtMost(MAXIMUM_AVERAGE_PIXEL_ABSOLUTE_DIFFERENCE); @@ -251,7 +251,7 @@ public final class GlEffectsFrameProcessorPixelTest { 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 = getBitmapAveragePixelAbsoluteDifferenceArgb8888(expectedBitmap, actualBitmap, testId); assertThat(averagePixelAbsoluteDifference).isAtMost(MAXIMUM_AVERAGE_PIXEL_ABSOLUTE_DIFFERENCE); @@ -268,7 +268,7 @@ public final class GlEffectsFrameProcessorPixelTest { 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 = getBitmapAveragePixelAbsoluteDifferenceArgb8888(expectedBitmap, actualBitmap, testId); assertThat(averagePixelAbsoluteDifference).isAtMost(MAXIMUM_AVERAGE_PIXEL_ABSOLUTE_DIFFERENCE); @@ -289,7 +289,7 @@ public final class GlEffectsFrameProcessorPixelTest { 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 = getBitmapAveragePixelAbsoluteDifferenceArgb8888(expectedBitmap, actualBitmap, testId); assertThat(averagePixelAbsoluteDifference).isAtMost(MAXIMUM_AVERAGE_PIXEL_ABSOLUTE_DIFFERENCE); @@ -306,7 +306,7 @@ public final class GlEffectsFrameProcessorPixelTest { 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 = getBitmapAveragePixelAbsoluteDifferenceArgb8888(expectedBitmap, actualBitmap, testId); assertThat(averagePixelAbsoluteDifference).isAtMost(MAXIMUM_AVERAGE_PIXEL_ABSOLUTE_DIFFERENCE); @@ -329,7 +329,7 @@ public final class GlEffectsFrameProcessorPixelTest { 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 = getBitmapAveragePixelAbsoluteDifferenceArgb8888(expectedBitmap, actualBitmap, testId); assertThat(averagePixelAbsoluteDifference).isAtMost(MAXIMUM_AVERAGE_PIXEL_ABSOLUTE_DIFFERENCE); @@ -361,7 +361,7 @@ public final class GlEffectsFrameProcessorPixelTest { Bitmap fullRotationAndCenterCropResultBitmap = 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 = getBitmapAveragePixelAbsoluteDifferenceArgb8888( centerCropResultBitmap, fullRotationAndCenterCropResultBitmap, testId); @@ -377,7 +377,7 @@ public final class GlEffectsFrameProcessorPixelTest { 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 = getBitmapAveragePixelAbsoluteDifferenceArgb8888(expectedBitmap, actualBitmap, testId); assertThat(averagePixelAbsoluteDifference).isAtMost(MAXIMUM_AVERAGE_PIXEL_ABSOLUTE_DIFFERENCE); @@ -418,7 +418,7 @@ public final class GlEffectsFrameProcessorPixelTest { Bitmap fullRotationBrightnessIncreaseAndCenterCropResultBitmap = 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 = getBitmapAveragePixelAbsoluteDifferenceArgb8888( centerCropAndBrightnessIncreaseResultBitmap, @@ -465,7 +465,7 @@ public final class GlEffectsFrameProcessorPixelTest { Bitmap fullRotationBrightnessIncreaseAndCenterCropResultBitmap = 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 = getBitmapAveragePixelAbsoluteDifferenceArgb8888( centerCropAndBrightnessIncreaseResultBitmap, @@ -487,7 +487,7 @@ public final class GlEffectsFrameProcessorPixelTest { 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 = getBitmapAveragePixelAbsoluteDifferenceArgb8888(expectedBitmap, actualBitmap, testId); assertThat(averagePixelAbsoluteDifference).isAtMost(MAXIMUM_AVERAGE_PIXEL_ABSOLUTE_DIFFERENCE); diff --git a/library/effect/src/androidTest/java/com/google/android/exoplayer2/effect/MatrixShaderProgramPixelTest.java b/library/effect/src/androidTest/java/com/google/android/exoplayer2/effect/MatrixShaderProgramPixelTest.java index f6c85bdf00..21f0d7e4d6 100644 --- a/library/effect/src/androidTest/java/com/google/android/exoplayer2/effect/MatrixShaderProgramPixelTest.java +++ b/library/effect/src/androidTest/java/com/google/android/exoplayer2/effect/MatrixShaderProgramPixelTest.java @@ -109,7 +109,7 @@ public final class MatrixShaderProgramPixelTest { Bitmap actualBitmap = createArgb8888BitmapFromCurrentGlFramebuffer(inputWidth, inputHeight); 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 = getBitmapAveragePixelAbsoluteDifferenceArgb8888(expectedBitmap, actualBitmap, testId); assertThat(averagePixelAbsoluteDifference).isAtMost(MAXIMUM_AVERAGE_PIXEL_ABSOLUTE_DIFFERENCE); @@ -131,7 +131,7 @@ public final class MatrixShaderProgramPixelTest { Bitmap actualBitmap = createArgb8888BitmapFromCurrentGlFramebuffer(inputWidth, inputHeight); 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 = getBitmapAveragePixelAbsoluteDifferenceArgb8888(expectedBitmap, actualBitmap, testId); assertThat(averagePixelAbsoluteDifference).isAtMost(MAXIMUM_AVERAGE_PIXEL_ABSOLUTE_DIFFERENCE); @@ -151,7 +151,7 @@ public final class MatrixShaderProgramPixelTest { Bitmap actualBitmap = createArgb8888BitmapFromCurrentGlFramebuffer(inputWidth, inputHeight); 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 = getBitmapAveragePixelAbsoluteDifferenceArgb8888(expectedBitmap, actualBitmap, testId); assertThat(averagePixelAbsoluteDifference).isAtMost(MAXIMUM_AVERAGE_PIXEL_ABSOLUTE_DIFFERENCE); @@ -171,7 +171,7 @@ public final class MatrixShaderProgramPixelTest { Bitmap actualBitmap = createArgb8888BitmapFromCurrentGlFramebuffer(inputWidth, inputHeight); 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 = getBitmapAveragePixelAbsoluteDifferenceArgb8888(expectedBitmap, actualBitmap, testId); assertThat(averagePixelAbsoluteDifference).isAtMost(MAXIMUM_AVERAGE_PIXEL_ABSOLUTE_DIFFERENCE); diff --git a/library/effect/src/androidTest/java/com/google/android/exoplayer2/effect/PresentationPixelTest.java b/library/effect/src/androidTest/java/com/google/android/exoplayer2/effect/PresentationPixelTest.java index c6f37daea6..9fbf92c604 100644 --- a/library/effect/src/androidTest/java/com/google/android/exoplayer2/effect/PresentationPixelTest.java +++ b/library/effect/src/androidTest/java/com/google/android/exoplayer2/effect/PresentationPixelTest.java @@ -115,7 +115,7 @@ public final class PresentationPixelTest { createArgb8888BitmapFromCurrentGlFramebuffer(outputSize.getWidth(), outputSize.getHeight()); 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 = getBitmapAveragePixelAbsoluteDifferenceArgb8888(expectedBitmap, actualBitmap, testId); assertThat(averagePixelAbsoluteDifference).isAtMost(MAXIMUM_AVERAGE_PIXEL_ABSOLUTE_DIFFERENCE); @@ -136,7 +136,7 @@ public final class PresentationPixelTest { createArgb8888BitmapFromCurrentGlFramebuffer(outputSize.getWidth(), outputSize.getHeight()); 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 = getBitmapAveragePixelAbsoluteDifferenceArgb8888(expectedBitmap, actualBitmap, testId); assertThat(averagePixelAbsoluteDifference).isAtMost(MAXIMUM_AVERAGE_PIXEL_ABSOLUTE_DIFFERENCE); @@ -157,7 +157,7 @@ public final class PresentationPixelTest { createArgb8888BitmapFromCurrentGlFramebuffer(outputSize.getWidth(), outputSize.getHeight()); 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 = getBitmapAveragePixelAbsoluteDifferenceArgb8888(expectedBitmap, actualBitmap, testId); assertThat(averagePixelAbsoluteDifference).isAtMost(MAXIMUM_AVERAGE_PIXEL_ABSOLUTE_DIFFERENCE); @@ -180,7 +180,7 @@ public final class PresentationPixelTest { createArgb8888BitmapFromCurrentGlFramebuffer(outputSize.getWidth(), outputSize.getHeight()); 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 = getBitmapAveragePixelAbsoluteDifferenceArgb8888(expectedBitmap, actualBitmap, testId); assertThat(averagePixelAbsoluteDifference).isAtMost(MAXIMUM_AVERAGE_PIXEL_ABSOLUTE_DIFFERENCE); @@ -203,7 +203,7 @@ public final class PresentationPixelTest { createArgb8888BitmapFromCurrentGlFramebuffer(outputSize.getWidth(), outputSize.getHeight()); 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 = getBitmapAveragePixelAbsoluteDifferenceArgb8888(expectedBitmap, actualBitmap, testId); assertThat(averagePixelAbsoluteDifference).isAtMost(MAXIMUM_AVERAGE_PIXEL_ABSOLUTE_DIFFERENCE); @@ -224,7 +224,7 @@ public final class PresentationPixelTest { createArgb8888BitmapFromCurrentGlFramebuffer(outputSize.getWidth(), outputSize.getHeight()); 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 = getBitmapAveragePixelAbsoluteDifferenceArgb8888(expectedBitmap, actualBitmap, testId); assertThat(averagePixelAbsoluteDifference).isAtMost(MAXIMUM_AVERAGE_PIXEL_ABSOLUTE_DIFFERENCE); @@ -245,7 +245,7 @@ public final class PresentationPixelTest { createArgb8888BitmapFromCurrentGlFramebuffer(outputSize.getWidth(), outputSize.getHeight()); 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 = getBitmapAveragePixelAbsoluteDifferenceArgb8888(expectedBitmap, actualBitmap, testId); assertThat(averagePixelAbsoluteDifference).isAtMost(MAXIMUM_AVERAGE_PIXEL_ABSOLUTE_DIFFERENCE); diff --git a/library/effect/src/main/java/com/google/android/exoplayer2/effect/ExternalTextureManager.java b/library/effect/src/main/java/com/google/android/exoplayer2/effect/ExternalTextureManager.java index 1d8102cd2b..3b94892278 100644 --- a/library/effect/src/main/java/com/google/android/exoplayer2/effect/ExternalTextureManager.java +++ b/library/effect/src/main/java/com/google/android/exoplayer2/effect/ExternalTextureManager.java @@ -35,7 +35,7 @@ import java.util.concurrent.atomic.AtomicInteger; * Forwards externally produced frames that become available via a {@link SurfaceTexture} to an * {@link ExternalShaderProgram} for consumption. */ -/* package */ class ExternalTextureManager implements InputListener { +/* package */ final class ExternalTextureManager implements InputListener { private final FrameProcessingTaskExecutor frameProcessingTaskExecutor; private final ExternalShaderProgram externalShaderProgram; diff --git a/library/effect/src/main/java/com/google/android/exoplayer2/effect/FrameCache.java b/library/effect/src/main/java/com/google/android/exoplayer2/effect/FrameCache.java index 2adac83952..9d4e14c1e9 100644 --- a/library/effect/src/main/java/com/google/android/exoplayer2/effect/FrameCache.java +++ b/library/effect/src/main/java/com/google/android/exoplayer2/effect/FrameCache.java @@ -27,7 +27,7 @@ import com.google.android.exoplayer2.util.FrameProcessingException; *

Example usage: cache the processed frames when presenting them on screen, to accommodate for * 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. */ public final int capacity; diff --git a/library/effect/src/main/java/com/google/android/exoplayer2/effect/FrameCacheShaderProgram.java b/library/effect/src/main/java/com/google/android/exoplayer2/effect/FrameCacheShaderProgram.java index 564fb20f31..2cb0dce666 100644 --- a/library/effect/src/main/java/com/google/android/exoplayer2/effect/FrameCacheShaderProgram.java +++ b/library/effect/src/main/java/com/google/android/exoplayer2/effect/FrameCacheShaderProgram.java @@ -35,7 +35,7 @@ import java.util.concurrent.Executor; * *

Implements {@link FrameCache}. */ -/* package */ class FrameCacheShaderProgram implements GlShaderProgram { +/* package */ final class FrameCacheShaderProgram implements GlShaderProgram { private static final String VERTEX_SHADER_TRANSFORMATION_ES2_PATH = "shaders/vertex_shader_transformation_es2.glsl"; private static final String FRAGMENT_SHADER_TRANSFORMATION_ES2_PATH = diff --git a/library/effect/src/main/java/com/google/android/exoplayer2/effect/InternalTextureManager.java b/library/effect/src/main/java/com/google/android/exoplayer2/effect/InternalTextureManager.java index 148db71bd1..4ef9078aff 100644 --- a/library/effect/src/main/java/com/google/android/exoplayer2/effect/InternalTextureManager.java +++ b/library/effect/src/main/java/com/google/android/exoplayer2/effect/InternalTextureManager.java @@ -30,11 +30,11 @@ import java.util.Queue; 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. * *

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 FrameProcessingTaskExecutor frameProcessingTaskExecutor; // 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( () -> { inputEnded = true; - signalEndOfOutput(); + maybeSignalEndOfOutput(); }); } @@ -145,12 +145,12 @@ import java.util.concurrent.LinkedBlockingQueue; currentPresentationTimeUs += currentBitmap.frameDurationUs; if (framesToQueueForCurrentBitmap == 0) { pendingBitmaps.remove(); - signalEndOfOutput(); + maybeSignalEndOfOutput(); } } @WorkerThread - private void signalEndOfOutput() { + private void maybeSignalEndOfOutput() { if (framesToQueueForCurrentBitmap == 0 && pendingBitmaps.isEmpty() && inputEnded @@ -160,10 +160,7 @@ import java.util.concurrent.LinkedBlockingQueue; } } - /** - * Value class specifying information to generate all the frames associated with a specific {@link - * Bitmap}. - */ + /** Information to generate all the frames associated with a specific {@link Bitmap}. */ private static final class BitmapFrameSequenceInfo { public final TextureInfo textureInfo; public final long frameDurationUs; diff --git a/library/effect/src/main/java/com/google/android/exoplayer2/effect/OverlaySettings.java b/library/effect/src/main/java/com/google/android/exoplayer2/effect/OverlaySettings.java index 2e6f6041fd..05af025d8d 100644 --- a/library/effect/src/main/java/com/google/android/exoplayer2/effect/OverlaySettings.java +++ b/library/effect/src/main/java/com/google/android/exoplayer2/effect/OverlaySettings.java @@ -38,12 +38,13 @@ public final class OverlaySettings { /** A builder for {@link OverlaySettings} instances. */ public static final class Builder { private boolean useHdr; - private float alpha = 1; + private float alpha; private float[] matrix; private Pair anchor; /** Creates a new {@link Builder}. */ public Builder() { + alpha = 1f; matrix = GlUtil.create4x4IdentityMatrix(); anchor = Pair.create(0f, 0f); } @@ -94,18 +95,14 @@ public final class OverlaySettings { *

The coordinates are specified in Normalised Device Coordinates (NDCs). Set to always * return {@code (0,0)} (the center) by default. * - * @param x the NDC x-coordinate. - * @param y the NDC y-coordinate. + * @param x The NDC x-coordinate in the range [-1, 1]. + * @param y The NDC y-coordinate in the range [-1, 1]. */ @CanIgnoreReturnValue public Builder setAnchor( @FloatRange(from = -1, to = 1) float x, @FloatRange(from = -1, to = 1) float y) { - checkArgument( - -1 <= x && x <= 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]."); + checkArgument(-1 <= x && x <= 1); + checkArgument(-1 <= y && y <= 1); this.anchor = Pair.create(x, y); return this; } diff --git a/library/transformer/src/androidTest/java/com/google/android/exoplayer2/transformer/mh/ToneMapHdrToSdrUsingOpenGlPixelTest.java b/library/transformer/src/androidTest/java/com/google/android/exoplayer2/transformer/mh/ToneMapHdrToSdrUsingOpenGlPixelTest.java index 4c57ae4eb7..cd5e3ace80 100644 --- a/library/transformer/src/androidTest/java/com/google/android/exoplayer2/transformer/mh/ToneMapHdrToSdrUsingOpenGlPixelTest.java +++ b/library/transformer/src/androidTest/java/com/google/android/exoplayer2/transformer/mh/ToneMapHdrToSdrUsingOpenGlPixelTest.java @@ -139,7 +139,7 @@ public final class ToneMapHdrToSdrUsingOpenGlPixelTest { } 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 = getBitmapAveragePixelAbsoluteDifferenceArgb8888(expectedBitmap, actualBitmap, testId); assertThat(averagePixelAbsoluteDifference) @@ -202,7 +202,7 @@ public final class ToneMapHdrToSdrUsingOpenGlPixelTest { } 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 = getBitmapAveragePixelAbsoluteDifferenceArgb8888(expectedBitmap, actualBitmap, testId); assertThat(averagePixelAbsoluteDifference) diff --git a/library/transformer/src/androidTest/java/com/google/android/exoplayer2/transformer/mh/ToneMapHdrToSdrUsingOpenGlTest.java b/library/transformer/src/androidTest/java/com/google/android/exoplayer2/transformer/mh/ToneMapHdrToSdrUsingOpenGlTest.java index d033892df4..ee65e5a71b 100644 --- a/library/transformer/src/androidTest/java/com/google/android/exoplayer2/transformer/mh/ToneMapHdrToSdrUsingOpenGlTest.java +++ b/library/transformer/src/androidTest/java/com/google/android/exoplayer2/transformer/mh/ToneMapHdrToSdrUsingOpenGlTest.java @@ -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.recordTestSkipped; 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.net.Uri; @@ -91,10 +90,9 @@ public class ToneMapHdrToSdrUsingOpenGlTest { new TransformerAndroidTestRunner.Builder(context, transformer) .build() .run(testId, mediaItem); - Log.i(TAG, "Tone mapped."); assertFileHasColorTransfer(exportTestResult.filePath, C.COLOR_TRANSFER_SDR); } 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) { throw exception; } @@ -142,10 +140,9 @@ public class ToneMapHdrToSdrUsingOpenGlTest { new TransformerAndroidTestRunner.Builder(context, transformer) .build() .run(testId, mediaItem); - Log.i(TAG, "Tone mapped."); assertFileHasColorTransfer(exportTestResult.filePath, C.COLOR_TRANSFER_SDR); } 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) { throw exception; } diff --git a/library/transformer/src/main/java/com/google/android/exoplayer2/transformer/ExoPlayerAssetLoader.java b/library/transformer/src/main/java/com/google/android/exoplayer2/transformer/ExoPlayerAssetLoader.java index 4cb0690c89..ce40abd7d1 100644 --- a/library/transformer/src/main/java/com/google/android/exoplayer2/transformer/ExoPlayerAssetLoader.java +++ b/library/transformer/src/main/java/com/google/android/exoplayer2/transformer/ExoPlayerAssetLoader.java @@ -299,18 +299,18 @@ public final class ExoPlayerAssetLoader implements AssetLoader { if (tracks.isTypeSelected(C.TRACK_TYPE_VIDEO)) { 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( TransformationException.createForAssetLoader( new IllegalStateException("The asset loader has no track to output."), 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 diff --git a/library/transformer/src/main/java/com/google/android/exoplayer2/transformer/Transformer.java b/library/transformer/src/main/java/com/google/android/exoplayer2/transformer/Transformer.java index 0526d002db..38d902d475 100644 --- a/library/transformer/src/main/java/com/google/android/exoplayer2/transformer/Transformer.java +++ b/library/transformer/src/main/java/com/google/android/exoplayer2/transformer/Transformer.java @@ -399,7 +399,7 @@ public final class Transformer { *

  • Duration will match duration of the input media. *
  • Sample mime type will match {@link TransformationRequest#audioMimeType}, or {@link * MimeTypes#AUDIO_AAC} if {@code null}. - *
  • Sample rate will be {@code 44100} hz. This can be modified by creating a {@link + *
  • Sample rate will be {@code 44100} Hz. This can be modified by creating a {@link * SonicAudioProcessor}, setting its {@linkplain * SonicAudioProcessor#setOutputSampleRateHz(int) sample rate}, and passing it to the * {@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 * 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 video MIME type. + * @throws IllegalStateException If the muxer doesn't support the requested audio/video MIME + * type. */ public Transformer build() { if (transformationRequest.audioMimeType != null) { diff --git a/library/transformer/src/main/java/com/google/android/exoplayer2/transformer/VideoSamplePipeline.java b/library/transformer/src/main/java/com/google/android/exoplayer2/transformer/VideoSamplePipeline.java index e871d5350e..0b0104fae3 100644 --- a/library/transformer/src/main/java/com/google/android/exoplayer2/transformer/VideoSamplePipeline.java +++ b/library/transformer/src/main/java/com/google/android/exoplayer2/transformer/VideoSamplePipeline.java @@ -55,6 +55,9 @@ import org.checkerframework.dataflow.qual.Pure; /** Pipeline to process, re-encode and mux raw video frames. */ /* 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 ColorInfo frameProcessorInputColor; private final FrameInfo firstFrameInfo; @@ -364,7 +367,7 @@ import org.checkerframework.dataflow.qual.Pure; if (transformationRequest.videoMimeType != null) { requestedOutputMimeType = transformationRequest.videoMimeType; } else if (MimeTypes.isImage(inputSampleMimeType)) { - requestedOutputMimeType = MimeTypes.VIDEO_H265; + requestedOutputMimeType = DEFAULT_OUTPUT_MIME_TYPE; } else { requestedOutputMimeType = inputSampleMimeType; } diff --git a/library/transformer/src/test/java/com/google/android/exoplayer2/transformer/EncoderUtilTest.java b/library/transformer/src/test/java/com/google/android/exoplayer2/transformer/EncoderUtilTest.java index 23271ba4e8..a2679b43b8 100644 --- a/library/transformer/src/test/java/com/google/android/exoplayer2/transformer/EncoderUtilTest.java +++ b/library/transformer/src/test/java/com/google/android/exoplayer2/transformer/EncoderUtilTest.java @@ -84,7 +84,8 @@ public class EncoderUtilTest { @Nullable Size closestSupportedResolution = - EncoderUtil.getSupportedResolution(encoderInfo, VIDEO_H264, 1920, 1080); + EncoderUtil.getSupportedResolution( + encoderInfo, VIDEO_H264, /* width= */ 1920, /* height= */ 1080); assertThat(closestSupportedResolution).isNotNull(); assertThat(closestSupportedResolution.getWidth()).isEqualTo(1920); @@ -98,7 +99,8 @@ public class EncoderUtilTest { @Nullable Size closestSupportedResolution = - EncoderUtil.getSupportedResolution(encoderInfo, VIDEO_H264, 1919, 1081); + EncoderUtil.getSupportedResolution( + encoderInfo, VIDEO_H264, /* width= */ 1919, /* height= */ 1081); assertThat(closestSupportedResolution).isNotNull(); assertThat(closestSupportedResolution.getWidth()).isEqualTo(1920); @@ -113,7 +115,8 @@ public class EncoderUtilTest { @Nullable Size closestSupportedResolution = - EncoderUtil.getSupportedResolution(encoderInfo, VIDEO_H264, 1920, 1920); + EncoderUtil.getSupportedResolution( + encoderInfo, VIDEO_H264, /* width= */ 1920, /* height= */ 1920); assertThat(closestSupportedResolution).isNotNull(); assertThat(closestSupportedResolution.getWidth()).isEqualTo(1440); @@ -127,7 +130,8 @@ public class EncoderUtilTest { @Nullable Size closestSupportedResolution = - EncoderUtil.getSupportedResolution(encoderInfo, VIDEO_H264, 2880, 1620); + EncoderUtil.getSupportedResolution( + encoderInfo, VIDEO_H264, /* width= */ 2880, /* height= */ 1620); assertThat(closestSupportedResolution).isNotNull(); assertThat(closestSupportedResolution.getWidth()).isEqualTo(1920); @@ -141,7 +145,8 @@ public class EncoderUtilTest { @Nullable Size closestSupportedResolution = - EncoderUtil.getSupportedResolution(encoderInfo, VIDEO_H264, 2160, 3840); + EncoderUtil.getSupportedResolution( + encoderInfo, VIDEO_H264, /* width= */ 2160, /* height= */ 3840); assertThat(closestSupportedResolution).isNotNull(); assertThat(closestSupportedResolution.getWidth()).isEqualTo(1080); @@ -155,7 +160,8 @@ public class EncoderUtilTest { @Nullable Size closestSupportedResolution = - EncoderUtil.getSupportedResolution(encoderInfo, VIDEO_H264, 7680, 4320); + EncoderUtil.getSupportedResolution( + encoderInfo, VIDEO_H264, /* width= */ 7680, /* height= */ 4320); assertThat(closestSupportedResolution).isNotNull(); assertThat(closestSupportedResolution.getWidth()).isEqualTo(1920); @@ -167,16 +173,15 @@ public class EncoderUtilTest { ImmutableList supportedEncoders = EncoderUtil.getSupportedEncoders(VIDEO_H264); MediaCodecInfo encoderInfo = supportedEncoders.get(0); - double aspectRatio = 1.5; @Nullable Size closestSupportedResolution = EncoderUtil.getSupportedResolution( - encoderInfo, VIDEO_H264, (int) (aspectRatio * 5000), 5000); + encoderInfo, VIDEO_H264, /* width= */ 7500, /* height= */ 5000); assertThat(closestSupportedResolution).isNotNull(); assertThat( (double) closestSupportedResolution.getWidth() / closestSupportedResolution.getHeight()) - .isEqualTo(aspectRatio); + .isEqualTo(7500.0 / 5000); } /** diff --git a/testutils/src/main/java/com/google/android/exoplayer2/testutil/DecodeOneFrameUtil.java b/testutils/src/main/java/com/google/android/exoplayer2/testutil/DecodeOneFrameUtil.java index 9cd47554d2..16526f67b7 100644 --- a/testutils/src/main/java/com/google/android/exoplayer2/testutil/DecodeOneFrameUtil.java +++ b/testutils/src/main/java/com/google/android/exoplayer2/testutil/DecodeOneFrameUtil.java @@ -38,7 +38,7 @@ import java.nio.ByteBuffer; import org.checkerframework.checker.nullness.qual.Nullable; /** Utilities for decoding a frame for tests. */ -public class DecodeOneFrameUtil { +public final class DecodeOneFrameUtil { public static final String NO_DECODER_SUPPORT_ERROR_STRING = "No MediaCodec decoders on this device support this value.";