From 7085c2fa6e90834b7ace3b22b16d9f14f5e9eb66 Mon Sep 17 00:00:00 2001 From: huangdarwin Date: Fri, 2 Sep 2022 09:49:26 +0000 Subject: [PATCH] Rename shouldPassthrough to shouldTranscode shouldPassthrough's internal checks seem to be check whether we should *not* pass through, which seemed a bit like a confusing double-negative to me. shouldTranscode is slightly more clear, by instead returning true when we do want to transcode. No functional changes intended. PiperOrigin-RevId: 471753771 --- .../transformer/TransformerVideoRenderer.java | 34 +++++++++---------- 1 file changed, 17 insertions(+), 17 deletions(-) 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 e9e498433c..19be11a6d4 100644 --- a/libraries/transformer/src/main/java/androidx/media3/transformer/TransformerVideoRenderer.java +++ b/libraries/transformer/src/main/java/androidx/media3/transformer/TransformerVideoRenderer.java @@ -108,10 +108,7 @@ import org.checkerframework.checker.nullness.qual.RequiresNonNull; /* mediaCodecName= */ null, TransformationException.ERROR_CODE_HDR_EDITING_UNSUPPORTED); } - if (shouldPassthrough(inputFormat)) { - samplePipeline = - new PassthroughSamplePipeline(inputFormat, transformationRequest, fallbackListener); - } else { + if (shouldTranscode(inputFormat)) { samplePipeline = new VideoTranscodingSamplePipeline( context, @@ -126,6 +123,9 @@ import org.checkerframework.checker.nullness.qual.RequiresNonNull; fallbackListener, asyncErrorListener, debugViewProvider); + } else { + samplePipeline = + new PassthroughSamplePipeline(inputFormat, transformationRequest, fallbackListener); } if (transformationRequest.flattenForSlowMotion) { sefSlowMotionFlattener = new SefSlowMotionFlattener(inputFormat); @@ -133,47 +133,47 @@ import org.checkerframework.checker.nullness.qual.RequiresNonNull; return true; } - private boolean shouldPassthrough(Format inputFormat) { + private boolean shouldTranscode(Format inputFormat) { if ((streamStartPositionUs - streamOffsetUs) != 0 && !clippingStartsAtKeyFrame) { - return false; + return true; } if (encoderFactory.videoNeedsEncoding()) { - return false; + return true; } if (transformationRequest.enableRequestSdrToneMapping) { - return false; + return true; } if (transformationRequest.videoMimeType != null && !transformationRequest.videoMimeType.equals(inputFormat.sampleMimeType)) { - return false; + return true; } if (transformationRequest.videoMimeType == null && !muxerWrapper.supportsSampleMimeType(inputFormat.sampleMimeType)) { - return false; + return true; } if (inputFormat.pixelWidthHeightRatio != 1f) { - return false; + return true; } if (transformationRequest.rotationDegrees != 0f) { - return false; + return true; } if (transformationRequest.scaleX != 1f) { - return false; + return true; } if (transformationRequest.scaleY != 1f) { - return false; + return true; } // 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 != decodedHeight) { - return false; + return true; } if (!effects.isEmpty()) { - return false; + return true; } - return true; + return false; } /**