Opus-silkq r4 lane report
Browse files at this commit8f45d036ec49109188ed703e5eda90058d978f28Parent: 511bc70- docs
- opus-silkq r4 lane report
1 changed file +68 -0
lanes/opus-silkq-r4.report.mdadded+68 -0
| @@ -0,0 +1,68 @@ | |||
| 1 | +# opus-silkq r4 — stereo SILK mid/side rate split | ||
| 2 | + | ||
| 3 | +Ported the libopus 1.5.2 `silk/stereo_LR_to_MS.c` rate logic into | ||
| 4 | +`SilkStereoEncoder`, replacing the static mid = 2/3 bps split that r3's | ||
| 5 | +bit-reservoir port had left regressing the synthetic stereo row. | ||
| 6 | + | ||
| 7 | +## What was ported (`SilkStereoEncoder::stereo_rates`, silk_enc_write.rs) | ||
| 8 | + | ||
| 9 | +- Overhead subtraction: `total = bps − (is10ms ? 1200 : 600)`, clamped ≥ 1. | ||
| 10 | +- `min_mid = 2000 + 600·fs_kHz` (NB 6800, MB 9200, WB 11600). | ||
| 11 | +- Split: `mid = 8·total/(13 + 3·frac)`; below `min_mid` the mid is clamped and | ||
| 12 | + the width drops as `4(2·side − min_mid)/((1 + 3·frac)·min_mid)`, clamped [0, 1]. | ||
| 13 | +- Width smoother: `smth += (width − smth)·0.01` each frame, state kept across | ||
| 14 | + packets (`smth_width` init 1.0, `width_prev_zero` init true — the | ||
| 15 | + mono→stereo transition semantics of `enc_API.c` 181–196, which fire at | ||
| 16 | + stream start since `nChannelsInternal` starts 0). | ||
| 17 | +- Branches, in libopus order: panned mono (`width_prev_zero && (8·total < | ||
| 18 | + 13·min_mid || frac·smth < 0.05)` → rates (total, 0), mid-only flag set, | ||
| 19 | + width 0); transition (same with `width_prev != 0`, thresholds 11·min_mid / | ||
| 20 | + 0.02 → width 0, side still coded one frame); `smth > 0.95` → width 1; | ||
| 21 | + else width = smth. Tail: side ≥ 1 bps. | ||
| 22 | +- Bitstream contract kept decoder-true: when mid-only is rate-driven (side | ||
| 23 | + trial not run), the header writes the side VAD as 0 and the mid-only icdf | ||
| 24 | + bit follows, matching libopus's forced `VAD_flags[1] = 0` (`enc_API.c` 456, | ||
| 25 | + 460–462). `write_stereo_packet_header` now takes the two VAD bools; | ||
| 26 | + `prev_mid_only` still resets side-encoder state on the first side-coded | ||
| 27 | + frame after a mid-only run (`prev_decode_only_middle` analog). | ||
| 28 | +- The old `side_energy < 1e-10` immediate mid-only and the | ||
| 29 | + `(bps/2).max(500)` side-rate reset in the `prev_mid_only` prologs are | ||
| 30 | + subsumed by the panned-mono rule and deleted. `set_bitrate` is now | ||
| 31 | + store-only; the split runs per frame in both `encode_frame_ms` and | ||
| 32 | + `encode_hybrid_ms` (mid energy is now accumulated alongside side energy). | ||
| 33 | + | ||
| 34 | +## Named simplifications | ||
| 35 | + | ||
| 36 | +1. `frac = sqrt(E_side/E_mid)` full-band — no LP/HP band split (libopus runs | ||
| 37 | + the ratio per band through the stereo predictors; ours are always zero). | ||
| 38 | +2. Smoother coefficient fixed at 0.01/frame — no speech-activity scaling | ||
| 39 | + (our encoder does not track speech activity; test material is always | ||
| 40 | + active, where libopus's coefficient also lands near 0.01). | ||
| 41 | +3. `silent_side_len` taper dropped — a no-op at 20 ms (320 − 128 = 192 ≥ | ||
| 42 | + LA_SHAPE_MS·fs_kHz = 80); it only affects 10 ms frames, which this | ||
| 43 | + encoder's stereo paths never code. | ||
| 44 | + | ||
| 45 | +## Measurements | ||
| 46 | + | ||
| 47 | +Oracle rate table (`oracle_decodes_our_packets_across_the_rate_table`), | ||
| 48 | +2 ch 16 kbps worst-channel corr: **.3407 → .4534** (was .4164 before r3). | ||
| 49 | +Floor raised 0.33 → 0.44; r3 regression comment deleted. | ||
| 50 | +Other 2 ch rows: 32 kbps .8943, 64 kbps .9773 — floors untouched, pass. | ||
| 51 | +`silk_stereo_speech_roundtrip`: NB20 .9803/.9922, MB20 .9855/.9942, | ||
| 52 | +WB20 .9906/.9956 (mono floors .9791/.9873/.9902/.9943; worst gap −.0018, | ||
| 53 | +assert corr + 0.01 ≥ mono holds); NB40/WB60 identical per-channel corr. | ||
| 54 | + | ||
| 55 | +Gate 2 (`silk_library_gate_vs_libopus`, mono, unchanged code path): | ||
| 56 | +12k .8526, 16k .8646, 24k .9146, 32k .9391 — identical to r3 baseline; | ||
| 57 | +RATE/LAG/DROPOUT gates pass. | ||
| 58 | + | ||
| 59 | +## Variants measured and rejected | ||
| 60 | + | ||
| 61 | +None — the libopus rule passed gate 1 on the first run (.4534 ≥ .40). | ||
| 62 | + | ||
| 63 | +## Why 16 kbps lands at panned mono | ||
| 64 | + | ||
| 65 | +16 kbps stereo WB: total = 15400, min_mid = 11600, frac ≈ .92 → | ||
| 66 | +8·total = 123200 < 13·min_mid = 150800 → panned mono from frame 1, | ||
| 67 | +permanent — exactly what libopus does at this rate; the mid keeps the full | ||
| 68 | +15400 bps instead of starving between two channels. | ||