[Working record] Android opensl Es:references & AAC Related

Source: Internet
Author: User

AAC V.s. MP3

Http://en.wikipedia.org/wiki/Advanced_Audio_Coding#AAC.27s_improvements_over_MP3

AAC Patent Lisense FAQ:

Http://www.vialicensing.com/licensing/aac-faq.aspx

Need a license but usually no fees, exept that's when end user products is (/contain?) encoders/decoders.

Overview:

$ (ndk_root)/docs/opensles/index.html

Decode Audio to PCM

Note:this feature is available at API level and higher.

A standard audio Player plays a audio device, and the data sink are specified as an output mix. However, as an Android extension, an audio player instead acts as a decoder if the data source was specified as a URI or an Droid file descriptor Data Locator with MIME data format, and the data sink is a Android simple buffer queue Data locator With PCM data format.

This feature was primarily intended for games to pre-load their audio assets when changing to a new game level, similar to android.media.SoundPool.

The application should initially enqueue a set of empty buffers to the Android simple buffer queue, which'll be filled W ITH PCM data. The Android simple buffer queue callback are invoked after all buffer is filled. The callback handler should process the PCM data, re-enqueue the now-empty buffer, and then return. The application is responsible for keeping track of decoded buffers; The callback parameter list does not include sufficient information to indicate which buffer is filled or which buffer to Enqueue Next.

The end of stream is determined implicitly by the data source. At the end of stream a SL_PLAYEVENT_HEADATEND event is delivered. The Android simple buffer queue callback'll no longer be called after all consumed data is decoded.

The sink ' s PCM data format typically matches that's the encoded data source with respect to sample rate, channel count, a nd bit depth. However, the platform implementation is permitted to decode to a different for sample rate, channel count, or bit depth. There is a provision to detect the actual PCM format; See section "Determining the format of decoded PCM data via metadata" below.

Decode to PCM supports pause and initial seek. Volume control, effects, looping, and playback rate is not supported.

Depending on the platform implementation, decoding could require resources that cannot being left idle. Therefore It is not recommended to starve the decoder by failing to provide a sufficient number of empty PCM buffers, e.g. By returning from the Android simple buffer queue callback without enqueueing another empty buffer. The result of decoder starvation is unspecified; The implementation choose to either drop the decoded PCM data, pause the decoding process, or in severe cases terminat E The decoder.

API docs:

$ (ndk_root)/docs/opensles/opensl_es_specification_1.0.1.pdf

Samples:

$ (ndk_root)/samples/nativeaudio

ADTS Header (Http://wiki.multimedia.cx/index.php?title=ADTS) :

Letter
Length (BITS) Description
A 12 Syncword 0xFFF, all bits must is 1
B 1 MPEG version:0 for MPEG-4, 1 for MPEG-2
C 2 Layer:always 0
D 1 Protection absent, Warning, set to 1 if there are no CRC and 0 if there is CRC
E 2 Profile, the MPEG-4 Audio Object Type minus 1
F 4 MPEG-4 sampling Frequency Index (Forbidden)
G 1 Private stream, set to 0 when encoding, ignore when decoding
H 3 MPEG-4 channel configuration (in the case of 0, the channel configuration was sent via an inband PCE)
I 1 Originality, set to 0 while encoding, ignore when decoding
J 1 Home, set to 0 when encoding, ignore when decoding
K 1 Copyrighted stream, set to 0 when encoding, ignore when decoding
L 1 Copyright start, set to 0 when encoding, ignore when decoding
M 13 Frame length, this value must include 7 or 9 bytes of header Length:framelength = (Protectionabsent = = 1? 7:9) + Size ( Aacframe)
O 11 Buffer fullness
P 2 Number of AAC frames (RDBS) in ADTS frame minus 1, for maximum compatibility always use 1 AAC frame per ADTS fram E
Q 16 CRC if protection absent is 0

AAC decoding test sample (decoding only):

Https://android.googlesource.com/platform/frameworks/wilhelm/+/master/tests/examples/slesTestDecodeAac.cpp

AAC encoding (offline):

Https://trac.ffmpeg.org/wiki/Encode/AAC

AAC profile suitable for streaming:

HE-AACV1 (aac+)/He-aacv2 (enhanced-aac+)

Http://en.wikipedia.org/wiki/High_Efficiency_Advanced_Audio_Coding

Related Article

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.