Enhanced AC-3, also called Dolby Digital Plus or E-AC-3, is specified in Annex E of ETSI
TS 102 366 (and ATSC A/52). It keeps AC-3’s sync word, filter bank, exponents and bit
allocation, and adds frames of one, two, three or six blocks, frames of any length up to
2,048 words, substreams for more channels and more programmes, richer metadata, and new
coding tools. It is not backwards
compatible: an AC-3 decoder cannot play it. Files of this kind usually have the
extension .ec3 or .eac3, but E-AC-3 streams also turn up as
.ac3. The 5-bit bsid at bits 40–44 tells the two apart: 0 to 8
is AC-3, 11 to 16 Enhanced AC-3 (16 in this version). An Enhanced AC-3 decoder must also
play AC-3.
Frame layout
0Sync information the sync word0B 77only2 bytes2Bit stream information stream type, size, rate, blocks, layout, metadatavaries…Audio frame strategies and flags for the whole framevaries…Audio blocks 1, 2, 3 or 6 of 256 samples a channelvaries…Auxiliary data as in AC-3varies…Error checkencinfo(1 bit, for the encoder) andcrc217 bits
Bit stream information
| Bits | Name | Present when | Meaning |
|---|---|---|---|
| 2 | strmtyp | always | stream type: 0 independent, 1 dependent, 2 independent and converted from AC-3, 3 reserved |
| 3 | substreamid | always | substream number, 0 to 7 |
| 11 | frmsiz | always | frame length in 16-bit words minus one: 1 to 2,048 words |
| 2 | fscod | always | 0 = 48 kHz, 1 = 44.1 kHz, 2 = 32 kHz, 3 reserved (but see below) |
| 2 | numblkscod | always | blocks a frame: 0 = 1, 1 = 2, 2 = 3, 3 = 6 |
| 3 | acmod | always | channel layout, as in AC-3 |
| 1 | lfeon | always | 1: the LFE channel is present |
| 5 | bsid | always | 16 (11 to 15 for compatible versions) |
| 5 | dialnorm | always | dialogue level, −1 to −31 dB, as in AC-3 |
| 1 + 8 | compre, compr | compr if set | heavy compression word, as in AC-3 |
| 5, 1 + 8 | dialnorm2, compr2e, compr2 | acmod 0 | the same for Ch2 |
| 1 + 16 | chanmape, chanmap | strmtyp 1; chanmap if set | a custom channel map for this dependent substream |
| 1 | mixmdate | always | 1: mixing metadata follows |
| 1 | infomdate | always (after the mixing metadata) | 1: informational metadata follows |
| 1 | convsync | strmtyp 0 and fewer than six blocks | a synchronisation point for a converter making AC-3 frames from these |
| 1 | blkid | strmtyp 2 and fewer than six blocks (with six it is 1) | 1: the first block here was the first of an original AC-3 frame |
| 6 | frmsizecod | strmtyp 2 and blkid 1 | the original AC-3 frame size code |
| 1 + 6 + n | addbsie, addbsil, addbsi | as in AC-3 | 1 to 64 bytes of additional information |
TS 102 366 lists fscod 3 as reserved, but its own syntax calls
that case the half sample rate (the sourcefscod field is present only
when fscod is below 3). Decoders such as FFmpeg’s read the next two bits
as fscod2 in place of numblkscod: 0 = 24 kHz, 1 = 22.05 kHz,
2 = 16 kHz, 3 reserved, with six blocks a frame.
Where a frame has fewer than six blocks, the frames that together hold six blocks form a frame set. A frame lasts 256 × blocks samples; its bit rate is its frmsiz + 1 words over that time.
Mixing metadata
Present when mixmdate is 1. It describes downmixing and how this programme
and another (a main service and an associated one, such as commentary or audio
description) should be mixed by a device that decodes both. The decoder’s own output is
not scaled by it.
| Bits | Name | Present when | Meaning |
|---|---|---|---|
| 2 | dmixmod | acmod above 2 | preferred stereo downmix, as in Annex D |
| 3 + 3 | ltrtcmixlev, lorocmixlev | three front channels | centre mix levels, Annex D codes |
| 3 + 3 | ltrtsurmixlev, lorosurmixlev | a surround channel | surround mix levels, Annex D codes |
| 1 + 5 | lfemixlevcode, lfemixlevcod | lfeon; code if set | level for mixing the LFE into L and R when there is no LFE output: 10 − code dB (+10 to −21 dB). A stereo or mono decoder then adds the LFE to L and R at that level − 4.5 dB. Without it, no LFE downmix |
| 1 + 6 | pgmscle, pgmscl | strmtyp 0 | scale for this programme in a mix: 0 mute, 1 to 63 = −50 to +12 dB in 1 dB steps (code − 51 dB); absent = 0 dB |
| 1 + 6 | pgmscl2e, pgmscl2 | and acmod 0 | the same for Ch2 |
| 1 + 6 | extpgmscle, extpgmscl | strmtyp 0 | scale for the other programme (another stream or independent substream), same scale |
| 2 | mixdef | strmtyp 0 | 0: nothing more; 1: 5 bits (premixcmpsel, drcsrc, premixcmpscl); 2: 12 bits of mixdata, reserved; 3: mixdeflen and 2 to 33 bytes |
| 1 | premixcmpsel | mixdef 1, or mixdata2e | compression word applied to the main programme before mixing: 0 dynrng (recommended), 1 compr |
| 1 | drcsrc | as above | DRC words for the mixed output: 0 the other programme’s (recommended), 1 this one’s |
| 3 | premixcmpscl | as above | share of that compression: 0 = 0 % (recommended), 1 = 16.7, 2 = 33.3, 3 = 50, 4 = 66.7, 5 = 83.3, 7 = 100 %; 6 is not listed. Decoders need not use these three fields |
| 5 | mixdeflen | mixdef 3 | the mixing data that follows is mixdeflen + 2 bytes |
| 1 | mixdata2e | mixdef 3 | 1: per-channel scales for the other programme follow |
| 1 + 4 each | extpgmlscle/extpgmlscl, extpgmcscle/extpgmcscl, extpgmrscle/extpgmrscl, extpgmlsscle/extpgmlsscl, extpgmrsscle/extpgmrsscl, extpgmlfescle/extpgmlfescl | mixdata2e; each scale if its flag is set | scale for the other programme’s L, C, R, Ls (or mono surround), Rs and LFE, added to extpgmscl: table below |
| 1 + 4 | dmixscle, dmixscl | mixdata2e | scale for the other programme when it has already been downmixed to two channels, added to extpgmscl |
| 1, 1 + 4, 1 + 4 | addche, extpgmaux1scle/extpgmaux1scl, extpgmaux2scle/extpgmaux2scl | mixdata2e; the rest if addche | scales for up to two further channels the other programme’s channel map places elsewhere |
| 1 | mixdata3e | mixdef 3 | 1: speech enhancement data follows |
| 5, 1 | spchdat, addspchdate | mixdata3e | how far the first channel or pair is dominated by speech; more follows if set |
| 5, 2, 1 | spchdat1, spchan1att, addspchdat1e | addspchdate | the same for a second channel or pair, which channels carry speech and whether the others may be attenuated |
| 5, 3 | spchdat2, spchan2att | addspchdat1e | the same for a third channel or pair |
| rest | mixdata, mixdatafill | mixdef 3 | the rest of the mixdeflen + 2 bytes: reserved, and zero fill to a byte |
| 1 + 8 + 6 | paninfoe, panmean, paninfo | strmtyp 0 and mono or dual mono | where to pan this mono programme: panmean in 1.5° steps clockwise from centre (0–239; 240–255 reserved); paninfo reserved. Absent: centre |
| 1 + 8 + 6 | paninfo2e, panmean2, paninfo2 | and acmod 0 | the same for Ch2 |
| 1 | frmmixcfginfoe | strmtyp 0 | 1: mixing configuration for the frame follows |
| 5 | blkmixcfginfo[0] | one block a frame | mixing configuration of the block |
| 1 (+5) each | blkmixcfginfoe, blkmixcfginfo[blk] | more blocks, per block | the same, for each block that has one |
The speech enhancement fields are placeholders whose meaning TS 102 366 does not yet define, and it gives no meaning for the block mixing configuration values.
| Code | 0 | 1 | 2 | 3 | 4 | 5 | 6 | 7 |
|---|---|---|---|---|---|---|---|---|
| Scale | −1 dB | −2 dB | −3 dB | −4 dB | −5 dB | −6 dB | −8 dB | −10 dB |
| Code | 8 | 9 | 10 | 11 | 12 | 13 | 14 | 15 |
| Scale | −12 dB | −14 dB | −16 dB | −19 dB | −22 dB | −25 dB | −28 dB | mute |
Panning a mono programme
With x = panmean, the mono associated programme is fed to the main programme’s channels with these factors (angles in radians):
| panmean | Stereo: L | Stereo: R |
|---|---|---|
| 0–19 | cos(π/2 · (x + 20)/40) | sin(π/2 · (x + 20)/40) |
| 20–99 | 0 | 1 |
| 100–139 | sin(π/2 · (x − 100)/40) | cos(π/2 · (x − 100)/40) |
| 140–219 | 1 | 0 |
| 220–239 | cos(π/2 · (x − 220)/40) | sin(π/2 · (x − 220)/40) |
| panmean | 5.1: L | C | R | Ls | Rs |
|---|---|---|---|---|---|
| 0–19 | 0 | cos(π/2 · x/20) | sin(π/2 · x/20) | 0 | 0 |
| 20–72 | 0 | 0 | cos(π/2 · (x − 20)/53) | 0 | sin(π/2 · (x − 20)/53) |
| 73–166 | 0 | 0 | 0 | sin(π/2 · (x − 73)/94) | cos(π/2 · (x − 73)/94) |
| 167–219 | sin(π/2 · (x − 167)/53) | 0 | 0 | cos(π/2 · (x − 167)/53) | 0 |
| 220–239 | cos(π/2 · (x − 220)/20) | sin(π/2 · (x − 220)/20) | 0 | 0 | 0 |
Informational metadata
Present when infomdate is 1; the fields mean what they do in
AC-3 and Annex D.
| Bits | Name | Present when |
|---|---|---|
| 3, 1, 1 | bsmod, copyrightb, origbs | always |
| 2 + 2 | dsurmod, dheadphonmod | acmod 2 |
| 2 | dsurexmod | acmod 6 or 7 (two surrounds) |
| 1, 5 + 2 + 1 | audprodie, mixlevel, roomtyp, adconvtyp | the rest if audprodie |
| 1, 5 + 2 + 1 | audprodi2e, mixlevel2, roomtyp2, adconvtyp2 | acmod 0; the rest if audprodi2e |
| 1 | sourcefscod | fscod below 3: 1 means the source was sampled at twice this rate |
Without informational metadata a stream has no bsmod (MP4’s dec3 box
then gives 0).
Audio frame
The audio frame holds settings that apply to the whole frame, so the blocks need not repeat them. Its strategy flags decide which block fields exist at all.
| Bits | Name | Present when | Meaning |
|---|---|---|---|
| 1 | expstre | six blocks (else 1) | 1: each block’s exponent strategies are sent; 0: one 5-bit code a channel for the whole frame |
| 1 | ahte | six blocks (else 0) | 1: some channel uses the Adaptive Hybrid Transform |
| 2 | snroffststr | always | SNR offsets: 0 one coarse and fine pair for the frame; 1 a pair per block (or reused), shared by all channels; 2 a coarse offset per block and a fine one per channel; 3 reserved |
| 1 | transproce | always | 1: transient pre-noise processing data follows |
| 1 | blkswe | always | 1: blocks carry blksw; 0: all long transforms |
| 1 | dithflage | always | 1: blocks carry dithflag; 0: dither always on |
| 1 | bamode | always | 1: blocks carry bit allocation parameters; 0: defaults (sdcycod 2, fdcycod 1, sgaincod 1, dbpbcod 2, floorcod 7) |
| 1 | frmfgaincode | always | 1: blocks may carry fast gain codes; 0: always code 4 |
| 1 | dbaflde | always | 1: blocks carry delta bit allocation syntax |
| 1 | skipflde | always | 1: blocks carry skip field syntax |
| 1 | spxattene | always | 1: spectral extension attenuation data follows |
| 1, then 1 + 1 each | cplinu[0], then cplstre[blk], cplinu[blk] | acmod above 1 | coupling on or off in each block; a block without a new strategy keeps the last |
| 2 + 2 each | cplexpstr[blk], chexpstr[blk][ch] | expstre 1 | exponent strategies of each block (the coupling one only where coupling is on) |
| 5 + 5 each | frmcplexpstr, frmchexpstr[ch] | expstre 0 (the coupling code only if some block couples) | a frame strategy code |
| 1 each | lfeexpstr[blk] | lfeon | LFE exponent strategy of each block |
| 1, 5 each | convexpstre, convexpstr[ch] | strmtyp 0 (the flag only with fewer than six blocks; otherwise 1) | exponent strategies for a converter to AC-3, as frame strategy codes; needed once every six blocks |
| 1 | cplahtinu | ahte, coupling in all six blocks, and its strategy or exponents new in only one | 1: the coupling channel uses AHT |
| 1 each | chahtinu[ch] | ahte and the channel’s exponents new in only one block | 1: the channel uses AHT |
| 1 | lfeahtinu | ahte, lfeon and LFE exponents new in only one block | 1: the LFE uses AHT |
| 6 + 4 | frmcsnroffst, frmfsnroffst | snroffststr 0 | coarse (−45 to +144 dB in 3 dB steps) and fine (0 to 2.8125 dB in 3/16 dB steps) SNR offsets for every channel and block |
| 1, 10 + 8 each | chintransproc[ch], transprocloc[ch], transproclen[ch] | transproce; the rest if set | transient position in 4-sample units from the frame’s first sample, and the processing length in samples |
| 1, 5 each | chinspxatten[ch], spxattencod[ch] | spxattene; the code if set | spectral extension notch filter, Table E.2.12 |
| 1 | blkstrtinfoe | more than one block | 1: block start information follows |
| (blocks − 1) × (4 + ⌈log2(frmsiz + 1)⌉) | blkstrtinfo | blkstrtinfoe | where the blocks start |
At the end of the audio frame the decoder sets, for every channel, “first spectral extension coordinates” and “first coupling coordinates”, and “first coupling leak”: the first block of the frame that uses each of them gets its values without an “exists” bit.
| Code | Blocks 0–5 | Code | Blocks 0–5 | Code | Blocks 0–5 | Code | Blocks 0–5 |
|---|---|---|---|---|---|---|---|
| 0 | D15 R R R R R | 8 | D25 R D15 R R R | 16 | D45 D15 R R R R | 24 | D45 D45 D15 R R R |
| 1 | D15 R R R R D45 | 9 | D25 R D25 R R D45 | 17 | D45 D15 R R R D45 | 25 | D45 D45 D25 R R D45 |
| 2 | D15 R R R D25 R | 10 | D25 R D25 R D25 R | 18 | D45 D25 R R D25 R | 26 | D45 D45 D25 R D25 R |
| 3 | D15 R R R D45 D45 | 11 | D25 R D25 R D45 D45 | 19 | D45 D25 R R D45 D45 | 27 | D45 D45 D25 R D45 D45 |
| 4 | D25 R R D25 R R | 12 | D25 R D45 D25 R R | 20 | D45 D25 R D25 R R | 28 | D45 D45 D45 D25 R R |
| 5 | D25 R R D25 R D45 | 13 | D25 R D45 D25 R D45 | 21 | D45 D25 R D25 R D45 | 29 | D45 D45 D45 D25 R D45 |
| 6 | D25 R R D45 D25 R | 14 | D25 R D45 D45 D25 R | 22 | D45 D25 R D45 D25 R | 30 | D45 D45 D45 D45 D25 R |
| 7 | D25 R R D45 D45 D45 | 15 | D25 R D45 D45 D45 D45 | 23 | D45 D25 R D45 D45 D45 | 31 | D45 D45 D45 D45 D45 D45 |
Audio block
An Enhanced AC-3 block follows the AC-3 block with these differences, in order:
| Part | Difference from AC-3 |
|---|---|
| blksw, dithflag | only if blkswe / dithflage; otherwise 0 / 1 |
| dynrng | as in AC-3 |
| Spectral extension | new: spxstre (1 implied in block 0), spxinu, chinspx[ch] (implied for mono), spxstrtf (2), spxbegf (3), spxendf (3), spxbndstrce and spxbndstrc; then for each channel in it spxcoe (implied the first time), spxblnd (5), mstrspxco (2) and per band spxcoexp (4) and spxcomant (2). See spectral extension |
| Coupling strategy | only where the audio frame’s cplstre is set; cplinu comes from the audio frame. New: ecplinu. In 2/0 both channels are coupled without chincpl bits. With ordinary coupling, cplendf is not sent when spectral extension is on, and cplbndstrce says whether cplbndstrc follows (otherwise the previous structure, or in the first coupled block the default, which joins sub-bands 8, 10, 11, 13, 14, 15, 16 and 17 to the ones before). With enhanced coupling: ecplbegf (4), ecplendf (4, unless spectral extension is on), ecplbndstrce and ecplbndstrc |
| Coupling coordinates | cplcoe implied the first time a channel couples in the frame. With enhanced coupling: one reserved bit, then per coupled channel ecplparam1e (implied the first time), rsvdfieldse (all but the first channel), ecplamp (5) per band, the reserved fields, and a reserved bit (all but the first channel) |
| Rematrixing | rematstr implied in block 0. The number of bands: with enhanced coupling 0, 1, 2, 3 or 4 for ecplbegf 0, 1, 2, 3–4 and above; with ordinary coupling as in AC-3; with spectral extension and no coupling 3 if spxbegf is below 2, else 4; otherwise 4 |
| Exponent strategies | none in the block: they come from the audio frame |
| chbwcod | only for channels neither coupled nor in spectral extension. A channel in spectral extension ends at the first synthesised bin, a coupled one at the start of (enhanced) coupling |
| Exponents | as in AC-3; with enhanced coupling the coupling exponents span its first to last bin |
| Bit allocation | baie and parameters only if bamode |
| SNR offsets | by snroffststr: none (frame values); or snroffste (implied in block 0), csnroffst and either blkfsnroffst (4, for every channel) or cplfsnroffst, fsnroffst[ch], lfefsnroffst. Fast gain codes are no longer here |
| Fast gain | new: fgaincode (if frmfgaincode), then cplfgaincod, fgaincod[ch], lfefgaincod (3 each); otherwise 4 |
| Converter SNR offset | new, independent substreams: convsnroffste and convsnroffst (10), the offset a converter to AC-3 needs |
| Coupling leak | cplleake implied in the first coupled block of the frame |
| Delta bit allocation, skip | only if dbaflde / skipflde |
| Mantissas | for a channel using AHT, read once, in the first block: chgaqmod (2), the gains, and the pre-mantissas of all six blocks (likewise cplgaqmod and lfegaqmod). See AHT |
Substreams and channel maps
One Enhanced AC-3 stream can carry several time-multiplexed substreams. Independent
substreams (strmtyp 0, or 2 when converted from AC-3) are programmes, each
decodable alone; they are numbered 0 to 7 in the order they appear, and substream 0
comes first in every stream. An AC-3 frame within an Enhanced AC-3 stream counts as
independent substream 0. Each independent substream may be followed by up to eight
dependent substreams (strmtyp 1, numbered 0 to 7), which add channels to it.
All substreams of a programme have the same number of blocks and the same sample rate.
Every decoder must play independent substream 0 and skip the rest; programme 1, that
is substream 0, is the default.
A programme of more than 5.1 channels keeps a 5.1 downmix in its independent
substream, for 5.1 and smaller systems, which ignore the dependent substreams. A
dependent substream’s channels replace the independent substream’s channels of the same
name, or add new ones. Without a channel map they are named by its acmod and
lfeon (a dependent 1/0 with LFE replaces C and LFE); with one, by the map. A
programme renders at most 16 channels. For dynamic range, a decoder rendering the full
programme uses the compr and dynrng of the last dependent
substream (the one with compre set), for all substreams of the programme.
| Bit | Location | Bit | Location |
|---|---|---|---|
| 0 | Left | 8 | Ts (top surround) |
| 1 | Centre | 9 | Lsd/Rsd pair (surround direct) |
| 2 | Right | 10 | Lw/Rw pair (wide) |
| 3 | Left surround | 11 | Vhl/Vhr pair (vertical height) |
| 4 | Right surround | 12 | Vhc (vertical height centre) |
| 5 | Lc/Rc pair (centre) | 13 | Lts/Rts pair (top surround) |
| 6 | Lrs/Rrs pair (rear surround) | 14 | LFE2 |
| 7 | Cs (centre surround) | 15 | LFE |
The coded channels take the set bits’ locations in order, a pair taking two channels, and the number of locations must equal the substream’s channel count. So a 2/2 dependent substream with bits 3, 4 and 6 set carries Ls, Rs, Lrs and Rrs. The locations are those of SMPTE 428-3.