From fd84350122c851d234ff17975348348cf47bcb46 Mon Sep 17 00:00:00 2001 From: vangel76 Date: Sun, 25 Oct 2026 12:03:57 +0100 Subject: [PATCH] opusenc: halve the a2nlsf bisection steps Each root was refined with 40 bisection steps, which shrinks the bracket to about 3e-15 rad. A Q15 NLSF step is 9.6e-5 rad, so 20 steps (3e-9 rad) are far more than the quantiser can see. The saved cos calls are the remaining bulk of the root search after the grid table. The coded packet streams are byte-identical to the 40-step search on 24 configurations of 90 s: speech-like and music-like input, mono and stereo, SILK NB 8k, MB 12k, WB 16k and 32k, hybrid SWB 32k and FB 64k. Co-Authored-By: Claude Sonnet 5.5 --- crates/opusenc/src/silk/analysis.rs | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/crates/opusenc/src/silk/analysis.rs b/crates/opusenc/src/silk/analysis.rs index 2808b64b1..c84619222 100644 --- a/crates/opusenc/src/silk/analysis.rs +++ b/crates/opusenc/src/silk/analysis.rs @@ -88,8 +88,8 @@ fn cos_series(p: &[f64], w: f64) -> f64 { const GRID: usize = 1024; /// Largest multiple of ω in the series (half the LPC order, at most 16 / 2). const MAX_H: usize = 8; -/// Bisection steps per root. -const BISECT_STEPS: usize = 40; +/// Bisection steps per root: the bracket shrinks to 3e-9 rad, far below one Q15 NLSF step (9.6e-5 rad). +const BISECT_STEPS: usize = 20; /// `cos(m · π g / GRID)` for every grid point `g` and `m` in `0..=MAX_H`, computed with the same /// expression as [`cos_series`], so the table values are bit-identical to calling `cos` there.