Merge "parse bitrate range for video/audio caps" into lmp-mr1-dev
This commit is contained in:
@@ -126,6 +126,7 @@ public final class MediaCodecInfo {
|
|||||||
new Rational(Integer.MAX_VALUE, 1));
|
new Rational(Integer.MAX_VALUE, 1));
|
||||||
private static final Range<Integer> SIZE_RANGE = Range.create(1, 32768);
|
private static final Range<Integer> SIZE_RANGE = Range.create(1, 32768);
|
||||||
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);
|
||||||
|
|
||||||
// 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);
|
||||||
@@ -711,7 +712,7 @@ public final class MediaCodecInfo {
|
|||||||
}
|
}
|
||||||
if (info.containsKey("bitrate-range")) {
|
if (info.containsKey("bitrate-range")) {
|
||||||
bitRates = bitRates.intersect(
|
bitRates = bitRates.intersect(
|
||||||
Utils.parseIntRange(info.getString("bitrate"), bitRates));
|
Utils.parseIntRange(info.getString("bitrate-range"), bitRates));
|
||||||
}
|
}
|
||||||
applyLimits(maxInputChannels, bitRates);
|
applyLimits(maxInputChannels, bitRates);
|
||||||
}
|
}
|
||||||
@@ -1061,7 +1062,7 @@ public final class MediaCodecInfo {
|
|||||||
}
|
}
|
||||||
|
|
||||||
private void initWithPlatformLimits() {
|
private void initWithPlatformLimits() {
|
||||||
mBitrateRange = Range.create(0, Integer.MAX_VALUE);
|
mBitrateRange = BITRATE_RANGE;
|
||||||
|
|
||||||
mWidthRange = SIZE_RANGE;
|
mWidthRange = SIZE_RANGE;
|
||||||
mHeightRange = SIZE_RANGE;
|
mHeightRange = SIZE_RANGE;
|
||||||
@@ -1090,7 +1091,7 @@ public final class MediaCodecInfo {
|
|||||||
Size blockSize = new Size(mBlockWidth, mBlockHeight);
|
Size blockSize = new Size(mBlockWidth, mBlockHeight);
|
||||||
Size alignment = new Size(mWidthAlignment, mHeightAlignment);
|
Size alignment = new Size(mWidthAlignment, mHeightAlignment);
|
||||||
Range<Integer> counts = null, widths = null, heights = null;
|
Range<Integer> counts = null, widths = null, heights = null;
|
||||||
Range<Integer> frameRates = null;
|
Range<Integer> frameRates = null, bitRates = null;
|
||||||
Range<Long> blockRates = null;
|
Range<Long> blockRates = null;
|
||||||
Range<Rational> ratios = null, blockRatios = null;
|
Range<Rational> ratios = null, blockRatios = null;
|
||||||
|
|
||||||
@@ -1148,6 +1149,16 @@ public final class MediaCodecInfo {
|
|||||||
frameRates = null;
|
frameRates = null;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
bitRates = Utils.parseIntRange(map.get("bitrate-range"), null);
|
||||||
|
if (bitRates != null) {
|
||||||
|
try {
|
||||||
|
bitRates = bitRates.intersect(BITRATE_RANGE);
|
||||||
|
} catch (IllegalArgumentException e) {
|
||||||
|
Log.w(TAG, "bitrate range (" + bitRates
|
||||||
|
+ ") is out of limits: " + BITRATE_RANGE);
|
||||||
|
bitRates = null;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
checkPowerOfTwo(
|
checkPowerOfTwo(
|
||||||
blockSize.getWidth(), "block-size width must be power of two");
|
blockSize.getWidth(), "block-size width must be power of two");
|
||||||
@@ -1196,6 +1207,9 @@ public final class MediaCodecInfo {
|
|||||||
if (frameRates != null) {
|
if (frameRates != null) {
|
||||||
mFrameRateRange = FRAME_RATE_RANGE.intersect(frameRates);
|
mFrameRateRange = FRAME_RATE_RANGE.intersect(frameRates);
|
||||||
}
|
}
|
||||||
|
if (bitRates != null) {
|
||||||
|
mBitrateRange = BITRATE_RANGE.intersect(bitRates);
|
||||||
|
}
|
||||||
} else {
|
} else {
|
||||||
// no unsupported profile/levels, so restrict values to known limits
|
// no unsupported profile/levels, so restrict values to known limits
|
||||||
if (widths != null) {
|
if (widths != null) {
|
||||||
@@ -1226,6 +1240,9 @@ public final class MediaCodecInfo {
|
|||||||
if (frameRates != null) {
|
if (frameRates != null) {
|
||||||
mFrameRateRange = mFrameRateRange.intersect(frameRates);
|
mFrameRateRange = mFrameRateRange.intersect(frameRates);
|
||||||
}
|
}
|
||||||
|
if (bitRates != null) {
|
||||||
|
mBitrateRange = mBitrateRange.intersect(bitRates);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
updateLimits();
|
updateLimits();
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user