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 {
3838 pub drc_scale: f32,
3939 /// Channel folding, off by default.
4040 pub downmix: Downmix,
41- /// Substitute pseudo-random noise for zero-bit mantissas (§7.3.4), which
42- /// is what the standard asks a decoder to do and what this defaults to.
41+ /// Generate the pseudo-random noise the format asks for: dither in place
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.
4345 ///
44- /// The sequence itself is implementation-defined ("any reasonably random
45- /// sequence"), so two conformant decoders differ by exactly this noise;
46- /// turning it off is how a comparison against another decoder isolates
47- /// everything else.
46+ /// Neither sequence is specified — §7.3.4 says "any reasonably random
47+ /// sequence" and §E3.6.4.2.4 just names a zero-mean unit-variance source —
48+ /// so two conformant decoders differ by exactly this noise and nothing
49+ /// else. Turning it off is how a comparison against another decoder
50+ /// isolates everything that *is* specified.
4851 pub dither: bool,
4952 }
5053
crates/ec-ac3/src/lib.rsmodified+8 -8
@@ -24,19 +24,19 @@
2424 //! it down or off.
2525 //! - **Dialogue normalisation is surfaced, never applied.** §7.6 puts
2626 //! `dialnorm` in the volume control, which is not in this crate.
27-//! - **Dither is on by default** (§7.3.4) but its sequence is
28-//! implementation-defined, so two conformant decoders differ by exactly that
29-//! noise; [`Options::dither`] turns it off when a comparison needs to
27+//! - **The noise this format asks for is on by default**: dither for zero-bit
28+//! mantissas (§7.3.4) and the spectral extension blend (§E3.6.4.2.4). Neither
29+//! sequence is specified, so two conformant decoders differ by exactly that
30+//! noise; [`Options::dither`] turns both off when a comparison needs to
3031 //! isolate everything else.
3132 //!
3233 //! Annex E coverage: the adaptive hybrid transform (with its vector and
3334 //! gain-adaptive quantizers) and spectral extension are decoded; enhanced
3435 //! 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 and
36-//! spectral extension the output tracks ffmpeg's to a per-channel correlation
37-//! of 0.994 rather than the 0.9999 the rest of the format reaches — the
38-//! remaining difference is in the AHT quantizer detail and the two decoders'
39-//! independent noise sources.
36+//! decoded wrongly. On a real Dolby Digital Plus stream that uses both, the
37+//! coded bins land within 0.01% of ffmpeg's energy and the whole channel within
38+//! 0.999 correlation once the two decoders' independent noise is taken out of
39+//! the comparison ([`Options::dither`]).
4040 //!
4141 //! No unsafe, no allocation on the block path beyond the output buffer, and no
4242 //! dependencies beyond the family IR and DSP crates.