Skip to main content

parse_sync_info

Function parse_sync_info 

Source
pub fn parse_sync_info(bytes: &[u8]) -> Result<SyncInfo, SyncError>
Expand description

Discriminate AC-3 vs E-AC-3 from the bsid field and parse the relevant sync header. Both wire formats share the leading 0x0B77 sync word.

The bsid byte sits at byte offset 5 in either format: syncword 0x0B77 (2) | crc1 (2) | fscod+frmsizecod (1) | bsid… ← For AC-3 (bsid≤10) the upper 5 bits of byte 5 are bsid; the lower 3 are bsmod. For E-AC-3 (bsid=16) the byte layout is different but bsid still occupies the top 5 bits of byte 5 (after a strmtyp+substreamid+ frmsiz reordering at bytes 2-4). The shared “bsid is the top 5 bits of byte 5” property gives us the discriminator without parsing the rest first.