forge
Explore
Log in

Don't you dare go Hollow

edith_codecs

Clone
★ 0

0 watching0 forksRust370.3 MiB9b67700Tahinli3 days ago4021 commits

lib.rs59 lines, 2.7 KiBHistoryRawDownload
1//! DTS Coherent Acoustics decoding, from ETSI TS 102 114.
2//!
3//! - [`DtsDecoder`] takes core frames (with or without a DTS-HD extension
4//! substream behind them) and hands back interleaved `f32` audio frames in
5//! the coded channel layout.
6//! - [`parse_frame_header`] and [`frame_size`] read the core header alone,
7//! which is what a container or a raw `.dts` sniffer needs to state a
8//! track's sample rate, channel count and frame length before decoding.
9//! - [`exss::parse_exss`] reads a DTS-HD extension substream header.
10//!
11//! Contracts worth knowing before implementing against this crate:
12//!
13//! - **Every stream word order is accepted**: 16-bit big endian (canonical),
14//! 16-bit little endian, and 14-bit-in-16 in either byte order. They are
15//! converted to the canonical bit string before anything is parsed.
16//! - **Decoding is integer and exact.** The subband samples, the quantizers
17//! and the synthesis bank are fixed point with 24-bit saturation, so the
18//! same stream gives the same 24-bit samples everywhere. Output is `f32`
19//! with 24-bit samples scaled by 2^-23, which `f32` holds without loss.
20//! - **DTS-HD**: the output is always the backward compatible core. XLL
21//! (lossless) is not decoded; it is named in [`FrameInfo::xll`] and
22//! [`Options::refuse_xll`] turns it into an explicit [`Error::Unsupported`].
23//! XBR, XXCH and LBR layers are ignored by name in
24//! [`FrameInfo::hd_extensions_ignored`].
25//! - **Downmix flags, dialogue normalisation and dynamic range data are
26//! surfaced where they are in the header and never applied.**
27//! - **Truncated input is [`Error::NeedMore`]**, a broken bit stream is
28//! [`Error::Corrupt`] and a construct this build does not implement is
29//! [`Error::Unsupported`] naming what and why. No input panics.
30//!
31//! The constant tables in [`tables_data`] are generated by
32//! `tools/gen_dts_tables.py` from the numeric tables printed in ETSI TS 102 114
33//! V1.6.1 and checked against them by `tests/spec_tables.rs`; the few tables
34//! the standard does not print usably are in `tables_residual.rs`.
35
36#![forbid(unsafe_code)]
37#![warn(missing_docs)]
38#![allow(clippy::needless_range_loop)]
39
40mod bits;
41mod core;
42mod dct;
43mod decoder;
44pub mod exss;
45mod header;
46mod huff;
47mod math;
48#[allow(missing_docs, clippy::excessive_precision)]
49pub mod tables_data;
50mod tables_residual;
51
52pub use crate::core::Extensions;
53pub use decoder::{DtsDecoder, FrameInfo, Options};
54pub use ec_core::Error;
55pub use header::{
56 find_sync, frame_size, parse_frame_header, to_canonical, FrameHeader, StreamFormat,
57 BIT_RATES, CHANNELS, PCM_RESOLUTION, SAMPLE_RATES, SYNC_CORE, SYNC_CORE_14_BE,
58 SYNC_CORE_14_LE, SYNC_CORE_LE, SYNC_EXSS,
59};