HDR: Disable tone mapping on unsupported pixel build ID.
Also, update tests to allow AnyOf error codes, and no longer check exception messages, which caused quite a bit of churn. PiperOrigin-RevId: 479570861
This commit is contained in:
parent
91caf7a650
commit
8548e3519e
@ -125,8 +125,8 @@ import org.checkerframework.checker.nullness.qual.PolyNull;
|
|||||||
public final class Util {
|
public final class Util {
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Like {@link android.os.Build.VERSION#SDK_INT}, but in a place where it can be conveniently
|
* Like {@link Build.VERSION#SDK_INT}, but in a place where it can be conveniently overridden for
|
||||||
* overridden for local testing.
|
* local testing.
|
||||||
*/
|
*/
|
||||||
@UnstableApi public static final int SDK_INT = Build.VERSION.SDK_INT;
|
@UnstableApi public static final int SDK_INT = Build.VERSION.SDK_INT;
|
||||||
|
|
||||||
|
@ -77,10 +77,6 @@ public class SetHdrEditingTest {
|
|||||||
assertThat(exception).hasCauseThat().isInstanceOf(IllegalArgumentException.class);
|
assertThat(exception).hasCauseThat().isInstanceOf(IllegalArgumentException.class);
|
||||||
assertThat(exception.errorCode)
|
assertThat(exception.errorCode)
|
||||||
.isEqualTo(TransformationException.ERROR_CODE_HDR_EDITING_UNSUPPORTED);
|
.isEqualTo(TransformationException.ERROR_CODE_HDR_EDITING_UNSUPPORTED);
|
||||||
assertThat(exception)
|
|
||||||
.hasCauseThat()
|
|
||||||
.hasMessageThat()
|
|
||||||
.isEqualTo("HDR editing and tone mapping not supported under API 31.");
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -155,22 +151,11 @@ public class SetHdrEditingTest {
|
|||||||
} catch (TransformationException exception) {
|
} catch (TransformationException exception) {
|
||||||
Log.i(TAG, checkNotNull(exception.getCause()).toString());
|
Log.i(TAG, checkNotNull(exception.getCause()).toString());
|
||||||
assertThat(exception).hasCauseThat().isInstanceOf(IllegalArgumentException.class);
|
assertThat(exception).hasCauseThat().isInstanceOf(IllegalArgumentException.class);
|
||||||
if (Util.SDK_INT < 31) {
|
assertThat(exception.errorCode)
|
||||||
assertThat(exception.errorCode)
|
.isAnyOf(
|
||||||
.isEqualTo(TransformationException.ERROR_CODE_HDR_EDITING_UNSUPPORTED);
|
TransformationException.ERROR_CODE_HDR_EDITING_UNSUPPORTED,
|
||||||
assertThat(exception)
|
TransformationException.ERROR_CODE_DECODING_FORMAT_UNSUPPORTED);
|
||||||
.hasCauseThat()
|
assertThat(isFallbackListenerInvoked.get()).isFalse();
|
||||||
.hasMessageThat()
|
|
||||||
.isEqualTo("HDR editing and tone mapping not supported under API 31.");
|
|
||||||
} else {
|
|
||||||
assertThat(exception.errorCode)
|
|
||||||
.isEqualTo(TransformationException.ERROR_CODE_DECODING_FORMAT_UNSUPPORTED);
|
|
||||||
assertThat(exception)
|
|
||||||
.hasCauseThat()
|
|
||||||
.hasMessageThat()
|
|
||||||
.isEqualTo("Tone-mapping requested but not supported by the decoder.");
|
|
||||||
assertThat(isFallbackListenerInvoked.get()).isFalse();
|
|
||||||
}
|
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -25,7 +25,6 @@ import android.net.Uri;
|
|||||||
import androidx.media3.common.C;
|
import androidx.media3.common.C;
|
||||||
import androidx.media3.common.MediaItem;
|
import androidx.media3.common.MediaItem;
|
||||||
import androidx.media3.common.util.Log;
|
import androidx.media3.common.util.Log;
|
||||||
import androidx.media3.common.util.Util;
|
|
||||||
import androidx.media3.transformer.TransformationException;
|
import androidx.media3.transformer.TransformationException;
|
||||||
import androidx.media3.transformer.TransformationRequest;
|
import androidx.media3.transformer.TransformationRequest;
|
||||||
import androidx.media3.transformer.TransformationTestResult;
|
import androidx.media3.transformer.TransformationTestResult;
|
||||||
@ -76,21 +75,10 @@ public class SetHdrToSdrToneMapTest {
|
|||||||
} catch (TransformationException exception) {
|
} catch (TransformationException exception) {
|
||||||
Log.i(TAG, checkNotNull(exception.getCause()).toString());
|
Log.i(TAG, checkNotNull(exception.getCause()).toString());
|
||||||
assertThat(exception).hasCauseThat().isInstanceOf(IllegalArgumentException.class);
|
assertThat(exception).hasCauseThat().isInstanceOf(IllegalArgumentException.class);
|
||||||
if (Util.SDK_INT < 31) {
|
assertThat(exception.errorCode)
|
||||||
assertThat(exception.errorCode)
|
.isAnyOf(
|
||||||
.isEqualTo(TransformationException.ERROR_CODE_HDR_EDITING_UNSUPPORTED);
|
TransformationException.ERROR_CODE_HDR_EDITING_UNSUPPORTED,
|
||||||
assertThat(exception)
|
TransformationException.ERROR_CODE_DECODING_FORMAT_UNSUPPORTED);
|
||||||
.hasCauseThat()
|
|
||||||
.hasMessageThat()
|
|
||||||
.isEqualTo("HDR editing and tone mapping not supported under API 31.");
|
|
||||||
} else {
|
|
||||||
assertThat(exception.errorCode)
|
|
||||||
.isEqualTo(TransformationException.ERROR_CODE_DECODING_FORMAT_UNSUPPORTED);
|
|
||||||
assertThat(exception)
|
|
||||||
.hasCauseThat()
|
|
||||||
.hasMessageThat()
|
|
||||||
.isEqualTo("Tone-mapping requested but not supported by the decoder.");
|
|
||||||
}
|
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -133,21 +121,10 @@ public class SetHdrToSdrToneMapTest {
|
|||||||
} catch (TransformationException exception) {
|
} catch (TransformationException exception) {
|
||||||
Log.i(TAG, checkNotNull(exception.getCause()).toString());
|
Log.i(TAG, checkNotNull(exception.getCause()).toString());
|
||||||
assertThat(exception).hasCauseThat().isInstanceOf(IllegalArgumentException.class);
|
assertThat(exception).hasCauseThat().isInstanceOf(IllegalArgumentException.class);
|
||||||
if (Util.SDK_INT < 31) {
|
assertThat(exception.errorCode)
|
||||||
assertThat(exception.errorCode)
|
.isAnyOf(
|
||||||
.isEqualTo(TransformationException.ERROR_CODE_HDR_EDITING_UNSUPPORTED);
|
TransformationException.ERROR_CODE_HDR_EDITING_UNSUPPORTED,
|
||||||
assertThat(exception)
|
TransformationException.ERROR_CODE_DECODING_FORMAT_UNSUPPORTED);
|
||||||
.hasCauseThat()
|
|
||||||
.hasMessageThat()
|
|
||||||
.isEqualTo("HDR editing and tone mapping not supported under API 31.");
|
|
||||||
} else {
|
|
||||||
assertThat(exception.errorCode)
|
|
||||||
.isEqualTo(TransformationException.ERROR_CODE_DECODING_FORMAT_UNSUPPORTED);
|
|
||||||
assertThat(exception)
|
|
||||||
.hasCauseThat()
|
|
||||||
.hasMessageThat()
|
|
||||||
.isEqualTo("Tone-mapping requested but not supported by the decoder.");
|
|
||||||
}
|
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -22,6 +22,7 @@ import static androidx.media3.common.util.Util.SDK_INT;
|
|||||||
|
|
||||||
import android.content.Context;
|
import android.content.Context;
|
||||||
import android.media.MediaCodec;
|
import android.media.MediaCodec;
|
||||||
|
import android.os.Build;
|
||||||
import android.view.Surface;
|
import android.view.Surface;
|
||||||
import androidx.annotation.Nullable;
|
import androidx.annotation.Nullable;
|
||||||
import androidx.annotation.VisibleForTesting;
|
import androidx.annotation.VisibleForTesting;
|
||||||
@ -76,9 +77,10 @@ import org.checkerframework.dataflow.qual.Pure;
|
|||||||
Transformer.AsyncErrorListener asyncErrorListener,
|
Transformer.AsyncErrorListener asyncErrorListener,
|
||||||
DebugViewProvider debugViewProvider)
|
DebugViewProvider debugViewProvider)
|
||||||
throws TransformationException {
|
throws TransformationException {
|
||||||
if (SDK_INT < 31 && ColorInfo.isTransferHdr(inputFormat.colorInfo)) {
|
if (ColorInfo.isTransferHdr(inputFormat.colorInfo)
|
||||||
|
&& (SDK_INT < 31 || deviceNeedsNoToneMappingWorkaround())) {
|
||||||
throw TransformationException.createForCodec(
|
throw TransformationException.createForCodec(
|
||||||
new IllegalArgumentException("HDR editing and tone mapping not supported under API 31."),
|
new IllegalArgumentException("HDR editing and tone mapping not supported."),
|
||||||
/* isVideo= */ true,
|
/* isVideo= */ true,
|
||||||
/* isDecoder= */ false,
|
/* isDecoder= */ false,
|
||||||
inputFormat,
|
inputFormat,
|
||||||
@ -290,6 +292,11 @@ import org.checkerframework.dataflow.qual.Pure;
|
|||||||
.build();
|
.build();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
private static boolean deviceNeedsNoToneMappingWorkaround() {
|
||||||
|
// Pixel build ID does not support tone mapping. See http://b/249297370#comment8.
|
||||||
|
return Build.ID.startsWith("TP1A.220905.004");
|
||||||
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Feeds at most one decoder output frame to the next step of the pipeline.
|
* Feeds at most one decoder output frame to the next step of the pipeline.
|
||||||
*
|
*
|
||||||
|
Loading…
x
Reference in New Issue
Block a user