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

Closed
zmelumian972 wants to merge 660 commits from upstream-pr/465 into main
zmelumian972 commented 2026-11-30 07:09:47 +00:00 (Migrated from github.com)

Imported from TaynanGT/Vice-Tay. Originally posted by zmelumian972 on 2026-11-30T07:09:47Z.


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

<!-- greyfinch-sync:TaynanGT/Vice-Tay:issue:5560721438 --> Imported from [TaynanGT/Vice-Tay](https://github.com/TaynanGT/Vice-Tay/pull/465). Originally posted by [zmelumian972](https://github.com/zmelumian972) on 2026-11-30T07:09:47Z. --- 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)
zmelumian972 commented 2026-11-30 07:11:04 +00:00 (Migrated from github.com)

Imported from TaynanGT/Vice-Tay. Originally posted by zmelumian972 on 2026-11-30T07:11:04Z.


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

<!-- greyfinch-sync:TaynanGT/Vice-Tay:comment:7271447925 --> Imported from [TaynanGT/Vice-Tay](https://github.com/TaynanGT/Vice-Tay/pull/465#issuecomment-7271447925). Originally posted by [zmelumian972](https://github.com/zmelumian972) on 2026-11-30T07:11:04Z. --- I am looking into mathematical model solution for the rest of the file, the LRU are MIT appearntly, which is good
Kal0s-design commented 2026-11-30 08:27:45 +00:00 (Migrated from github.com)

Imported from TaynanGT/Vice-Tay. Originally posted by Kal0s-design on 2026-11-30T08:27:45Z.

Review: COMMENTED


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

<!-- greyfinch-sync:TaynanGT/Vice-Tay:review:6108889568 --> Imported from [TaynanGT/Vice-Tay](https://github.com/TaynanGT/Vice-Tay/pull/465#pullrequestreview-6108889568). Originally posted by [Kal0s-design](https://github.com/Kal0s-design) on 2026-11-30T08:27:45Z. **Review:** COMMENTED --- 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
zmelumian972 commented 2026-11-30 17:04:34 +00:00 (Migrated from github.com)

Imported from TaynanGT/Vice-Tay. Originally posted by zmelumian972 on 2026-11-30T17:04:34Z.


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.

<!-- greyfinch-sync:TaynanGT/Vice-Tay:comment:7285679975 --> Imported from [TaynanGT/Vice-Tay](https://github.com/TaynanGT/Vice-Tay/pull/465#issuecomment-7285679975). Originally posted by [zmelumian972](https://github.com/zmelumian972) on 2026-11-30T17:04:34Z. --- 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

Sign in to join this conversation.
No reviewers
No labels
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.

Reference
TaynanGT/Vice-Tay!465
No description provided.