Understanding AAC: Difference between revisions

From MultimediaWiki
Jump to navigation Jump to search
No edit summary
No edit summary
Line 24: Line 24:
* provisions all over the libfaad source for error recovery (ER)
* provisions all over the libfaad source for error recovery (ER)


== Packaging/Encapsulation ==
== Packaging/Encapsulation And Setup Data==
There is a variety of methods for packaging AAC data from transport. 2 methods used in packaging raw streams are to use ADTS and ADIF headers. The libfaad knowledge base also makes reference to LATM and LOAS packaging.
There is a variety of methods for packaging AAC data from transport. 2 methods used in packaging raw streams are to use ADTS and ADIF headers. The libfaad knowledge base also makes reference to LATM and LOAS packaging.


Line 32: Line 32:
  4 bits: channel configuration
  4 bits: channel configuration
These are the possible object types:
These are the possible object types:
* 1: MAIN
* 0: NULL
* 2: LC (low complexity)
* 1: AAC Main
* 3: SSR
* 2: AAC Low complexity
* 4: LTP (long term prediction)
* 3: AAC SSR
* 5: HE_AAC (high efficiency)
* 4: AAC Long term prediction
* 17: ER_LC (low complexity with error recovery)
* 5: AAC High efficiency
* 19: ER_LTP (long term prediction with error recovery)
* 6: Scalable
* 23: LD
* 7: TwinVQ
* 27: DRM_ER_LC 27
* 8: CELP
* 9: HVXC
* 10: Reserved
* 11: Reserved
* 12: TTSI
* 13: Main synthetic
* 14: Wavetable synthesis
* 15: General MIDI
* 16: Algorithmic Synthesis and Audio FX
* 17: AAC Low complexity with error recovery
* 18: Reserved
* 19: AAC Long term prediction with error recovery
* 20: AAC scalable with error recovery
* 21: TwinVQ with error recovery
* 22: BSAC with error recovery
* 23: AAC LD with error recovery
* 24: CELP with error recovery
* 25: HXVC with error recovery
* 26: HILN with error recovery
* 27: Parametric with error recovery
* 28: Reserved
* 29: Reserved
* 30: Reserved
* 31: Reserved
There are 12 supported frequencies (frequency indices 12..15 are invalid):
There are 12 supported frequencies (frequency indices 12..15 are invalid):
* 0: 96000 Hz
* 0: 96000 Hz
Line 57: Line 80:
'''(TODO)'''
'''(TODO)'''


== Syntax Elements ==
== Frames And Syntax Elements ==
An AAC frame is comprised of blocks called syntax elements. There are 8 different syntax elements:
In an MPEG-4 file, the AAC data is broken up into a series of variable length frames.
 
An AAC frame is comprised of blocks called syntax elements. Read the first 3 bits from the frame's bitstream to find the first element type. Decode the element. Proceed to read the first 3 bits of the next element and repeat the decoding process until the frame is depleted.
 
There are 8 different syntax elements:
* 0 SCE  single channel element (codes a single audio channel)
* 0 SCE  single channel element (codes a single audio channel)
* 1 CPE  channel pair element (codes stereo signal)
* 1 CPE  channel pair element (codes stereo signal)
Line 72: Line 99:
  center - left/right - surround left/right - lfe - end  
  center - left/right - surround left/right - lfe - end  
An ID within the respective CPE blocks indicates its channel assignments (front vs. surround).
An ID within the respective CPE blocks indicates its channel assignments (front vs. surround).
== Decoding Process ==
The decoding process will first focus on decoding low complexity (LC) AAC streams. This is because they are the least complex. LC streams also show up most commonly in MP4 files (including iTunes music).
* Decoding AAC SCE
* [[Decoding AAC CPE]]
* Decoding AAC CCE
* Decoding AAC LFE
* Decoding AAC DSE
* Decoding AAC PCE
* Decoding AAC FIL
* [[ Decoding AAC END]]

Revision as of 22:19, 24 December 2005

This portion of the MultimediaWiki tracks an effort to get an open, freely-distributable, usable, and clear specification for the Advanced Audio Coding (AAC) format. The goal is to understand enough details about the format to create new decoder implementations that can handle production bitstreams starting with data packaged inside MPEG-4 files.

The homepage for libfaad has a Wiki that provides some decent details regarding the background coding concepts: http://www.audiocoding.com/modules/wiki/?page=AAC

More possible details here: http://www.ietf.org/proceedings/99nov/I-D/draft-ietf-avt-rtp-mpeg2aac-00.txt

Overview

AAC is a perceptual audio codec which means that it throws away certain information during the compression process, information that has been deemed less important.

Surface details of the format can be found at Wikipedia: http://en.wikipedia.org/wiki/Advanced_Audio_Coding

Conformance vectors can be obtained here: ftp://mpaudconf:adif2mp4@ftp.iis.fhg.de/

AAC is a variable bitrate (VBR) block-based codec where each block decodes to 1024 time-domain samples. Allegedly, each frame stands alone and does not depend on previous frames (whereas many perceptual audio codecs overlap data with the previous frame).

AAC includes a variety of profiles:

  • low complexity (LC): reported to be the simplest (Apple iTunes files)
  • main (MAIN): LC profile with backwards prediction
  • sample-rate scalability (SRS): submitted by Sony and reportedly similar to ATRAC/3
  • long term prediction (LTP): main profile with forward prediction
  • high efficiency (HE, HE-AAC, aacPlus): uses spectral band replication (SBR) and may use parametric stereo
  • FAAD refers to another profile named LD, possibly the same as SRS
  • provisions all over the libfaad source for error recovery (ER)

Packaging/Encapsulation And Setup Data

There is a variety of methods for packaging AAC data from transport. 2 methods used in packaging raw streams are to use ADTS and ADIF headers. The libfaad knowledge base also makes reference to LATM and LOAS packaging.

Much AAC data is encapsulated in MPEG-4 files which is an extension of the Apple QuickTime container format. the MPEG-4 file will audio 'trak' atom which will contain a 'stsd' description atom which will contain an 'mp4a' atom which will contain an 'esds' atom. Part of the esds atom contains the setup data for associated AAC stream. (TODO: need to document the precise format and method for obtaining the setup data.) This setup data is generally 2 bytes. Actually, it is generally 13 bits but padded to 16 bits. This setup data has the following layout:

5 bits: object type
4 bits: frequency index
4 bits: channel configuration

These are the possible object types:

  • 0: NULL
  • 1: AAC Main
  • 2: AAC Low complexity
  • 3: AAC SSR
  • 4: AAC Long term prediction
  • 5: AAC High efficiency
  • 6: Scalable
  • 7: TwinVQ
  • 8: CELP
  • 9: HVXC
  • 10: Reserved
  • 11: Reserved
  • 12: TTSI
  • 13: Main synthetic
  • 14: Wavetable synthesis
  • 15: General MIDI
  • 16: Algorithmic Synthesis and Audio FX
  • 17: AAC Low complexity with error recovery
  • 18: Reserved
  • 19: AAC Long term prediction with error recovery
  • 20: AAC scalable with error recovery
  • 21: TwinVQ with error recovery
  • 22: BSAC with error recovery
  • 23: AAC LD with error recovery
  • 24: CELP with error recovery
  • 25: HXVC with error recovery
  • 26: HILN with error recovery
  • 27: Parametric with error recovery
  • 28: Reserved
  • 29: Reserved
  • 30: Reserved
  • 31: Reserved

There are 12 supported frequencies (frequency indices 12..15 are invalid):

  • 0: 96000 Hz
  • 1: 88200 Hz
  • 2: 64000 Hz
  • 3: 48000 Hz
  • 4: 44100 Hz
  • 5: 32000 Hz
  • 6: 24000 Hz
  • 7: 22050 Hz
  • 8: 16000 Hz
  • 9: 12000 Hz
  • 10: 11025 Hz
  • 11: 8000 Hz

These are the channel configurations: (TODO)

Frames And Syntax Elements

In an MPEG-4 file, the AAC data is broken up into a series of variable length frames.

An AAC frame is comprised of blocks called syntax elements. Read the first 3 bits from the frame's bitstream to find the first element type. Decode the element. Proceed to read the first 3 bits of the next element and repeat the decoding process until the frame is depleted.

There are 8 different syntax elements:

  • 0 SCE single channel element (codes a single audio channel)
  • 1 CPE channel pair element (codes stereo signal)
  • 2 CCE something to do with channel coupling, not implemented in libfaad2
  • 3 LFE low-frequency effects? referenced as "special effects" in RTP doc
  • 4 DSE data stream element (user data)
  • 5 PCE program configuration element (describe bitstream)
  • 6 FIL fill element (pad space/extension data)
  • 7 END marks the end of the frame

This is an example layout for a 5.1 audio stream:

SCE CPE CPE LFE END

indicates

center - left/right - surround left/right - lfe - end 

An ID within the respective CPE blocks indicates its channel assignments (front vs. surround).

Decoding Process

The decoding process will first focus on decoding low complexity (LC) AAC streams. This is because they are the least complex. LC streams also show up most commonly in MP4 files (including iTunes music).