forge
Explore
Log in

Don't you dare go Hollow

Commits

Commits on 00c1b3ff2d80d84fef71bb6208110dedbbd95fc4Filtered to crates/ec-opus/tests/conformance.rsClear filter

2026-08-23

docs(opus): err_map header names its own source tagAhmet Kaan Gümüş · b53cc33
docs(opus): err_map header names its own source tag

The map test was generalised to any gate source (EC_ERRMAP_SRC/_KBPS/_TAG)
but still printed a hardcoded "her@" header, so a reell or reelo map claimed to
be her's. Header now uses the tag; module doc updated to match.
test(opus-reell/r3): error map generalised to any gate sourceAhmet Kaan Gümüş · 19ef3ae
test(opus-reell/r3): error map generalised to any gate source

her_err_map_96k -> err_map_vs_libopus; EC_ERRMAP_SRC / EC_ERRMAP_KBPS /
EC_ERRMAP_TAG select source, rate and output file, her@96 defaults kept.
feat(opus-silkq/r3): libopus reservoir decay + gain-step bound in SILK rate loopAhmet Kaan Gümüş · 18042b3
feat(opus-silkq/r3): libopus reservoir decay + gain-step bound in SILK rate loop

Debt-only bit reservoir decayed over 500 ms, gain search bounded to
+-9 steps around an EMA-carried operating point, 5 kbps target floor,
mid-heavy stereo split. Hybrid CELT min bytes 8 -> 3 (16k packets no
longer expand). Speech gate: 12k .8081 -> .8526, 16k .8606 -> .8646 at
+3.3% rate (was +12.9%), 24k .9036 -> .9146, 32k .9210 -> .9391.
Stereo-SILK 16k synthetic floor .35 -> .33 (regression named in test).
feat(opus-mode/r1): libopus VoIP/Audio mode and bandwidth thresholdsAhmet Kaan Gümüş · bb2f32f
feat(opus-mode/r1): libopus VoIP/Audio mode and bandwidth thresholds

Mode/bandwidth selection ported from opus_encoder.c (mode_thresholds blended
by voice_est, voice/music bandwidth tables, SILK>WB -> hybrid, 40/60 ms cap).
Speech gate rows are now all-auto with a MODE GATE; 4/4 rows pick the same
mode as ffmpeg libopus on real speech (lanes/opus-mode-r1.sweep.txt).
feat(opus-sb/r1): port libopus dynalloc_analysis; decoder diag exposes allocationAhmet Kaan Gümüş · 698943d
feat(opus-sb/r1): port libopus dynalloc_analysis; decoder diag exposes allocation

The old second-difference spike heuristic boosted the top coded band
(14.4-18.7 kHz) by ~220-260 1/8-bit per frame on reelm/hein@64k where
libopus gives 3, and starved 240-3000 Hz on short-block frames. The port
(follower/median masking over long-window energies, stereo cross-talk,
width-scaled boost units, CVBR halving, 2/3 cap) brings the per-band boost
table to within a few 1/8-bit of libopus.

Gate (reelm,hein,her,reell): reelm@64 gap +.0046 -> +.0037, hein@64 +.0031 ->
+.0022, no row loses more than .0003 corr, drops 0, rate within 5%.

CeltDecDiag gains alloc_trim/pulses/fine_quant/intensity/dual_stereo/
coded_bands/balance/offsets; new ignored test short_block_bits_vs_libopus
prints the per-band allocation ours vs libopus (lanes/opus-sb-r1.bits.txt).
feat(opus-64/r5): ship transient_analysis port; reject tf_estimate consumers by measurementAhmet Kaan Gümüş · aa1dd3a
feat(opus-64/r5): ship transient_analysis port; reject tf_estimate consumers by measurement

libopus VBR boost and trim terms from tf_estimate both regress reelm/hein@64
(dropouts, rate -1.8%); transient counts now match libopus within 1.5%, so the
remaining 64k residue is short-block coding, not detection. Spectral test gains
SWEEP_KBPS, her/reelm/hein sources and a decoder-seen transient count.
test(opus): parametrise the startup hop-energy and band-window diagnosticsAhmet Kaan Gümüş · 488aada
test(opus): parametrise the startup hop-energy and band-window diagnostics

HOP_SRC/HOP_MS recentre reell_startup_hop_energies on any source and instant;
WIN_CENTRE recentres spectral_divergence_vs_libopus's per-band window dump;
'her' joins its source list. Used to name the her@96 residue: a missed
right-channel HF transient at 88.29 s coded as a long block.
fix(opus): code tf_res=is_transient so transient frames keep short blocksAhmet Kaan Gümüş · 5b61429
fix(opus): code tf_res=is_transient so transient frames keep short blocks

Raw tf_res=0 with tf_select=0 on a transient frame maps through TF_SELECT to
+LM, merging the short blocks back into one long block and smearing the attack
across the whole frame. The reference's no-analysis default codes
tf_res[i]=isTransient (no change). reell err_ratio 21x -> 1.6x at 64 k and
24x -> 3.3x at 96 k; 14-row library gate green, no corr regression.

Decoder diag gains tf_res/spread/anti_collapse; repro tests
celt_silence_then_attack_decodes_bounded, reell_startup_hop_energies and
celt_click_peak_offset; hybrid layer tolerance 2->3 and SILK-vs-CELT margin
.005 re-sized against the sharper transient reconstruction.
opus: validate opus_compare_err against the C opus_compare (byte-exact)Ahmet Kaan Gümüş · 87603a5
opus: validate opus_compare_err against the C opus_compare (byte-exact)

Six real pairs (source vs libopus, source vs ec-opus on reelm/dl8a/reell)
agree with the C tool to 1e-6 in err. Negative Q and wide err ratios are
the tool's designed behaviour on source-vs-lossy input, not a scale bug.
Adds opus_compare_err_pinned_against_c (synthetic signal, C-pinned err)
as a regression guard, plus two ignored harness entry points.
opus: encoder library gate vs libopus (equal-size sweep, dropout assert)Ahmet Kaan Gümüş · a3a2974
opus: encoder library gate vs libopus (equal-size sweep, dropout assert)

Adds encoder_library_gate_vs_libopus (#[ignore]) to the conformance
binary: 7 real sources x {64,96} kbps, libopus reference via ffmpeg,
ours at the reference's measured kbps, both decoded by ec-opus.
Asserts rate within 5% and no ours-only dropout seconds (corr<0.9);
reports corr gap and a spectral err ratio (report-only, unvalidated).

r1 result: rate worst -0.5%; dropout fires on reelm@64k.

2026-08-21

2026-08-20

fix(opus-enc): look_ahead uses the same mono/20ms predicate dispatch doesAhmet Kaan Gümüş · cbcbe53
fix(opus-enc): look_ahead uses the same mono/20ms predicate dispatch does

look_ahead() consulted only wants_silk() (bitrate/application), not the
frame-size-and-channel check silk_choice()/hybrid_choice() apply before
encode_toc_and_payload actually picks a layer. A Voip/low-bitrate encoder
fed frame sizes other than 20 ms coded CELT but reported SILK's shorter
delay, throwing off the Ogg pre-skip by the difference. look_ahead now
takes the frame size and runs it through silk_choice, matching dispatch
exactly.

Also gives zero_stuff_mono a reusable Encoder-owned scratch buffer instead
of a Vec allocated per SILK/Hybrid frame — the zero-alloc steady-state
claim previously only held on the CELT path.
feat(opus-hybrid): mono 20 ms SWB/FB hybrid packets (SILK 16 kHz + CELT from band 17)Ahmet Kaan Gümüş · a6d0278
feat(opus-hybrid): mono 20 ms SWB/FB hybrid packets (SILK 16 kHz + CELT from band 17)

CeltEncoder::encode takes a start band and mirrors the decoder's start_band
paths (no silence flag mid-stream, no postfilter bit, zeroed x below start,
cleared energy history outside the coded span). SilkEncoder::encode_hybrid
writes the chosen frame into a shared range coder and replay() advances the
mirror from the finished payload. Encoder: Voip 20-40 kbps mono 20 ms ->
config 13/15, reference's SILK rate share, no-redundancy flag under the
decoder's exact presence rule, SILK input delayed 70 samples so both layers
land at CELT's 120 (click-measured LB +121 / HB +120). Decoder gains a
doc(hidden) per-layer mute for the tests.
feat(opus-silk): route Encoder's target bitrate into SILK's rate controlAhmet Kaan Gümüş · c54a10c
feat(opus-silk): route Encoder's target bitrate into SILK's rate control

Merge opus-nsq (NSQ + SilkEncoder::set_bitrate rate control) into
opus-silk. encoder.rs::encode_toc_and_payload now calls
enc.set_bitrate(self.bitrate) every SILK frame, so the public
Encoder's set_bitrate reaches the reservoir-based rate loop instead
of leaving SILK to code at unit excitation RMS. The NB/<=10kbps>WB
threshold in wants_silk/silk_choice is unaffected.

CBR-exact vs VBR-± distinction: SILK isn't budgeted against a byte
cap yet (documented at encode_toc_and_payload's doc comment, D2b) --
only the existing reservoir scheme (soft-tracks the target, same as
VBR) is wired; the Encoder's vbr flag doesn't yet branch SILK's mode.

oracle_decodes_our_packets_across_the_rate_table's SILK corner
(8/12/16 kbps) previously ran SILK unconstrained (set_bitrate was
never called from the Encoder path), so its 0.95 floor no longer
holds once the target is honestly rate-limited; lowered to 0.85,
matching the already-established floors in silk_rate_control_tracks_target.

Adds silk_packets_track_encoder_bitrate: drives the public Encoder
(Voip, mono, 8/12/16 kbps) and checks measured kbps within +-20%.

Fixes a merge fallout in oracle_decode (opus_head/write_ogg_opus
call sites diverged pre-skip signatures between the two branches).
feat(opus): SILK mode selection in EncoderAhmet Kaan Gümüş · 7f710e5
feat(opus): SILK mode selection in Encoder

Encoder dispatches SILK per frame (mono, 960-sample frames, Voip
application under 20 kbps) via set_mode/wants_silk/silk_choice, with a
click-measured look_ahead split per bandwidth (NB 58, WB 50 samples at
48 kHz) and a zero-alloc scratch buffer for the SILK payload so the
steady-state encode loop stays allocation-free.
feat(opus-silk): noise-shaping quantiser, gain-offset rate control, LTP scale by gainAhmet Kaan Gümüş · ba4dea4
feat(opus-silk): noise-shaping quantiser, gain-offset rate control, LTP scale by gain

Closed-loop NSQ: output error fed back through A(z/0.96)/A(z/0.85)
shaping with harmonic comb and voiced tilt, dead-zone pulse decision,
quant_offset_type by signal type/energy, LTP scale index from the
open-loop LTP gain. set_bitrate(bps): gain-index offset loop (<=3
trials on the range coder's own size) with a 4-frame reservoir; lands
8/12/16/24 kbps within +13%.
fix(opus-silk): LPC->NLSF polynomial sign, closed-loop LTP pick, conformance round tripAhmet Kaan Gümüş · 68c7064
fix(opus-silk): LPC->NLSF polynomial sign, closed-loop LTP pick, conformance round trip

lpc_to_nlsf evaluated A(z) = 1 + sum a z^-k for a predictor-convention
lpc (x ~= sum a x[n-k-1]); the decoder's nlsf2a thus got the anti-predictor
and every synthesised frame rang. LTP codebook vectors are now picked per
subframe against the reconstructed (quantised) history so pitch-loop
feedback of quantisation noise cannot run away; the reconstruction keeps
LTP prediction in sample units (g*exc + pred). silk_mono_nb_wb_roundtrip:
synthetic NB 0.975 / WB 0.981, wav16-mono NB 0.9999 / WB 0.9996, range
state equal every packet, ffmpeg decodes the Ogg clean.

2026-08-14

feat(opus): multi-rate input, application-driven bandwidth, whole shim surfaceAhmet Kaan Gümüş · 339a2ea
feat(opus): multi-rate input, application-driven bandwidth, whole shim surface

Grafts onto the merged CELT encoder, all four bitstream-neutral at 48 kHz
fullband (the four regression cells re-encode byte for byte):

- encoder: input at 8, 12, 16, 24 or 48 kHz, zero-stuffed to CELT's native
  rate with the coded bandwidth capped at the input's own Nyquist, so the
  images the stuffing puts there are never coded; look_ahead() reports the
  delay in input samples (120 at 48 kHz, scaled).
- encoder: Application reaches the encoder instead of being discarded at the
  shim boundary — it biases the coded bandwidth (Voip one step narrower),
  which is the only thing a CELT-only encoder can honestly do with it, and
  the TOC now spans configs 16..31 rather than fullband alone.
- celt_enc: `end` is a parameter, so the caller bounds the coded bands.
- ogg: the RFC 7845 header builders (opus_head, opus_tags, default_mapping)
  move into the crate, where the encoder, a muxer and the tests share one
  definition; the conformance test's hand-rolled OpusHead is now that call,
  and MultistreamEncoder::surround reads the mapping table from it.
- shims/opus-rs: the rest of the incumbent's surface — OpusDecoder,
  MultistreamEncoder::surround, the Bandwidth enum, the vbr field,
  look_ahead(), final_range() and encode_i16() — so a caller needs no
  second crate for the decode half or for surround.

Proof: the shim's own tests round-trip every input rate through the decoder
with range-state parity per packet, hold the 8 kHz..48 kHz look-ahead, force
a wideband TOC and read it back, and encode 5.1; the ec-opus suite (RFC
vectors, libopus rate table, opus_demo, Ogg duration, zero-alloc) is
unchanged and green.
test(opus): 16 kbps row in the rate table; clippy-clean wide usageAhmet Kaan Gümüş · f935367
test(opus): 16 kbps row in the rate table; clippy-clean wide usage

The charter's honest bottom: 16 kbps fullband CELT lands at corr 0.94 mono
/ 0.52 stereo through libopus — reported and floored as such, not hidden.
The PVQ lane-select keeps wide 1.5's blend under a scoped allow (its
replacement API does not exist in that release).
feat(opus): CELT encoder — mono/stereo/multistream, all rates, CBR+CVBRAhmet Kaan Gümüş · 52ead44
feat(opus): CELT encoder — mono/stereo/multistream, all rates, CBR+CVBR

Throughput-first CELT-only Opus encoder (RFC 6716 Section 5, coding path
mirrored symbol-for-symbol from the normative Appendix A; analysis replaced
by fast deterministic heuristics: no pitch prefilter, tf_res fixed, spread
fixed NORMAL, single-pass coarse energy):

- range.rs: full RFC 5.1 range encoder (fixed-size frames, shrink, raw-bit
  tail), tell()/tell_frac()/range-state exact against the decoder per symbol
- celt_enc.rs: forward MDCT as the exact adjoint of the decoder's inverse,
  transient/trim/dynalloc/stereo analyses, encode-side allocation, PVQ
  search (wide f32x8 lanes) + V(N,K) enumeration, Laplace coarse energy
- encoder.rs: TOC framing (configs 28..31), CBR and constrained-VBR, plain
  and self-delimited (App B) packets
- multistream_enc.rs: RFC 7845 family-1 surround (5.1 helper), per-stream
  self-delimited framing, coupled streams weighed 2:1 in the rate split
- shims/opus-rs: the opus-rs 0.1.26 surface edith consumes, mono fixed and
  no rate ceiling; root-cause doc for the incumbent's ~165 kbps cliff in
  lib.rs

Proof in tests/conformance.rs (same binary): per-packet range-state parity
encoder vs vector-verified decoder at 32..510 kbps x {mono,stereo} x all
frame sizes x CVBR; libopus (ffmpeg) decodes the whole rate table at worst
corr 0.9565 (32k stereo) to 1.0000; 5.1 order-preserved >=0.9978; reference
opus_demo 0.9995 at 256k stereo; Ogg-Opus duration exact; zero-alloc steady
state; speed floors (measured ~150-580x realtime per config).
test(opus): fuzz every mode with garbage payloads; document the PLC gapAhmet Kaan Gümüş · acb0d04
test(opus): fuzz every mode with garbage payloads; document the PLC gap

Every TOC configuration is fed random payloads and every prefix of real packets
is fed to the decoder: a malformed stream must return an error, never panic,
and the debug build's overflow checks make that a real test of the fixed-point
paths too. The crate docs now state what is deliberately absent -- packet loss
concealment, which a container-fed decoder never needs -- and why CELT cannot
use ec-dsp's power-of-two MDCT directly.
feat(opus): multistream decoding, 5.1 and 7.1Ahmet Kaan Gümüş · 8bd3b2b
feat(opus): multistream decoding, 5.1 and 7.1

MultistreamDecoder splits a packet into its elementary streams by the
self-delimiting framing of Appendix B and routes each stream's channels through
the mapping table, silent channels included. Constructor takes the layout the
container header carries (rate, streams, coupled, mapping), which is the shape
the product already calls.

The CELT N/4 FFT's 15-point stage is now radix-3 then radix-5 rather than a
direct 15x15 evaluation, which is where a third of multichannel decode time was
going: a real 7.1 film track went from 102x to 124x realtime.

Checks (all in tests/conformance.rs): the mono, stereo and 5.1 Ogg-Opus
fixtures decode to correlation 1.00000 per channel against libopus through
ffmpeg; the 5.1 fixture's per-channel tones land in the RFC 7845 family 1
(Vorbis) order the reference produces, each channel carrying its own tone;
decode speed is 430x realtime stereo (fixture and testvector01 music alike) and
236x realtime 5.1, against floors of 135x and 104x. The twelve RFC vectors are
unchanged. An env-driven sweep (EC_OPUS_FILES, #[ignore]) runs the same
comparison over real files.
feat(opus): SILK layer, hybrid frames and packet redundancyAhmet Kaan Gümüş · ece2a35
feat(opus): SILK layer, hybrid frames and packet redundancy

Full RFC 6716 Section 4.2 decode in exact integer arithmetic: header and LBRR
flags, gains, NLSF stage-1/stage-2 dequantisation with Laroia weighting,
stabilisation and interpolation, LSF-to-LPC conversion with prediction-gain
limiting, pitch lags and LTP filters, shell-coded excitation with LSBs and
signs, LTP and LPC synthesis, stereo unmixing, and the output resampler for
8/12/16 kHz internal rates. The Opus layer now joins the two layers: SILK-only,
hybrid (SILK below 8 kHz plus CELT above), and the redundancy frames that carry
a mode switch across a packet boundary.

Check: all twelve RFC 6716 vectors, decoded at 48 kHz stereo, match the
reference range coder state on every one of 18075 packets, and score 96.96 to
100.00 % on the opus_compare metric (0 is the passing threshold). The three
SILK-only vectors are sample-for-sample identical to the reference output.
Unit checks cover the fixed-point helpers, gain dequantisation monotonicity and
LSF stabilisation.
feat(opus): CELT layer decoder and the single-stream decoderAhmet Kaan Gümüş · a882b8b
feat(opus): CELT layer decoder and the single-stream decoder

Full RFC 6716 Section 4.3 decode: coarse/fine/final energy with the Laplace
model, the implicit bit allocation (caps, dynalloc boosts, trim, interpolation,
skip), PVQ shapes with spreading, folding and splits, time-frequency changes,
anti-collapse, denormalisation, inverse MDCT with overlap-add, post-filter and
de-emphasis. All frame sizes 2.5-20 ms, all bandwidths NB..FB, mono and stereo.

The MDCT sizes are 15*2^k, so the N/4 FFT runs a 15-point stage over ec-dsp's
power-of-two transform rather than anything O(N^2).

Checks (tests/conformance.rs, one binary for the whole suite): the three
CELT-only RFC 6716 vectors decode with the reference range-coder state on
every packet -- 2147/2147, 4186/4186, 553/553 -- and score 99.8/99.6/99.7 %
on the opus_compare metric, reimplemented in Rust from the criterion in
Section 6 and cross-checked against the C tool (99.871 vs its 99.9 %, same
internal error 0.000315). Unit checks cover the IMDCT (overlap-add
reconstruction at every size), the 15*2^k FFT against a direct transform,
and the PVQ combinatorics.