1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
//! Pure-Rust Dolby AC-4 audio decoder foundation.
//!
//! AC-4 is a complex, hierarchical codec — multiple presentations,
//! nested substream descriptors, ASF/ASF-A2/A-SPX coefficient streams
//! driven by huffman-coded scalefactor data, plus an EMDF metadata
//! sidecar carrying DRC / downmix / dialog-norm info. Full decode is
//! weeks of work.
//!
//! What this crate lands today (per ETSI TS 103 190-1 V1.4.1):
//!
//! * **Sync framing** — `ac4_syncframe()` from Annex G: `0xAC40` plain
//! and `0xAC41` CRC-protected, 16-bit `frame_size()` with 24-bit
//! escape, plus a standalone CRC-16 helper. See [`sync`].
//! * **Table of contents** — full `ac4_toc()` walker in [`toc`]:
//! bitstream_version, sequence_counter, fs_index, frame_rate_index,
//! b_iframe_global, payload_base, per-presentation
//! `ac4_presentation_info()` (single / multi-substream, configs 0..=5
//! + extension escape, HSF extension, pre-virtualised flag, extra
//! EMDF substreams), per-substream `ac4_substream_info()`
//! (channel_mode prefix decoder, sf_multiplier, bitrate_indicator,
//! content_type w/ language tag, b_iframe),
//! `substream_index_table()` byte sizes, and the `variable_bits(n)`
//! codec.
//! * **Decoder** — [`decoder::Ac4Decoder`] accepts either a sync-wrapped
//! packet (`0xAC40` / `0xAC41` prefix) or a bare MP4-style
//! `raw_ac4_frame` payload, parses the TOC, and emits a silent S16
//! `AudioFrame` with the correct channel count, sample rate, and
//! samples-per-frame for the stream configuration.
//!
//! Known gaps (Unsupported or stubbed):
//!
//! * ASF / ASF-A2 / A-SPX substream coefficient decoding — the
//! generated PCM is silence.
//! * Per-substream `metadata()` payload parsing (DRC, dialog norm,
//! downmix coefficients) — bits are skipped via `substream_size`.
//! * TS 103 190-2 IFM (immersive / object) decoding.
//! * Encoder.
//!
//! Downstream consumers should therefore treat this crate as a
//! container / framing aid today and expect the audio to be silent
//! until the coefficient pipeline lands.
use ;
use ;
/// Canonical codec id.
pub const CODEC_ID_STR: &str = "ac4";
/// Register the AC-4 decoder in a codec registry.