videocodec CTS: Add test to validate 10-bit decoding
Besides validating 10 bit decoding, the test also validates
color aspects
Bug: 254741964
Test: atest android.videocodec.cts.VideoDecoderValidationTest
Change-Id: I91c421f893393c33560613c4fa4e0734942b16b1
diff --git a/tests/videocodec/AndroidTest.xml b/tests/videocodec/AndroidTest.xml
index d0687d5..dfee526d 100644
--- a/tests/videocodec/AndroidTest.xml
+++ b/tests/videocodec/AndroidTest.xml
@@ -26,7 +26,7 @@
</target_preparer>
<target_preparer class="com.android.compatibility.common.tradefed.targetprep.MediaPreparer">
<option name="push-all" value="true" />
- <option name="media-folder-name" value="CtsVideoCodecTestCases-1.1" />
+ <option name="media-folder-name" value="CtsVideoCodecTestCases-1.2" />
<option name="dynamic-config-module" value="CtsVideoCodecTestCases" />
</target_preparer>
<target_preparer class="com.android.tradefed.targetprep.suite.SuiteApkInstaller">
diff --git a/tests/videocodec/DynamicConfig.xml b/tests/videocodec/DynamicConfig.xml
index 9de764d..5b41fdc 100644
--- a/tests/videocodec/DynamicConfig.xml
+++ b/tests/videocodec/DynamicConfig.xml
@@ -1,5 +1,5 @@
<dynamicConfig>
<entry key="media_files_url">
- <value>https://storage.googleapis.com/android_media/cts/tests/videocodec/CtsVideoCodecTestCases-1.1.zip</value>
+ <value>https://storage.googleapis.com/android_media/cts/tests/videocodec/CtsVideoCodecTestCases-1.2.zip</value>
</entry>
</dynamicConfig>
diff --git a/tests/videocodec/README.md b/tests/videocodec/README.md
index 48c947b..8508f8e 100644
--- a/tests/videocodec/README.md
+++ b/tests/videocodec/README.md
@@ -1,7 +1,7 @@
## Video Codec CTS Tests
The tests present in this folder are an extension of tests at cts/tests/tests/media/encoder/.
-The test vectors used by the test suite is available at [link](https://storage.googleapis.com/android_media/cts/tests/videocodec/CtsVideoCodecTestCases-1.1.zip) and is downloaded automatically while running tests. Manual installation of these can be done using copy_media.sh script in this directory.
+The test vectors used by the test suite is available at [link](https://storage.googleapis.com/android_media/cts/tests/videocodec/CtsVideoCodecTestCases-1.2.zip) and is downloaded automatically while running tests. Manual installation of these can be done using copy_media.sh script in this directory.
### Commands
```sh
diff --git a/tests/videocodec/copy_media.sh b/tests/videocodec/copy_media.sh
index 3d79c32..9c17ae7 100755
--- a/tests/videocodec/copy_media.sh
+++ b/tests/videocodec/copy_media.sh
@@ -17,7 +17,7 @@
## script to install cts video test files manually
adbOptions=" "
-resLabel=CtsVideoCodecTestCases-1.1
+resLabel=CtsVideoCodecTestCases-1.2
srcDir="/tmp/$resLabel"
tgtDir="/sdcard/test"
usage="Usage: $0 [-h] [-s serial]"
diff --git a/tests/videocodec/src/android/videocodec/cts/VideoDecoderValidationTest.java b/tests/videocodec/src/android/videocodec/cts/VideoDecoderValidationTest.java
new file mode 100644
index 0000000..84bc521
--- /dev/null
+++ b/tests/videocodec/src/android/videocodec/cts/VideoDecoderValidationTest.java
@@ -0,0 +1,110 @@
+/*
+ * Copyright (C) 2022 The Android Open Source Project
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+package android.videocodec.cts;
+
+import static android.mediav2.common.cts.CodecTestBase.SupportClass.CODEC_OPTIONAL;
+
+import static org.junit.Assert.assertEquals;
+
+import android.media.MediaExtractor;
+import android.media.MediaFormat;
+import android.mediav2.common.cts.CodecDecoderTestBase;
+import android.os.Build;
+
+import androidx.test.filters.LargeTest;
+import androidx.test.filters.SdkSuppress;
+
+import com.android.compatibility.common.util.ApiTest;
+
+import org.junit.Assume;
+import org.junit.Test;
+import org.junit.runner.RunWith;
+import org.junit.runners.Parameterized;
+
+import java.io.IOException;
+import java.util.ArrayList;
+import java.util.Arrays;
+import java.util.Collection;
+import java.util.List;
+
+/**
+ * This test is similar to {@link android.mediav2.cts.CodecDecoderValidationTest},
+ * {@link android.mediav2.cts.DecoderColorAspectsTest}, except the test clips are longer in
+ * duration and are larger resolutions.
+ */
+@RunWith(Parameterized.class)
+// P010 support was added in Android T, hence limit the following tests to Android T and above
+@SdkSuppress(minSdkVersion = Build.VERSION_CODES.TIRAMISU, codeName = "Tiramisu")
+public class VideoDecoderValidationTest extends CodecDecoderTestBase {
+ private static final String MEDIA_DIR = WorkDir.getMediaDirString();
+
+ private final long mRefCRC;
+ private final int mRange;
+ private final int mStandard;
+ private final int mTransfer;
+
+ public VideoDecoderValidationTest(String decoder, String mediaType, String testFile,
+ long refCRC, int range, int standard, int transfer, String allTestParams) {
+ super(decoder, mediaType, MEDIA_DIR + testFile, allTestParams);
+ mRefCRC = refCRC;
+ mRange = range;
+ mStandard = standard;
+ mTransfer = transfer;
+ }
+
+ @Parameterized.Parameters(name = "{index}({0}_{1})")
+ public static Collection<Object[]> input() {
+ final boolean isEncoder = false;
+ final boolean needAudio = true;
+ final boolean needVideo = true;
+ // mediaType, testfile, checksum, range, standard, transfer
+ final List<Object[]> exhaustiveArgsList = new ArrayList<>(Arrays.asList(new Object[][]{
+ {MediaFormat.MIMETYPE_VIDEO_HEVC, "HLG_Concert_HEVC_yuv420p10le_4k.mp4",
+ 4194958348L, MediaFormat.COLOR_RANGE_LIMITED,
+ MediaFormat.COLOR_STANDARD_BT2020, MediaFormat.COLOR_TRANSFER_HLG},
+ {MediaFormat.MIMETYPE_VIDEO_HEVC, "HLG_BirthdayParty_HEVC_yuv420p10le_4k.mp4",
+ 152715480L, MediaFormat.COLOR_RANGE_LIMITED,
+ MediaFormat.COLOR_STANDARD_BT2020, MediaFormat.COLOR_TRANSFER_HLG},
+ }));
+ return prepareParamList(exhaustiveArgsList, isEncoder, needAudio, needVideo, false);
+ }
+
+ /**
+ * Extract, Decode and Validate. Check description of class {@link VideoDecoderValidationTest}
+ */
+ @ApiTest(apis = {"MediaCodecInfo.CodecCapabilities#COLOR_FormatYUVP010",
+ "android.media.MediaFormat#KEY_COLOR_RANGE",
+ "android.media.MediaFormat#KEY_COLOR_STANDARD",
+ "android.media.MediaFormat#KEY_COLOR_TRANSFER"})
+ @LargeTest
+ @Test
+ public void testDecodeAndValidate() throws IOException, InterruptedException {
+ MediaFormat format = setUpSource(mTestFile);
+ mExtractor.release();
+ ArrayList<MediaFormat> formats = new ArrayList<>();
+ formats.add(format);
+ checkFormatSupport(mCodecName, mMime, false, formats, null, CODEC_OPTIONAL);
+ decodeToMemory(mTestFile, mCodecName, 0, MediaExtractor.SEEK_TO_CLOSEST_SYNC,
+ Integer.MAX_VALUE);
+ validateColorAspects(getOutputFormat(), mRange, mStandard, mTransfer);
+ Assume.assumeFalse("skip checksum verification due to tone mapping",
+ mSkipChecksumVerification);
+ assertEquals("checksum mismatch. \n" + mTestConfig + mTestEnv, mRefCRC,
+ mOutputBuff.getCheckSumImage());
+ }
+}
+
diff --git a/tests/videocodec/src/android/videocodec/cts/WorkDir.java b/tests/videocodec/src/android/videocodec/cts/WorkDir.java
index 2256294..4729742 100644
--- a/tests/videocodec/src/android/videocodec/cts/WorkDir.java
+++ b/tests/videocodec/src/android/videocodec/cts/WorkDir.java
@@ -23,6 +23,6 @@
*/
class WorkDir extends WorkDirBase {
static final String getMediaDirString() {
- return getMediaDirString("CtsVideoCodecTestCases-1.1");
+ return getMediaDirString("CtsVideoCodecTestCases-1.2");
}
}