Decode an AMR file using OpenSL

256 views
Skip to first unread message

ronimusic

unread,
Feb 26, 2014, 7:57:58 AM2/26/14
to andro...@googlegroups.com
Is it possible to use OpenSLES to decode an AMR file into PCM samples?
I have a OpenSL playback engine that works fine and also various decoders for mp3 etc.

My need is to decode AMR files in real time to feed my playback engine, I can't simply playback the files
since I need the raw PCM samples for further processing before sending them to my playback engine.

All examples I’ve found creates a complete simple buffer player for playing audio files, my need is simply to decode a file 
or portions of it and to be able to seek to a desired position.

I have one example named “slesTestDecodeAAC” written by someone at Google that decodes a raw AAC ADTS file but there must be a simpler way?
This example requires knowledge about the internal AAC file format. 
And converting the example to support AMR files would require the same knowledge about AMR files.

Any hints appreciated.

Thanks,
Rolf Nilsson

Glenn Kasten

unread,
Feb 27, 2014, 11:43:25 AM2/27/14
to andro...@googlegroups.com
These days, for API 16 and above I recommend MediaCodec instead:

ronimusic

unread,
Mar 6, 2014, 8:36:06 AM3/6/14
to andro...@googlegroups.com

Thanks for the info about the Java MediaCodec.

I don't want to use Java for decoding but I managed to get the OpenSL decoder to work.
However AMR/3GP files are not supported, 3GP files with AAC audio works but not AMR.

This page
states "The table below describes the media format support built into the Android platform"
and the table includes the AMR decoder.
I've tested with four Android devices but no luck. It seems AMR isn't supported 
but a confirmation or an explanation from someone with better knowledge would be great.

I also found out what seems to be a bug?

I build my JNI stuff both for arm and Intel, when decoding mono mp3 files on the 
Intel platform (Samsung Galaxy 3 10.1), the files play back at half speed and an 
octave down, seems as the decoder return a duplicate of every sample (I didn't 
check that but that's what it sound like). This device uses Android 4.2.2 so 
first I thought that might be the cause? Stereo mp3 files work fine as does other formats, both mono and stereo files.

I then tested with three arm devices: Amazon Kindle - Android 4.0.x, Google 
Nexus 4 and 10 both running Android 4.4.2. Works perfect. So this seems to be an 
Intel issue. I don't know where to report bugs so this is the report.
Reply all
Reply to author
Forward
0 new messages