forge
Explore
Log in

Don't you dare go Hollow

Ten headroom bits under the forward network, measured on BD

Browse files at this commit

636712fa9c1c09b493428d6cfe0b048501d43e79Ahmet Kaan GümüşParent: 1be1614
  • perf
    • ten headroom bits under the forward network, measured on BD
Show full message
perf(av1): ten headroom bits under the forward network, measured on BD

Six bits of headroom left the fixed-point network's rounding worth 3.9 BD
points on screen capture against libaom. Ten put the coefficient
resolution at 1/256 of a unit of the `8 * orthonormal` scale a level is
formed on, which is where the BD gate stops moving -- 13 bits measures
identical -- and stays under 2^27 for a 12-bit residual through two
64-point passes.

BD-rate vs libaom 216.6/233.5/289.8 (base 216.4/235.5/289.2), vs rav1e
157.4/175.9/138.1 (base 157.8/178.3/141.1), 1080p/2160p/screen: six of
the eight numbers improve, screen-vs-libaom is +0.6 and 1080p-vs-libaom
+0.2.

Also measured and REVERTED: the row pass's `Vec` in a thread-local
scratch, as the inverse transform's is, +5.0% instructions -- reusing the
buffer needs a `memset` where a fresh allocation is already zeroed, and
that zeroing is what the all-zero-row skip reads. Noted at the function.
crates/ec-av1/src/transform.rsmodified+12 -5
@@ -1736,11 +1736,12 @@ const FORWARD_RANGE: usize = 32;
1736 /// The network rounds to an integer at every butterfly, so its output LSB is1736 /// The network rounds to an integer at every butterfly, so its output LSB is
1737 /// what the quantizer's input resolution costs: unshifted, one LSB at 4x4 is1737 /// what the quantizer's input resolution costs: unshifted, one LSB at 4x4 is
1738 /// four whole units of the `8 * orthonormal` scale the levels are formed on1738 /// four whole units of the `8 * orthonormal` scale the levels are formed on
1739-/// -- coarser than a fine quantizer's own step. Six bits put that back at1739+/// -- coarser than a fine quantizer's own step, and worth 3.9 BD points on
1740-/// 1/16 of a unit and cost nothing: the widest case (a 13-bit residual1740+/// screen capture. Ten bits put it at 1/256 of a unit, which is where the BD
1741-/// through two 64-point passes, gain 32) stays under 2^25, well inside `i32`1741+/// gate stops moving (13 bits measured identical), and cost nothing: the
1742-/// and far inside [`FORWARD_RANGE`].1742+/// widest case, a 12-bit residual through two 64-point passes (gain 32),
1743-const FORWARD_PRECISION_BITS: u32 = 6;1743+/// stays under 2^27 -- inside `i32` and far inside [`FORWARD_RANGE`].
1744+const FORWARD_PRECISION_BITS: u32 = 10;
1744 1745
1745 /// [`forward_dct_n`]'s uniform gain at one size, measured from the network1746 /// [`forward_dct_n`]'s uniform gain at one size, measured from the network
1746 /// itself rather than derived: an impulse through it is `g` times1747 /// itself rather than derived: an impulse through it is `g` times
@@ -1795,6 +1796,12 @@ pub fn forward_transform_2d(residual: &[i32], side: usize) -> Vec<f64> {
1795 /// The row pass, in fixed point: each of `side` residual rows through1796 /// The row pass, in fixed point: each of `side` residual rows through
1796 /// [`forward_dct_fixed`], at [`FORWARD_PRECISION_BITS`] extra precision and1797 /// [`forward_dct_fixed`], at [`FORWARD_PRECISION_BITS`] extra precision and
1797 /// the network's own gain (both of which [`forward_scale`] divides back out).1798 /// the network's own gain (both of which [`forward_scale`] divides back out).
1799+///
1800+/// The `Vec` is per call on purpose: holding it in a thread-local scratch, as
1801+/// the inverse transform's row pass does, was MEASURED +5.0% instructions on
1802+/// the sequence bench -- a fresh zeroed allocation costs less here than the
1803+/// `memset` reusing one needs plus the thread-local access, because the
1804+/// zeroing is what the all-zero-row skip below reads.
1798 fn forward_rows(residual: &[i32], side: usize) -> Vec<i32> {1805 fn forward_rows(residual: &[i32], side: usize) -> Vec<i32> {
1799 assert_eq!(1806 assert_eq!(
1800 residual.len(),1807 residual.len(),