summaryrefslogtreecommitdiff
path: root/tests/tests/media/src/android/media/cts/DecodeAccuracyTestBase.java
diff options
context:
space:
mode:
Diffstat (limited to 'tests/tests/media/src/android/media/cts/DecodeAccuracyTestBase.java')
-rw-r--r--tests/tests/media/src/android/media/cts/DecodeAccuracyTestBase.java31
1 files changed, 27 insertions, 4 deletions
diff --git a/tests/tests/media/src/android/media/cts/DecodeAccuracyTestBase.java b/tests/tests/media/src/android/media/cts/DecodeAccuracyTestBase.java
index 0e92e3df92e..58f16075748 100644
--- a/tests/tests/media/src/android/media/cts/DecodeAccuracyTestBase.java
+++ b/tests/tests/media/src/android/media/cts/DecodeAccuracyTestBase.java
@@ -20,6 +20,7 @@ import android.media.cts.R;
import static org.junit.Assert.assertNotNull;
import com.android.compatibility.common.util.ApiLevelUtil;
+import com.android.compatibility.common.util.MediaUtils;
import android.annotation.TargetApi;
import android.annotation.SuppressLint;
@@ -38,6 +39,7 @@ import android.graphics.SurfaceTexture;
import android.media.MediaCodec;
import android.media.MediaCodec.BufferInfo;
import android.media.MediaCodec.CodecException;
+import android.media.MediaCodecInfo.VideoCapabilities;
import android.media.MediaCodecList;
import android.media.MediaExtractor;
import android.media.MediaFormat;
@@ -480,10 +482,27 @@ public class DecodeAccuracyTestBase {
if (ApiLevelUtil.isBefore(Build.VERSION_CODES.KITKAT)) {
return;
}
- if (videoFormat.getMaxWidth() != VideoFormat.INT_UNSET
- && videoFormat.getMaxHeight() != VideoFormat.INT_UNSET) {
- mediaFormat.setInteger(MediaFormat.KEY_MAX_WIDTH, videoFormat.getMaxWidth());
- mediaFormat.setInteger(MediaFormat.KEY_MAX_HEIGHT, videoFormat.getMaxHeight());
+ // Set KEY_MAX_WIDTH and KEY_MAX_HEIGHT when isAbrEnabled() is set.
+ if (videoFormat.isAbrEnabled()) {
+ try {
+ // Check for max resolution supported by the codec.
+ final MediaCodec decoder = MediaUtils.getDecoder(mediaFormat);
+ final VideoCapabilities videoCapabilities = MediaUtils.getVideoCapabilities(
+ decoder.getName(), videoFormat.getMimeType());
+ decoder.release();
+ final int maxWidth = videoCapabilities.getSupportedWidths().getUpper();
+ final int maxHeight =
+ videoCapabilities.getSupportedHeightsFor(maxWidth).getUpper();
+ if (maxWidth >= videoFormat.getWidth() && maxHeight >= videoFormat.getHeight()) {
+ mediaFormat.setInteger(MediaFormat.KEY_MAX_WIDTH, maxWidth);
+ mediaFormat.setInteger(MediaFormat.KEY_MAX_HEIGHT, maxHeight);
+ return;
+ }
+ } catch (NullPointerException exception) { /* */ }
+ // Set max width/height to current size if can't get codec's max supported
+ // width/height or max is not greater than the current size.
+ mediaFormat.setInteger(MediaFormat.KEY_MAX_WIDTH, videoFormat.getWidth());
+ mediaFormat.setInteger(MediaFormat.KEY_MAX_HEIGHT, videoFormat.getHeight());
}
}
@@ -1591,6 +1610,10 @@ class VideoFormat {
return getParsedName().getHeight();
}
+ public boolean isAbrEnabled() {
+ return false;
+ }
+
public String getOriginalSize() {
if (width == INT_UNSET || height == INT_UNSET) {
return getParsedName().getSize();