forge
Explore
Log in

Don't you dare go Hollow

edith_codecs

Clone
★ 0

0 watching0 forksRust370.3 MiB214cdf2Tahinli3 months ago821 commits

lib.rs45 lines, 2.0 KiBHistoryRawDownload
1//! Vorbis I — decoder and encoder.
2//!
3//! The decoder is the whole format: both floor types, all three residue types,
4//! square-polar channel coupling, every legal blocksize and the four window
5//! shapes a long block takes next to a short one. It is written against the
6//! Xiph Vorbis I specification and nothing else.
7//!
8//! The encoder is deliberately narrower and states its own terms:
9//!
10//! - **Any channel count, natively.** Mono, stereo and surround each get a
11//! setup header written for that layout, with coupling where coupling pays
12//! (stereo) and none where it does not. There is no stereo-only profile to
13//! work around and no dual-mono widening of a mono mix.
14//! - **No pre-roll.** The first block is centred on input sample 0, so the
15//! decoder's first output sample *is* input sample 0. A caller does not feed
16//! silence ahead of the mix and does not subtract a hop from every granule.
17//! - **Exact length.** The last packet's granule states the input's own sample
18//! count, so a file decodes to exactly as many samples as went in — no block
19//! grid overshoot survives to the player.
20//! - **ABR.** [`EncoderConfig::bitrate_bps`] is tracked by a feedback loop over
21//! the headroom the floor leaves under the masking curve;
22//! [`EncoderConfig::quality`] sets where that loop starts, and holds the
23//! headroom still when no bitrate is asked for. The loop tracks rather than
24//! hits: a signal too simple to spend the budget on comes out under it.
25//!
26//! Timing contract: an audio packet answers the samples that became final when
27//! its window closed, so the *first* packet of a stream answers none. That is
28//! Vorbis, not an artefact — a block's left half is only half of the samples it
29//! overlaps.
30
31#![forbid(unsafe_code)]
32#![warn(missing_docs)]
33
34mod bits;
35mod codebook;
36mod decode;
37mod encode;
38mod floor;
39mod residue;
40mod setup;
41mod window;
42
43pub use decode::{VorbisDecoder, channel_map};
44pub use encode::{BlockLog, EncoderConfig, VorbisEncoder};
45pub use setup::{Comments, Identification};