Skip to content
Original file line number Diff line number Diff line change
Expand Up @@ -2249,6 +2249,22 @@ public static int getAudioTrackChannelConfig(int channelCount) {
}
case 12:
return AudioFormat.CHANNEL_OUT_7POINT1POINT4;
case 24:
return Util.SDK_INT >= 32
? AudioFormat.CHANNEL_OUT_7POINT1POINT4 |
AudioFormat.CHANNEL_OUT_FRONT_LEFT_OF_CENTER |
AudioFormat.CHANNEL_OUT_FRONT_RIGHT_OF_CENTER |
AudioFormat.CHANNEL_OUT_BACK_CENTER |
AudioFormat.CHANNEL_OUT_TOP_CENTER |
AudioFormat.CHANNEL_OUT_TOP_FRONT_CENTER |
AudioFormat.CHANNEL_OUT_TOP_BACK_CENTER |
AudioFormat.CHANNEL_OUT_TOP_SIDE_LEFT |
AudioFormat.CHANNEL_OUT_TOP_SIDE_RIGHT |
AudioFormat.CHANNEL_OUT_BOTTOM_FRONT_LEFT |
AudioFormat.CHANNEL_OUT_BOTTOM_FRONT_RIGHT |
AudioFormat.CHANNEL_OUT_BOTTOM_FRONT_CENTER |
AudioFormat.CHANNEL_OUT_LOW_FREQUENCY_2
: AudioFormat.CHANNEL_INVALID;
default:
return AudioFormat.CHANNEL_INVALID;
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -4181,13 +4181,22 @@ public boolean isEnabled() {
}

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;
int linearChannelCount;
if (MimeTypes.AUDIO_E_AC3_JOC.equals(format.sampleMimeType)) {
// 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
linearChannelCount = format.channelCount == 16 ? 12 : format.channelCount;
} else if (MimeTypes.AUDIO_AC4.equals(format.sampleMimeType)) {
// For AC-4 level 3 or level 4, the format may be object based. When the channel count is
// 18 (level 3 17.1 OBI) or 21 (level 4 20.1 OBI), it is mapped to 24 linear channels
// (There are some channels used for metadata transfer).
linearChannelCount = (format.channelCount == 18 || format.channelCount == 21)
? 24
: format.channelCount;
} else {
linearChannelCount = format.channelCount;
}
int channelConfig = Util.getAudioTrackChannelConfig(linearChannelCount);
if (channelConfig == AudioFormat.CHANNEL_INVALID) {
return false;
Expand Down
Loading