forge
Explore
Log in

Don't you dare go Hollow

Switch the spectral extension noise with the dither option

Browse files at this commit

6432e088c0dc1d9bc768d2bc01f6010bfcb54bafAhmet Kaan GümüşParent: 9a40807
  • fix
    • switch the spectral extension noise with the dither option
Show full message
fix(ac3): switch the spectral extension noise with the dither option

§E3.6.4.2.4's noise() is a zero-mean unit-variance source the standard
leaves to the implementation, exactly like §7.3.4's dither: two conformant
decoders differ by it and by nothing else. It now follows the same option,
so a comparison against another decoder can isolate what the standard does
specify, and the default still generates both.

On the Dolby Digital Plus track that uses spectral extension this is the
whole remaining difference: 0.9988 per-channel correlation with both
decoders' noise in, 0.9994 with it out.
crates/ec-ac3/src/decoder.rsmodified+9 -6
@@ -38,13 +38,16 @@ pub struct Options {
38 pub drc_scale: f32,38 pub drc_scale: f32,
39 /// Channel folding, off by default.39 /// Channel folding, off by default.
40 pub downmix: Downmix,40 pub downmix: Downmix,
41- /// Substitute pseudo-random noise for zero-bit mantissas (§7.3.4), which41+ /// Generate the pseudo-random noise the format asks for: dither in place
42- /// is what the standard asks a decoder to do and what this defaults to.42+ /// of zero-bit mantissas (§7.3.4) and the blend that fills the spectral
43+ /// extension band (§E3.6.4.2.4). On by default, because both are what the
44+ /// standard asks a decoder to do.
43 ///45 ///
44- /// The sequence itself is implementation-defined ("any reasonably random46+ /// Neither sequence is specified — §7.3.4 says "any reasonably random
45- /// sequence"), so two conformant decoders differ by exactly this noise;47+ /// sequence" and §E3.6.4.2.4 just names a zero-mean unit-variance source —
46- /// turning it off is how a comparison against another decoder isolates48+ /// so two conformant decoders differ by exactly this noise and nothing
47- /// everything else.49+ /// else. Turning it off is how a comparison against another decoder
50+ /// isolates everything that *is* specified.
48 pub dither: bool,51 pub dither: bool,
49 }52 }
50 53
crates/ec-ac3/src/lib.rsmodified+8 -8
@@ -24,19 +24,19 @@
24 //! it down or off.24 //! it down or off.
25 //! - **Dialogue normalisation is surfaced, never applied.** §7.6 puts25 //! - **Dialogue normalisation is surfaced, never applied.** §7.6 puts
26 //! `dialnorm` in the volume control, which is not in this crate.26 //! `dialnorm` in the volume control, which is not in this crate.
27-//! - **Dither is on by default** (§7.3.4) but its sequence is27+//! - **The noise this format asks for is on by default**: dither for zero-bit
28-//! implementation-defined, so two conformant decoders differ by exactly that28+//! mantissas (§7.3.4) and the spectral extension blend (§E3.6.4.2.4). Neither
29-//! noise; [`Options::dither`] turns it off when a comparison needs to29+//! sequence is specified, so two conformant decoders differ by exactly that
30+//! noise; [`Options::dither`] turns both off when a comparison needs to
30 //! isolate everything else.31 //! isolate everything else.
31 //!32 //!
32 //! Annex E coverage: the adaptive hybrid transform (with its vector and33 //! Annex E coverage: the adaptive hybrid transform (with its vector and
33 //! gain-adaptive quantizers) and spectral extension are decoded; enhanced34 //! gain-adaptive quantizers) and spectral extension are decoded; enhanced
34 //! coupling and dependent substreams above 5.1 are refused by name rather than35 //! coupling and dependent substreams above 5.1 are refused by name rather than
35-//! decoded wrongly. On a real Dolby Digital Plus stream that uses AHT and36+//! decoded wrongly. On a real Dolby Digital Plus stream that uses both, the
36-//! spectral extension the output tracks ffmpeg's to a per-channel correlation37+//! coded bins land within 0.01% of ffmpeg's energy and the whole channel within
37-//! of 0.994 rather than the 0.9999 the rest of the format reaches — the38+//! 0.999 correlation once the two decoders' independent noise is taken out of
38-//! remaining difference is in the AHT quantizer detail and the two decoders'39+//! the comparison ([`Options::dither`]).
39-//! independent noise sources.
40 //!40 //!
41 //! No unsafe, no allocation on the block path beyond the output buffer, and no41 //! No unsafe, no allocation on the block path beyond the output buffer, and no
42 //! dependencies beyond the family IR and DSP crates.42 //! dependencies beyond the family IR and DSP crates.