Audio: opus-pure 0.2.4 decodes some SILK frames differently from libopus (upstream fix stephenberry/opus-pure#13) #2762

Open
opened 2026-11-26 05:13:40 +00:00 by github-bot · 3 comments
Owner

@⁠Concombre37 on GitHub · 2026-11-25 19:56 UTC · original

VIctory decodes the title's Opus packets for xapu.dll with opus-pure 0.2.4 (crates/victory-hle/src/modules/apu.rs). The README says these results are "unverified against the title". I compared opus-pure with libopus on synthetic streams and found one defect upstream.

What is wrong. In silk_lpc_inverse_pred_gain, opus-pure uses a stability limit of 16773043. libopus uses SILK_FIX_CONST(0.99975, 24), which is 16773022. When an LPC filter's coefficients fall between the two limits, opus-pure skips the bandwidth expansion that libopus applies. From that frame on, the SILK decode drifts from libopus. In the repro, the error reaches 520 LSB and lasts several frames.

Scope. Only SILK and hybrid packets are affected, so low-bitrate speech-type streams. CELT packets agree with libopus to about 85 dB before and after the fix (float paths). I have not checked which modes the title's xapu streams use, so the effect in game is unknown.

What to do here. When a fixed opus-pure is released, update opus-pure in the workspace Cargo.toml. No VIctory code changes are needed.

Synthetic data only, no game data. AI-assisted (Claude Code).

**@⁠Concombre37** on GitHub · 2026-11-25 19:56 UTC · [original](https://github.com/Marvisak/VIctory/issues/2762) VIctory decodes the title's Opus packets for `xapu.dll` with `opus-pure` 0.2.4 (`crates/victory-hle/src/modules/apu.rs`). The README says these results are "unverified against the title". I compared `opus-pure` with libopus on synthetic streams and found one defect upstream. **What is wrong.** In `silk_lpc_inverse_pred_gain`, `opus-pure` uses a stability limit of 16773043. libopus uses `SILK_FIX_CONST(0.99975, 24)`, which is 16773022. When an LPC filter's coefficients fall between the two limits, `opus-pure` skips the bandwidth expansion that libopus applies. From that frame on, the SILK decode drifts from libopus. In the repro, the error reaches 520 LSB and lasts several frames. - Upstream issue: stephenberry/opus-pure#12 - Fix: stephenberry/opus-pure#13. With the fix, the repro stream decodes bit-identically to libopus. The crate's own tests pass and none of its frozen hashes change. **Scope.** Only SILK and hybrid packets are affected, so low-bitrate speech-type streams. CELT packets agree with libopus to about 85 dB before and after the fix (float paths). I have not checked which modes the title's `xapu` streams use, so the effect in game is unknown. **What to do here.** When a fixed `opus-pure` is released, update `opus-pure` in the workspace `Cargo.toml`. No VIctory code changes are needed. Synthetic data only, no game data. AI-assisted (Claude Code).
github-bot locked as GitHub sync and limited conversation to collaborators 2026-11-26 05:13:40 +00:00
Author
Owner

@⁠rezioliver-collab on GitHub · 2026-11-25 21:46 UTC · original

I reproduced the opus-pure 0.2.4 discrepancy on an Apple M1 against libopus 1.6.1. With the upstream fix (b21b020), every f32 sample written by VIctory’s apu::process matched the reference bit for bit across the two packets: 640/640 at 16 kHz and 1,920/1,920 at 48 kHz. VIctory opens the decoder at 48 kHz. The 16 kHz run used the same function as a control.

I decoded synthetic mono packets 33 and 34 in sequence with one decoder instance per run. Packet 33 matched on 0.2.4. The table shows packet 34 only, with zero-based indices from the start of that packet. The first mismatch and mismatch count were the same for s16 and f32.

Output rate First differing sample on 0.2.4 Differing samples in packet 34 Peak s16 error (LSB) Peak absolute f32 error
16 kHz 13 306 / 320 282 0.00860596
48 kHz 34 922 / 960 284 0.00866699

Packet 34 on its own with a fresh decoder matched even on 0.2.4 at both rates. Applying only the SILK fix to 0.2.4 gave the same output as the upstream PR head. I compared the float bytes written by apu::process directly with opus_decode_float, and the integer samples separately with opus_decode. The results held with both the default libopus build and -ffp-contract=off. Synthetic packet pair · Upstream fix

**@⁠rezioliver-collab** on GitHub · 2026-11-25 21:46 UTC · [original](https://github.com/Marvisak/VIctory/issues/2762#issuecomment-7175519950) I reproduced the `opus-pure` 0.2.4 discrepancy on an Apple M1 against **libopus 1.6.1**. With the upstream fix (`b21b020`), every `f32` sample written by VIctory’s `apu::process` matched the reference bit for bit across the two packets: **640/640 at 16 kHz** and **1,920/1,920 at 48 kHz**. VIctory opens the decoder at 48 kHz. The 16 kHz run used the same function as a control. I decoded synthetic mono packets 33 and 34 in sequence with one decoder instance per run. Packet 33 matched on 0.2.4. The table shows packet 34 only, with zero-based indices from the start of that packet. The first mismatch and mismatch count were the same for `s16` and `f32`. | Output rate | First differing sample on 0.2.4 | Differing samples in packet 34 | Peak `s16` error (LSB) | Peak absolute `f32` error | |---|---:|---:|---:|---:| | 16 kHz | 13 | 306 / 320 | 282 | 0.00860596 | | 48 kHz | 34 | 922 / 960 | 284 | 0.00866699 | Packet 34 on its own with a fresh decoder matched even on 0.2.4 at both rates. Applying only the SILK fix to 0.2.4 gave the same output as the upstream PR head. I compared the float bytes written by `apu::process` directly with `opus_decode_float`, and the integer samples separately with `opus_decode`. The results held with both the default libopus build and `-ffp-contract=off`. [Synthetic packet pair](https://github.com/stephenberry/opus-pure/issues/12) · [Upstream fix](https://github.com/stephenberry/opus-pure/pull/13)
Author
Owner

@⁠Ingenioeren on GitHub · 2026-11-25 21:49 UTC · original

The published opus-pure 0.2.5 still has this discrepancy. It was published on November 23 and still has A_LIMIT = 16773043. I tested the official crate from crates.io, checked its checksum, and used a temporary path override in a VIctory 61bfc77 checkout. Registry release · Upstream SILK fix

On Windows, VIctory's apu::process produced the same 1,920 float samples with both 0.2.4 and 0.2.5, processing the two synthetic mono packets through one 48 kHz decoder. Applying the upstream correction to 0.2.5 left the first packet unchanged and changed 922 of 960 samples in the second, starting at sample 34, with a peak absolute difference of 0.00866699. That matches the discrepancy reported above against libopus 1.6.1. Changing the limit alone produced the same output as the full patch for this two-packet case.

So the dependency update for this issue needs a release containing the upstream fix. This comparison used the published and locally corrected Rust decoder on Windows.

AI-assisted. Synthetic packets from the upstream repro only.

**@⁠Ingenioeren** on GitHub · 2026-11-25 21:49 UTC · [original](https://github.com/Marvisak/VIctory/issues/2762#issuecomment-7175586220) The published `opus-pure` **0.2.5** still has this discrepancy. It was published on November 23 and still has `A_LIMIT = 16773043`. I tested the official crate from crates.io, checked its checksum, and used a temporary path override in a VIctory `61bfc77` checkout. [Registry release](https://crates.io/crates/opus-pure/0.2.5) · [Upstream SILK fix](https://github.com/stephenberry/opus-pure/pull/13) On Windows, VIctory's `apu::process` produced the same 1,920 float samples with both 0.2.4 and 0.2.5, processing the two synthetic mono packets through one 48 kHz decoder. Applying the upstream correction to 0.2.5 left the first packet unchanged and changed **922 of 960** samples in the second, starting at sample 34, with a peak absolute difference of **0.00866699**. That matches the discrepancy reported above against libopus 1.6.1. Changing the limit alone produced the same output as the full patch for this two-packet case. So the dependency update for this issue needs a release containing the upstream fix. This comparison used the published and locally corrected Rust decoder on Windows. _AI-assisted. Synthetic packets from the upstream repro only._
Author
Owner

@⁠Marvisak on GitHub · 2026-11-26 00:44 UTC · original

Automated triage for the maintainers.

Accurate as to our side: the workspace Cargo.toml pins opus-pure = "0.2.4" (0.2.4 in Cargo.lock), used by crates/victory-hle/src/modules/apu.rs. The defect itself is upstream (stephenberry/opus-pure#12, fix in #13), and as the comment above shows, 0.2.5 does not yet contain it. Nothing needs to change here until a release with the fix exists; then it is a version bump. Kept open to track that.


Generated by Claude Code

**@⁠Marvisak** on GitHub · 2026-11-26 00:44 UTC · [original](https://github.com/Marvisak/VIctory/issues/2762#issuecomment-7179062585) <!-- victory-issue-triage v1 verdict=tracked seen=2026-11-25T21:49:31Z at=2026-11-26T01:02:00Z --> Automated triage for the maintainers. Accurate as to our side: the workspace `Cargo.toml` pins `opus-pure = "0.2.4"` (0.2.4 in `Cargo.lock`), used by `crates/victory-hle/src/modules/apu.rs`. The defect itself is upstream (stephenberry/opus-pure#12, fix in #13), and as the comment above shows, 0.2.5 does not yet contain it. Nothing needs to change here until a release with the fix exists; then it is a version bump. Kept open to track that. --- _Generated by [Claude Code](https://claude.ai/code)_
This discussion has been locked. Commenting is limited to contributors.
No milestone
No assignees
1 participant
Notifications
Due date
The due date is invalid or out of range. Please use the format "yyyy-mm-dd".

No due date set.

Dependencies

No dependencies set

Reference
github/Marvisak--VIctory#2762
No description provided.