An AC-3 stream, defined in ATSC A/52, is a run of sync frames with nothing between them. Each frame stands alone and holds 1536 samples of each channel, as six audio blocks of 256 samples. All values are big-endian, most significant bit first.
Frame layout
0Sync information sync word, CRC, sample rate, frame size5 bytes5Bit stream information version, channels, dialogue level and morevaries…Audio blocks 0 to 5 256 samples per channel eachvaries…Auxiliary data unused space, then its lengthvaries…Error check a reserved bit and the second CRC17 bits
Sync information
| Bits | Width | Name | Meaning |
|---|---|---|---|
| 0–15 | 16 | syncword | 0B 77 |
| 16–31 | 16 | crc1 | the check on the first part of the frame |
| 32–33 | 2 | fscod | the sample rate code |
| 34–39 | 6 | frmsizecod | the frame size code |
Sample rate codes
| fscod | Rate |
|---|---|
| 0 | 48,000 Hz |
| 1 | 44,100 Hz |
| 2 | 32,000 Hz |
| 3 | reserved; the stream cannot be decoded |
A bsid of 9 or 10 halves or quarters the rate; see
bit stream information.
Frame size codes
Two codes share each bit rate. At 44,100 Hz, a frame cannot be a whole number of 16-bit words long, so the second code of each pair adds one word to even things out. Lengths are in 16-bit words; double them for bytes.
| frmsizecod | Bit rate | 48,000 Hz | 44,100 Hz | 32,000 Hz |
|---|---|---|---|---|
| 0, 1 | 32 kbit/s | 64 | 69, 70 | 96 |
| 2, 3 | 40 kbit/s | 80 | 87, 88 | 120 |
| 4, 5 | 48 kbit/s | 96 | 104, 105 | 144 |
| 6, 7 | 56 kbit/s | 112 | 121, 122 | 168 |
| 8, 9 | 64 kbit/s | 128 | 139, 140 | 192 |
| 10, 11 | 80 kbit/s | 160 | 174, 175 | 240 |
| 12, 13 | 96 kbit/s | 192 | 208, 209 | 288 |
| 14, 15 | 112 kbit/s | 224 | 243, 244 | 336 |
| 16, 17 | 128 kbit/s | 256 | 278, 279 | 384 |
| 18, 19 | 160 kbit/s | 320 | 348, 349 | 480 |
| 20, 21 | 192 kbit/s | 384 | 417, 418 | 576 |
| 22, 23 | 224 kbit/s | 448 | 487, 488 | 672 |
| 24, 25 | 256 kbit/s | 512 | 557, 558 | 768 |
| 26, 27 | 320 kbit/s | 640 | 696, 697 | 960 |
| 28, 29 | 384 kbit/s | 768 | 835, 836 | 1,152 |
| 30, 31 | 448 kbit/s | 896 | 975, 976 | 1,344 |
| 32, 33 | 512 kbit/s | 1,024 | 1,114, 1,115 | 1,536 |
| 34, 35 | 576 kbit/s | 1,152 | 1,253, 1,254 | 1,728 |
| 36, 37 | 640 kbit/s | 1,280 | 1,393, 1,394 | 1,920 |
| 38 to 63 | not valid | |||
Auxiliary data and the error check
Unused bits at the end of the frame can carry auxiliary data. A reader starts at the end of the frame and works backwards to find it.
| Width in bits | Name | Meaning |
|---|---|---|
| varies | auxbits | auxiliary data and padding |
| 14 | auxdatal | the length of the auxiliary data in bits; only if auxdatae is 1 |
| 1 | auxdatae | 1 means auxdatal is present |
| 1 | crcrsv | reserved; can be used to adjust the frame’s CRC |
| 16 | crc2 | the check on the frame |
CRC
Both checks use the 16-bit polynomial x16 + x15 + x2 + 1
(0x8005), starting from 0. crc1 applies to the first
five-eighths of the frame after the sync word, measured in 16-bit words. crc2
completes the check, so that running the CRC over the whole frame from byte 2 to its
last byte, both check words included, gives zero. A frame that fails can be repeated
or muted.
An example
A frame starting 0B 77 D1 2C 18 at 48,000 Hz:
| Field | Value |
|---|---|
| syncword | 0B 77 |
| crc1 | D1 2C, the frame’s own check |
| fscod | 00: 48,000 Hz |
| frmsizecod | 011000, 24: 256 kbit/s |
The frame is 512 words long, 1,024 bytes.