Skip to content

24 bit and 32 bit int MediaCodec and AudioTrack output #1931

New issue

Have a question about this project? # for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “#”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? # to your account

Open
nift4 opened this issue Nov 30, 2024 · 1 comment
Open

24 bit and 32 bit int MediaCodec and AudioTrack output #1931

nift4 opened this issue Nov 30, 2024 · 1 comment
Assignees

Comments

@nift4
Copy link

nift4 commented Nov 30, 2024

[REQUIRED] Use case description

Some manufacturers utilize 24 bit and 32 bit int output support in their flagship device's hardware. Utilizing this hardware mode in MediaCodec and AudioTrack would avoid wasting memory and CPU time in converting to 32bit float values and would also avoid quality loss of converting to 16bit int.
Additionally, considering #415, this is required to output bit perfect audio if files are in 24 bit int or 32 bit int format.

Proposed solution

In google/ExoPlayer#6749, 32 bit float output support was added to ExoPlayer. Similar to that issue, 24 bit and 32 bit int support would solve this issue.

Alternatives considered

Keep converting to 32 bit float or 16 bit int, wasting battery and not fully utilizing user's hardware.

@tonihei
Copy link
Collaborator

tonihei commented Jan 7, 2025

Thanks for the request! This work is already planned as a prerequisite for #415. I can leave the issue open separately, as they are slightly different requests.

nift4 added a commit to nift4/media that referenced this issue Mar 9, 2025
...and remove hard requirement for 16-bit PCM support in the audio
sink even if that's not needed to playback.

If the audio file is using 24-bit or 32-bit (int) PCM,
MediaCodecAudioRenderer tries to output float, and if that is not
supported, falls back to 16-bit PCM. This commit changes this
behavior to first trying the media file format, then any close
high-resolution audio formats (such as float) and then fall back
to 16-bit PCM. The behaviour with DefaultAudioSink does not change,
but if an audio sink supports any more optimal formats, they will
now be used with MediaCodecAudioRenderer.

Issue: androidx#1931
nift4 added a commit to nift4/media that referenced this issue Mar 23, 2025
This allows future extensions such as direct 24 bit / 32 bit (int)
playback in DefaultAudioSink, and is a step towards Issue: androidx#1931

Run audio processors possibly discarding data first to avoid wasting
CPU on data that'll be discarded anyway.
nift4 added a commit to nift4/media that referenced this issue Mar 23, 2025
This allows future extensions such as direct 24 bit / 32 bit (int)
playback in DefaultAudioSink, and is a step towards Issue: androidx#1931

Run audio processors possibly discarding data first to avoid wasting
CPU on data that'll be discarded anyway.
# for free to join this conversation on GitHub. Already have an account? # to comment
Projects
None yet
Development

No branches or pull requests

2 participants