From fd1fb96aa0bcee1cdb3e335492406093fc155b0b Mon Sep 17 00:00:00 2001 From: christosts Date: Tue, 14 Jun 2022 16:45:16 +0000 Subject: [PATCH] Spatializer: Assume linear channel count for E-AC3 JOC streams #minor-release PiperOrigin-RevId: 454884692 (cherry picked from commit 6dc4b39cb7165577bfa862675c8111c10df843e1) --- .../exoplayer2/trackselection/DefaultTrackSelector.java | 9 ++++++++- 1 file changed, 8 insertions(+), 1 deletion(-) diff --git a/library/core/src/main/java/com/google/android/exoplayer2/trackselection/DefaultTrackSelector.java b/library/core/src/main/java/com/google/android/exoplayer2/trackselection/DefaultTrackSelector.java index 92fb7544af..b4e78584dc 100644 --- a/library/core/src/main/java/com/google/android/exoplayer2/trackselection/DefaultTrackSelector.java +++ b/library/core/src/main/java/com/google/android/exoplayer2/trackselection/DefaultTrackSelector.java @@ -3678,10 +3678,17 @@ public class DefaultTrackSelector extends MappingTrackSelector { } public boolean canBeSpatialized(AudioAttributes audioAttributes, Format format) { + // For E-AC3 JOC, the format is object based. When the channel count is 16, this maps to 12 + // linear channels and the rest are used for objects. See + // https://github.com/google/ExoPlayer/pull/10322#discussion_r895265881 + int linearChannelCount = + MimeTypes.AUDIO_E_AC3_JOC.equals(format.sampleMimeType) && format.channelCount == 16 + ? 12 + : format.channelCount; AudioFormat.Builder builder = new AudioFormat.Builder() .setEncoding(AudioFormat.ENCODING_PCM_16BIT) - .setChannelMask(Util.getAudioTrackChannelConfig(format.channelCount)); + .setChannelMask(Util.getAudioTrackChannelConfig(linearChannelCount)); if (format.sampleRate != Format.NO_VALUE) { builder.setSampleRate(format.sampleRate); }