The structure of AC3 and EAC3 audio

AC-3 audio compression standard (also known as Dolby Digital and A/52) was released by Dolby Laboratories in 1991. Enhanced AC3 (EAC3) was published in 2005 as a non-backwards compatible extension to AC3 bitstream syntax with additional coding tools and features. This article is a high level overview of AC3 and EAC3 bitstream syntax. Also in the article we will show the location of some parameters of the original audio (channel count, frame_size, sampling rate) in encoded elementary audio stream. To analyze AC3/EAC3 audio we will use Virinext Bitstream Analyzer. You can download the evaluation version on the Download page. For license acquiring please check the Buy license page.

High level AC3/EAC3 bitstream overview

At the high level AC3/EAC3 audio is the sequence of audio frames. Each frame starts from syncword 0x0B77 with 16 bits size and consists from syncframe, bsi (bit stream information) and a few extra groups of headers. AC3 and EAC3 have different bitstream syntax. The type of bitstream is signalled by bsid value (bitstream Identification) which is located with the same offset for both formats.

Further in this article we will consider the location of some parameters of the audio (frame size, sample rate, channels count) in encoded AC3 and EAC3 elementary streams. As an example we will use the files with parameters in the screenshots below.

Frame size

For AC3 elementary stream, frame size is calculated based on frmsizecod (frame size code) and fscod (sampling frequency code) fields from syncinfo by the following formula:

frame_size = FrameSizeCodeTable[frmsizecod][fscod] * 2

The FrameSizeCodeTable is described in AC3 specification.

For EAC3 elementary stream, frame size is calculated based on frmsiz (frame size) field from bsi:

frame_size = (bsi.m_frmsiz + 1) * 2

In the AC3 example file we have fscod = 1, frmsizecod = 20, FrameSizeCodeTable[20][1] = 417, that means frame_size=834 bytes. In the EAC3 example file we have frmsiz = 767, so frame_size = 1536 bytes.

Sampling rate

For AC3 sampling rate is calculated based on fscod (sample rate code) value from syncinfo based on the following table.

Sampling Rate table from AC3 and EAC3 specification

For EAC3 sampling rate is calculated with the same table based on fscod or fscod2 (sample rate code 2) values from bsi. By default, the fscod value is used. When fscod equals 3, the fscod2 field is present in bitstream and its value is used. When fscod2 value is used, the value from the Sampling Rate table should be divided by 2.

In the AC3 example file we have fscod = 1, that means sampling rate is 44.1 kHz. In the EAC3 example file we have fscod = 0, so sampling rate is 48 kHz.

Channels count

For both AC3 and EAC3 acmod (audio coding mode) value from bsi is used for determining number of channels with the following table.

Channels Count table from AC3/EAC3 specification

One extra channel can be used for frequency effects channel. When value of lfeon field is equal to 1, this channel is enabled and number of channel should be incremented by 1. So, number of channels can be calculated by following formula:

channels_count = AudioCodingTable[acmod] + lfeon

In the AC3 example file we have acmod = 2, lfeon = 0, that means audio has 2 channels. In the EAC3 example file we have acmod = 7, lfeon = 1, so audio has 6 channels.

Conclusion

We have provided a high level overview of AC3 and EAC3 audio and described the location of a few parameters of audio in encoded bitstream. AC3 and EAC3 audio files can be analyzed with Virinext Bitstream Analyzer. It is a GUI tool for both in-depth and high-level analysis for many encoding standards including AC3 and EAC3 audio.