ADTS, the Audio Data Transport Stream, is the transport a raw .aac file
almost always uses. It is defined in ISO/IEC 13818-7 and carried over into ISO/IEC 14496-3.
The file is a run of ADTS frames with nothing between them. Each frame has its own header,
so a player can begin anywhere by finding the next sync word. Bytes are read most
significant bit first.
Header fields
The header is 7 bytes, or 9 with a CRC. The first 28 bits never change within a stream (the fixed header); the rest may change from frame to frame (the variable header).
| Bits | Width | Name | Meaning |
|---|---|---|---|
| 0–11 | 12 | syncword | twelve ones, FFF |
| 12 | 1 | ID | 0 MPEG-4, 1 MPEG-2. It says which standard’s profiles apply; the stream itself is laid out the same |
| 13–14 | 2 | layer | always 00 |
| 15 | 1 | protection_absent | 1 no CRC, 0 a CRC follows the header |
| 16–17 | 2 | profile | see profiles |
| 18–21 | 4 | sampling_frequency_index | see sampling rates; 15 is forbidden here |
| 22 | 1 | private_bit | free for applications; decoders ignore it |
| 23–25 | 3 | channel_configuration | see channels |
| 26 | 1 | original/copy | 1 original, 0 copy |
| 27 | 1 | home | home usage; ignored by decoders |
| 28 | 1 | copyright_identification_bit | one bit of a 72-bit copyright identifier, sent a bit per frame |
| 29 | 1 | copyright_identification_start | 1 means this frame’s bit is the first of the identifier |
| 30–42 | 13 | aac_frame_length | length of the whole ADTS frame in bytes, header and any CRC included |
| 43–53 | 11 | adts_buffer_fullness | state of the bit reservoir; 0x7FF means variable bit rate |
| 54–55 | 2 | number_of_raw_data_blocks_in_frame | the number of raw data blocks in the frame, minus one |
| 56–71 | 16 | crc_check | present only when protection_absent is 0 |
After the header come the raw data blocks. Each normally decodes to 1024 samples per channel. Most encoders write one block per frame, which is the most widely compatible choice.
Profiles
The field holds an MPEG-4 audio object type minus one, so it can name only the first four. SBR and PS cannot be stated here; a decoder finds them in the extension data of the blocks.
| Value | MPEG-4 (ID 0) | MPEG-2 (ID 1) |
|---|---|---|
00 | AAC Main | Main |
01 | AAC LC (Low Complexity) | Low Complexity |
10 | AAC SSR (Scalable Sampling Rate) | Scalable Sampling Rate |
11 | AAC LTP (Long Term Prediction) | reserved |
Sampling rates
| Index | Rate | Index | Rate |
|---|---|---|---|
| 0 | 96,000 Hz | 8 | 16,000 Hz |
| 1 | 88,200 Hz | 9 | 12,000 Hz |
| 2 | 64,000 Hz | 10 | 11,025 Hz |
| 3 | 48,000 Hz | 11 | 8,000 Hz |
| 4 | 44,100 Hz | 12 | 7,350 Hz |
| 5 | 32,000 Hz | 13, 14 | reserved |
| 6 | 24,000 Hz | 15 | forbidden in ADTS |
| 7 | 22,050 Hz |
Channel configurations
The field is three bits, so a value above 7 cannot be written in ADTS. Where it is 0, a program config element in the stream states the layout.
| Value | Channels | Layout |
|---|---|---|
| 0 | – | defined by a program config element in the raw data |
| 1 | 1 | front centre |
| 2 | 2 | front left, front right |
| 3 | 3 | front centre, front left, front right |
| 4 | 4 | front centre, front left, front right, back centre |
| 5 | 5 | front centre, front left, front right, back left, back right |
| 6 | 6 (5.1) | as 5, plus low-frequency effects |
| 7 | 8 (7.1) | front centre, left and right centre front, left and right outside front, left and right surround, low-frequency effects |
Configuration 7 is a wide front layout, not the usual 7.1 with side and back pairs: its elements are a single channel element, three channel pair elements and an LFE element, the first pair being the inner front speakers.
Frames with several blocks
When number_of_raw_data_blocks_in_frame is above 0, a frame holds more than
one raw data block. Then, if the frame is protected, the header carries a 16-bit
raw_data_block_position for each block after the first, before the
header’s crc_check, and each raw data block is followed by its own
16-bit crc_check. A frame with one block has neither of these.
The checks use the standard’s 16-bit CRC, with the polynomial x16 + x15 + x2 + 1. The exact bits each one covers are set out in ISO/IEC 13818-7, which this site could not read, so they are not given here.
An example
The header FF F1 50 80 2E 7F FC, typical of a stereo AAC LC stream at
44,100 Hz:
| Field | Bits | Value |
|---|---|---|
| syncword | 1111 1111 1111 | sync |
| ID, layer | 0, 00 | MPEG-4 |
| protection_absent | 1 | no CRC; the header is 7 bytes |
| profile | 01 | AAC LC |
| sampling_frequency_index | 0100 | 44,100 Hz |
| private_bit | 0 | |
| channel_configuration | 010 | stereo |
| original/copy, home | 0, 0 | |
| copyright bits | 0, 0 | |
| aac_frame_length | 0000101110011 | 371 bytes |
| adts_buffer_fullness | 11111111111 | 0x7FF: variable bit rate |
| number_of_raw_data_blocks_in_frame | 00 | one block |
The next frame begins 371 bytes after this one.
Decoding
A decoder looks for the sync word, checks the header (a layer of 00, a
sampling index from 0 to 12, a frame length at least as long as the header), and
decodes each raw data block that follows it. Each block ends with
ID_END and byte alignment, so a reader that knows only where the frame
starts can still find the blocks. The profile field becomes the object type
(profile + 1), and the sampling index and channel configuration complete the
configuration that an MP4 file would give in its AudioSpecificConfig. SBR and parametric
stereo are found implicitly, in the first frame’s fill elements; when they are there the
output rate is twice the header’s rate.
Real files often start with an ID3v2 tag, and some have stray bytes between frames, so a reader skips to the next byte that starts a valid header.
The site’s file explorer opens an ADTS .aac file frame by frame: every
header field, the CRC and block positions, each raw data block down to its elements,
scalefactors, TNS and spectral data, and the SBR and parametric stereo data, with a
table of all the frames and the sound to play. It skips ID3 tags and junk, and handles
protected frames and frames with several blocks. It also plays ADTS inside WAV files
(format tags 0x1600, 0x1608, 0x160A, and
0x1610 with a payload type of 1). The decoder is
explorer/formats/shared/audio/aac.js; its output matches FFmpeg’s on every
stream tested.