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
This commit is contained in:
huangdarwin 2022-09-02 09:49:26 +00:00 committed by Marc Baechinger
parent bc88f8be54
commit 7085c2fa6e

View File

@ -108,10 +108,7 @@ import org.checkerframework.checker.nullness.qual.RequiresNonNull;
/* mediaCodecName= */ null, /* mediaCodecName= */ null,
TransformationException.ERROR_CODE_HDR_EDITING_UNSUPPORTED); TransformationException.ERROR_CODE_HDR_EDITING_UNSUPPORTED);
} }
if (shouldPassthrough(inputFormat)) { if (shouldTranscode(inputFormat)) {
samplePipeline =
new PassthroughSamplePipeline(inputFormat, transformationRequest, fallbackListener);
} else {
samplePipeline = samplePipeline =
new VideoTranscodingSamplePipeline( new VideoTranscodingSamplePipeline(
context, context,
@ -126,6 +123,9 @@ import org.checkerframework.checker.nullness.qual.RequiresNonNull;
fallbackListener, fallbackListener,
asyncErrorListener, asyncErrorListener,
debugViewProvider); debugViewProvider);
} else {
samplePipeline =
new PassthroughSamplePipeline(inputFormat, transformationRequest, fallbackListener);
} }
if (transformationRequest.flattenForSlowMotion) { if (transformationRequest.flattenForSlowMotion) {
sefSlowMotionFlattener = new SefSlowMotionFlattener(inputFormat); sefSlowMotionFlattener = new SefSlowMotionFlattener(inputFormat);
@ -133,47 +133,47 @@ import org.checkerframework.checker.nullness.qual.RequiresNonNull;
return true; return true;
} }
private boolean shouldPassthrough(Format inputFormat) { private boolean shouldTranscode(Format inputFormat) {
if ((streamStartPositionUs - streamOffsetUs) != 0 && !clippingStartsAtKeyFrame) { if ((streamStartPositionUs - streamOffsetUs) != 0 && !clippingStartsAtKeyFrame) {
return false; return true;
} }
if (encoderFactory.videoNeedsEncoding()) { if (encoderFactory.videoNeedsEncoding()) {
return false; return true;
} }
if (transformationRequest.enableRequestSdrToneMapping) { if (transformationRequest.enableRequestSdrToneMapping) {
return false; return true;
} }
if (transformationRequest.videoMimeType != null if (transformationRequest.videoMimeType != null
&& !transformationRequest.videoMimeType.equals(inputFormat.sampleMimeType)) { && !transformationRequest.videoMimeType.equals(inputFormat.sampleMimeType)) {
return false; return true;
} }
if (transformationRequest.videoMimeType == null if (transformationRequest.videoMimeType == null
&& !muxerWrapper.supportsSampleMimeType(inputFormat.sampleMimeType)) { && !muxerWrapper.supportsSampleMimeType(inputFormat.sampleMimeType)) {
return false; return true;
} }
if (inputFormat.pixelWidthHeightRatio != 1f) { if (inputFormat.pixelWidthHeightRatio != 1f) {
return false; return true;
} }
if (transformationRequest.rotationDegrees != 0f) { if (transformationRequest.rotationDegrees != 0f) {
return false; return true;
} }
if (transformationRequest.scaleX != 1f) { if (transformationRequest.scaleX != 1f) {
return false; return true;
} }
if (transformationRequest.scaleY != 1f) { if (transformationRequest.scaleY != 1f) {
return false; return true;
} }
// The decoder rotates encoded frames for display by inputFormat.rotationDegrees. // The decoder rotates encoded frames for display by inputFormat.rotationDegrees.
int decodedHeight = int decodedHeight =
(inputFormat.rotationDegrees % 180 == 0) ? inputFormat.height : inputFormat.width; (inputFormat.rotationDegrees % 180 == 0) ? inputFormat.height : inputFormat.width;
if (transformationRequest.outputHeight != C.LENGTH_UNSET if (transformationRequest.outputHeight != C.LENGTH_UNSET
&& transformationRequest.outputHeight != decodedHeight) { && transformationRequest.outputHeight != decodedHeight) {
return false; return true;
} }
if (!effects.isEmpty()) { if (!effects.isEmpty()) {
return false; return true;
} }
return true; return false;
} }
/** /**