Commit 6d9baa6e by andrewlewis Committed by christosts

Skip tests if muxing is unsupported

PiperOrigin-RevId: 509802784
parent 4759e007
...@@ -580,43 +580,48 @@ public final class AndroidTestUtil { ...@@ -580,43 +580,48 @@ public final class AndroidTestUtil {
} }
/** /**
* Checks whether the test should be skipped because the device is incapable of decoding and * Returns whether the test should be skipped because the device is incapable of decoding the
* encoding the given formats. * 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. * <p>If the test should be skipped, logs the reason for skipping.
* *
* @param context The {@link Context context}. * @param context The {@link Context context}.
* @param testId The test ID. * @param testId The test ID.
* @param decodingFormat The {@link Format format} to decode. * @param inputFormat The {@link Format format} to decode.
* @param encodingFormat The {@link Format format} to encode, optional. * @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. * @return Whether the test should be skipped.
*/ */
public static boolean skipAndLogIfInsufficientCodecSupport( public static boolean skipAndLogIfFormatsUnsupported(
Context context, String testId, Format decodingFormat, @Nullable Format encodingFormat) Context context, String testId, Format inputFormat, @Nullable Format outputFormat)
throws IOException, JSONException { throws IOException, JSONException {
boolean canDecode = false; boolean canDecode = false;
@Nullable MediaCodecUtil.DecoderQueryException queryException = null; @Nullable MediaCodecUtil.DecoderQueryException queryException = null;
try { try {
canDecode = canDecode(decodingFormat); canDecode = canDecode(inputFormat);
} catch (MediaCodecUtil.DecoderQueryException e) { } catch (MediaCodecUtil.DecoderQueryException e) {
queryException = e; queryException = e;
} }
boolean canEncode = encodingFormat == null || canEncode(encodingFormat); boolean canEncode = outputFormat == null || canEncode(outputFormat);
boolean canMux = outputFormat == null || canMux(outputFormat);
if (canDecode && canEncode) { if (canDecode && canEncode && canMux) {
return false; return false;
} }
StringBuilder skipReasonBuilder = new StringBuilder(); StringBuilder skipReasonBuilder = new StringBuilder();
if (!canDecode) { if (!canDecode) {
skipReasonBuilder.append("Cannot decode ").append(decodingFormat).append('\n'); skipReasonBuilder.append("Cannot decode ").append(inputFormat).append('\n');
if (queryException != null) { if (queryException != null) {
skipReasonBuilder.append(queryException).append('\n'); skipReasonBuilder.append(queryException).append('\n');
} }
} }
if (!canEncode) { 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()); recordTestSkipped(context, testId, skipReasonBuilder.toString());
return true; return true;
...@@ -714,7 +719,7 @@ public final class AndroidTestUtil { ...@@ -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}. * the given resolution and {@linkplain Format#averageBitrate bitrate}.
* *
* <p>Assumes support encoding if the {@link Format#averageBitrate bitrate} is not set. * <p>Assumes support encoding if the {@link Format#averageBitrate bitrate} is not set.
...@@ -737,6 +742,14 @@ public final class AndroidTestUtil { ...@@ -737,6 +742,14 @@ public final class AndroidTestUtil {
return sizeSupported && bitrateSupported; 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. * Creates a {@link File} of the {@code fileName} in the application cache directory.
* *
......
...@@ -51,11 +51,11 @@ public class ForceInterpretHdrVideoAsSdrTest { ...@@ -51,11 +51,11 @@ public class ForceInterpretHdrVideoAsSdrTest {
String testId = "forceInterpretHdrVideoAsSdrTest_hdr10File_transformsOrThrows"; String testId = "forceInterpretHdrVideoAsSdrTest_hdr10File_transformsOrThrows";
Context context = ApplicationProvider.getApplicationContext(); Context context = ApplicationProvider.getApplicationContext();
if (AndroidTestUtil.skipAndLogIfInsufficientCodecSupport( if (AndroidTestUtil.skipAndLogIfFormatsUnsupported(
context, context,
testId, testId,
/* decodingFormat= */ MP4_ASSET_1080P_4_SECOND_HDR10_FORMAT, /* inputFormat= */ MP4_ASSET_1080P_4_SECOND_HDR10_FORMAT,
/* encodingFormat= */ null)) { /* outputFormat= */ null)) {
return; return;
} }
...@@ -87,11 +87,11 @@ public class ForceInterpretHdrVideoAsSdrTest { ...@@ -87,11 +87,11 @@ public class ForceInterpretHdrVideoAsSdrTest {
String testId = "forceInterpretHdrVideoAsSdrTest_hlg10File_transformsOrThrows"; String testId = "forceInterpretHdrVideoAsSdrTest_hlg10File_transformsOrThrows";
Context context = ApplicationProvider.getApplicationContext(); Context context = ApplicationProvider.getApplicationContext();
if (AndroidTestUtil.skipAndLogIfInsufficientCodecSupport( if (AndroidTestUtil.skipAndLogIfFormatsUnsupported(
context, context,
testId, testId,
/* decodingFormat= */ MP4_ASSET_1080P_5_SECOND_HLG10_FORMAT, /* inputFormat= */ MP4_ASSET_1080P_5_SECOND_HLG10_FORMAT,
/* encodingFormat= */ null)) { /* outputFormat= */ null)) {
return; return;
} }
......
...@@ -21,7 +21,7 @@ import static com.google.android.exoplayer2.testutil.BitmapPixelTestUtil.readBit ...@@ -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_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.MP4_ASSET_1080P_5_SECOND_HLG10_FORMAT;
import static com.google.android.exoplayer2.transformer.AndroidTestUtil.recordTestSkipped; 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 static com.google.common.truth.Truth.assertThat;
import android.graphics.Bitmap; import android.graphics.Bitmap;
...@@ -95,11 +95,11 @@ public final class ToneMapHdrToSdrUsingOpenGlPixelTest { ...@@ -95,11 +95,11 @@ public final class ToneMapHdrToSdrUsingOpenGlPixelTest {
recordTestSkipped(getApplicationContext(), testId, SKIP_REASON_NO_YUV); recordTestSkipped(getApplicationContext(), testId, SKIP_REASON_NO_YUV);
return; return;
} }
if (skipAndLogIfInsufficientCodecSupport( if (skipAndLogIfFormatsUnsupported(
getApplicationContext(), getApplicationContext(),
testId, testId,
/* decodingFormat= */ MP4_ASSET_1080P_5_SECOND_HLG10_FORMAT, /* inputFormat= */ MP4_ASSET_1080P_5_SECOND_HLG10_FORMAT,
/* encodingFormat= */ null)) { /* outputFormat= */ null)) {
return; return;
} }
ColorInfo hlgColor = ColorInfo hlgColor =
...@@ -158,11 +158,11 @@ public final class ToneMapHdrToSdrUsingOpenGlPixelTest { ...@@ -158,11 +158,11 @@ public final class ToneMapHdrToSdrUsingOpenGlPixelTest {
recordTestSkipped(getApplicationContext(), testId, SKIP_REASON_NO_YUV); recordTestSkipped(getApplicationContext(), testId, SKIP_REASON_NO_YUV);
return; return;
} }
if (skipAndLogIfInsufficientCodecSupport( if (skipAndLogIfFormatsUnsupported(
getApplicationContext(), getApplicationContext(),
testId, testId,
/* decodingFormat= */ MP4_ASSET_1080P_4_SECOND_HDR10_FORMAT, /* inputFormat= */ MP4_ASSET_1080P_4_SECOND_HDR10_FORMAT,
/* encodingFormat= */ null)) { /* outputFormat= */ null)) {
return; return;
} }
ColorInfo pqColor = ColorInfo pqColor =
......
...@@ -68,11 +68,11 @@ public class ToneMapHdrToSdrUsingOpenGlTest { ...@@ -68,11 +68,11 @@ public class ToneMapHdrToSdrUsingOpenGlTest {
return; return;
} }
if (AndroidTestUtil.skipAndLogIfInsufficientCodecSupport( if (AndroidTestUtil.skipAndLogIfFormatsUnsupported(
getApplicationContext(), getApplicationContext(),
testId, testId,
/* decodingFormat= */ MP4_ASSET_1080P_5_SECOND_HLG10_FORMAT, /* inputFormat= */ MP4_ASSET_1080P_5_SECOND_HLG10_FORMAT,
/* encodingFormat= */ null)) { /* outputFormat= */ null)) {
return; return;
} }
...@@ -119,11 +119,11 @@ public class ToneMapHdrToSdrUsingOpenGlTest { ...@@ -119,11 +119,11 @@ public class ToneMapHdrToSdrUsingOpenGlTest {
return; return;
} }
if (AndroidTestUtil.skipAndLogIfInsufficientCodecSupport( if (AndroidTestUtil.skipAndLogIfFormatsUnsupported(
getApplicationContext(), getApplicationContext(),
testId, testId,
/* decodingFormat= */ MP4_ASSET_1080P_4_SECOND_HDR10_FORMAT, /* inputFormat= */ MP4_ASSET_1080P_4_SECOND_HDR10_FORMAT,
/* encodingFormat= */ null)) { /* outputFormat= */ null)) {
return; return;
} }
......
...@@ -44,11 +44,11 @@ public final class TranscodeQualityTest { ...@@ -44,11 +44,11 @@ public final class TranscodeQualityTest {
Context context = ApplicationProvider.getApplicationContext(); Context context = ApplicationProvider.getApplicationContext();
String testId = "transformHighQualityTargetingAvcToAvc1920x1080_ssim"; String testId = "transformHighQualityTargetingAvcToAvc1920x1080_ssim";
if (AndroidTestUtil.skipAndLogIfInsufficientCodecSupport( if (AndroidTestUtil.skipAndLogIfFormatsUnsupported(
context, context,
testId, testId,
/* decodingFormat= */ AndroidTestUtil.MP4_ASSET_WITH_INCREASING_TIMESTAMPS_FORMAT, /* inputFormat= */ AndroidTestUtil.MP4_ASSET_WITH_INCREASING_TIMESTAMPS_FORMAT,
/* encodingFormat= */ AndroidTestUtil.MP4_ASSET_WITH_INCREASING_TIMESTAMPS_FORMAT)) { /* outputFormat= */ AndroidTestUtil.MP4_ASSET_WITH_INCREASING_TIMESTAMPS_FORMAT)) {
return; return;
} }
...@@ -86,11 +86,11 @@ public final class TranscodeQualityTest { ...@@ -86,11 +86,11 @@ public final class TranscodeQualityTest {
Context context = ApplicationProvider.getApplicationContext(); Context context = ApplicationProvider.getApplicationContext();
String testId = "transcodeAvcToHevc_ssim"; String testId = "transcodeAvcToHevc_ssim";
if (AndroidTestUtil.skipAndLogIfInsufficientCodecSupport( if (AndroidTestUtil.skipAndLogIfFormatsUnsupported(
context, context,
testId, testId,
/* decodingFormat= */ AndroidTestUtil.MP4_ASSET_WITH_INCREASING_TIMESTAMPS_FORMAT, /* inputFormat= */ AndroidTestUtil.MP4_ASSET_WITH_INCREASING_TIMESTAMPS_FORMAT,
/* encodingFormat= */ AndroidTestUtil.MP4_ASSET_WITH_INCREASING_TIMESTAMPS_FORMAT /* outputFormat= */ AndroidTestUtil.MP4_ASSET_WITH_INCREASING_TIMESTAMPS_FORMAT
.buildUpon() .buildUpon()
.setSampleMimeType(MimeTypes.VIDEO_H265) .setSampleMimeType(MimeTypes.VIDEO_H265)
.build())) { .build())) {
......
...@@ -105,11 +105,11 @@ public class TransformationTest { ...@@ -105,11 +105,11 @@ public class TransformationTest {
String testId = TAG + "_transform4K60"; String testId = TAG + "_transform4K60";
Context context = ApplicationProvider.getApplicationContext(); Context context = ApplicationProvider.getApplicationContext();
if (AndroidTestUtil.skipAndLogIfInsufficientCodecSupport( if (AndroidTestUtil.skipAndLogIfFormatsUnsupported(
context, context,
testId, testId,
/* decodingFormat= */ MP4_REMOTE_4K60_PORTRAIT_FORMAT, /* inputFormat= */ MP4_REMOTE_4K60_PORTRAIT_FORMAT,
/* encodingFormat= */ null)) { /* outputFormat= */ null)) {
return; return;
} }
...@@ -130,11 +130,8 @@ public class TransformationTest { ...@@ -130,11 +130,8 @@ public class TransformationTest {
String testId = TAG + "_transform8K24"; String testId = TAG + "_transform8K24";
Context context = ApplicationProvider.getApplicationContext(); Context context = ApplicationProvider.getApplicationContext();
if (AndroidTestUtil.skipAndLogIfInsufficientCodecSupport( if (AndroidTestUtil.skipAndLogIfFormatsUnsupported(
context, context, testId, /* inputFormat= */ MP4_REMOTE_8K24_FORMAT, /* outputFormat= */ null)) {
testId,
/* decodingFormat= */ MP4_REMOTE_8K24_FORMAT,
/* encodingFormat= */ null)) {
return; return;
} }
Transformer transformer = Transformer transformer =
......
...@@ -34,7 +34,7 @@ import static com.google.android.exoplayer2.transformer.AndroidTestUtil.MP4_REMO ...@@ -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_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_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.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.content.Context;
import android.net.Uri; import android.net.Uri;
...@@ -130,11 +130,11 @@ public class BitrateAnalysisTest { ...@@ -130,11 +130,11 @@ public class BitrateAnalysisTest {
} }
Context context = ApplicationProvider.getApplicationContext(); Context context = ApplicationProvider.getApplicationContext();
if (skipAndLogIfInsufficientCodecSupport( if (skipAndLogIfFormatsUnsupported(
context, context,
testId, testId,
/* decodingFormat= */ AndroidTestUtil.getFormatForTestFile(fileUri), /* inputFormat= */ AndroidTestUtil.getFormatForTestFile(fileUri),
/* encodingFormat= */ AndroidTestUtil.getFormatForTestFile(fileUri) /* outputFormat= */ AndroidTestUtil.getFormatForTestFile(fileUri)
.buildUpon() .buildUpon()
.setAverageBitrate(bitrate) .setAverageBitrate(bitrate)
.build())) { .build())) {
......
...@@ -96,11 +96,11 @@ public class EncoderPerformanceAnalysisTest { ...@@ -96,11 +96,11 @@ public class EncoderPerformanceAnalysisTest {
"analyzePerformance_%s_OpRate_%d_Priority_%d", filename, operatingRate, priority); "analyzePerformance_%s_OpRate_%d_Priority_%d", filename, operatingRate, priority);
Context context = ApplicationProvider.getApplicationContext(); Context context = ApplicationProvider.getApplicationContext();
if (AndroidTestUtil.skipAndLogIfInsufficientCodecSupport( if (AndroidTestUtil.skipAndLogIfFormatsUnsupported(
context, context,
testId, testId,
/* decodingFormat= */ AndroidTestUtil.getFormatForTestFile(fileUri), /* inputFormat= */ AndroidTestUtil.getFormatForTestFile(fileUri),
/* encodingFormat= */ AndroidTestUtil.getFormatForTestFile(fileUri))) { /* outputFormat= */ AndroidTestUtil.getFormatForTestFile(fileUri))) {
return; return;
} }
......
...@@ -40,7 +40,7 @@ import static com.google.android.exoplayer2.transformer.AndroidTestUtil.MP4_REMO ...@@ -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_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.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.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.transformer.ExportTestResult.SSIM_UNSET;
import static com.google.android.exoplayer2.util.Assertions.checkNotNull; import static com.google.android.exoplayer2.util.Assertions.checkNotNull;
import static com.google.android.exoplayer2.util.Assertions.checkState; import static com.google.android.exoplayer2.util.Assertions.checkState;
...@@ -141,11 +141,11 @@ public class SsimMapperTest { ...@@ -141,11 +141,11 @@ public class SsimMapperTest {
String.format( String.format(
"ssim_search_VBR_%s", checkNotNull(getLast(FORWARD_SLASH_SPLITTER.split(mimeType)))); "ssim_search_VBR_%s", checkNotNull(getLast(FORWARD_SLASH_SPLITTER.split(mimeType))));
if (skipAndLogIfInsufficientCodecSupport( if (skipAndLogIfFormatsUnsupported(
ApplicationProvider.getApplicationContext(), ApplicationProvider.getApplicationContext(),
testIdPrefix + "_codecSupport", testIdPrefix + "_codecSupport",
/* decodingFormat= */ getFormatForTestFile(fileUri), /* inputFormat= */ getFormatForTestFile(fileUri),
/* encodingFormat= */ null)) { /* outputFormat= */ null)) {
return; return;
} }
......
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