From 2e3ffe1e94a16d6ca1e5c09f818969cbcd531abe Mon Sep 17 00:00:00 2001 From: olly Date: Fri, 25 Nov 2016 10:17:55 -0800 Subject: [PATCH] Assume support for vertical video if rotated resolution supported Issue: #2034 ------------- Created by MOE: https://github.com/google/moe MOE_MIGRATED_REVID=140209306 --- .../exoplayer2/mediacodec/MediaCodecInfo.java | 27 +++++++++++++++---- 1 file changed, 22 insertions(+), 5 deletions(-) diff --git a/library/src/main/java/com/google/android/exoplayer2/mediacodec/MediaCodecInfo.java b/library/src/main/java/com/google/android/exoplayer2/mediacodec/MediaCodecInfo.java index a32b4a181f..835e2f69b4 100644 --- a/library/src/main/java/com/google/android/exoplayer2/mediacodec/MediaCodecInfo.java +++ b/library/src/main/java/com/google/android/exoplayer2/mediacodec/MediaCodecInfo.java @@ -153,8 +153,14 @@ public final class MediaCodecInfo { return false; } if (!videoCapabilities.isSizeSupported(width, height)) { - logNoSupport("size.support, " + width + "x" + height); - return false; + // Capabilities are known to be inaccurately reported for vertical resolutions on some devices + // (b/31387661). If the video is vertical and the capabilities indicate support if the width + // and height are swapped, we assume that the vertical resolution is also supported. + if (width >= height || !videoCapabilities.isSizeSupported(height, width)) { + logNoSupport("size.support, " + width + "x" + height); + return false; + } + logAssumedSupport("size.rotated, " + width + "x" + height); } return true; } @@ -181,8 +187,14 @@ public final class MediaCodecInfo { return false; } if (!videoCapabilities.areSizeAndRateSupported(width, height, frameRate)) { - logNoSupport("sizeAndRate.support, " + width + "x" + height + "x" + frameRate); - return false; + // Capabilities are known to be inaccurately reported for vertical resolutions on some devices + // (b/31387661). If the video is vertical and the capabilities indicate support if the width + // and height are swapped, we assume that the vertical resolution is also supported. + if (width >= height || !videoCapabilities.areSizeAndRateSupported(height, width, frameRate)) { + logNoSupport("sizeAndRate.support, " + width + "x" + height + "x" + frameRate); + return false; + } + logAssumedSupport("sizeAndRate.rotated, " + width + "x" + height + "x" + frameRate); } return true; } @@ -240,7 +252,12 @@ public final class MediaCodecInfo { } private void logNoSupport(String message) { - Log.d(TAG, "FalseCheck [" + message + "] [" + name + ", " + mimeType + "] [" + Log.d(TAG, "NoSupport [" + message + "] [" + name + ", " + mimeType + "] [" + + Util.DEVICE_DEBUG_INFO + "]"); + } + + private void logAssumedSupport(String message) { + Log.d(TAG, "AssumedSupport [" + message + "] [" + name + ", " + mimeType + "] [" + Util.DEVICE_DEBUG_INFO + "]"); }