HDR: Throw error if attempting HDR editing under API 31.
HDR editing is not supported under API 31 PiperOrigin-RevId: 459211106
This commit is contained in:
parent
bf88f28539
commit
77d353b58b
@ -84,6 +84,11 @@ public final class ColorInfo implements Bundleable {
|
||||
}
|
||||
}
|
||||
|
||||
/** Returns whether the {@code ColorInfo} uses an HDR {@link C.ColorTransfer}. */
|
||||
public static boolean isHdr(@Nullable ColorInfo colorInfo) {
|
||||
return colorInfo != null && colorInfo.colorTransfer != C.COLOR_TRANSFER_SDR;
|
||||
}
|
||||
|
||||
/**
|
||||
* The color space of the video. Valid values are {@link C#COLOR_SPACE_BT601}, {@link
|
||||
* C#COLOR_SPACE_BT709}, {@link C#COLOR_SPACE_BT2020} or {@link Format#NO_VALUE} if unknown.
|
||||
|
@ -67,6 +67,7 @@ public final class TransformationException extends Exception {
|
||||
ERROR_CODE_ENCODER_INIT_FAILED,
|
||||
ERROR_CODE_ENCODING_FAILED,
|
||||
ERROR_CODE_OUTPUT_FORMAT_UNSUPPORTED,
|
||||
ERROR_CODE_HDR_EDITING_UNSUPPORTED,
|
||||
ERROR_CODE_GL_INIT_FAILED,
|
||||
ERROR_CODE_GL_PROCESSING_FAILED,
|
||||
ERROR_CODE_MUXING_FAILED,
|
||||
@ -149,6 +150,8 @@ public final class TransformationException extends Exception {
|
||||
* Codec.DecoderFactory encoders} available.
|
||||
*/
|
||||
public static final int ERROR_CODE_OUTPUT_FORMAT_UNSUPPORTED = 4003;
|
||||
/** Caused by the encoder not supporting HDR formats. */
|
||||
public static final int ERROR_CODE_HDR_EDITING_UNSUPPORTED = 4004;
|
||||
|
||||
// Video editing errors (5xxx).
|
||||
|
||||
@ -179,6 +182,7 @@ public final class TransformationException extends Exception {
|
||||
.put("ERROR_CODE_ENCODER_INIT_FAILED", ERROR_CODE_ENCODER_INIT_FAILED)
|
||||
.put("ERROR_CODE_ENCODING_FAILED", ERROR_CODE_ENCODING_FAILED)
|
||||
.put("ERROR_CODE_OUTPUT_FORMAT_UNSUPPORTED", ERROR_CODE_OUTPUT_FORMAT_UNSUPPORTED)
|
||||
.put("ERROR_CODE_HDR_EDITING_UNSUPPORTED", ERROR_CODE_HDR_EDITING_UNSUPPORTED)
|
||||
.put("ERROR_CODE_GL_INIT_FAILED", ERROR_CODE_GL_INIT_FAILED)
|
||||
.put("ERROR_CODE_GL_PROCESSING_FAILED", ERROR_CODE_GL_PROCESSING_FAILED)
|
||||
.put("ERROR_CODE_MUXING_FAILED", ERROR_CODE_MUXING_FAILED)
|
||||
|
@ -18,6 +18,7 @@ package com.google.android.exoplayer2.transformer;
|
||||
|
||||
import static com.google.android.exoplayer2.source.SampleStream.FLAG_REQUIRE_FORMAT;
|
||||
import static com.google.android.exoplayer2.util.Assertions.checkNotNull;
|
||||
import static com.google.android.exoplayer2.util.Util.SDK_INT;
|
||||
|
||||
import android.content.Context;
|
||||
import com.google.android.exoplayer2.C;
|
||||
@ -25,6 +26,7 @@ import com.google.android.exoplayer2.Format;
|
||||
import com.google.android.exoplayer2.FormatHolder;
|
||||
import com.google.android.exoplayer2.decoder.DecoderInputBuffer;
|
||||
import com.google.android.exoplayer2.source.SampleStream.ReadDataResult;
|
||||
import com.google.android.exoplayer2.video.ColorInfo;
|
||||
import com.google.common.collect.ImmutableList;
|
||||
import java.nio.ByteBuffer;
|
||||
import org.checkerframework.checker.nullness.qual.MonotonicNonNull;
|
||||
@ -91,6 +93,15 @@ import org.checkerframework.checker.nullness.qual.RequiresNonNull;
|
||||
return false;
|
||||
}
|
||||
Format inputFormat = checkNotNull(formatHolder.format);
|
||||
if (SDK_INT < 31 && ColorInfo.isHdr(inputFormat.colorInfo)) {
|
||||
throw TransformationException.createForCodec(
|
||||
new IllegalArgumentException("HDR editing not supported under API 31."),
|
||||
/* isVideo= */ true,
|
||||
/* isDecoder= */ false,
|
||||
inputFormat,
|
||||
/* mediaCodecName= */ null,
|
||||
TransformationException.ERROR_CODE_HDR_EDITING_UNSUPPORTED);
|
||||
}
|
||||
if (shouldPassthrough(inputFormat)) {
|
||||
samplePipeline =
|
||||
new PassthroughSamplePipeline(inputFormat, transformationRequest, fallbackListener);
|
||||
|
@ -108,7 +108,8 @@ import org.checkerframework.dataflow.qual.Pure;
|
||||
boolean enableRequestSdrToneMapping = transformationRequest.enableRequestSdrToneMapping;
|
||||
// TODO(b/237674316): While HLG10 is correctly reported, HDR10 currently will be incorrectly
|
||||
// processed as SDR, because the inputFormat.colorInfo reports the wrong value.
|
||||
boolean useHdr = transformationRequest.enableHdrEditing && isHdr(inputFormat.colorInfo);
|
||||
boolean useHdr =
|
||||
transformationRequest.enableHdrEditing && ColorInfo.isHdr(inputFormat.colorInfo);
|
||||
if (useHdr && !encoderWrapper.supportsHdr()) {
|
||||
// TODO(b/236316454): Also check whether GlEffectsFrameProcessor supports HDR, i.e., whether
|
||||
// EXT_YUV_target is supported.
|
||||
@ -167,11 +168,6 @@ import org.checkerframework.dataflow.qual.Pure;
|
||||
maxPendingFrameCount = decoder.getMaxPendingFrameCount();
|
||||
}
|
||||
|
||||
/** Whether this is a supported HDR format. */
|
||||
private static boolean isHdr(@Nullable ColorInfo colorInfo) {
|
||||
return colorInfo != null && colorInfo.colorTransfer != C.COLOR_TRANSFER_SDR;
|
||||
}
|
||||
|
||||
@Override
|
||||
@Nullable
|
||||
public DecoderInputBuffer dequeueInputBuffer() throws TransformationException {
|
||||
|
Loading…
x
Reference in New Issue
Block a user