in android/media/MediaCodecInfo.java [2048:2641]
private void applyLevelLimits() {
long maxBlocksPerSecond = 0;
int maxBlocks = 0;
int maxBps = 0;
int maxDPBBlocks = 0;
int errors = ERROR_NONE_SUPPORTED;
CodecProfileLevel[] profileLevels = mParent.profileLevels;
String mime = mParent.getMimeType();
if (mime.equalsIgnoreCase(MediaFormat.MIMETYPE_VIDEO_AVC)) {
maxBlocks = 99;
maxBlocksPerSecond = 1485;
maxBps = 64000;
maxDPBBlocks = 396;
for (CodecProfileLevel profileLevel: profileLevels) {
int MBPS = 0, FS = 0, BR = 0, DPB = 0;
boolean supported = true;
switch (profileLevel.level) {
case CodecProfileLevel.AVCLevel1:
MBPS = 1485; FS = 99; BR = 64; DPB = 396; break;
case CodecProfileLevel.AVCLevel1b:
MBPS = 1485; FS = 99; BR = 128; DPB = 396; break;
case CodecProfileLevel.AVCLevel11:
MBPS = 3000; FS = 396; BR = 192; DPB = 900; break;
case CodecProfileLevel.AVCLevel12:
MBPS = 6000; FS = 396; BR = 384; DPB = 2376; break;
case CodecProfileLevel.AVCLevel13:
MBPS = 11880; FS = 396; BR = 768; DPB = 2376; break;
case CodecProfileLevel.AVCLevel2:
MBPS = 11880; FS = 396; BR = 2000; DPB = 2376; break;
case CodecProfileLevel.AVCLevel21:
MBPS = 19800; FS = 792; BR = 4000; DPB = 4752; break;
case CodecProfileLevel.AVCLevel22:
MBPS = 20250; FS = 1620; BR = 4000; DPB = 8100; break;
case CodecProfileLevel.AVCLevel3:
MBPS = 40500; FS = 1620; BR = 10000; DPB = 8100; break;
case CodecProfileLevel.AVCLevel31:
MBPS = 108000; FS = 3600; BR = 14000; DPB = 18000; break;
case CodecProfileLevel.AVCLevel32:
MBPS = 216000; FS = 5120; BR = 20000; DPB = 20480; break;
case CodecProfileLevel.AVCLevel4:
MBPS = 245760; FS = 8192; BR = 20000; DPB = 32768; break;
case CodecProfileLevel.AVCLevel41:
MBPS = 245760; FS = 8192; BR = 50000; DPB = 32768; break;
case CodecProfileLevel.AVCLevel42:
MBPS = 522240; FS = 8704; BR = 50000; DPB = 34816; break;
case CodecProfileLevel.AVCLevel5:
MBPS = 589824; FS = 22080; BR = 135000; DPB = 110400; break;
case CodecProfileLevel.AVCLevel51:
MBPS = 983040; FS = 36864; BR = 240000; DPB = 184320; break;
case CodecProfileLevel.AVCLevel52:
MBPS = 2073600; FS = 36864; BR = 240000; DPB = 184320; break;
default:
Log.w(TAG, "Unrecognized level "
+ profileLevel.level + " for " + mime);
errors |= ERROR_UNRECOGNIZED;
}
switch (profileLevel.profile) {
case CodecProfileLevel.AVCProfileConstrainedHigh:
case CodecProfileLevel.AVCProfileHigh:
BR *= 1250; break;
case CodecProfileLevel.AVCProfileHigh10:
BR *= 3000; break;
case CodecProfileLevel.AVCProfileExtended:
case CodecProfileLevel.AVCProfileHigh422:
case CodecProfileLevel.AVCProfileHigh444:
Log.w(TAG, "Unsupported profile "
+ profileLevel.profile + " for " + mime);
errors |= ERROR_UNSUPPORTED;
supported = false;
// fall through - treat as base profile
case CodecProfileLevel.AVCProfileConstrainedBaseline:
case CodecProfileLevel.AVCProfileBaseline:
case CodecProfileLevel.AVCProfileMain:
BR *= 1000; break;
default:
Log.w(TAG, "Unrecognized profile "
+ profileLevel.profile + " for " + mime);
errors |= ERROR_UNRECOGNIZED;
BR *= 1000;
}
if (supported) {
errors &= ~ERROR_NONE_SUPPORTED;
}
maxBlocksPerSecond = Math.max(MBPS, maxBlocksPerSecond);
maxBlocks = Math.max(FS, maxBlocks);
maxBps = Math.max(BR, maxBps);
maxDPBBlocks = Math.max(maxDPBBlocks, DPB);
}
int maxLengthInBlocks = (int)(Math.sqrt(maxBlocks * 8));
applyMacroBlockLimits(
maxLengthInBlocks, maxLengthInBlocks,
maxBlocks, maxBlocksPerSecond,
16 /* blockWidth */, 16 /* blockHeight */,
1 /* widthAlignment */, 1 /* heightAlignment */);
} else if (mime.equalsIgnoreCase(MediaFormat.MIMETYPE_VIDEO_MPEG2)) {
int maxWidth = 11, maxHeight = 9, maxRate = 15;
maxBlocks = 99;
maxBlocksPerSecond = 1485;
maxBps = 64000;
for (CodecProfileLevel profileLevel: profileLevels) {
int MBPS = 0, FS = 0, BR = 0, FR = 0, W = 0, H = 0;
boolean supported = true;
switch (profileLevel.profile) {
case CodecProfileLevel.MPEG2ProfileSimple:
switch (profileLevel.level) {
case CodecProfileLevel.MPEG2LevelML:
FR = 30; W = 45; H = 36; MBPS = 40500; FS = 1620; BR = 15000; break;
default:
Log.w(TAG, "Unrecognized profile/level "
+ profileLevel.profile + "/"
+ profileLevel.level + " for " + mime);
errors |= ERROR_UNRECOGNIZED;
}
break;
case CodecProfileLevel.MPEG2ProfileMain:
switch (profileLevel.level) {
case CodecProfileLevel.MPEG2LevelLL:
FR = 30; W = 22; H = 18; MBPS = 11880; FS = 396; BR = 4000; break;
case CodecProfileLevel.MPEG2LevelML:
FR = 30; W = 45; H = 36; MBPS = 40500; FS = 1620; BR = 15000; break;
case CodecProfileLevel.MPEG2LevelH14:
FR = 60; W = 90; H = 68; MBPS = 183600; FS = 6120; BR = 60000; break;
case CodecProfileLevel.MPEG2LevelHL:
FR = 60; W = 120; H = 68; MBPS = 244800; FS = 8160; BR = 80000; break;
case CodecProfileLevel.MPEG2LevelHP:
FR = 60; W = 120; H = 68; MBPS = 489600; FS = 8160; BR = 80000; break;
default:
Log.w(TAG, "Unrecognized profile/level "
+ profileLevel.profile + "/"
+ profileLevel.level + " for " + mime);
errors |= ERROR_UNRECOGNIZED;
}
break;
case CodecProfileLevel.MPEG2Profile422:
case CodecProfileLevel.MPEG2ProfileSNR:
case CodecProfileLevel.MPEG2ProfileSpatial:
case CodecProfileLevel.MPEG2ProfileHigh:
Log.i(TAG, "Unsupported profile "
+ profileLevel.profile + " for " + mime);
errors |= ERROR_UNSUPPORTED;
supported = false;
break;
default:
Log.w(TAG, "Unrecognized profile "
+ profileLevel.profile + " for " + mime);
errors |= ERROR_UNRECOGNIZED;
}
if (supported) {
errors &= ~ERROR_NONE_SUPPORTED;
}
maxBlocksPerSecond = Math.max(MBPS, maxBlocksPerSecond);
maxBlocks = Math.max(FS, maxBlocks);
maxBps = Math.max(BR * 1000, maxBps);
maxWidth = Math.max(W, maxWidth);
maxHeight = Math.max(H, maxHeight);
maxRate = Math.max(FR, maxRate);
}
applyMacroBlockLimits(maxWidth, maxHeight,
maxBlocks, maxBlocksPerSecond,
16 /* blockWidth */, 16 /* blockHeight */,
1 /* widthAlignment */, 1 /* heightAlignment */);
mFrameRateRange = mFrameRateRange.intersect(12, maxRate);
} else if (mime.equalsIgnoreCase(MediaFormat.MIMETYPE_VIDEO_MPEG4)) {
int maxWidth = 11, maxHeight = 9, maxRate = 15;
maxBlocks = 99;
maxBlocksPerSecond = 1485;
maxBps = 64000;
for (CodecProfileLevel profileLevel: profileLevels) {
int MBPS = 0, FS = 0, BR = 0, FR = 0, W = 0, H = 0;
boolean strict = false; // true: W, H and FR are individual max limits
boolean supported = true;
switch (profileLevel.profile) {
case CodecProfileLevel.MPEG4ProfileSimple:
switch (profileLevel.level) {
case CodecProfileLevel.MPEG4Level0:
strict = true;
FR = 15; W = 11; H = 9; MBPS = 1485; FS = 99; BR = 64; break;
case CodecProfileLevel.MPEG4Level1:
FR = 30; W = 11; H = 9; MBPS = 1485; FS = 99; BR = 64; break;
case CodecProfileLevel.MPEG4Level0b:
strict = true;
FR = 15; W = 11; H = 9; MBPS = 1485; FS = 99; BR = 128; break;
case CodecProfileLevel.MPEG4Level2:
FR = 30; W = 22; H = 18; MBPS = 5940; FS = 396; BR = 128; break;
case CodecProfileLevel.MPEG4Level3:
FR = 30; W = 22; H = 18; MBPS = 11880; FS = 396; BR = 384; break;
case CodecProfileLevel.MPEG4Level4a:
FR = 30; W = 40; H = 30; MBPS = 36000; FS = 1200; BR = 4000; break;
case CodecProfileLevel.MPEG4Level5:
FR = 30; W = 45; H = 36; MBPS = 40500; FS = 1620; BR = 8000; break;
case CodecProfileLevel.MPEG4Level6:
FR = 30; W = 80; H = 45; MBPS = 108000; FS = 3600; BR = 12000; break;
default:
Log.w(TAG, "Unrecognized profile/level "
+ profileLevel.profile + "/"
+ profileLevel.level + " for " + mime);
errors |= ERROR_UNRECOGNIZED;
}
break;
case CodecProfileLevel.MPEG4ProfileAdvancedSimple:
switch (profileLevel.level) {
case CodecProfileLevel.MPEG4Level0:
case CodecProfileLevel.MPEG4Level1:
FR = 30; W = 11; H = 9; MBPS = 2970; FS = 99; BR = 128; break;
case CodecProfileLevel.MPEG4Level2:
FR = 30; W = 22; H = 18; MBPS = 5940; FS = 396; BR = 384; break;
case CodecProfileLevel.MPEG4Level3:
FR = 30; W = 22; H = 18; MBPS = 11880; FS = 396; BR = 768; break;
case CodecProfileLevel.MPEG4Level3b:
FR = 30; W = 22; H = 18; MBPS = 11880; FS = 396; BR = 1500; break;
case CodecProfileLevel.MPEG4Level4:
FR = 30; W = 44; H = 36; MBPS = 23760; FS = 792; BR = 3000; break;
case CodecProfileLevel.MPEG4Level5:
FR = 30; W = 45; H = 36; MBPS = 48600; FS = 1620; BR = 8000; break;
default:
Log.w(TAG, "Unrecognized profile/level "
+ profileLevel.profile + "/"
+ profileLevel.level + " for " + mime);
errors |= ERROR_UNRECOGNIZED;
}
break;
case CodecProfileLevel.MPEG4ProfileMain: // 2-4
case CodecProfileLevel.MPEG4ProfileNbit: // 2
case CodecProfileLevel.MPEG4ProfileAdvancedRealTime: // 1-4
case CodecProfileLevel.MPEG4ProfileCoreScalable: // 1-3
case CodecProfileLevel.MPEG4ProfileAdvancedCoding: // 1-4
case CodecProfileLevel.MPEG4ProfileCore: // 1-2
case CodecProfileLevel.MPEG4ProfileAdvancedCore: // 1-4
case CodecProfileLevel.MPEG4ProfileSimpleScalable: // 0-2
case CodecProfileLevel.MPEG4ProfileHybrid: // 1-2
// Studio profiles are not supported by our codecs.
// Only profiles that can decode simple object types are considered.
// The following profiles are not able to.
case CodecProfileLevel.MPEG4ProfileBasicAnimated: // 1-2
case CodecProfileLevel.MPEG4ProfileScalableTexture: // 1
case CodecProfileLevel.MPEG4ProfileSimpleFace: // 1-2
case CodecProfileLevel.MPEG4ProfileAdvancedScalable: // 1-3
case CodecProfileLevel.MPEG4ProfileSimpleFBA: // 1-2
Log.i(TAG, "Unsupported profile "
+ profileLevel.profile + " for " + mime);
errors |= ERROR_UNSUPPORTED;
supported = false;
break;
default:
Log.w(TAG, "Unrecognized profile "
+ profileLevel.profile + " for " + mime);
errors |= ERROR_UNRECOGNIZED;
}
if (supported) {
errors &= ~ERROR_NONE_SUPPORTED;
}
maxBlocksPerSecond = Math.max(MBPS, maxBlocksPerSecond);
maxBlocks = Math.max(FS, maxBlocks);
maxBps = Math.max(BR * 1000, maxBps);
if (strict) {
maxWidth = Math.max(W, maxWidth);
maxHeight = Math.max(H, maxHeight);
maxRate = Math.max(FR, maxRate);
} else {
// assuming max 60 fps frame rate and 1:2 aspect ratio
int maxDim = (int)Math.sqrt(FS * 2);
maxWidth = Math.max(maxDim, maxWidth);
maxHeight = Math.max(maxDim, maxHeight);
maxRate = Math.max(Math.max(FR, 60), maxRate);
}
}
applyMacroBlockLimits(maxWidth, maxHeight,
maxBlocks, maxBlocksPerSecond,
16 /* blockWidth */, 16 /* blockHeight */,
1 /* widthAlignment */, 1 /* heightAlignment */);
mFrameRateRange = mFrameRateRange.intersect(12, maxRate);
} else if (mime.equalsIgnoreCase(MediaFormat.MIMETYPE_VIDEO_H263)) {
int maxWidth = 11, maxHeight = 9, maxRate = 15;
int minWidth = maxWidth, minHeight = maxHeight;
int minAlignment = 16;
maxBlocks = 99;
maxBlocksPerSecond = 1485;
maxBps = 64000;
for (CodecProfileLevel profileLevel: profileLevels) {
int MBPS = 0, BR = 0, FR = 0, W = 0, H = 0, minW = minWidth, minH = minHeight;
boolean strict = false; // true: support only sQCIF, QCIF (maybe CIF)
switch (profileLevel.level) {
case CodecProfileLevel.H263Level10:
strict = true; // only supports sQCIF & QCIF
FR = 15; W = 11; H = 9; BR = 1; MBPS = W * H * FR; break;
case CodecProfileLevel.H263Level20:
strict = true; // only supports sQCIF, QCIF & CIF
FR = 30; W = 22; H = 18; BR = 2; MBPS = W * H * 15; break;
case CodecProfileLevel.H263Level30:
strict = true; // only supports sQCIF, QCIF & CIF
FR = 30; W = 22; H = 18; BR = 6; MBPS = W * H * FR; break;
case CodecProfileLevel.H263Level40:
strict = true; // only supports sQCIF, QCIF & CIF
FR = 30; W = 22; H = 18; BR = 32; MBPS = W * H * FR; break;
case CodecProfileLevel.H263Level45:
// only implies level 10 support
strict = profileLevel.profile == CodecProfileLevel.H263ProfileBaseline
|| profileLevel.profile ==
CodecProfileLevel.H263ProfileBackwardCompatible;
if (!strict) {
minW = 1; minH = 1; minAlignment = 4;
}
FR = 15; W = 11; H = 9; BR = 2; MBPS = W * H * FR; break;
case CodecProfileLevel.H263Level50:
// only supports 50fps for H > 15
minW = 1; minH = 1; minAlignment = 4;
FR = 60; W = 22; H = 18; BR = 64; MBPS = W * H * 50; break;
case CodecProfileLevel.H263Level60:
// only supports 50fps for H > 15
minW = 1; minH = 1; minAlignment = 4;
FR = 60; W = 45; H = 18; BR = 128; MBPS = W * H * 50; break;
case CodecProfileLevel.H263Level70:
// only supports 50fps for H > 30
minW = 1; minH = 1; minAlignment = 4;
FR = 60; W = 45; H = 36; BR = 256; MBPS = W * H * 50; break;
default:
Log.w(TAG, "Unrecognized profile/level " + profileLevel.profile
+ "/" + profileLevel.level + " for " + mime);
errors |= ERROR_UNRECOGNIZED;
}
switch (profileLevel.profile) {
case CodecProfileLevel.H263ProfileBackwardCompatible:
case CodecProfileLevel.H263ProfileBaseline:
case CodecProfileLevel.H263ProfileH320Coding:
case CodecProfileLevel.H263ProfileHighCompression:
case CodecProfileLevel.H263ProfileHighLatency:
case CodecProfileLevel.H263ProfileInterlace:
case CodecProfileLevel.H263ProfileInternet:
case CodecProfileLevel.H263ProfileISWV2:
case CodecProfileLevel.H263ProfileISWV3:
break;
default:
Log.w(TAG, "Unrecognized profile "
+ profileLevel.profile + " for " + mime);
errors |= ERROR_UNRECOGNIZED;
}
if (strict) {
// Strict levels define sub-QCIF min size and enumerated sizes. We cannot
// express support for "only sQCIF & QCIF (& CIF)" using VideoCapabilities
// but we can express "only QCIF (& CIF)", so set minimume size at QCIF.
// minW = 8; minH = 6;
minW = 11; minH = 9;
} else {
// any support for non-strict levels (including unrecognized profiles or
// levels) allow custom frame size support beyond supported limits
// (other than bitrate)
mAllowMbOverride = true;
}
errors &= ~ERROR_NONE_SUPPORTED;
maxBlocksPerSecond = Math.max(MBPS, maxBlocksPerSecond);
maxBlocks = Math.max(W * H, maxBlocks);
maxBps = Math.max(BR * 64000, maxBps);
maxWidth = Math.max(W, maxWidth);
maxHeight = Math.max(H, maxHeight);
maxRate = Math.max(FR, maxRate);
minWidth = Math.min(minW, minWidth);
minHeight = Math.min(minH, minHeight);
}
// unless we encountered custom frame size support, limit size to QCIF and CIF
// using aspect ratio.
if (!mAllowMbOverride) {
mBlockAspectRatioRange =
Range.create(new Rational(11, 9), new Rational(11, 9));
}
applyMacroBlockLimits(
minWidth, minHeight,
maxWidth, maxHeight,
maxBlocks, maxBlocksPerSecond,
16 /* blockWidth */, 16 /* blockHeight */,
minAlignment /* widthAlignment */, minAlignment /* heightAlignment */);
mFrameRateRange = Range.create(1, maxRate);
} else if (mime.equalsIgnoreCase(MediaFormat.MIMETYPE_VIDEO_VP8)) {
maxBlocks = Integer.MAX_VALUE;
maxBlocksPerSecond = Integer.MAX_VALUE;
// TODO: set to 100Mbps for now, need a number for VP8
maxBps = 100000000;
// profile levels are not indicative for VPx, but verify
// them nonetheless
for (CodecProfileLevel profileLevel: profileLevels) {
switch (profileLevel.level) {
case CodecProfileLevel.VP8Level_Version0:
case CodecProfileLevel.VP8Level_Version1:
case CodecProfileLevel.VP8Level_Version2:
case CodecProfileLevel.VP8Level_Version3:
break;
default:
Log.w(TAG, "Unrecognized level "
+ profileLevel.level + " for " + mime);
errors |= ERROR_UNRECOGNIZED;
}
switch (profileLevel.profile) {
case CodecProfileLevel.VP8ProfileMain:
break;
default:
Log.w(TAG, "Unrecognized profile "
+ profileLevel.profile + " for " + mime);
errors |= ERROR_UNRECOGNIZED;
}
errors &= ~ERROR_NONE_SUPPORTED;
}
final int blockSize = 16;
applyMacroBlockLimits(Short.MAX_VALUE, Short.MAX_VALUE,
maxBlocks, maxBlocksPerSecond, blockSize, blockSize,
1 /* widthAlignment */, 1 /* heightAlignment */);
} else if (mime.equalsIgnoreCase(MediaFormat.MIMETYPE_VIDEO_VP9)) {
maxBlocksPerSecond = 829440;
maxBlocks = 36864;
maxBps = 200000;
int maxDim = 512;
for (CodecProfileLevel profileLevel: profileLevels) {
long SR = 0; // luma sample rate
int FS = 0; // luma picture size
int BR = 0; // bit rate kbps
int D = 0; // luma dimension
switch (profileLevel.level) {
case CodecProfileLevel.VP9Level1:
SR = 829440; FS = 36864; BR = 200; D = 512; break;
case CodecProfileLevel.VP9Level11:
SR = 2764800; FS = 73728; BR = 800; D = 768; break;
case CodecProfileLevel.VP9Level2:
SR = 4608000; FS = 122880; BR = 1800; D = 960; break;
case CodecProfileLevel.VP9Level21:
SR = 9216000; FS = 245760; BR = 3600; D = 1344; break;
case CodecProfileLevel.VP9Level3:
SR = 20736000; FS = 552960; BR = 7200; D = 2048; break;
case CodecProfileLevel.VP9Level31:
SR = 36864000; FS = 983040; BR = 12000; D = 2752; break;
case CodecProfileLevel.VP9Level4:
SR = 83558400; FS = 2228224; BR = 18000; D = 4160; break;
case CodecProfileLevel.VP9Level41:
SR = 160432128; FS = 2228224; BR = 30000; D = 4160; break;
case CodecProfileLevel.VP9Level5:
SR = 311951360; FS = 8912896; BR = 60000; D = 8384; break;
case CodecProfileLevel.VP9Level51:
SR = 588251136; FS = 8912896; BR = 120000; D = 8384; break;
case CodecProfileLevel.VP9Level52:
SR = 1176502272; FS = 8912896; BR = 180000; D = 8384; break;
case CodecProfileLevel.VP9Level6:
SR = 1176502272; FS = 35651584; BR = 180000; D = 16832; break;
case CodecProfileLevel.VP9Level61:
SR = 2353004544L; FS = 35651584; BR = 240000; D = 16832; break;
case CodecProfileLevel.VP9Level62:
SR = 4706009088L; FS = 35651584; BR = 480000; D = 16832; break;
default:
Log.w(TAG, "Unrecognized level "
+ profileLevel.level + " for " + mime);
errors |= ERROR_UNRECOGNIZED;
}
switch (profileLevel.profile) {
case CodecProfileLevel.VP9Profile0:
case CodecProfileLevel.VP9Profile1:
case CodecProfileLevel.VP9Profile2:
case CodecProfileLevel.VP9Profile3:
case CodecProfileLevel.VP9Profile2HDR:
case CodecProfileLevel.VP9Profile3HDR:
break;
default:
Log.w(TAG, "Unrecognized profile "
+ profileLevel.profile + " for " + mime);
errors |= ERROR_UNRECOGNIZED;
}
errors &= ~ERROR_NONE_SUPPORTED;
maxBlocksPerSecond = Math.max(SR, maxBlocksPerSecond);
maxBlocks = Math.max(FS, maxBlocks);
maxBps = Math.max(BR * 1000, maxBps);
maxDim = Math.max(D, maxDim);
}
final int blockSize = 8;
int maxLengthInBlocks = Utils.divUp(maxDim, blockSize);
maxBlocks = Utils.divUp(maxBlocks, blockSize * blockSize);
maxBlocksPerSecond = Utils.divUp(maxBlocksPerSecond, blockSize * blockSize);
applyMacroBlockLimits(
maxLengthInBlocks, maxLengthInBlocks,
maxBlocks, maxBlocksPerSecond,
blockSize, blockSize,
1 /* widthAlignment */, 1 /* heightAlignment */);
} else if (mime.equalsIgnoreCase(MediaFormat.MIMETYPE_VIDEO_HEVC)) {
// CTBs are at least 8x8 so use 8x8 block size
maxBlocks = 36864 >> 6; // 192x192 pixels == 576 8x8 blocks
maxBlocksPerSecond = maxBlocks * 15;
maxBps = 128000;
for (CodecProfileLevel profileLevel: profileLevels) {
double FR = 0;
int FS = 0;
int BR = 0;
switch (profileLevel.level) {
/* The HEVC spec talks only in a very convoluted manner about the
existence of levels 1-3.1 for High tier, which could also be
understood as 'decoders and encoders should treat these levels
as if they were Main tier', so we do that. */
case CodecProfileLevel.HEVCMainTierLevel1:
case CodecProfileLevel.HEVCHighTierLevel1:
FR = 15; FS = 36864; BR = 128; break;
case CodecProfileLevel.HEVCMainTierLevel2:
case CodecProfileLevel.HEVCHighTierLevel2:
FR = 30; FS = 122880; BR = 1500; break;
case CodecProfileLevel.HEVCMainTierLevel21:
case CodecProfileLevel.HEVCHighTierLevel21:
FR = 30; FS = 245760; BR = 3000; break;
case CodecProfileLevel.HEVCMainTierLevel3:
case CodecProfileLevel.HEVCHighTierLevel3:
FR = 30; FS = 552960; BR = 6000; break;
case CodecProfileLevel.HEVCMainTierLevel31:
case CodecProfileLevel.HEVCHighTierLevel31:
FR = 33.75; FS = 983040; BR = 10000; break;
case CodecProfileLevel.HEVCMainTierLevel4:
FR = 30; FS = 2228224; BR = 12000; break;
case CodecProfileLevel.HEVCHighTierLevel4:
FR = 30; FS = 2228224; BR = 30000; break;
case CodecProfileLevel.HEVCMainTierLevel41:
FR = 60; FS = 2228224; BR = 20000; break;
case CodecProfileLevel.HEVCHighTierLevel41:
FR = 60; FS = 2228224; BR = 50000; break;
case CodecProfileLevel.HEVCMainTierLevel5:
FR = 30; FS = 8912896; BR = 25000; break;
case CodecProfileLevel.HEVCHighTierLevel5:
FR = 30; FS = 8912896; BR = 100000; break;
case CodecProfileLevel.HEVCMainTierLevel51:
FR = 60; FS = 8912896; BR = 40000; break;
case CodecProfileLevel.HEVCHighTierLevel51:
FR = 60; FS = 8912896; BR = 160000; break;
case CodecProfileLevel.HEVCMainTierLevel52:
FR = 120; FS = 8912896; BR = 60000; break;
case CodecProfileLevel.HEVCHighTierLevel52:
FR = 120; FS = 8912896; BR = 240000; break;
case CodecProfileLevel.HEVCMainTierLevel6:
FR = 30; FS = 35651584; BR = 60000; break;
case CodecProfileLevel.HEVCHighTierLevel6:
FR = 30; FS = 35651584; BR = 240000; break;
case CodecProfileLevel.HEVCMainTierLevel61:
FR = 60; FS = 35651584; BR = 120000; break;
case CodecProfileLevel.HEVCHighTierLevel61:
FR = 60; FS = 35651584; BR = 480000; break;
case CodecProfileLevel.HEVCMainTierLevel62:
FR = 120; FS = 35651584; BR = 240000; break;
case CodecProfileLevel.HEVCHighTierLevel62:
FR = 120; FS = 35651584; BR = 800000; break;
default:
Log.w(TAG, "Unrecognized level "
+ profileLevel.level + " for " + mime);
errors |= ERROR_UNRECOGNIZED;
}
switch (profileLevel.profile) {
case CodecProfileLevel.HEVCProfileMain:
case CodecProfileLevel.HEVCProfileMain10:
case CodecProfileLevel.HEVCProfileMain10HDR10:
break;
default:
Log.w(TAG, "Unrecognized profile "
+ profileLevel.profile + " for " + mime);
errors |= ERROR_UNRECOGNIZED;
}
/* DPB logic:
if (width * height <= FS / 4) DPB = 16;
else if (width * height <= FS / 2) DPB = 12;
else if (width * height <= FS * 0.75) DPB = 8;
else DPB = 6;
*/
FS >>= 6; // convert pixels to blocks
errors &= ~ERROR_NONE_SUPPORTED;
maxBlocksPerSecond = Math.max((int)(FR * FS), maxBlocksPerSecond);
maxBlocks = Math.max(FS, maxBlocks);
maxBps = Math.max(BR * 1000, maxBps);
}
int maxLengthInBlocks = (int)(Math.sqrt(maxBlocks * 8));
applyMacroBlockLimits(
maxLengthInBlocks, maxLengthInBlocks,
maxBlocks, maxBlocksPerSecond,
8 /* blockWidth */, 8 /* blockHeight */,
1 /* widthAlignment */, 1 /* heightAlignment */);
} else {
Log.w(TAG, "Unsupported mime " + mime);
// using minimal bitrate here. should be overriden by
// info from media_codecs.xml
maxBps = 64000;
errors |= ERROR_UNSUPPORTED;
}
mBitrateRange = Range.create(1, maxBps);
mParent.mError |= errors;
}