//! Dolby TrueHD and MLP decoding for the edith_codecs family. //! //! Written from Dolby's public TrueHD/MLP documentation of the bitstream's //! *shape* — major sync, per-substream access-unit directory, FIR/IIR filter //! parameters, the Huffman/LSB entropy coder and matrixing — not from any //! third party's source. The syntax layer ([`sync`]) and the lossless //! substream decode ([`decode`], reached through //! [`TrueHdDecoder::decode_access_unit`]) are both verified bit-exact //! against an external decoder on a real 7.1 Blu-ray remux (first 60 s, //! 23 040 000 of 23 040 000 samples) and on externally encoded MLP/TrueHD //! mono, stereo and 5.1 streams. //! //! Scope, stated once so a caller knows what to expect: //! //! - **In scope**: major sync detection and parsing (format id, sample rate, //! channel presentations), the access-unit header's per-substream //! directory (end pointers, checksum/parity), and the //! three PCM-presentation substreams a real Blu-ray track carries: 2-ch, //! 6-ch (5.1) and 8-ch (7.1), each built from restart headers, FIR/IIR //! predictor filters, Huffman/LSB residual entropy and the channel //! matrixing that turns decorrelated substream channels back into PCM, //! plus the stream's own lossless check. //! - **Atmos streams are decoded as their PCM presentations**: a TrueHD //! stream may carry a 4th substream (Dolby Atmos object audio, a 16-channel //! extension). It is backward compatible: substreams 0..2 are the ordinary //! 2-ch, 6-ch and 8-ch PCM presentations, and the decoder reconstructs the //! highest of them (8-ch, 7.1) exactly as it does for a 3-substream stream. //! The 4th substream is located through its directory end pointer and //! skipped, not decoded, the way legacy decoders (ffmpeg's included) do. Its //! bytes are never read, so its parity is not checked. A directory with more //! than 4 entries is [`Error::Corrupt`]. //! - **Out of scope, refused by name via [`Error::Unsupported`]**: decoding the //! Atmos object audio itself (the 16-channel presentation carried by the 4th //! substream), a different payload riding the same access unit and not a //! bigger version of the 3 PCM presentations above; a PCM substream asking //! for more than 8 matrix channels; and any metadata semantics beyond parsing //! the bytes (dialogue normalisation curves, downmix hints and the like stay //! unopinionated data on the parsed structs, same as this family treats //! AC-3's `dialnorm`). //! //! No unsafe, no panics on malformed input: truncated data is //! [`Error::NeedMore`], a bitstream that violates its own rules is //! [`Error::Corrupt`], and a construct this build does not implement is //! [`Error::Unsupported`] naming *what* and *why*. #![forbid(unsafe_code)] #![warn(missing_docs)] pub mod decode; pub mod encode; pub mod sync; pub use decode::CheckStats; pub use ec_core::Error; pub use encode::TrueHdEncoder; pub use sync::{ AccessUnitHeader, MajorSyncFormat, MajorSyncInfo, SubstreamInfo, TrueHdDecoder, frame_length, };