Work around incorrect channel count for raw audio

The raw audio decoder's output audio format is stereo when the number of input
channels is (for example) 10 channels. Add a temporary workaround that uses the
input channel count for raw audio. This code should be removed in future when
we bypass the decoder entirely for raw audio.

Tested manually on a WAVE file with 18 audio channels.

PiperOrigin-RevId: 625307624
This commit is contained in:
andrewlewis 2024-04-16 06:19:08 -07:00 committed by Copybara-Service
parent ea48fe579e
commit 3be49a5841
2 changed files with 10 additions and 0 deletions

View File

@ -11,6 +11,8 @@
* Add `reset` to `BasePreloadManager` to release all the holding sources
while keep the preload manager instance.
* Transformer:
* Work around a decoder bug where the number of audio channels was capped
at stereo when handling PCM input.
* Track Selection:
* Extractors:
* Audio:

View File

@ -262,6 +262,14 @@ import org.checkerframework.checker.nullness.qual.RequiresNonNull;
if (decoderOutputFormat == null) {
return false;
}
// TODO: b/332708880 - The raw decoder caps number of audio channels to stereo. Remove this
// workaround and bypass MediaCodec for raw audio instead.
if (checkNotNull(inputFormat.sampleMimeType).equals(MimeTypes.AUDIO_RAW)) {
decoderOutputFormat =
decoderOutputFormat.buildUpon().setChannelCount(inputFormat.channelCount).build();
}
outputFormat = overrideOutputFormat(decoderOutputFormat);
} else {
// TODO(b/278259383): Move surface creation out of video sampleConsumer. Init decoder and