Bug: 111264136

Clone this repo:
  1. 107cb12 Update to v0.1.4 from upstream project am: 2ae5f6ff8a by Harish Mahendrakar · 9 weeks ago main-16k-with-phones master
  2. 2ae5f6f Update to v0.1.4 from upstream project by Harish Mahendrakar · 9 weeks ago
  3. 6180367 Update to v0.1.2 from upstream project am: 06b7d72a41 am: c13fd2dbf2 am: 8e00512043 am: 92ad84ae51 by Harish Mahendrakar · 6 months ago
  4. 92ad84a Update to v0.1.2 from upstream project am: 06b7d72a41 am: c13fd2dbf2 am: 8e00512043 by Harish Mahendrakar · 6 months ago
  5. 8e00512 Update to v0.1.2 from upstream project am: 06b7d72a41 am: c13fd2dbf2 by Harish Mahendrakar · 6 months ago

Introduction of the Ex-HEAAC Decoder

Ex-HEAAC (Extended HE AAC), the latest upgrade to the MPEG AAC codec family, is the audio codec of choice for digital radio and low bit rate streaming applications. Selected as the mandatory audio codec for DRM (Digital Radio Mondiale), Ex-HEAAC bridges the gap between speech and audio coding, and provides consistent high quality audio for all signal types, such as speech, music or mixed content.

Another important feature is the codec’s coding efficiency. The audio codec produces excellent sound for both music and speech, delivering high quality performance at bit rates starting as low as 6 kbit/s for mono and 12 kbit/s for stereo services. Thus Ex-HEAAC streaming apps and streaming radio players may switch to very low bit rate streams and offer a continuous playback even while the network is congested. Once more bandwidth becomes available on the network again, the Ex-HEAAC client can request a higher bitrate version and seamless switch over the full range of bitrates. Audio bitrate that’s being saved due to the improved coding efficiency can be used to improve video quality. Ex-HEAAC supports AAC and HEAAC v2 as well.

AAC is a popular audio coding technique recommended by MPEG committee. The codec handles audio signals sampled in the range of 8 kHz to 96 kHz. It operates on a frame of 1024 samples. The bit-rates supported are in the range of 8 kbps to 576 kbps per channel.

SBR and PS are the tools used in combination with the AAC general audio codec resulting in HEAAC v2 (also known as Enhanced AAC Plus). It provides significant increase in coding gain. In SBR, the high-band, i.e. the high frequency part of the spectrum is replicated using the low-band. In PS, channel redundancy is exploited and parameters are extracted from a down-mixed channel.The bit-rate is by far below the bit-rate required when using conventional AAC coding. This translates into better quality at lower bit-rates.

Introduction to Ex-HEAAC Decoder APIs

Files to be included are

Decoder APIs

A single API is used to get and set configurations and execute the decode thread, based on command index passed.

  • ia_xheaacd_dec_api
API CommandAPI Sub CommandDescription
IA_API_CMD_GET_LIB_ID_STRINGSIA_CMD_TYPE_LIB_NAMEGets the decoder library name
IA_API_CMD_GET_LIB_ID_STRINGSIA_CMD_TYPE_LIB_VERSIONGets the decoder version
IA_API_CMD_GET_API_SIZE0Gets the memory requirements size of the API
IA_API_CMD_INITIA_CMD_TYPE_INIT_API_PRE_CONFIG_PARAMSSets the configuration parameters of the Ex-HEAAC v2 Decoder to default values
IA_API_CMD_INITIA_CMD_TYPE_INIT_API_POST_CONFIG_PARAMSSets the attributes(size, priority, alignment) of all memory types required by the application onto the memory structure
IA_API_CMD_SET_CONFIG_PARAMIA_ENHAACPLUS_DEC_CONFIG_PARAM_SAMP_FREQSets the core AAC sampling frequency for RAW header decoding
IA_API_CMD_SET_CONFIG_PARAMIA_ENHAACPLUS_DEC_CONFIG_PCM_WDSZSets the bit width of the output pcm samples.The value has to be 16
IA_API_CMD_SET_CONFIG_PARAMIA_ENHAACPLUS_DEC_CONFIG_PARAM_DOWNMIXSets the parameter whether the output needs to be down-mix to mono(1) or not(0)
IA_API_CMD_SET_CONFIG_PARAMIA_ENHAACPLUS_DEC_CONFIG_PARAM_TOSTEREOSets the flag to disable interleave mono to stereo
IA_API_CMD_SET_CONFIG_PARAMIA_ENHAACPLUS_DEC_CONFIG_PARAM_DSAMPLESets the parameter whether the output needs to be downsampled(1) or not(0).This is valid only for Ex-HEAAC v2 build
IA_API_CMD_SET_CONFIG_PARAMIA_ENHAACPLUS_DEC_CONFIG_FRAMEOKSets the flag to 0 or 1 to indicate whether the current frame is valid(1) or not(0)
IA_API_CMD_SET_CONFIG_PARAMIA_ENHAACPLUS_DEC_CONFIG_ISMP4Sets the flag to 0 or 1 to indicate whether given test vector is an mp4 file or not
IA_API_CMD_SET_CONFIG_PARAMIA_ENHAACPLUS_DEC_CONFIG_PARAM_DISABLE_SYNCSets the flag of ADTS syncing or not ADTS syncing as 0 or 1
IA_API_CMD_SET_CONFIG_PARAMIA_ENHAACPLUS_DEC_CONFIG_PARAM_AUTO_SBR_UPSAMPLESets the parameter auto SBR upsample to 0 or 1.Used in case of stream changing from SBR present to SBR not present.This is valid only for Ex-HEAAC v2 build
IA_API_CMD_SET_CONFIG_PARAMIA_ENHAACPLUS_DEC_CONFIG_PARAM_MAX_CHANNELSets the maximum number of channels present.Its maximum value is 2 for stereo library and 8 for multichannel library
IA_API_CMD_SET_CONFIG_PARAMIA_ENHAACPLUS_DEC_CONFIG_PARAM_COUP_CHANNELSets the number of coupling channels to be used for coupling.It can take values from 0 to 16.This command is supported only if the library has multichannel support
IA_API_CMD_SET_CONFIG_PARAMIA_ENHAACPLUS_DEC_CONFIG_PARAM_DOWNMIX_STEREOSets the flag of downmixing n number of channels to stereo.Can be 0 or 1. This command is supported only if the library has multichannel support
IA_API_CMD_SET_CONFIG_PARAMIA_ENHAACPLUS_DEC_CONFIG_PARAM_ISLOASSets the flag indicating that the input file is a .loas file.Can be 0 or 1
IA_API_CMD_GET_N_MEMTABS0Gets the number of memory types
IA_API_CMD_GET_N_TABLES0Gets the number of tables
IA_API_CMD_GET_MEM_INFO_SIZE0Gets the size of the memory type being referred to by the index
IA_API_CMD_GET_MEM_INFO_ALIGNMENT0Gets the alignment information of the memory-type being referred to by the index
IA_API_CMD_GET_MEM_INFO_TYPE0Gets the type of memory being referred to by the index
IA_API_CMD_SET_MEM_PTR0Sets the pointer to the memory being referred to by the index to the input value
IA_API_CMD_GET_TABLE_INFO_SIZE0Gets the size of the memory type being referred to by the index
IA_API_CMD_GET_TABLE_INFO_ALIGNMENT0Gets the alignment information of the memory-type being referred to by the index
IA_API_CMD_GET_TABLE_PTR0Gets the address of the current location of the table
IA_API_CMD_SET_TABLE_PTR0Sets the relocated table address
IA_API_CMD_INPUT_OVER0Signals the end of bit-stream to the library
IA_API_CMD_SET_INPUT_BYTES0Sets the number of bytes available in the input buffer for initialization
IA_API_CMD_INITIA_CMD_TYPE_INIT_PROCESSSearch for the valid header, does header decode to get the parameters and initializes state and configuration structure
IA_API_CMD_INITIA_CMD_TYPE_INIT_DONE_QUERYChecks if the initialization process has completed
IA_API_CMD_GET_CURIDX_INPUT_BUF0Gets the number of input buffer bytes consumed by the last initialization
IA_API_CMD_GET_CONFIG_PARAMIA_ENHAACPLUS_DEC_CONFIG_PARAM_SAMP_FREQGets the sampling frequency
IA_API_CMD_GET_CONFIG_PARAMIA_ENHAACPLUS_DEC_CONFIG_PARAM_NUM_CHANNELSGets the output number of channels
IA_API_CMD_GET_CONFIG_PARAMIA_ENHAACPLUS_DEC_CONFIG_PARAM_PCM_WDSZGets the output PCM word size
IA_API_CMD_GET_CONFIG_PARAMIA_ENHAACPLUS_DEC_CONFIG_PARAM_CHANNEL_MODEGets the channel mode. (Mono or PS/Stereo/Dual-mono)
IA_API_CMD_GET_CONFIG_PARAMIA_ENHAACPLUS_DEC_CONFIG_PARAM_CHANNEL_MASKGets the channel mask
IA_API_CMD_GET_CONFIG_PARAMIA_ENHAACPLUS_DEC_CONFIG_PARAM_SBR_MODEGets the SBR mode (Present/ Not Present).This is valid only for Ex-HEAAC v2 build
IA_API_CMD_EXECUTEIA_CMD_TYPE_DO_EXECUTEExecutes the decode thread
IA_API_CMD_EXECUTEIA_CMD_TYPE_DONE_QUERYChecks if the end of decode has been reached
IA_API_CMD_GET_OUTPUT_BYTES0Gets the number of bytes output by the decoder in the last frame

Flowchart of calling sequence

API Flowchart

Building the Ex-HEAAC Decoder

Building for AOSP

  • Makefiles for building the Ex-HEAAC decoder library is provided in root(libxaac/) folder.
  • Makefiles for building the Ex-HEAAC decoder testbench is provided in test folder.
  • Build the library followed by the application using the below commands: Go to root directory
$ mm

Using CMake

Users can also use cmake to build for x86, x86_64, and Windows (MSVS project) platforms.

Building for native platforms

Run the following commands to build the Ex-HEAAC Decoder for native platform:

Go to the root directory(libxaac/) of the Ex-HEAAC Decoder.
Create a new folder in the project root directory and move to the newly created folder.

$ cd <path to libxaac>
$ mkdir bin
$ cd bin
$ cmake ..
$ cmake --build .

Creating MSVS project files

To create MSVS project files for the Ex-HEAAC decoder from cmake, run the following commands:

Go to the root directory(libxaac/) of the Ex-HEAAC Decoder.
Create a new folder in the project root directory and move to the newly created folder.

$ cd <path to libxaac>
$ mkdir bin
$ cd bin
$ cmake -G "Visual Studio 15 2017" ..

The above command creates MSVS 2017 project files. If the version is different, modify the generator name accordingly. The Ex-HEAAC decoder can be built using these project files.

Running the Ex-HEAAC Decoder

The Ex-HEAAC Decoder can be run by providing command-line parameters(CLI options) directly or by providing a parameter file as a command line argument.

Command line usage :

<exceutable> -ifile:<input_file> -imeta:<meta_data_file> -ofile:<out_file> [options]

[options] can be,
[-pcmsz:<pcmwordsize>]
[-dmix:<down_mix>]
[-tostereo:<interleave_to_stereo>]
[-dsample:<down_sample_sbr>]
[-fs:<RAW_sample_rate>]
[-nosync:<disable_sync>]
[-sbrup:<auto_sbr_upsample>]
[-maxchannel:<maximum_num_channels>]
[-mp4:<mp4_flag>]

where,
  <inputfile>        	 is the input AAC file name.
  <meta_data_file> 	 	 is a text file which contains metadata for USAC files with an MP4 container.
  <outputfile>       	 is the output file name.
  <pcmwordsize>      	 is the bits per sample info. Only 16 is valid
  <down_mix> 		 	 is to enable/disable always mono output. Default 0.
  <interleave_to_stereo> is to enable/disable always interleaved to stereo output. Default 1.
  <down_sample_sbr> 	 is to enable/disable down-sampled SBR output. Default auto identification from header.
  <RAW_sample_rate> 	 is to indicate the core AAC sample rate for a RAW stream. If this is specified no other file format headers are searched for.
  <disable_sync> 		 is to disable the ADTS/ADIF sync search i.e when enabled the decoder expects the header to be at the start of input buffer. Default 0.
  <auto_sbr_upsample> 	 is to enable(1) or disable(0) auto SBR upsample in case of stream changing from SBR present to SBR not present. Default 1.
  <maximum_num_channels> is the number of maxiumum channels the input may have. Default is 6 (5.1).
  <mp4_flag> 			 is a flag that should be set to 1 when passing raw stream along with meta data text file.

Sample CLI:

<xaac_dec_exe> -ifile:in_file.aac -ofile:out_file.wav -pcmsz:16 					 

Validating the Ex-HEAAC Decoder

Conformance testing for AAC/HEAAC v1/HEAAC v2 mainly involves comparing decoder under test output with the ISO and 3GPP reference decoded output.

Testing for USAC is done using encoded streams generated using ISO USAC reference encoder. The output generated by ITTIAM USAC decoder is compared against the output generated by ISO USAC decoder for 16-bit conformance on the respective(ARMv7, ARMv8, X86_32, X86_64) platforms.