forge
Explore
Log in

Don't you dare go Hollow

Commits

Commits on 00c1b3ff2d80d84fef71bb6208110dedbbd95fc4Filtered to crates/ec-opus/src/celt_enc.rsClear filter

2026-08-23

feat(opus): tf Viterbi gets libopus importance[] from dynalloc_analysisAhmet Kaan Gümüş · 95bb40e
feat(opus): tf Viterbi gets libopus importance[] from dynalloc_analysis

tf_analysis() was called with importance[i] = 13 for every band, a stand-in
constant. libopus derives it in dynalloc_analysis (celt_encoder.c:1176-1189)
as floor(.5 + 13*exp2(min(follower[i], 4))), with a flat 13 only on the
early-return path, and calls dynalloc_analysis before the tf decision. Both
now match: the call moved ahead of tf_res (it reads only band_log_e, so the
move is state-safe) and it fills importance[].

Metric-neutral on the 14-row library gate (corr moves <= 0.0001, err_ratio
unchanged, RATE/DROPOUT green); it ships as reference faithfulness.

Also corrects the module doc, which still described TF_ANALYSIS as false, and
records in lanes/opus-reell-r3.report.md that the reell@96 err_ratio premise was
wrong: our decode before the first attack is quieter than the reference by
orders of magnitude, not pre-echoing.
feat(opus-vbr/r1): keep TF boost x1 by measurement; lane report + 14-row sweepAhmet Kaan Gümüş · a31c8b1
feat(opus-vbr/r1): keep TF boost x1 by measurement; lane report + 14-row sweep
feat(opus-int/r1): intensity band from libopus equiv_rate + hysteresis_decisionAhmet Kaan Gümüş · 9c017b0
feat(opus-int/r1): intensity band from libopus equiv_rate + hysteresis_decision

Replaces the 1.0-era effective_rate ladder with the 1.3.1 formula and
threshold/hysteresis tables, shared by the VBR target and the stereo
decision so CBR frames get it too. 14-row gate corr-neutral (±.0001).
feat(opus-sp/r1): enable tf_analysis; lane report + 14-row sweepAhmet Kaan Gümüş · 187bef2
feat(opus-sp/r1): enable tf_analysis; lane report + 14-row sweep
feat(opus-sp/r1): port libopus spreading_decision (tonal/hf averages, tapset, spread_weight)Ahmet Kaan Gümüş · 7a1f515
feat(opus-sp/r1): port libopus spreading_decision (tonal/hf averages, tapset, spread_weight)

Decoder-seen spread histogram on long frames, ours vs libopus: reelm [0,12,3442,739]
vs [0,0,3303,910]; hein [1,20,3800,151] vs [0,0,3809,138] (was a constant SPREAD_NORMAL).
Gate reelm,hein,her,reell: corr within .0001 of lane-opus-sb, reelm@64 err_ratio .69 -> .65.
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/r4): paste tf_analysis port, gate OFFAhmet Kaan Gümüş · c1fe246
feat(opus-64/r4): paste tf_analysis port, gate OFF

Port the libopus tf_analysis Viterbi search and float-mode
transient_analysis from lanes/opus-64-r3.handoff.md (edits 1-6).
tf_analysis is gated behind const TF_ANALYSIS: bool = false: the
2-row gate (reelm/hein @64k) showed both corr gaps grow and minsec
drop vs the no-analysis baseline, so the search stays disabled.
tf_res falls back to the no-analysis default.

transient_analysis is replaced unconditionally (Edit 3); the new
float-mode detector is the source of the baseline divergence
(ON ~= OFF on the gate rows).

cargo check clean; cargo test -p ec-opus --release 34+27 green;
gate RATE+DROPOUT passed (ON and OFF). See lanes/opus-64-r4.report.md.
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: VBR target shaping with activity cut and credit banking (celt)Ahmet Kaan Gümüş · b6d1cd3
opus: VBR target shaping with activity cut and credit banking (celt)

The reelm@64k dropout second was reservoir arithmetic: quiet frames
spent the flat rate at reservoir 0, the following transient run went
into debt, and the two loudest frames starved at 135 B vs libopus 252 B.
Port libopus compute_vbr shaping: activity cut below .4 (peak band
level proxy, no tonality analysis), tot_boost and tf terms, floor-depth
and 2x caps; release reservoir debt at most 8 B/frame and floor the
reservoir at -8x rate so quiet runs bank credit for attacks.

14-row library gate: 0 dropout rows, rate -1.1%..0%, 12/14 corr >= ref,
worst change her@64 -0.0002.

2026-08-21

2026-08-20

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.

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).