1*15dc779aSAndroid Build Coastguard Worker# Introduction to libxaac 2*15dc779aSAndroid Build Coastguard Worker 3*15dc779aSAndroid Build Coastguard WorkerExtended HE-AAC, the latest innovation member of the MPEG AAC codec family, is ideally suited for adaptive bit rate streaming and digital radio applications. Extended HE-AAC bridges the gap between speech and audio coding and ensures consistent high-quality audio for all signal types, including speech, music, and mixed material. It is the required audio codec for DRM (Digital Radio Mondiale). When it comes to coding, the codec is incredibly effective, generating high-quality audio for music and speech at bitrates as low as 6 kbit/s for mono and 12 kbit/s for stereo services. By switching to extremely low bitrate streams, Extended HE-AAC streaming apps and streaming radio players can provide uninterrupted playback even during very congested network conditions. 4*15dc779aSAndroid Build Coastguard Worker 5*15dc779aSAndroid Build Coastguard WorkerAs the Extended High Efficiency AAC Profile is a logical evolution of the MPEG Audio's popular AAC Family profiles, the codec supports AAC-LC, HE-AACv1 (AAC+) and HE-AACv2 (eAAC+) audio object type encoding. The bitrate that was saved with AAC family tools can be used to enhance video quality. Extended HE-AAC is a well-liked option for a number of applications since it is a strong and effective audio codec that provides high-quality audio at low bitrates. 6*15dc779aSAndroid Build Coastguard Worker 7*15dc779aSAndroid Build Coastguard Worker 8*15dc779aSAndroid Build Coastguard Worker 9*15dc779aSAndroid Build Coastguard WorkerOne of the key features of libxaac (refer to above image) is that it has support for AAC-LD (Low Delay), AAC-ELD (Enhanced Low Delay), and AAC-ELDv2 (Enhanced Low Delay version 2) modes. AAC-LD mode provides low latency encoding, making it suitable for applications such as interactive communication and live audio streaming. It helps to reduce the delay in the encoding process to improve the real-time performance of the system. AAC-ELD mode improves the low-delay performance of HE-AAC by reducing the coding delay while maintaining high audio quality. It was observed that minimum delay it can achieve is 15ms. In order to achieve low delay coding scheme and low bitrate, it uses the Low Delay SBR tool. AAC-ELDv2 is the most advanced version of AAC-based low delay coding. It provides an enhanced version of AAC-ELD, which provides even lower coding delay and higher audio quality. 10*15dc779aSAndroid Build Coastguard Worker 11*15dc779aSAndroid Build Coastguard WorkerMPEG-D USAC, also known as Unified Speech and Audio Coding, is designed to provide high-quality audio coding at low bit rates. MPEG-D USAC combines advanced audio coding techniques with state-of-the-art speech coding algorithms to achieve significant compression gains while maintaining perceptual audio quality. The standard supports a wide range of audio content, including music, speech, and mixed audio, making it versatile for different use cases. With its ability to deliver high-fidelity audio at reduced bit rates, MPEG-D USAC plays a crucial role in optimizing bandwidth usage and enhancing the user experience in the digital audio domain. 12*15dc779aSAndroid Build Coastguard Worker 13*15dc779aSAndroid Build Coastguard WorkerOverall, libxaac, with support for AAC-LD, AAC-ELD, and AAC-ELDv2 modes, is a versatile audio coding technology that can be used for a wide range of applications, such as broadcasting, streaming, and teleconferencing which requires high-quality audio compression with minimal delay. 14*15dc779aSAndroid Build Coastguard Worker 15*15dc779aSAndroid Build Coastguard WorkerAlso, the libxaac supports MPEG-D DRC (Dynamic Range Control) for the Extended HE-AAC profile in both encoder and decoder. MPEG-D DRC offers a bitrate efficient representation of dynamically compressed versions of an audio signal. This is achieved by adding a low-bitrate DRC metadata stream to the audio signal. DRC includes dedicated sections for metadata-based loudness leveling, clipping prevention, ducking, and for generating a fade-in and fade-out to supplement the main dynamic range compression functionality. The DRC effects available at the DRC decoder are generated at the DRC encoder side. At the DRC decoder side, the audio signal may be played back without applying DRC, or an appropriate DRC effect is selected and applied based on the given playback scenario. It offers flexible solutions to efficiently support the widespread demand for technologies such as loudness normalization and dynamic range compression for various playback scenarios. 16*15dc779aSAndroid Build Coastguard Worker 17*15dc779aSAndroid Build Coastguard Worker#### Note 18*15dc779aSAndroid Build Coastguard Worker* The operating points for MPEG-D USAC (along with MPEG-D DRC) in libxaac encoder is currently restricted to 64 kbps and 96 kbps. It is recommended to use the encoder at these operating points only. The support shall be extended to other operating points soon. 19*15dc779aSAndroid Build Coastguard Worker* Further Quality enhancements for AAC-ELD and AAC-ELDv2 modes may be pushed as quality assessment is in progress. 20*15dc779aSAndroid Build Coastguard Worker 21*15dc779aSAndroid Build Coastguard Worker# Building the libxaac decoder and encoder 22*15dc779aSAndroid Build Coastguard Worker 23*15dc779aSAndroid Build Coastguard Worker## Building for AOSP 24*15dc779aSAndroid Build Coastguard Worker* Makefile for building the libxaac decoder and encoder library is provided in root(`libxaac/`) folder. 25*15dc779aSAndroid Build Coastguard Worker* Makefile for building the libxaac decoder and encoder testbench is provided in `test` folder. 26*15dc779aSAndroid Build Coastguard Worker* Build the library followed by the application using the below commands: 27*15dc779aSAndroid Build Coastguard WorkerGo to root directory 28*15dc779aSAndroid Build Coastguard Worker``` 29*15dc779aSAndroid Build Coastguard Worker$ mm 30*15dc779aSAndroid Build Coastguard Worker``` 31*15dc779aSAndroid Build Coastguard Worker 32*15dc779aSAndroid Build Coastguard Worker## Using CMake 33*15dc779aSAndroid Build Coastguard WorkerUsers can also use cmake to build for `x86`, `x86_64`, `armv7`, `armv8` and Windows (MSVS project) platforms. 34*15dc779aSAndroid Build Coastguard Worker 35*15dc779aSAndroid Build Coastguard Worker### Creating MSVS project files 36*15dc779aSAndroid Build Coastguard WorkerTo create MSVS project files for the libxaac decoder and encoder from cmake, run the following commands: 37*15dc779aSAndroid Build Coastguard Worker``` 38*15dc779aSAndroid Build Coastguard WorkerGo to the root directory(libxaac/). 39*15dc779aSAndroid Build Coastguard WorkerCreate a new folder in the project root directory and move to the newly created folder. 40*15dc779aSAndroid Build Coastguard Worker 41*15dc779aSAndroid Build Coastguard Worker$ cd <path to libxaac> 42*15dc779aSAndroid Build Coastguard Worker$ mkdir bin 43*15dc779aSAndroid Build Coastguard Worker$ cd bin 44*15dc779aSAndroid Build Coastguard Worker$ cmake -G "Visual Studio 15 2017" .. 45*15dc779aSAndroid Build Coastguard Worker``` 46*15dc779aSAndroid Build Coastguard Worker 47*15dc779aSAndroid Build Coastguard WorkerAbove command will create Win32 version of MSVS workspace 48*15dc779aSAndroid Build Coastguard WorkerTo create MSVS project files for Win64 version from cmake, run the following commands: 49*15dc779aSAndroid Build Coastguard Worker``` 50*15dc779aSAndroid Build Coastguard Worker$ mkdir cmake_build 51*15dc779aSAndroid Build Coastguard Worker$ cd cmake_build 52*15dc779aSAndroid Build Coastguard Worker$ cmake -G "Visual Studio 15 2017 Win64" .. 53*15dc779aSAndroid Build Coastguard Worker``` 54*15dc779aSAndroid Build Coastguard WorkerThe above command creates MSVS 2017 project files. If the version is different, modify the generator name accordingly. 55*15dc779aSAndroid Build Coastguard Worker 56*15dc779aSAndroid Build Coastguard Worker### Building for native platforms 57*15dc779aSAndroid Build Coastguard WorkerRun the following commands to build the libxaac decoder and encoder for native platform: 58*15dc779aSAndroid Build Coastguard Worker``` 59*15dc779aSAndroid Build Coastguard WorkerGo to the root directory(libxaac/). 60*15dc779aSAndroid Build Coastguard WorkerCreate a new folder in the project root directory and move to the newly created folder. 61*15dc779aSAndroid Build Coastguard Worker 62*15dc779aSAndroid Build Coastguard Worker$ cd <path to libxaac> 63*15dc779aSAndroid Build Coastguard Worker$ mkdir bin 64*15dc779aSAndroid Build Coastguard Worker$ cd bin 65*15dc779aSAndroid Build Coastguard Worker$ cmake .. 66*15dc779aSAndroid Build Coastguard Worker$ make 67*15dc779aSAndroid Build Coastguard Worker``` 68*15dc779aSAndroid Build Coastguard Worker 69*15dc779aSAndroid Build Coastguard Worker### Cross-compiler based builds 70*15dc779aSAndroid Build Coastguard WorkerEnsure to edit the file cmake/toolchains/*_toolchain.cmake to set proper paths in host for corresponding platforms. 71*15dc779aSAndroid Build Coastguard Worker 72*15dc779aSAndroid Build Coastguard Worker### Building for x86_32 on a x86_64 Linux machine 73*15dc779aSAndroid Build Coastguard Worker``` 74*15dc779aSAndroid Build Coastguard Worker$ cd <path to libxaac> 75*15dc779aSAndroid Build Coastguard Worker$ mkdir build 76*15dc779aSAndroid Build Coastguard Worker$ cd build 77*15dc779aSAndroid Build Coastguard Worker$ cmake .. -DCMAKE_TOOLCHAIN_FILE=../cmake/toolchains/x86_toolchain.cmake 78*15dc779aSAndroid Build Coastguard Worker$ make 79*15dc779aSAndroid Build Coastguard Worker``` 80*15dc779aSAndroid Build Coastguard Worker 81*15dc779aSAndroid Build Coastguard Worker### Building for aarch32/aarch64 82*15dc779aSAndroid Build Coastguard WorkerUpdate 'CMAKE_C_COMPILER', 'CMAKE_CXX_COMPILER', 'CMAKE_C_COMPILER_AR', and 'CMAKE_CXX_COMPILER_AR' in CMAKE_TOOLCHAIN_FILE passed below 83*15dc779aSAndroid Build Coastguard Worker``` 84*15dc779aSAndroid Build Coastguard Worker$ cd <path to libxaac> 85*15dc779aSAndroid Build Coastguard Worker$ mkdir build 86*15dc779aSAndroid Build Coastguard Worker$ cd build 87*15dc779aSAndroid Build Coastguard Worker``` 88*15dc779aSAndroid Build Coastguard Worker 89*15dc779aSAndroid Build Coastguard Worker### For aarch64 90*15dc779aSAndroid Build Coastguard Worker``` 91*15dc779aSAndroid Build Coastguard Worker$ cmake .. -DCMAKE_TOOLCHAIN_FILE=../cmake/toolchains/aarch64_toolchain.cmake 92*15dc779aSAndroid Build Coastguard Worker$ make 93*15dc779aSAndroid Build Coastguard Worker``` 94*15dc779aSAndroid Build Coastguard Worker 95*15dc779aSAndroid Build Coastguard Worker### For aarch32 96*15dc779aSAndroid Build Coastguard Worker``` 97*15dc779aSAndroid Build Coastguard Worker$ cmake .. -DCMAKE_TOOLCHAIN_FILE=../cmake/toolchains/aarch32_toolchain.cmake 98*15dc779aSAndroid Build Coastguard Worker$ make 99*15dc779aSAndroid Build Coastguard Worker``` 100*15dc779aSAndroid Build Coastguard Worker 101*15dc779aSAndroid Build Coastguard Worker### For API and testbench usage of decoder, please refer [`README_dec.md`](README_dec.md) 102*15dc779aSAndroid Build Coastguard Worker### For API and testbench usage of encoder, please refer [`README_enc.md`](README_enc.md) 103