Commit 3a70c6ca by kimvde Committed by Tofunmi Adigun-Hameed

Fix encoder expecting HDR while tone-mapping requested

If tone-mapping was requested for a device supporting HDR encoding,
isToneMapped was false in VideoSamplePipeline.EncoderWrapper. This was
causing the encoder to expect HDR.

Also did some renamings to improve readability

PiperOrigin-RevId: 530584010
parent 756b77eb
...@@ -118,7 +118,7 @@ import org.checkerframework.dataflow.qual.Pure; ...@@ -118,7 +118,7 @@ import org.checkerframework.dataflow.qual.Pure;
fallbackListener); fallbackListener);
boolean isMediaCodecToneMapping = boolean isMediaCodecToneMapping =
encoderWrapper.getSupportedInputHdrMode() == HDR_MODE_TONE_MAP_HDR_TO_SDR_USING_MEDIACODEC encoderWrapper.getHdrModeAfterFallback() == HDR_MODE_TONE_MAP_HDR_TO_SDR_USING_MEDIACODEC
&& ColorInfo.isTransferHdr(decoderInputColor); && ColorInfo.isTransferHdr(decoderInputColor);
videoFrameProcessorInputColor = isMediaCodecToneMapping ? SDR_BT709_LIMITED : decoderInputColor; videoFrameProcessorInputColor = isMediaCodecToneMapping ? SDR_BT709_LIMITED : decoderInputColor;
...@@ -330,8 +330,7 @@ import org.checkerframework.dataflow.qual.Pure; ...@@ -330,8 +330,7 @@ import org.checkerframework.dataflow.qual.Pure;
private final TransformationRequest transformationRequest; private final TransformationRequest transformationRequest;
private final FallbackListener fallbackListener; private final FallbackListener fallbackListener;
private final String requestedOutputMimeType; private final String requestedOutputMimeType;
private final boolean isInputToneMapped; private final @TransformationRequest.HdrMode int hdrModeAfterFallback;
private final @TransformationRequest.HdrMode int supportedFallbackHdrMode;
private @MonotonicNonNull SurfaceInfo encoderSurfaceInfo; private @MonotonicNonNull SurfaceInfo encoderSurfaceInfo;
...@@ -361,16 +360,14 @@ import org.checkerframework.dataflow.qual.Pure; ...@@ -361,16 +360,14 @@ import org.checkerframework.dataflow.qual.Pure;
requestedOutputMimeType = inputSampleMimeType; requestedOutputMimeType = inputSampleMimeType;
} }
isInputToneMapped =
isTransferHdr(inputFormat.colorInfo)
&& getSupportedEncodersForHdrEditing(requestedOutputMimeType, inputFormat.colorInfo)
.isEmpty();
// HdrMode fallback is only supported from HDR_MODE_KEEP_HDR to // HdrMode fallback is only supported from HDR_MODE_KEEP_HDR to
// HDR_MODE_TONE_MAP_HDR_TO_SDR_USING_MEDIACODEC. // HDR_MODE_TONE_MAP_HDR_TO_SDR_USING_MEDIACODEC.
boolean fallbackToMediaCodec = boolean fallbackToMediaCodec =
isInputToneMapped && transformationRequest.hdrMode == HDR_MODE_KEEP_HDR; isTransferHdr(inputFormat.colorInfo)
supportedFallbackHdrMode = && transformationRequest.hdrMode == HDR_MODE_KEEP_HDR
&& getSupportedEncodersForHdrEditing(requestedOutputMimeType, inputFormat.colorInfo)
.isEmpty();
hdrModeAfterFallback =
fallbackToMediaCodec fallbackToMediaCodec
? HDR_MODE_TONE_MAP_HDR_TO_SDR_USING_MEDIACODEC ? HDR_MODE_TONE_MAP_HDR_TO_SDR_USING_MEDIACODEC
: transformationRequest.hdrMode; : transformationRequest.hdrMode;
...@@ -378,6 +375,11 @@ import org.checkerframework.dataflow.qual.Pure; ...@@ -378,6 +375,11 @@ import org.checkerframework.dataflow.qual.Pure;
/** Returns the {@link ColorInfo} expected from the input surface. */ /** Returns the {@link ColorInfo} expected from the input surface. */
public ColorInfo getSupportedInputColor() { public ColorInfo getSupportedInputColor() {
boolean isHdrEditingEnabled =
transformationRequest.hdrMode == HDR_MODE_KEEP_HDR
&& !getSupportedEncodersForHdrEditing(requestedOutputMimeType, inputFormat.colorInfo)
.isEmpty();
boolean isInputToneMapped = !isHdrEditingEnabled && isTransferHdr(inputFormat.colorInfo);
if (isInputToneMapped) { if (isInputToneMapped) {
// When tone-mapping HDR to SDR is enabled, assume we get BT.709 to avoid having the encoder // When tone-mapping HDR to SDR is enabled, assume we get BT.709 to avoid having the encoder
// populate default color info, which depends on the resolution. // populate default color info, which depends on the resolution.
...@@ -389,8 +391,8 @@ import org.checkerframework.dataflow.qual.Pure; ...@@ -389,8 +391,8 @@ import org.checkerframework.dataflow.qual.Pure;
return checkNotNull(inputFormat.colorInfo); return checkNotNull(inputFormat.colorInfo);
} }
public @TransformationRequest.HdrMode int getSupportedInputHdrMode() { public @TransformationRequest.HdrMode int getHdrModeAfterFallback() {
return supportedFallbackHdrMode; return hdrModeAfterFallback;
} }
@Nullable @Nullable
...@@ -441,7 +443,7 @@ import org.checkerframework.dataflow.qual.Pure; ...@@ -441,7 +443,7 @@ import org.checkerframework.dataflow.qual.Pure;
/* hasOutputFormatRotation= */ outputRotationDegrees != 0, /* hasOutputFormatRotation= */ outputRotationDegrees != 0,
requestedEncoderFormat, requestedEncoderFormat,
actualEncoderFormat, actualEncoderFormat,
supportedFallbackHdrMode)); hdrModeAfterFallback));
encoderSurfaceInfo = encoderSurfaceInfo =
new SurfaceInfo( new SurfaceInfo(
......
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