From 87beb273e464d291423ccb4129c83f36195343f1 Mon Sep 17 00:00:00 2001 From: hschlueter Date: Wed, 29 Jun 2022 10:28:54 +0000 Subject: [PATCH] Fix outputHeight pass-through condition. The outputHeight in the TransformationRequest is the height of the frame as it would be displayed (i.e., after applying any rotation specified in the format). So pass-through should only be used if the requested outputHeight matches the input format's height after applying the rotation. PiperOrigin-RevId: 457934867 --- .../media3/transformer/TransformerVideoRenderer.java | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/libraries/transformer/src/main/java/androidx/media3/transformer/TransformerVideoRenderer.java b/libraries/transformer/src/main/java/androidx/media3/transformer/TransformerVideoRenderer.java index b97b14c57e..03902a400d 100644 --- a/libraries/transformer/src/main/java/androidx/media3/transformer/TransformerVideoRenderer.java +++ b/libraries/transformer/src/main/java/androidx/media3/transformer/TransformerVideoRenderer.java @@ -148,8 +148,11 @@ import org.checkerframework.checker.nullness.qual.RequiresNonNull; if (transformationRequest.scaleY != 1f) { return false; } + // The decoder rotates encoded frames for display by inputFormat.rotationDegrees. + int decodedHeight = + (inputFormat.rotationDegrees % 180 == 0) ? inputFormat.height : inputFormat.width; if (transformationRequest.outputHeight != C.LENGTH_UNSET - && transformationRequest.outputHeight != inputFormat.height) { + && transformationRequest.outputHeight != decodedHeight) { return false; } if (!effects.isEmpty()) {