Ship BCPack's rANS models from Microsoft's MIT reference decoder #465

Closed
github-bot wants to merge 660 commits from github-bot/gh-465 into main AGit
Owner

@⁠zmelumian972 on GitHub · 2026-11-30 07:09 UTC · original
zmelumian972:bcpack-mit-models → main · +60197 −5442 · 207 files · 660 commits · closed without merging

Microsoft published BCPack's 128 static rANS models in silicon-rans (mdu_minirans.v, MIT, commit 2f6827d). Its freq_table matches the first 2,304 bytes of the format tables row for row (128 of 128), so that part can ship under Microsoft's licence. bcpack_models.rs holds the values, generated from the Verilog, with the MIT notice.

The runtime now refuses a VICTORY_BCPACK_TABLES file whose models differ, so a wrong or corrupt file is reported instead of decoding to block noise (#385). The synthetic test tables use the real models instead of uniform ones. The asset policy page notes the exception's source.

The rank tables, BC7 control words and dictionaries (75.7 KB) still come only from the local file. The bcpack-rs findings on the same retail stores show that data alone solves the rank tables and most BC7 control codes exactly, but not the dictionaries: a BC5 fit got 61 of 428 entry halves exact and 135 within ±1. BC7 dictionaries haven't been fitted yet, so whether a fitted fallback is good enough is still open.

The 13 BCPack tests pass in victory-formats. Under Wine, the dstorage BCPack tests pass, including the existing BC4 stream and a new test for the refusal. The staged asset policy check and clippy are clean.

🤖 Generated with Claude Code

**@⁠zmelumian972** on GitHub · 2026-11-30 07:09 UTC · [original](https://github.com/TaynanGT/Vice-Tay/pull/465) `zmelumian972:bcpack-mit-models` → `main` · +60197 −5442 · 207 files · 660 commits · closed without merging Microsoft published BCPack's 128 static rANS models in [silicon-rans](https://github.com/microsoft/silicon-rans) (`mdu_minirans.v`, MIT, commit 2f6827d). Its `freq_table` matches the first 2,304 bytes of the format tables row for row (128 of 128), so that part can ship under Microsoft's licence. `bcpack_models.rs` holds the values, generated from the Verilog, with the MIT notice. The runtime now refuses a `VICTORY_BCPACK_TABLES` file whose models differ, so a wrong or corrupt file is reported instead of decoding to block noise (#385). The synthetic test tables use the real models instead of uniform ones. The asset policy page notes the exception's source. The rank tables, BC7 control words and dictionaries (75.7 KB) still come only from the local file. The bcpack-rs findings on the same retail stores show that data alone solves the rank tables and most BC7 control codes exactly, but not the dictionaries: a BC5 fit got 61 of 428 entry halves exact and 135 within ±1. BC7 dictionaries haven't been fitted yet, so whether a fitted fallback is good enough is still open. The 13 BCPack tests pass in `victory-formats`. Under Wine, the `dstorage` BCPack tests pass, including the existing BC4 stream and a new test for the refusal. The staged asset policy check and clippy are clean. 🤖 Generated with [Claude Code](https://claude.com/claude-code)
Microsoft published the 128 static rANS models of the BCPack decoder in
silicon-rans (mdu_minirans.v, MIT). They equal the first 2,304 bytes of the
format tables, so they can ship with VIctory under that licence.

- bcpack_models.rs: MODEL_FREQS, generated from freq_table, with the MIT notice.
- dstorage: refuse a VICTORY_BCPACK_TABLES file whose models differ, so a
  wrong or corrupt file is reported instead of decoding to block noise (#385).
- Synthetic test tables use the real models instead of uniform ones.

The rank tables, BC7 control words and dictionaries still come only from the
user's local file.

Co-Authored-By: Claude Opus 5.5 <[email protected]>
github-bot locked as GitHub sync and limited conversation to collaborators 2026-11-30 07:12:11 +00:00
Author
Owner

@⁠zmelumian972 on GitHub · 2026-11-30 07:11 UTC · original

I am looking into mathematical model solution for the rest of the file, the LRU are MIT appearntly, which is good

**@⁠zmelumian972** on GitHub · 2026-11-30 07:11 UTC · [original](https://github.com/TaynanGT/Vice-Tay/pull/465#issuecomment-7271447925) I am looking into mathematical model solution for the rest of the file, the LRU are MIT appearntly, which is good
Author
Owner

@⁠Kal0s-design on GitHub · 2026-11-30 08:27 UTC · original · reviewed

Checked the shipped models against the source and ran the tests natively on Windows.

  • Values: I parsed freq_table from mdu_minirans.v at microsoft/silicon-rans 2f6827d8 and compared it with MODEL_FREQS. All 128 rows (g < 8, 16 each) are identical. The Verilog rows have 10 entries; the tenth, which the PR drops, is 0 in every one of these 128 rows, so nothing is lost. The 9-bit group (g = 8) is rightly left out, since the format has 128 models.
  • Licence: the notice in bcpack_models.rs is the repository's LICENSE word for word (the PR adds a final full stop the original lacks). Copyright line Copyright (c) Microsoft Corporation. matches.
  • Refusal: read_bcpack_tables compares the first 2,304 bytes before Tables::parse, so a shorter file whose prefix happens to match falls through to the size check (bytes.len() != TABLES_SIZE) and is still refused, just with that message. That's fine.
  • Tests on Windows: victory-formats bcpack 13 pass (4 ignored: the ones that need real tables), and victory-hle dstorage 20 pass, including bcpack_tables_with_other_models_are_refused. CI is green.

What I couldn't check: real BCPack streams still need the rank tables, BC7 control words and dictionaries from a local file I don't have, so decoding actual game data isn't exercised here. The PR text already says so.

AI-assisted: yes

**@⁠Kal0s-design** on GitHub · 2026-11-30 08:27 UTC · [original](https://github.com/TaynanGT/Vice-Tay/pull/465#pullrequestreview-6108889568) · **reviewed** Checked the shipped models against the source and ran the tests natively on Windows. - **Values:** I parsed `freq_table` from `mdu_minirans.v` at microsoft/silicon-rans `2f6827d8` and compared it with `MODEL_FREQS`. All 128 rows (`g < 8`, 16 each) are identical. The Verilog rows have 10 entries; the tenth, which the PR drops, is 0 in every one of these 128 rows, so nothing is lost. The 9-bit group (`g = 8`) is rightly left out, since the format has 128 models. - **Licence:** the notice in `bcpack_models.rs` is the repository's `LICENSE` word for word (the PR adds a final full stop the original lacks). Copyright line `Copyright (c) Microsoft Corporation.` matches. - **Refusal:** `read_bcpack_tables` compares the first 2,304 bytes before `Tables::parse`, so a shorter file whose prefix happens to match falls through to the size check (`bytes.len() != TABLES_SIZE`) and is still refused, just with that message. That's fine. - **Tests on Windows:** `victory-formats` bcpack 13 pass (4 ignored: the ones that need real tables), and `victory-hle` dstorage 20 pass, including `bcpack_tables_with_other_models_are_refused`. CI is green. What I couldn't check: real BCPack streams still need the rank tables, BC7 control words and dictionaries from a local file I don't have, so decoding actual game data isn't exercised here. The PR text already says so. AI-assisted: yes
github-bot closed this pull request 2026-11-30 17:08:21 +00:00
Author
Owner

@⁠zmelumian972 on GitHub · 2026-11-30 17:04 UTC · original

Superseded by the new main, which ships the full BCPack tables built in (Tables::builtin, bcpack-tables.bin). There is no user table file left to check against the models.

**@⁠zmelumian972** on GitHub · 2026-11-30 17:04 UTC · [original](https://github.com/TaynanGT/Vice-Tay/pull/465#issuecomment-7285679975) Superseded by the new main, which ships the full BCPack tables built in (`Tables::builtin`, `bcpack-tables.bin`). There is no user table file left to check against the models.

Pull request closed

This discussion has been locked. Commenting is limited to contributors.
No description provided.