Files
effectcraft/crates
68a637adb9 opusenc: memoise SILK rate-loop trials, ring buffer for noise feedback (#2399)
* opusenc: memoise SILK rate-loop trials, ring buffer for noise feedback

Rate loop: each probe clones the encoder and the range coder and codes the
whole frame, about 7 trials per frame. The hard-limit check recomputed the
trial of the chosen offset and the final step coded the frame a third time.
Keep every trial (offset, bits, encoder state, range coder): the hard-limit
check now hits the memo and the final step adopts the memoised state and
coder. If the chosen offset is somehow not in the memo it is coded as before.

Quantiser: the noise-feedback history was shifted with copy_within for every
sample (the quantiser runs about 7 times per frame). Keep it in a
double-length ring so the 16 most recent errors are one contiguous slice;
the dot product reads the same pairs in the same order, and the history is
written back to the channel at the end.

The packet streams are byte-identical to before (cmp on 24 configurations
of 90 s: speech-like and music-like input, mono and stereo, SILK NB/MB/WB
and hybrid SWB/FB).

Co-Authored-By: Claude Sonnet 5.5 <noreply@anthropic.com>

* opusenc: noise-feedback ring as a helper type, equivalence tests for the SILK rate loop

`quantize` was at cognitive complexity 31 on current main (limit 30). The
double-length ring for the noise-feedback history moves into `NfRing`
(push / window / to_array), and the end-of-frame bookkeeping of `encode`
into `end_frame`.

Tests: the ring matches a shifted history over 100 pushes, and an encoder
that adopts the memoised trial produces the same bytes, noise-feedback
history and LPC state, frame after frame, as one that codes every frame
again at the chosen offset (the step before the memo), for 8/12/16 kHz,
mono and stereo, with and without a tight hard limit.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>

---------

Co-authored-by: Claude Sonnet 5.5 <noreply@anthropic.com>
Co-authored-by: FredApps <153173854+FredApps@users.noreply.github.com>
2026-11-06 22:35:42 +01:00
..
2026-11-03 09:05:06 -05:00