## AC3 (Dolby Digital) Headers

This is just a quick reference to the frame header of an AC3 stream. There is no intention to fully explain AC3, for that you should read standard A/52b, available from ATSC.org (Advanced Television Systems Committee).

An AC3 frame has the following structure:
syncframe()
{
syncinfo();
bsi();
for(blk=0, blk<6, blk++)
{
audblk();
}
auxdata();
errorcheck();
} // end of syncframe

### Syncinfo

byte 0 | byte 1 | byte 2 | byte 3 | byte 4
--- | --- | --- | --- | ---
7 | 6 | 5 | 4 | 3 | 2 | 1 | 0 | 7 | 6 | 5 | 4 | 3 | 2 | 1 | 0 | 7 | 6 | 5 | 4 | 3 | 2 | 1 | 0 | 7 | 6 | 5 | 4 | 3 | 2 | 1 | 0 | 7 | 6 | 5 | 4 | 3 | 2 | 1 | 0
Syncword - 0B77 | CRC1 | fscod | frmsizcod

CRC1 applies to the first 5/8 of the frame

fscod sampling rate values

value | sampling rate
--- | ---
00 | 48K
01 | 44.1K
10 | 32K
11 | reserved

frmsizcod frame size code

value | nominal bit rate | 16-bit words per syncframe
--- | --- | ---
Fs=32K | Fs=44.1K | Fs=48K
000000 | 32Kbps | 96 | 69 | 64
000001 | 32Kbps | 96 | 70 | 64
000010 | 40Kbps | 120 | 87 | 80
000011 | 40Kbps | 120 | 88 | 80
000100 | 48Kbps | 144 | 104 | 96
000101 | 48Kbps | 144 | 105 | 96
000110 | 56Kbps | 168 | 121 | 112
000111 | 56Kbps | 168 | 122 | 112
001000 | 64Kbps | 192 | 139 | 128
001001 | 64Kbps | 192 | 140 | 128
001010 | 80Kbps | 240 | 174 | 160
001011 | 80Kbps | 240 | 175 | 160
001100 | 96Kbps | 288 | 208 | 192
001101 | 96Kbps | 288 | 209 | 192
001110 | 112Kbps | 336 | 243 | 224
001111 | 112Kbps | 336 | 244 | 224
010000 | 128Kbps | 384 | 278 | 256
010001 | 128Kbps | 384 | 279 | 256
010010 | 160Kbps | 480 | 348 | 320
010011 | 160Kbps | 480 | 349 | 320
010100 | 192Kbps | 576 | 417 | 384
010101 | 192Kbps | 576 | 418 | 384
010110 | 224Kbps | 672 | 487 | 448
010111 | 224Kbps | 672 | 488 | 448
011000 | 256Kbps | 768 | 557 | 512
011001 | 256Kbps | 768 | 558 | 512
011010 | 320Kbps | 960 | 696 | 640
011011 | 320Kbps | 960 | 697 | 640
011100 | 384Kbps | 1152 | 835 | 768
011101 | 384Kbps | 1152 | 836 | 768
011110 | 448Kbps | 1344 | 975 | 896
011111 | 448Kbps | 1344 | 976 | 896
100000 | 512Kbps | 1536 | 1114 | 1024
100001 | 512Kbps | 1536 | 1115 | 1024
100010 | 576Kbps | 1728 | 1253 | 1152
100011 | 576Kbps | 1728 | 1254 | 1152
100100 | 640Kbps | 1920 | 1393 | 1280
100101 | 640Kbps | 1920 | 1394 | 1280
100110 to 111111 | reserved

### BSI

The BSI contains many conditionally included fields, so there is no fixed alignment.

standard (A52) variable | bit length | alternate (A52a) variable
--- | --- | ---
bsid = 8 in this version | 5 | bsid = 6 in this version
bsmod | 3 | no change
acmod | 3 | :
if((acmod & 0x1) && (acmod != 0x1)) /* 3 front channels */ {cmixlev} | 2 | :
if(acmod & 0x4) /* if a surround channel exists */ {surmixlev} | 2 | :
if(acmod == 0x2) /* if in 2/0 mode */ {dsurmod} | 2 | :
lfeon | 1 | :
dialnorm | 5 | :
compre | 1 | :
if(compre) {compr} | 8 | :
lancode | 1 | :
if(langcode) {langcod} | 8 | :
audioprodie | 1 | :
if(audioprodie) {mixlevel} | 5 | :
if(audioprodie) {roomtyp} | 2 | :
if(acmod == 0) /* 1+1 mode, so some items need a second value */ |  | :
{ |  | :
dialnorm2 | 5 | :
compr2e | 1 | :
if(compr2e) {compr2} | 8 | :
lancod2e | 1 | :
if(langcod2e) {langcod2} | 8 | :
audioprodi2e | 1 | :
if(audioprodi2e) {mixlevel2} | 5 | :
if(audioprodi2e) {roomtyp2} | 2 | :
} |  | :
copyrightb | 1 | :
origbs | 1 | no change
timecod1e | 1 | xbsi1e
if(timecod1e) {timecod1} | 14 | if(xbsi1e) {
dmixmod (2 bits)
ltrtcmixlev (3 bits)
ltrtsurmixlev (3 bits)
lorocmixlev (3 bits)
lorosurmixlev (3 bits)
}
timecod2e | 1 | xbsi2e
if(timecod2e) {timecod2} | 14 | if(xbsi2e) {
dsurexmod (2 bits)
dheadphonmod (2 bits)
adconvtyp (1 bit)
xbsi2 (8 bits - reserved for future expansion)
encinfo (1 bit - reserved for encoder use)
}
addbsie | 1 | no change
if(addbsie) {addbsil} | 6 | :
if(addbsie) {addbsi} | 8*addbsil | no change

bsmod bitstream mode

bsmod | acmod | Type of Service
--- | --- | ---
000 | any | main audio service: complete main (CM)
001 | any | main audio service: music and effects (ME)
010 | any | associated service: visually impaired (VI)
011 | any | associated service: hearing impaired (HI)
100 | any | associated service: dialog (D)
101 | any | associated service: commentary (C)
110 | any | associated service: emergency (E)
111 | 001 | associated service: voice over (VO)
111 | 010 to 111 | main audio service: karaoke

acmod audio coding mode

acmod | audio coding mode | nfchans | Channel Array Order
--- | --- | --- | ---
000 | 1+1 | 2 | Ch1, Ch2
001 | 1/0 | 1 | C
010 | 2/0 | 2 | L, R
011 | 3/0 | 3 | L, C, R
100 | 2/1 | 3 | L, R, S
101 | 3/1 | 4 | L, C, R, S
110 | 2/2 | 4 | L, R, SL, SR
111 | 3/2 | 5 | L, C, R, SL, SR

cmixlev - center mix level (acmod 3, 5, 7)

value | center mix level
--- | ---
00 | 0.707 (-3.0 dB)
01 | 0.595 (-4.5 dB)
10 | 0.500 (-6.0 dB)
11 | reserved

surmixlev - surround mix level (acmod 4, 5, 6, 7)

value | surround mix level
--- | ---
00 | 0.707 (-3.0 dB)
01 | 0.500 (-6.0 dB)
10 | 0
11 | reserved

dsurmod - dolby surround mode (acmod 2)

value | indication
--- | ---
00 | not indicated
01 | Not Dolby Surround encoded
10 | Dolby Surround encoded
11 | reserved

lfeon - Low frequency effects (LFE) on, 0=off, 1=on
dialnorm - Dialog normalization, average level, in -dB, of dialog channel with respect to digital 100%. The value of 0 is reserved, and decoders should use -31 dB
compre and compr - see section 7.7.2 of A52A
langcode and langcod - reserved
audproie - audio production information exists
mixlevel - mixing level, the absolute acoustic sound pressure level of an individual channel during the final mixing session. The peak mixing level is 80 + the 5-bit value dB SPL.

roomtyp - The type and calibration of the mixing room used for the final mixing session.

roomtyp | Type of Mixing Room
--- | ---
00 | not indicated
01 | large room, X curve monitor
10 | small room, flat monitor
11 | reserved

dialnorm2, compr2e, compr2, langcod2e, langcod2, audprodi2e, mixlevel2, roomtyp2 - same as above, but for Ch2 of 1+1 mode.
copyrightb - copyright bit, 0=not protected by copyright, 1=protected by copyright.
origbs - original bit stream, 1=original, 0=copy

timecod1e, timecod1 - most significant 14 bits of time code, as follows:

13 | 12 | 11 | 10 | 9 | 8 | 7 | 6 | 5 | 4 | 3 | 2 | 1 | 0
--- | --- | --- | --- | --- | --- | --- | --- | --- | --- | --- | --- | --- | ---
hours (0-23) | minutes (0-59) | seconds/8 (0-7)

timecod2e, timecod2 - least significant 14 bits of time code, as follows:

13 | 12 | 11 | 10 | 9 | 8 | 7 | 6 | 5 | 4 | 3 | 2 | 1 | 0
--- | --- | --- | --- | --- | --- | --- | --- | --- | --- | --- | --- | --- | ---
seconds mod 8 (0-7) | frames (0-29) | 1/64 frames (0-63)

addbsie - flag for presence of additional bit stream information.
addbsil - length in bytes of additional bit stream information.
addbsi - additional bit stream information, up to 64 bytes.

#### Fields of alternate (A52a) BSI

dmixmod - preferred stereo downmix mode

dmixmod | Indication
--- | ---
00 | not indicated
01 | Lt/Rt downmix preferred
10 | Lo/Ro downmix preferred
11 | reserved

ltrtcmixlev - Lt/Rt Center Mix Level
ltrtsurmixlev - Lt/Rt Surround Mix Level
lorocmixlev - Lo/Ro Center Mix Level
lorosurmixlev - Lo/Ro Surround Mix Level

value | level
--- | ---
000 | 1.414 (+3.0 dB)
001 | 1.189 (+1.5 dB)
010 | 1.000 (0.0 dB)
011 | 0.841 (-1.5 dB)
100 | 0.707 (-3.0 dB)
101 | 0.595 (-4.5 dB)
110 | 0.500 (-6.0 dB)
111 | 0.000 (-inf dB)

dsurexmod - Dolby Surround EX Mode

dsurexmod | Indication
--- | ---
00 | not indicated
01 | Not Dolby Surround EX encoded
10 | Dolby Surround EX encoded
11 | reserved

dheadphonmod - Dolby Headphone Mode

dheadphonmod | Indication
--- | ---
00 | not indicated
01 | Not Dolby Headphone encoded
10 | Dolby Headphone encoded
11 | reserved

adconvtyp - A/D Converter zType

adconvtyp | Indication
--- | ---
0 | Standard
1 | HDCD

DVD-Video info home | Copyright © 2001 - 2020 STN Software, all rights reserved.