From e16ab27b6372293799237dd49f2ba22c8c7f4b33 Mon Sep 17 00:00:00 2001 From: olly Date: Mon, 26 Oct 2020 18:45:46 +0000 Subject: [PATCH] No-op refactor of MediaCodecInfo.isSeamlessAdaptationSupported PiperOrigin-RevId: 339084261 --- .../exoplayer2/mediacodec/MediaCodecInfo.java | 44 +++++++++++-------- 1 file changed, 26 insertions(+), 18 deletions(-) diff --git a/library/core/src/main/java/com/google/android/exoplayer2/mediacodec/MediaCodecInfo.java b/library/core/src/main/java/com/google/android/exoplayer2/mediacodec/MediaCodecInfo.java index 404066e96d..95cd0f40eb 100644 --- a/library/core/src/main/java/com/google/android/exoplayer2/mediacodec/MediaCodecInfo.java +++ b/library/core/src/main/java/com/google/android/exoplayer2/mediacodec/MediaCodecInfo.java @@ -327,34 +327,42 @@ public final class MediaCodecInfo { */ public boolean isSeamlessAdaptationSupported( Format oldFormat, Format newFormat, boolean isNewFormatComplete) { + if (!Util.areEqual(oldFormat.sampleMimeType, newFormat.sampleMimeType)) { + return false; + } + if (isVideo) { - return Assertions.checkNotNull(oldFormat.sampleMimeType).equals(newFormat.sampleMimeType) - && oldFormat.rotationDegrees == newFormat.rotationDegrees + return oldFormat.rotationDegrees == newFormat.rotationDegrees && (adaptive || (oldFormat.width == newFormat.width && oldFormat.height == newFormat.height)) && ((!isNewFormatComplete && newFormat.colorInfo == null) || Util.areEqual(oldFormat.colorInfo, newFormat.colorInfo)); } else { - if (!MimeTypes.AUDIO_AAC.equals(mimeType) - || !Assertions.checkNotNull(oldFormat.sampleMimeType).equals(newFormat.sampleMimeType) - || oldFormat.channelCount != newFormat.channelCount + if (oldFormat.channelCount != newFormat.channelCount || oldFormat.sampleRate != newFormat.sampleRate) { return false; } - // Check the codec profile levels support adaptation. - @Nullable - Pair oldCodecProfileLevel = - MediaCodecUtil.getCodecProfileAndLevel(oldFormat); - @Nullable - Pair newCodecProfileLevel = - MediaCodecUtil.getCodecProfileAndLevel(newFormat); - if (oldCodecProfileLevel == null || newCodecProfileLevel == null) { - return false; + + // Check whether we're adapting between two xHE-AAC formats, for which adaptation is possible + // without reconfiguration. + if (MimeTypes.AUDIO_AAC.equals(mimeType)) { + @Nullable + Pair oldCodecProfileLevel = + MediaCodecUtil.getCodecProfileAndLevel(oldFormat); + @Nullable + Pair newCodecProfileLevel = + MediaCodecUtil.getCodecProfileAndLevel(newFormat); + if (oldCodecProfileLevel != null && newCodecProfileLevel != null) { + int oldProfile = oldCodecProfileLevel.first; + int newProfile = newCodecProfileLevel.first; + if (oldProfile == CodecProfileLevel.AACObjectXHE + && newProfile == CodecProfileLevel.AACObjectXHE) { + return true; + } + } } - int oldProfile = oldCodecProfileLevel.first; - int newProfile = newCodecProfileLevel.first; - return oldProfile == CodecProfileLevel.AACObjectXHE - && newProfile == CodecProfileLevel.AACObjectXHE; + + return false; } }