Commit e16ab27b by olly Committed by Oliver Woodman

No-op refactor of MediaCodecInfo.isSeamlessAdaptationSupported

PiperOrigin-RevId: 339084261
parent 50566fb8
...@@ -327,34 +327,42 @@ public final class MediaCodecInfo { ...@@ -327,34 +327,42 @@ public final class MediaCodecInfo {
*/ */
public boolean isSeamlessAdaptationSupported( public boolean isSeamlessAdaptationSupported(
Format oldFormat, Format newFormat, boolean isNewFormatComplete) { Format oldFormat, Format newFormat, boolean isNewFormatComplete) {
if (!Util.areEqual(oldFormat.sampleMimeType, newFormat.sampleMimeType)) {
return false;
}
if (isVideo) { if (isVideo) {
return Assertions.checkNotNull(oldFormat.sampleMimeType).equals(newFormat.sampleMimeType) return oldFormat.rotationDegrees == newFormat.rotationDegrees
&& oldFormat.rotationDegrees == newFormat.rotationDegrees
&& (adaptive && (adaptive
|| (oldFormat.width == newFormat.width && oldFormat.height == newFormat.height)) || (oldFormat.width == newFormat.width && oldFormat.height == newFormat.height))
&& ((!isNewFormatComplete && newFormat.colorInfo == null) && ((!isNewFormatComplete && newFormat.colorInfo == null)
|| Util.areEqual(oldFormat.colorInfo, newFormat.colorInfo)); || Util.areEqual(oldFormat.colorInfo, newFormat.colorInfo));
} else { } else {
if (!MimeTypes.AUDIO_AAC.equals(mimeType) if (oldFormat.channelCount != newFormat.channelCount
|| !Assertions.checkNotNull(oldFormat.sampleMimeType).equals(newFormat.sampleMimeType)
|| oldFormat.channelCount != newFormat.channelCount
|| oldFormat.sampleRate != newFormat.sampleRate) { || oldFormat.sampleRate != newFormat.sampleRate) {
return false; return false;
} }
// Check the codec profile levels support adaptation.
@Nullable // Check whether we're adapting between two xHE-AAC formats, for which adaptation is possible
Pair<Integer, Integer> oldCodecProfileLevel = // without reconfiguration.
MediaCodecUtil.getCodecProfileAndLevel(oldFormat); if (MimeTypes.AUDIO_AAC.equals(mimeType)) {
@Nullable @Nullable
Pair<Integer, Integer> newCodecProfileLevel = Pair<Integer, Integer> oldCodecProfileLevel =
MediaCodecUtil.getCodecProfileAndLevel(newFormat); MediaCodecUtil.getCodecProfileAndLevel(oldFormat);
if (oldCodecProfileLevel == null || newCodecProfileLevel == null) { @Nullable
return false; Pair<Integer, Integer> 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 false;
return oldProfile == CodecProfileLevel.AACObjectXHE
&& newProfile == CodecProfileLevel.AACObjectXHE;
} }
} }
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or sign in to comment