Commit 27ed3b2b by huangdarwin Committed by Ian Baker

Transformer: Reduce scope of createSupportedTransformationRequest

This was only used in EncoderWrapper, so move createSupportedTransformationRequest
from VideoSamplePipeline to EncoderWrapper to reduce its scope.

PiperOrigin-RevId: 527226578
parent d838f2c6
...@@ -299,47 +299,6 @@ import org.checkerframework.dataflow.qual.Pure; ...@@ -299,47 +299,6 @@ import org.checkerframework.dataflow.qual.Pure;
return encoderWrapper.isEnded(); return encoderWrapper.isEnded();
} }
/**
* Creates a {@link TransformationRequest}, based on an original {@code TransformationRequest} and
* parameters specifying alterations to it that indicate device support.
*
* @param transformationRequest The requested transformation.
* @param hasOutputFormatRotation Whether the input video will be rotated to landscape during
* processing, with {@link Format#rotationDegrees} of 90 added to the output format.
* @param requestedFormat The requested format.
* @param supportedFormat A format supported by the device.
* @param supportedHdrMode A {@link TransformationRequest.HdrMode} supported by the device.
* @return The created instance.
*/
@Pure
private static TransformationRequest createSupportedTransformationRequest(
TransformationRequest transformationRequest,
boolean hasOutputFormatRotation,
Format requestedFormat,
Format supportedFormat,
@TransformationRequest.HdrMode int supportedHdrMode) {
// TODO(b/259570024): Consider including bitrate in the revised fallback design.
TransformationRequest.Builder supportedRequestBuilder = transformationRequest.buildUpon();
if (transformationRequest.hdrMode != supportedHdrMode) {
supportedRequestBuilder.setHdrMode(supportedHdrMode);
}
if (!Util.areEqual(requestedFormat.sampleMimeType, supportedFormat.sampleMimeType)) {
supportedRequestBuilder.setVideoMimeType(supportedFormat.sampleMimeType);
}
if (hasOutputFormatRotation) {
if (requestedFormat.width != supportedFormat.width) {
supportedRequestBuilder.setResolution(/* outputHeight= */ supportedFormat.width);
}
} else if (requestedFormat.height != supportedFormat.height) {
supportedRequestBuilder.setResolution(supportedFormat.height);
}
return supportedRequestBuilder.build();
}
private static Size getDecodedSize(Format format) { private static Size getDecodedSize(Format format) {
// The decoder rotates encoded frames for display by firstInputFormat.rotationDegrees. // The decoder rotates encoded frames for display by firstInputFormat.rotationDegrees.
int decodedWidth = (format.rotationDegrees % 180 == 0) ? format.width : format.height; int decodedWidth = (format.rotationDegrees % 180 == 0) ? format.width : format.height;
...@@ -491,6 +450,47 @@ import org.checkerframework.dataflow.qual.Pure; ...@@ -491,6 +450,47 @@ import org.checkerframework.dataflow.qual.Pure;
return encoderSurfaceInfo; return encoderSurfaceInfo;
} }
/**
* Creates a {@link TransformationRequest}, based on an original {@code TransformationRequest}
* and parameters specifying alterations to it that indicate device support.
*
* @param transformationRequest The requested transformation.
* @param hasOutputFormatRotation Whether the input video will be rotated to landscape during
* processing, with {@link Format#rotationDegrees} of 90 added to the output format.
* @param requestedFormat The requested format.
* @param supportedFormat A format supported by the device.
* @param supportedHdrMode A {@link TransformationRequest.HdrMode} supported by the device.
* @return The created instance.
*/
@Pure
private static TransformationRequest createSupportedTransformationRequest(
TransformationRequest transformationRequest,
boolean hasOutputFormatRotation,
Format requestedFormat,
Format supportedFormat,
@TransformationRequest.HdrMode int supportedHdrMode) {
// TODO(b/259570024): Consider including bitrate in the revised fallback design.
TransformationRequest.Builder supportedRequestBuilder = transformationRequest.buildUpon();
if (transformationRequest.hdrMode != supportedHdrMode) {
supportedRequestBuilder.setHdrMode(supportedHdrMode);
}
if (!Util.areEqual(requestedFormat.sampleMimeType, supportedFormat.sampleMimeType)) {
supportedRequestBuilder.setVideoMimeType(supportedFormat.sampleMimeType);
}
if (hasOutputFormatRotation) {
if (requestedFormat.width != supportedFormat.width) {
supportedRequestBuilder.setResolution(/* outputHeight= */ supportedFormat.width);
}
} else if (requestedFormat.height != supportedFormat.height) {
supportedRequestBuilder.setResolution(supportedFormat.height);
}
return supportedRequestBuilder.build();
}
public void signalEndOfInputStream() throws ExportException { public void signalEndOfInputStream() throws ExportException {
if (encoder != null) { if (encoder != null) {
encoder.signalEndOfInputStream(); encoder.signalEndOfInputStream();
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or sign in to comment