Reading Dolby AC-4 frames from an .ac4 file
In an .ac4 file, each raw_ac4_frame
is
encapsulated in an ac4_syncframe
, as defined in ETSI TS 103 190-1. An AC-4 sync frame must first be converted to a raw AC-4 frame by stripping its sync word, frame size, and optional
CRC words before packetization.
Procedure
-
To locate the start of an AC-4 raw frame,
search for the 16-bit sync word. The value of the sync word can be either
0xAC40
or0xAC41
. -
Read the 16 bits immediately succeeding the sync word.
- If the 16-bit value is not equal to
0xFFFF
, the value is the frame size. - If the 16-bit value is equal to
0xFFFF
, read the next 24 bits as the frame size.
- If the 16-bit value is not equal to
- According to the frame size, read the next bits succeeding the frame size as the raw AC-4 frame.
- Optional :
If the sync word is
0xAC41
, the AC-4 simple transport frame includes a 16-bit CRC word based on theframe_size
element and theraw_ac4_frame
element. Read the 16 bits immediately succeeding the raw AC-4 frame, and verify that the value matches the CRC calculated using the IBM-CRC-16 polynomial:x¹⁶+x¹⁵+x²+1
. -
Read the next 16 bits.
- If the sync word is
0xAC40
, they are the 16 bits immediately succeeding the raw AC-4 frame. - If the sync word is
0xAC41
, they are the 16 bits immediately succeeding the CRC word.
- If the sync word is
- Verify that the 16-bit word is also a sync word; otherwise, this is not a proper AC-4 bitstream.