Merge "media: use MediaProperties.resolution_limit_32bit()" am: b721e9b48d am: 31d3ee2188 am: d2ec1478af am: 3bdacfd4b3

Original change: https://android-review.googlesource.com/c/platform/frameworks/base/+/1840914

Change-Id: If0c0d2611fe4827c635e096e8a64c2106c24666f
This commit is contained in:
Treehugger Robot
2021-10-05 23:25:03 +00:00
committed by Automerger Merge Worker

View File

@@ -28,6 +28,7 @@ import android.compat.annotation.UnsupportedAppUsage;
import android.os.Build; import android.os.Build;
import android.os.Process; import android.os.Process;
import android.os.SystemProperties; import android.os.SystemProperties;
import android.sysprop.MediaProperties;
import android.util.Log; import android.util.Log;
import android.util.Pair; import android.util.Pair;
import android.util.Range; import android.util.Range;
@@ -196,13 +197,20 @@ public final class MediaCodecInfo {
private static final Range<Rational> POSITIVE_RATIONALS = private static final Range<Rational> POSITIVE_RATIONALS =
Range.create(new Rational(1, Integer.MAX_VALUE), Range.create(new Rational(1, Integer.MAX_VALUE),
new Rational(Integer.MAX_VALUE, 1)); new Rational(Integer.MAX_VALUE, 1));
private static final Range<Integer> SIZE_RANGE =
Process.is64Bit() ? Range.create(1, 32768) : Range.create(1, 4096);
private static final Range<Integer> FRAME_RATE_RANGE = Range.create(0, 960); private static final Range<Integer> FRAME_RATE_RANGE = Range.create(0, 960);
private static final Range<Integer> BITRATE_RANGE = Range.create(0, 500000000); private static final Range<Integer> BITRATE_RANGE = Range.create(0, 500000000);
private static final int DEFAULT_MAX_SUPPORTED_INSTANCES = 32; private static final int DEFAULT_MAX_SUPPORTED_INSTANCES = 32;
private static final int MAX_SUPPORTED_INSTANCES_LIMIT = 256; private static final int MAX_SUPPORTED_INSTANCES_LIMIT = 256;
private static final class LazyHolder {
private static final Range<Integer> SIZE_RANGE = Process.is64Bit()
? Range.create(1, 32768)
: Range.create(1, MediaProperties.resolution_limit_32bit().orElse(4096));
}
private static Range<Integer> getSizeRange() {
return LazyHolder.SIZE_RANGE;
}
// found stuff that is not supported by framework (=> this should not happen) // found stuff that is not supported by framework (=> this should not happen)
private static final int ERROR_UNRECOGNIZED = (1 << 0); private static final int ERROR_UNRECOGNIZED = (1 << 0);
// found profile/level for which we don't have capability estimates // found profile/level for which we don't have capability estimates
@@ -2234,12 +2242,12 @@ public final class MediaCodecInfo {
private void initWithPlatformLimits() { private void initWithPlatformLimits() {
mBitrateRange = BITRATE_RANGE; mBitrateRange = BITRATE_RANGE;
mWidthRange = SIZE_RANGE; mWidthRange = getSizeRange();
mHeightRange = SIZE_RANGE; mHeightRange = getSizeRange();
mFrameRateRange = FRAME_RATE_RANGE; mFrameRateRange = FRAME_RATE_RANGE;
mHorizontalBlockRange = SIZE_RANGE; mHorizontalBlockRange = getSizeRange();
mVerticalBlockRange = SIZE_RANGE; mVerticalBlockRange = getSizeRange();
// full positive ranges are supported as these get calculated // full positive ranges are supported as these get calculated
mBlockCountRange = POSITIVE_INTEGERS; mBlockCountRange = POSITIVE_INTEGERS;
@@ -2253,7 +2261,7 @@ public final class MediaCodecInfo {
mHeightAlignment = 2; mHeightAlignment = 2;
mBlockWidth = 2; mBlockWidth = 2;
mBlockHeight = 2; mBlockHeight = 2;
mSmallerDimensionUpperLimit = SIZE_RANGE.getUpper(); mSmallerDimensionUpperLimit = getSizeRange().getUpper();
} }
private @Nullable List<PerformancePoint> getPerformancePoints(Map<String, Object> map) { private @Nullable List<PerformancePoint> getPerformancePoints(Map<String, Object> map) {
@@ -2494,10 +2502,10 @@ public final class MediaCodecInfo {
// codec supports profiles that we don't know. // codec supports profiles that we don't know.
// Use supplied values clipped to platform limits // Use supplied values clipped to platform limits
if (widths != null) { if (widths != null) {
mWidthRange = SIZE_RANGE.intersect(widths); mWidthRange = getSizeRange().intersect(widths);
} }
if (heights != null) { if (heights != null) {
mHeightRange = SIZE_RANGE.intersect(heights); mHeightRange = getSizeRange().intersect(heights);
} }
if (counts != null) { if (counts != null) {
mBlockCountRange = POSITIVE_INTEGERS.intersect( mBlockCountRange = POSITIVE_INTEGERS.intersect(