From 8af4d268260ac8c519a7efe0d1b969a591f255e3 Mon Sep 17 00:00:00 2001 From: Wonsik Kim Date: Thu, 30 Sep 2021 00:39:43 -0700 Subject: [PATCH] media: use MediaProperties.resolution_limit_32bit() For 32-bit resolution limit, read from MediaProperties.resolution_limit_32bit(). Bug: 194771349 Test: cts/media/device-small Change-Id: I30269383eed2929ff88da21913cebb4111d72e10 --- media/java/android/media/MediaCodecInfo.java | 26 +++++++++++++------- 1 file changed, 17 insertions(+), 9 deletions(-) diff --git a/media/java/android/media/MediaCodecInfo.java b/media/java/android/media/MediaCodecInfo.java index c7c503d64801c..6fe771ad9cc5e 100644 --- a/media/java/android/media/MediaCodecInfo.java +++ b/media/java/android/media/MediaCodecInfo.java @@ -27,6 +27,7 @@ import android.compat.annotation.UnsupportedAppUsage; import android.os.Build; import android.os.Process; import android.os.SystemProperties; +import android.sysprop.MediaProperties; import android.util.Log; import android.util.Pair; import android.util.Range; @@ -195,13 +196,20 @@ public final class MediaCodecInfo { private static final Range POSITIVE_RATIONALS = Range.create(new Rational(1, Integer.MAX_VALUE), new Rational(Integer.MAX_VALUE, 1)); - private static final Range SIZE_RANGE = - Process.is64Bit() ? Range.create(1, 32768) : Range.create(1, 4096); private static final Range FRAME_RATE_RANGE = Range.create(0, 960); private static final Range BITRATE_RANGE = Range.create(0, 500000000); private static final int DEFAULT_MAX_SUPPORTED_INSTANCES = 32; private static final int MAX_SUPPORTED_INSTANCES_LIMIT = 256; + private static final class LazyHolder { + private static final Range SIZE_RANGE = Process.is64Bit() + ? Range.create(1, 32768) + : Range.create(1, MediaProperties.resolution_limit_32bit().orElse(4096)); + } + private static Range getSizeRange() { + return LazyHolder.SIZE_RANGE; + } + // found stuff that is not supported by framework (=> this should not happen) private static final int ERROR_UNRECOGNIZED = (1 << 0); // found profile/level for which we don't have capability estimates @@ -2131,12 +2139,12 @@ public final class MediaCodecInfo { private void initWithPlatformLimits() { mBitrateRange = BITRATE_RANGE; - mWidthRange = SIZE_RANGE; - mHeightRange = SIZE_RANGE; + mWidthRange = getSizeRange(); + mHeightRange = getSizeRange(); mFrameRateRange = FRAME_RATE_RANGE; - mHorizontalBlockRange = SIZE_RANGE; - mVerticalBlockRange = SIZE_RANGE; + mHorizontalBlockRange = getSizeRange(); + mVerticalBlockRange = getSizeRange(); // full positive ranges are supported as these get calculated mBlockCountRange = POSITIVE_INTEGERS; @@ -2150,7 +2158,7 @@ public final class MediaCodecInfo { mHeightAlignment = 2; mBlockWidth = 2; mBlockHeight = 2; - mSmallerDimensionUpperLimit = SIZE_RANGE.getUpper(); + mSmallerDimensionUpperLimit = getSizeRange().getUpper(); } private @Nullable List getPerformancePoints(Map map) { @@ -2391,10 +2399,10 @@ public final class MediaCodecInfo { // codec supports profiles that we don't know. // Use supplied values clipped to platform limits if (widths != null) { - mWidthRange = SIZE_RANGE.intersect(widths); + mWidthRange = getSizeRange().intersect(widths); } if (heights != null) { - mHeightRange = SIZE_RANGE.intersect(heights); + mHeightRange = getSizeRange().intersect(heights); } if (counts != null) { mBlockCountRange = POSITIVE_INTEGERS.intersect(