Skip tests if muxing is unsupported

PiperOrigin-RevId: 509802784
This commit is contained in:
andrewlewis 2023-02-15 13:17:09 +00:00 committed by christosts
parent 4759e0075c
commit 6d9baa6e99
9 changed files with 67 additions and 57 deletions

View file

@ -580,43 +580,48 @@ public final class AndroidTestUtil {
}
/**
* Checks whether the test should be skipped because the device is incapable of decoding and
* encoding the given formats.
* Returns whether the test should be skipped because the device is incapable of decoding the
* input format, or encoding/muxing the output format. Assumes the input will always need to be
* decoded, and both encoded and muxed if {@code outputFormat} is non-null.
*
* <p>If the test should be skipped, logs the reason for skipping.
*
* @param context The {@link Context context}.
* @param testId The test ID.
* @param decodingFormat The {@link Format format} to decode.
* @param encodingFormat The {@link Format format} to encode, optional.
* @param inputFormat The {@link Format format} to decode.
* @param outputFormat The {@link Format format} to encode/mux or {@code null} if the output won't
* be encoded or muxed.
* @return Whether the test should be skipped.
*/
public static boolean skipAndLogIfInsufficientCodecSupport(
Context context, String testId, Format decodingFormat, @Nullable Format encodingFormat)
public static boolean skipAndLogIfFormatsUnsupported(
Context context, String testId, Format inputFormat, @Nullable Format outputFormat)
throws IOException, JSONException {
boolean canDecode = false;
@Nullable MediaCodecUtil.DecoderQueryException queryException = null;
try {
canDecode = canDecode(decodingFormat);
canDecode = canDecode(inputFormat);
} catch (MediaCodecUtil.DecoderQueryException e) {
queryException = e;
}
boolean canEncode = encodingFormat == null || canEncode(encodingFormat);
if (canDecode && canEncode) {
boolean canEncode = outputFormat == null || canEncode(outputFormat);
boolean canMux = outputFormat == null || canMux(outputFormat);
if (canDecode && canEncode && canMux) {
return false;
}
StringBuilder skipReasonBuilder = new StringBuilder();
if (!canDecode) {
skipReasonBuilder.append("Cannot decode ").append(decodingFormat).append('\n');
skipReasonBuilder.append("Cannot decode ").append(inputFormat).append('\n');
if (queryException != null) {
skipReasonBuilder.append(queryException).append('\n');
}
}
if (!canEncode) {
skipReasonBuilder.append("Cannot encode ").append(encodingFormat);
skipReasonBuilder.append("Cannot encode ").append(outputFormat);
}
if (!canMux) {
skipReasonBuilder.append("Cannot mux ").append(outputFormat);
}
recordTestSkipped(context, testId, skipReasonBuilder.toString());
return true;
@ -714,7 +719,7 @@ public final class AndroidTestUtil {
}
/**
* Checks whether the top ranked encoder from {@link EncoderUtil#getSupportedEncoders} supports
* Returns whether the top ranked encoder from {@link EncoderUtil#getSupportedEncoders} supports
* the given resolution and {@linkplain Format#averageBitrate bitrate}.
*
* <p>Assumes support encoding if the {@link Format#averageBitrate bitrate} is not set.
@ -737,6 +742,14 @@ public final class AndroidTestUtil {
return sizeSupported && bitrateSupported;
}
/** Returns whether the specified format can be muxed via the default muxer. */
private static boolean canMux(Format format) {
String mimeType = checkNotNull(format.sampleMimeType);
return new DefaultMuxer.Factory()
.getSupportedSampleMimeTypes(MimeTypes.getTrackType(mimeType))
.contains(mimeType);
}
/**
* Creates a {@link File} of the {@code fileName} in the application cache directory.
*

View file

@ -51,11 +51,11 @@ public class ForceInterpretHdrVideoAsSdrTest {
String testId = "forceInterpretHdrVideoAsSdrTest_hdr10File_transformsOrThrows";
Context context = ApplicationProvider.getApplicationContext();
if (AndroidTestUtil.skipAndLogIfInsufficientCodecSupport(
if (AndroidTestUtil.skipAndLogIfFormatsUnsupported(
context,
testId,
/* decodingFormat= */ MP4_ASSET_1080P_4_SECOND_HDR10_FORMAT,
/* encodingFormat= */ null)) {
/* inputFormat= */ MP4_ASSET_1080P_4_SECOND_HDR10_FORMAT,
/* outputFormat= */ null)) {
return;
}
@ -87,11 +87,11 @@ public class ForceInterpretHdrVideoAsSdrTest {
String testId = "forceInterpretHdrVideoAsSdrTest_hlg10File_transformsOrThrows";
Context context = ApplicationProvider.getApplicationContext();
if (AndroidTestUtil.skipAndLogIfInsufficientCodecSupport(
if (AndroidTestUtil.skipAndLogIfFormatsUnsupported(
context,
testId,
/* decodingFormat= */ MP4_ASSET_1080P_5_SECOND_HLG10_FORMAT,
/* encodingFormat= */ null)) {
/* inputFormat= */ MP4_ASSET_1080P_5_SECOND_HLG10_FORMAT,
/* outputFormat= */ null)) {
return;
}

View file

@ -21,7 +21,7 @@ import static com.google.android.exoplayer2.testutil.BitmapPixelTestUtil.readBit
import static com.google.android.exoplayer2.transformer.AndroidTestUtil.MP4_ASSET_1080P_4_SECOND_HDR10_FORMAT;
import static com.google.android.exoplayer2.transformer.AndroidTestUtil.MP4_ASSET_1080P_5_SECOND_HLG10_FORMAT;
import static com.google.android.exoplayer2.transformer.AndroidTestUtil.recordTestSkipped;
import static com.google.android.exoplayer2.transformer.AndroidTestUtil.skipAndLogIfInsufficientCodecSupport;
import static com.google.android.exoplayer2.transformer.AndroidTestUtil.skipAndLogIfFormatsUnsupported;
import static com.google.common.truth.Truth.assertThat;
import android.graphics.Bitmap;
@ -95,11 +95,11 @@ public final class ToneMapHdrToSdrUsingOpenGlPixelTest {
recordTestSkipped(getApplicationContext(), testId, SKIP_REASON_NO_YUV);
return;
}
if (skipAndLogIfInsufficientCodecSupport(
if (skipAndLogIfFormatsUnsupported(
getApplicationContext(),
testId,
/* decodingFormat= */ MP4_ASSET_1080P_5_SECOND_HLG10_FORMAT,
/* encodingFormat= */ null)) {
/* inputFormat= */ MP4_ASSET_1080P_5_SECOND_HLG10_FORMAT,
/* outputFormat= */ null)) {
return;
}
ColorInfo hlgColor =
@ -158,11 +158,11 @@ public final class ToneMapHdrToSdrUsingOpenGlPixelTest {
recordTestSkipped(getApplicationContext(), testId, SKIP_REASON_NO_YUV);
return;
}
if (skipAndLogIfInsufficientCodecSupport(
if (skipAndLogIfFormatsUnsupported(
getApplicationContext(),
testId,
/* decodingFormat= */ MP4_ASSET_1080P_4_SECOND_HDR10_FORMAT,
/* encodingFormat= */ null)) {
/* inputFormat= */ MP4_ASSET_1080P_4_SECOND_HDR10_FORMAT,
/* outputFormat= */ null)) {
return;
}
ColorInfo pqColor =

View file

@ -68,11 +68,11 @@ public class ToneMapHdrToSdrUsingOpenGlTest {
return;
}
if (AndroidTestUtil.skipAndLogIfInsufficientCodecSupport(
if (AndroidTestUtil.skipAndLogIfFormatsUnsupported(
getApplicationContext(),
testId,
/* decodingFormat= */ MP4_ASSET_1080P_5_SECOND_HLG10_FORMAT,
/* encodingFormat= */ null)) {
/* inputFormat= */ MP4_ASSET_1080P_5_SECOND_HLG10_FORMAT,
/* outputFormat= */ null)) {
return;
}
@ -119,11 +119,11 @@ public class ToneMapHdrToSdrUsingOpenGlTest {
return;
}
if (AndroidTestUtil.skipAndLogIfInsufficientCodecSupport(
if (AndroidTestUtil.skipAndLogIfFormatsUnsupported(
getApplicationContext(),
testId,
/* decodingFormat= */ MP4_ASSET_1080P_4_SECOND_HDR10_FORMAT,
/* encodingFormat= */ null)) {
/* inputFormat= */ MP4_ASSET_1080P_4_SECOND_HDR10_FORMAT,
/* outputFormat= */ null)) {
return;
}

View file

@ -44,11 +44,11 @@ public final class TranscodeQualityTest {
Context context = ApplicationProvider.getApplicationContext();
String testId = "transformHighQualityTargetingAvcToAvc1920x1080_ssim";
if (AndroidTestUtil.skipAndLogIfInsufficientCodecSupport(
if (AndroidTestUtil.skipAndLogIfFormatsUnsupported(
context,
testId,
/* decodingFormat= */ AndroidTestUtil.MP4_ASSET_WITH_INCREASING_TIMESTAMPS_FORMAT,
/* encodingFormat= */ AndroidTestUtil.MP4_ASSET_WITH_INCREASING_TIMESTAMPS_FORMAT)) {
/* inputFormat= */ AndroidTestUtil.MP4_ASSET_WITH_INCREASING_TIMESTAMPS_FORMAT,
/* outputFormat= */ AndroidTestUtil.MP4_ASSET_WITH_INCREASING_TIMESTAMPS_FORMAT)) {
return;
}
@ -86,11 +86,11 @@ public final class TranscodeQualityTest {
Context context = ApplicationProvider.getApplicationContext();
String testId = "transcodeAvcToHevc_ssim";
if (AndroidTestUtil.skipAndLogIfInsufficientCodecSupport(
if (AndroidTestUtil.skipAndLogIfFormatsUnsupported(
context,
testId,
/* decodingFormat= */ AndroidTestUtil.MP4_ASSET_WITH_INCREASING_TIMESTAMPS_FORMAT,
/* encodingFormat= */ AndroidTestUtil.MP4_ASSET_WITH_INCREASING_TIMESTAMPS_FORMAT
/* inputFormat= */ AndroidTestUtil.MP4_ASSET_WITH_INCREASING_TIMESTAMPS_FORMAT,
/* outputFormat= */ AndroidTestUtil.MP4_ASSET_WITH_INCREASING_TIMESTAMPS_FORMAT
.buildUpon()
.setSampleMimeType(MimeTypes.VIDEO_H265)
.build())) {

View file

@ -105,11 +105,11 @@ public class TransformationTest {
String testId = TAG + "_transform4K60";
Context context = ApplicationProvider.getApplicationContext();
if (AndroidTestUtil.skipAndLogIfInsufficientCodecSupport(
if (AndroidTestUtil.skipAndLogIfFormatsUnsupported(
context,
testId,
/* decodingFormat= */ MP4_REMOTE_4K60_PORTRAIT_FORMAT,
/* encodingFormat= */ null)) {
/* inputFormat= */ MP4_REMOTE_4K60_PORTRAIT_FORMAT,
/* outputFormat= */ null)) {
return;
}
@ -130,11 +130,8 @@ public class TransformationTest {
String testId = TAG + "_transform8K24";
Context context = ApplicationProvider.getApplicationContext();
if (AndroidTestUtil.skipAndLogIfInsufficientCodecSupport(
context,
testId,
/* decodingFormat= */ MP4_REMOTE_8K24_FORMAT,
/* encodingFormat= */ null)) {
if (AndroidTestUtil.skipAndLogIfFormatsUnsupported(
context, testId, /* inputFormat= */ MP4_REMOTE_8K24_FORMAT, /* outputFormat= */ null)) {
return;
}
Transformer transformer =

View file

@ -34,7 +34,7 @@ import static com.google.android.exoplayer2.transformer.AndroidTestUtil.MP4_REMO
import static com.google.android.exoplayer2.transformer.AndroidTestUtil.MP4_REMOTE_3840W_2160H_5_SECOND_HIGHMOTION;
import static com.google.android.exoplayer2.transformer.AndroidTestUtil.MP4_REMOTE_640W_480H_31_SECOND_ROOF_SONYXPERIAXZ3;
import static com.google.android.exoplayer2.transformer.AndroidTestUtil.MP4_REMOTE_7680W_4320H_31_SECOND_ROOF_SAMSUNGS20ULTRA5G;
import static com.google.android.exoplayer2.transformer.AndroidTestUtil.skipAndLogIfInsufficientCodecSupport;
import static com.google.android.exoplayer2.transformer.AndroidTestUtil.skipAndLogIfFormatsUnsupported;
import android.content.Context;
import android.net.Uri;
@ -130,11 +130,11 @@ public class BitrateAnalysisTest {
}
Context context = ApplicationProvider.getApplicationContext();
if (skipAndLogIfInsufficientCodecSupport(
if (skipAndLogIfFormatsUnsupported(
context,
testId,
/* decodingFormat= */ AndroidTestUtil.getFormatForTestFile(fileUri),
/* encodingFormat= */ AndroidTestUtil.getFormatForTestFile(fileUri)
/* inputFormat= */ AndroidTestUtil.getFormatForTestFile(fileUri),
/* outputFormat= */ AndroidTestUtil.getFormatForTestFile(fileUri)
.buildUpon()
.setAverageBitrate(bitrate)
.build())) {

View file

@ -96,11 +96,11 @@ public class EncoderPerformanceAnalysisTest {
"analyzePerformance_%s_OpRate_%d_Priority_%d", filename, operatingRate, priority);
Context context = ApplicationProvider.getApplicationContext();
if (AndroidTestUtil.skipAndLogIfInsufficientCodecSupport(
if (AndroidTestUtil.skipAndLogIfFormatsUnsupported(
context,
testId,
/* decodingFormat= */ AndroidTestUtil.getFormatForTestFile(fileUri),
/* encodingFormat= */ AndroidTestUtil.getFormatForTestFile(fileUri))) {
/* inputFormat= */ AndroidTestUtil.getFormatForTestFile(fileUri),
/* outputFormat= */ AndroidTestUtil.getFormatForTestFile(fileUri))) {
return;
}

View file

@ -40,7 +40,7 @@ import static com.google.android.exoplayer2.transformer.AndroidTestUtil.MP4_REMO
import static com.google.android.exoplayer2.transformer.AndroidTestUtil.MP4_REMOTE_854W_480H_30_SECOND_ROOF_ONEPLUSNORD2_DOWNSAMPLED;
import static com.google.android.exoplayer2.transformer.AndroidTestUtil.MP4_REMOTE_854W_480H_30_SECOND_ROOF_REDMINOTE9_DOWNSAMPLED;
import static com.google.android.exoplayer2.transformer.AndroidTestUtil.getFormatForTestFile;
import static com.google.android.exoplayer2.transformer.AndroidTestUtil.skipAndLogIfInsufficientCodecSupport;
import static com.google.android.exoplayer2.transformer.AndroidTestUtil.skipAndLogIfFormatsUnsupported;
import static com.google.android.exoplayer2.transformer.ExportTestResult.SSIM_UNSET;
import static com.google.android.exoplayer2.util.Assertions.checkNotNull;
import static com.google.android.exoplayer2.util.Assertions.checkState;
@ -141,11 +141,11 @@ public class SsimMapperTest {
String.format(
"ssim_search_VBR_%s", checkNotNull(getLast(FORWARD_SLASH_SPLITTER.split(mimeType))));
if (skipAndLogIfInsufficientCodecSupport(
if (skipAndLogIfFormatsUnsupported(
ApplicationProvider.getApplicationContext(),
testIdPrefix + "_codecSupport",
/* decodingFormat= */ getFormatForTestFile(fileUri),
/* encodingFormat= */ null)) {
/* inputFormat= */ getFormatForTestFile(fileUri),
/* outputFormat= */ null)) {
return;
}