Introduction
AC-3 is the audio codec of Dolby Digital. It carries one to 5.1 channels (five full-bandwidth channels and a low-frequency effects channel) at 32 to 640 kbit/s, sampled at 48, 44.1 or 32 kHz (the ranges of the frame size table). Its specification here is ETSI TS 102 366 V1.4.1 (2017-09), read in full this session as a PDF (through PDFKit); in that document “AC-3” names the algorithm of the main body (with or without Annex D) and “E-AC-3” the algorithm of Annex E (Enhanced AC-3, Dolby Digital Plus). The ATSC A/52 edition publishes the same codec, but its PDF could not be downloaded this session (the server refused a plain request), so no statement on these pages is checked against A/52 and “identical” is not claimed. The annexes are A (AC-3 in the MPEG-2 multiplex), C (karaoke, informative), D (alternate bit stream syntax), E (Enhanced AC-3), F (ISO base media file format), G (E-AC-3 in MPEG-2), H (EMDF metadata), I (MPEG-DASH signalling) and J (CMAF).
An .ac3 file is a raw AC-3 stream, usually extracted from a film or
prepared for authoring a disc. Most AC-3 audio lives inside video containers
instead. Enhanced AC-3 streams are usually saved as .ec3 or
.eac3, and sometimes as .ac3.
Structure
An AC-3 stream is a run of sync frames, each standing alone. A frame starts with the
16-bit sync word 0B 77, a CRC, and a byte giving the sample rate and the
frame size. The bit stream information follows: the stream version, the service type,
the channel layout, whether the LFE channel is present, dialogue level and other
settings. Then come six audio blocks of 256 new samples per channel, 1536 samples in
all, unused auxiliary bits and a closing CRC. Every frame carries everything needed to
decode it; only the overlap of the inverse transform joins one frame to the next.
Each block holds the frequency coefficients of its channels in floating-point form: exponents, sent as a coarse spectral envelope, and mantissas whose sizes the decoder works out for itself by running the same bit allocation the encoder ran. Above a chosen frequency, channels can share one coupling channel; in stereo, sum and difference can be sent instead of left and right. The decoder turns the coefficients back into samples with an inverse MDCT of 512 or two of 256 points, a window and overlap-add.
The bytes of a stream are normally in big-endian order, sync word 0B 77;
a stream stored as little-endian 16-bit words starts its frames with 77 0B
instead, and the specification allows that in MP4 files.
0Sync frame repeated to the end of the streamvaries+0Sync info 0B 77, CRC, sample rate and frame size5 bytes+5Bit stream info version, channel layout, LFE, settingsvaries…Audio blocks six of 256 samples per channelvaries…CRC closing check2 bytes
The reference pages cover every part of the frame:
- Sync frame – the frame layout, sample rates, every frame size code, the auxiliary data and the CRCs
- Bit stream information – versions, service types, channel layouts, mix levels, time codes, the Annex D syntax and karaoke
- Audio block – every field of a block: coupling, rematrixing, exponents, bit allocation and mantissas
- Decoding – exponents, the bit allocation and its tables, quantisers, coupling, gains, the transform, downmixing and error checks
- Enhanced AC-3 – the Annex E frame: bit stream information, audio frame, audio block and substreams
- E-AC-3 coding tools – the hybrid transform, spectral extension, enhanced coupling and transient pre-noise processing
- Metadata (EMDF) – the Annex H container for loudness, programme and other metadata
- In other files – MPEG-2 transport streams, MP4, MPEG-DASH, CMAF and WAV
The site’s file explorer decodes AC-3 and Enhanced AC-3 when they are inside a WAV file,
with the decoder in explorer/formats/shared/audio/ac3.js, which follows TS
102 366 throughout.
Not described
Known, not yet covered
- Reference: the ATSC A/52 edition of the specification was not read (its PDF returned HTTP 403 to a plain download), so differences between it and ETSI TS 102 366 V1.4.1, if any, are not recorded. The ETSI Annex G note says A/52:2012 Annex G, not reproduced in the ETSI text, defines E-AC-3 in System A transport streams.
- Reference: ETSI EN 300 468 and TS 101 154 (DVB transport of AC-3 and E-AC-3) and the RFCs for RTP are referred to but not summarised beyond what TS 102 366 says.
- Viewer: the decoder has been tested on streams built with ffmpeg, not on real .ac3 or .ec3 files, since none were available.
Unknown
- Reference and viewer: values that ETSI TS 102 366 leaves undefined: EMDF key IDs and how the protection bits are computed, block-mixing configuration values, speech-enhancement data, reserved fields of enhanced coupling, and EMDF payload IDs from 8 up. Shown as labelled values or bytes.
Links
Software
- VLC media player – free player for almost any audio or video file (Windows, macOS, Linux, mobile)
- foobar2000 – free music player and converter (Windows, macOS, mobile)
- FFmpeg – command-line tool that encodes and decodes AC-3 (Windows, macOS, Linux)
Developers
- libavcodec – FFmpeg’s codec library, which encodes and decodes AC-3 (C)
Reference
- ETSI TS 102 366 V1.4.1 – Digital Audio Compression (AC-3, Enhanced AC-3) Standard, free from ETSI (PDF)
- ATSC A/52 – the Digital Audio Compression Standard, published by ATSC (not read for these pages)
- RFC 4184 – carrying AC-3 in RTP, with notes on the frame
- RFC 4598 – carrying Enhanced AC-3 in RTP