diff options
Diffstat (limited to 'tests/video/src/android/video/cts/CodecPerformanceTestBase.java')
-rw-r--r-- | tests/video/src/android/video/cts/CodecPerformanceTestBase.java | 36 |
1 files changed, 34 insertions, 2 deletions
diff --git a/tests/video/src/android/video/cts/CodecPerformanceTestBase.java b/tests/video/src/android/video/cts/CodecPerformanceTestBase.java index 01670342f61..5a34fce371b 100644 --- a/tests/video/src/android/video/cts/CodecPerformanceTestBase.java +++ b/tests/video/src/android/video/cts/CodecPerformanceTestBase.java @@ -50,6 +50,14 @@ class CodecPerformanceTestBase { // passing the test static final double FPS_TOLERANCE_FACTOR; static final boolean IS_AT_LEAST_VNDK_S; + + static final int DEVICE_INITIAL_SDK; + + // Some older devices can not support concurrent instances of both decoder and encoder + // at max resolution. To handle such cases, this test is limited to test the + // resolutions that are less than half of max supported frame sizes of encoder. + static final boolean EXCLUDE_ENCODER_MAX_RESOLUTION; + static final String mInputPrefix = WorkDir.getMediaDirString(); ArrayList<MediaCodec.BufferInfo> mBufferInfos; @@ -83,18 +91,30 @@ class CodecPerformanceTestBase { // os.Build.VERSION.DEVICE_INITIAL_SDK_INT can be used here, but it was called // os.Build.VERSION.FIRST_SDK_INT in Android R and below. Using DEVICE_INITIAL_SDK_INT // will mean that the tests built in Android S can't be run on Android R and below. - int deviceInitialSdk = SystemProperties.getInt("ro.product.first_api_level", 0); + DEVICE_INITIAL_SDK = SystemProperties.getInt("ro.product.first_api_level", 0); // fps tolerance factor is kept quite low for devices launched on Android R and lower - FPS_TOLERANCE_FACTOR = deviceInitialSdk <= Build.VERSION_CODES.R ? 0.67 : 0.95; + FPS_TOLERANCE_FACTOR = DEVICE_INITIAL_SDK <= Build.VERSION_CODES.R ? 0.67 : 0.95; IS_AT_LEAST_VNDK_S = SystemProperties.getInt("ro.vndk.version", 0) > Build.VERSION_CODES.R; + + // Encoders on devices launched on Android Q and lower aren't tested at maximum resolution + EXCLUDE_ENCODER_MAX_RESOLUTION = DEVICE_INITIAL_SDK <= Build.VERSION_CODES.Q; } @Before public void prologue() { assumeTrue("For VNDK R and below, operating rate <= 0 isn't tested", IS_AT_LEAST_VNDK_S || mMaxOpRateScalingFactor > 0.0); + + assumeTrue("For devices launched on Android P and below, operating rate tests are disabled", + DEVICE_INITIAL_SDK > Build.VERSION_CODES.P); + + if (DEVICE_INITIAL_SDK <= Build.VERSION_CODES.Q) { + assumeTrue("For devices launched with Android Q and below, operating rate tests are " + + "limited to operating rate scaling factor > 0.0 and <= 1.25", + mMaxOpRateScalingFactor > 0.0 && mMaxOpRateScalingFactor <= 1.25); + } } public CodecPerformanceTestBase(String decoderName, String testFile, int keyPriority, @@ -283,6 +303,18 @@ class CodecPerformanceTestBase { return minComplexity; } + static int getMaxFrameSize(String codecName, String mime) throws IOException { + MediaCodec codec = MediaCodec.createByCodecName(codecName); + MediaCodecInfo.CodecCapabilities codecCapabilities = + codec.getCodecInfo().getCapabilitiesForType(mime); + MediaCodecInfo.VideoCapabilities vc = codecCapabilities.getVideoCapabilities(); + Range<Integer> heights = vc.getSupportedHeights(); + Range<Integer> widths = vc.getSupportedWidthsFor(heights.getUpper()); + int maxFrameSize = heights.getUpper() * widths.getUpper(); + codec.release(); + return maxFrameSize; + } + void enqueueDecoderInput(int bufferIndex) { MediaCodec.BufferInfo info = mBufferInfos.get(mSampleIndex++); if (info.size > 0 && (info.flags & MediaCodec.BUFFER_FLAG_CODEC_CONFIG) == 0) { |