Skip to content

Commit 47f3aab

Browse files
copybara-githubicbaker
authored andcommitted
Merge pull request #1265 from DolbyLaboratories:dlb/ac4-level4/dev_new2
PiperOrigin-RevId: 696157037 (cherry picked from commit 74611bb)
1 parent 57d0721 commit 47f3aab

16 files changed

+1393
-11
lines changed

RELEASENOTES.md

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,9 @@
22

33
### Unreleased changes
44

5+
* Extractors:
6+
* Add AC-4 Level-4 ISO base media file format support
7+
([#1265](https://github.com/androidx/media/pull/1265)).
58
* Text:
69
* Fix garbled CEA-608 subtitles in content with more than one SEI message
710
per sample.

libraries/common/src/main/java/androidx/media3/common/util/Util.java

Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2250,6 +2250,24 @@ public static int getAudioTrackChannelConfig(int channelCount) {
22502250
}
22512251
case 12:
22522252
return AudioFormat.CHANNEL_OUT_7POINT1POINT4;
2253+
case 24:
2254+
if (Util.SDK_INT >= 32) {
2255+
return AudioFormat.CHANNEL_OUT_7POINT1POINT4
2256+
| AudioFormat.CHANNEL_OUT_FRONT_LEFT_OF_CENTER
2257+
| AudioFormat.CHANNEL_OUT_FRONT_RIGHT_OF_CENTER
2258+
| AudioFormat.CHANNEL_OUT_BACK_CENTER
2259+
| AudioFormat.CHANNEL_OUT_TOP_CENTER
2260+
| AudioFormat.CHANNEL_OUT_TOP_FRONT_CENTER
2261+
| AudioFormat.CHANNEL_OUT_TOP_BACK_CENTER
2262+
| AudioFormat.CHANNEL_OUT_TOP_SIDE_LEFT
2263+
| AudioFormat.CHANNEL_OUT_TOP_SIDE_RIGHT
2264+
| AudioFormat.CHANNEL_OUT_BOTTOM_FRONT_LEFT
2265+
| AudioFormat.CHANNEL_OUT_BOTTOM_FRONT_RIGHT
2266+
| AudioFormat.CHANNEL_OUT_BOTTOM_FRONT_CENTER
2267+
| AudioFormat.CHANNEL_OUT_LOW_FREQUENCY_2;
2268+
} else {
2269+
return AudioFormat.CHANNEL_INVALID;
2270+
}
22532271
default:
22542272
return AudioFormat.CHANNEL_INVALID;
22552273
}

libraries/exoplayer/src/main/java/androidx/media3/exoplayer/trackselection/DefaultTrackSelector.java

Lines changed: 10 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -4224,18 +4224,22 @@ public boolean isEnabled() {
42244224

42254225
public boolean canBeSpatialized(AudioAttributes audioAttributes, Format format) {
42264226
int linearChannelCount;
4227-
if (Objects.equals(format.sampleMimeType, MimeTypes.AUDIO_E_AC3_JOC)
4228-
&& format.channelCount == 16) {
4227+
if (Objects.equals(format.sampleMimeType, MimeTypes.AUDIO_E_AC3_JOC)) {
42294228
// For E-AC3 JOC, the format is object based. When the channel count is 16, this maps to 12
42304229
// linear channels and the rest are used for objects. See
42314230
// https://github.com/google/ExoPlayer/pull/10322#discussion_r895265881
4232-
linearChannelCount = 12;
4233-
} else if (Objects.equals(format.sampleMimeType, MimeTypes.AUDIO_IAMF)
4234-
&& format.channelCount == Format.NO_VALUE) {
4231+
linearChannelCount = format.channelCount == 16 ? 12 : format.channelCount;
4232+
} else if (Objects.equals(format.sampleMimeType, MimeTypes.AUDIO_IAMF)) {
42354233
// IAMF with no channel count specified, assume 5.1 channels. This depends on
42364234
// IamfDecoder.SPATIALIZED_OUTPUT_LAYOUT being set to AudioFormat.CHANNEL_OUT_5POINT1. Any
42374235
// changes to that constant will require updates to this logic.
4238-
linearChannelCount = 6;
4236+
linearChannelCount = format.channelCount == Format.NO_VALUE ? 6 : format.channelCount;
4237+
} else if (Objects.equals(format.sampleMimeType, MimeTypes.AUDIO_AC4)) {
4238+
// For AC-4 level 3 or level 4, the format may be object based. When the channel count is
4239+
// 18 (level 3 17.1 OBI) or 21 (level 4 20.1 OBI), it is mapped to 24 linear channels (some
4240+
// channels are used for metadata transfer).
4241+
linearChannelCount =
4242+
(format.channelCount == 18 || format.channelCount == 21) ? 24 : format.channelCount;
42394243
} else {
42404244
linearChannelCount = format.channelCount;
42414245
}

0 commit comments

Comments
 (0)