Expand description
AC-3 / E-AC-3 bitstream sync-header parser.
Pure-Rust, decoder-free. We only walk enough of the syncframe to populate
the dac3 / dec3 MP4 sample-entry config fields. No coefficient parsing.
Refs:
- AC-3: ETSI TS 102 366 v1.4.1 (Annex E) — same wire format as ATSC A/52. Syncword = 0x0B77 (BE). bsid<=8 (no sub-stream extensions).
- E-AC-3: ETSI TS 102 366 §E.1.2 / §E.1.3 — bsid==16; the same 0x0B77 syncword starts each independent / dependent substream frame.
Squad-26 (AC-3 + E-AC-3 passthrough into MP4) — pure-Rust per task notes (“Do NOT introduce a Dolby decoder”).
Structs§
- Ac3Sync
Info - Parsed AC-3 sync-header fields needed to populate the MP4
dac3AudioSpecificConfig box per ETSI TS 102 366 §F.4 (AC3SpecificBox). - Eac3
Sync Info - Parsed E-AC-3 sync-header fields needed to populate the MP4
dec3AudioSpecificConfig box per ETSI TS 102 366 §F.6 (EC3SpecificBox).
Enums§
- Sync
Error - Sync
Info - Parsed bitstream sync info — discriminated union returned by the
codec-agnostic
parse_sync_infoentry point.
Functions§
- ac3_
bit_ rate_ kbps - Nominal bit-rate (in kbps) for an AC-3 frame given
bit_rate_code(frmsizecod >> 1) per ETSI TS 102 366 Table F.6 / ATSC A/52 Table 5.18. 0..=18 are valid; everything above is reserved (returns 0). - ac3_
sample_ rate_ hz - Sample rate in Hz from the AC-3 fscod (Table F.5). Reserved (3) is
invalid for AC-3 — caller already rejected it; for E-AC-3 with fscod==3
the sample rate comes from
eac3_sample_rate_hzinstead. - channel_
count - Channel count derived from acmod + lfeon per ETSI TS 102 366 Table F.4. 1+1 dual-mono (acmod==0) gets two distinct mono streams (count=2). All other modes follow the conventional layout: 1.0 / 2.0 / 3.0 / 2.1 / 3.1 / 2.2 / 3.2 plus an optional LFE.
- eac3_
sample_ rate_ hz - Sample rate in Hz for an E-AC-3 frame. fscod==3 selects the reduced- rate table (24/22.05/16 kHz); otherwise the standard 48/44.1/32 kHz table applies.
- eac3_
samples_ per_ frame - Number of audio samples per E-AC-3 syncframe = numblkscod-derived blocks × 256 samples/block. AC-3 syncframes are always 6 blocks × 256 = 1536 samples.
- parse_
sync_ info - 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.