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, front left and right, side left and right, back left and right, low-frequency effects |
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.