mirror of
https://github.com/samsonjs/media.git
synced 2026-04-27 15:07:40 +00:00
Round impossible H264 resolutions up to valid values for capabilities check
If an odd resolution is impossible in the specification itself, then we know that the caller is passing invalid data. Round up on the assumption it's a rounding error so that playback can proceed. Issue: #6551 PiperOrigin-RevId: 275226813
This commit is contained in:
parent
40dbe10b12
commit
b0d0914ce5
1 changed files with 15 additions and 6 deletions
|
|
@ -377,18 +377,13 @@ public final class MediaCodecInfo {
|
||||||
@TargetApi(21)
|
@TargetApi(21)
|
||||||
public Point alignVideoSizeV21(int width, int height) {
|
public Point alignVideoSizeV21(int width, int height) {
|
||||||
if (capabilities == null) {
|
if (capabilities == null) {
|
||||||
logNoSupport("align.caps");
|
|
||||||
return null;
|
return null;
|
||||||
}
|
}
|
||||||
VideoCapabilities videoCapabilities = capabilities.getVideoCapabilities();
|
VideoCapabilities videoCapabilities = capabilities.getVideoCapabilities();
|
||||||
if (videoCapabilities == null) {
|
if (videoCapabilities == null) {
|
||||||
logNoSupport("align.vCaps");
|
|
||||||
return null;
|
return null;
|
||||||
}
|
}
|
||||||
int widthAlignment = videoCapabilities.getWidthAlignment();
|
return alignVideoSizeV21(videoCapabilities, width, height);
|
||||||
int heightAlignment = videoCapabilities.getHeightAlignment();
|
|
||||||
return new Point(Util.ceilDivide(width, widthAlignment) * widthAlignment,
|
|
||||||
Util.ceilDivide(height, heightAlignment) * heightAlignment);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
|
@ -519,6 +514,11 @@ public final class MediaCodecInfo {
|
||||||
@TargetApi(21)
|
@TargetApi(21)
|
||||||
private static boolean areSizeAndRateSupportedV21(VideoCapabilities capabilities, int width,
|
private static boolean areSizeAndRateSupportedV21(VideoCapabilities capabilities, int width,
|
||||||
int height, double frameRate) {
|
int height, double frameRate) {
|
||||||
|
// Don't ever fail due to alignment. See: https://github.com/google/ExoPlayer/issues/6551.
|
||||||
|
Point alignedSize = alignVideoSizeV21(capabilities, width, height);
|
||||||
|
width = alignedSize.x;
|
||||||
|
height = alignedSize.y;
|
||||||
|
|
||||||
if (frameRate == Format.NO_VALUE || frameRate <= 0) {
|
if (frameRate == Format.NO_VALUE || frameRate <= 0) {
|
||||||
return capabilities.isSizeSupported(width, height);
|
return capabilities.isSizeSupported(width, height);
|
||||||
} else {
|
} else {
|
||||||
|
|
@ -530,6 +530,15 @@ public final class MediaCodecInfo {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@TargetApi(21)
|
||||||
|
private static Point alignVideoSizeV21(VideoCapabilities capabilities, int width, int height) {
|
||||||
|
int widthAlignment = capabilities.getWidthAlignment();
|
||||||
|
int heightAlignment = capabilities.getHeightAlignment();
|
||||||
|
return new Point(
|
||||||
|
Util.ceilDivide(width, widthAlignment) * widthAlignment,
|
||||||
|
Util.ceilDivide(height, heightAlignment) * heightAlignment);
|
||||||
|
}
|
||||||
|
|
||||||
@TargetApi(23)
|
@TargetApi(23)
|
||||||
private static int getMaxSupportedInstancesV23(CodecCapabilities capabilities) {
|
private static int getMaxSupportedInstancesV23(CodecCapabilities capabilities) {
|
||||||
return capabilities.getMaxSupportedInstances();
|
return capabilities.getMaxSupportedInstances();
|
||||||
|
|
|
||||||
Loading…
Reference in a new issue