diff --git a/libraries/transformer/src/androidTest/java/androidx/media3/transformer/FrameEditorTest.java b/libraries/transformer/src/androidTest/java/androidx/media3/transformer/FrameEditorTest.java index f1c83863bd..72310bfd3d 100644 --- a/libraries/transformer/src/androidTest/java/androidx/media3/transformer/FrameEditorTest.java +++ b/libraries/transformer/src/androidTest/java/androidx/media3/transformer/FrameEditorTest.java @@ -60,6 +60,8 @@ public final class FrameEditorTest { private static final int DEQUEUE_TIMEOUT_US = 5_000_000; /** Time to wait for the frame editor's input to be populated by the decoder, in milliseconds. */ private static final int SURFACE_WAIT_MS = 1000; + /** The ratio of width over height, for each pixel in a frame. */ + private static final float PIXEL_WIDTH_HEIGHT_RATIO = 1; private @MonotonicNonNull FrameEditor frameEditor; private @MonotonicNonNull ImageReader frameEditorOutputImageReader; @@ -91,6 +93,7 @@ public final class FrameEditorTest { getApplicationContext(), width, height, + PIXEL_WIDTH_HEIGHT_RATIO, identityMatrix, frameEditorOutputImageReader.getSurface(), Transformer.DebugViewProvider.NONE); diff --git a/libraries/transformer/src/main/java/androidx/media3/transformer/FrameEditor.java b/libraries/transformer/src/main/java/androidx/media3/transformer/FrameEditor.java index a6fbf32a25..4fc93b6a46 100644 --- a/libraries/transformer/src/main/java/androidx/media3/transformer/FrameEditor.java +++ b/libraries/transformer/src/main/java/androidx/media3/transformer/FrameEditor.java @@ -47,6 +47,7 @@ import java.util.concurrent.atomic.AtomicInteger; * @param context A {@link Context}. * @param outputWidth The output width in pixels. * @param outputHeight The output height in pixels. + * @param pixelWidthHeightRatio The ratio of width over height, for each pixel. * @param transformationMatrix The transformation matrix to apply to each frame. * @param outputSurface The {@link Surface}. * @param debugViewProvider Provider for optional debug views to show intermediate output. @@ -56,9 +57,22 @@ import java.util.concurrent.atomic.AtomicInteger; Context context, int outputWidth, int outputHeight, + float pixelWidthHeightRatio, Matrix transformationMatrix, Surface outputSurface, - Transformer.DebugViewProvider debugViewProvider) { + Transformer.DebugViewProvider debugViewProvider) + throws TransformationException { + if (pixelWidthHeightRatio != 1.0f) { + // TODO(http://b/211782176): Consider implementing support for non-square pixels. + throw new TransformationException( + "FrameEditor Error", + new IllegalArgumentException( + "Transformer's frame editor currently does not support frame edits on non-square" + + " pixels. The pixelWidthHeightRatio is: " + + pixelWidthHeightRatio), + TransformationException.ERROR_CODE_GL_INIT_FAILED); + } + EGLDisplay eglDisplay = GlUtil.createEglDisplay(); EGLContext eglContext = GlUtil.createEglContext(eglDisplay); EGLSurface eglSurface = GlUtil.getEglSurface(eglDisplay, outputSurface); diff --git a/libraries/transformer/src/main/java/androidx/media3/transformer/TransformationException.java b/libraries/transformer/src/main/java/androidx/media3/transformer/TransformationException.java index 273f3f15fd..4a8f86cdd8 100644 --- a/libraries/transformer/src/main/java/androidx/media3/transformer/TransformationException.java +++ b/libraries/transformer/src/main/java/androidx/media3/transformer/TransformationException.java @@ -288,7 +288,7 @@ public final class TransformationException extends Exception { * Returns whether the error data associated to this exception equals the error data associated to * {@code other}. * - *
Note that this method does not compare the exceptions' stacktraces. + *
Note that this method does not compare the exceptions' stack traces. */ public boolean errorInfoEquals(@Nullable TransformationException other) { if (this == other) { diff --git a/libraries/transformer/src/main/java/androidx/media3/transformer/VideoSamplePipeline.java b/libraries/transformer/src/main/java/androidx/media3/transformer/VideoSamplePipeline.java index 8d9f83b672..7b706fa6db 100644 --- a/libraries/transformer/src/main/java/androidx/media3/transformer/VideoSamplePipeline.java +++ b/libraries/transformer/src/main/java/androidx/media3/transformer/VideoSamplePipeline.java @@ -104,6 +104,7 @@ import org.checkerframework.checker.nullness.qual.MonotonicNonNull; context, outputWidth, outputHeight, + inputFormat.pixelWidthHeightRatio, transformationRequest.transformationMatrix, /* outputSurface= */ checkNotNull(encoder.getInputSurface()), debugViewProvider);