Repository navigation
Conversation
tools/bcpack_calibration already exports `unpack` (third_party/bcpack-rs). decode_lanes now tries it first and keeps the Python model for the streams it refuses, so strict output is unchanged. About 60x faster on the entropy layer and 12x end to end for BC1 on synthetic chunks; LEONIDA_BCPACK_NATIVE=0 turns it off. tests/test_bcpack_native.py checks the two agree (skipped when the library is not built). Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
third_party/bcpack-rs follows the hardware RTL and has no virtual zero bytes, so it refused every q = 0 fragment whose omitted trailing zero comes before a symbol, and those chunks fell back to Python. tools/bcpack_calibration now exports unpack_model, a line-by-line port of _decode_lanes_raw fed bcpack.py's own probability tables: it accepts exactly the streams Python accepts, with the same symbols (8,000 synthetic chunks, sound and corrupt, single and multi-fragment: 0 disagreements). About 30x on the lane layer and 10x end to end for BC1, q = 0 included. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
… the lanes decode_blocks (tools/bcpack_calibration/src/blocks.rs) ports _bc1_blocks and _bc4_blocks and runs them on the lanes of unpack_model without building Python lists. It takes only the strict path: a non-zero lane 1 or a history entry that is not confirmed hands the whole chunk back to Python, so errors and provisional entries do not change. Synthetic 16,384-block chunks: BC1 420 -> 23 ms, BC4 540 -> 14 ms against Python, same SHA-256. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
This was referenced Nov 23, 2026
Contributor
Author
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Depends on: #6029 (this branch contains its two commits; only the last commit is new here).
Claimed in #5781 (comment).
What
New export
decode_blocks(tools/bcpack_calibration/src/blocks.rs). It ports_bc1_blocksand_bc4_blocksand runs them directly on the lanes from #6029'sunpack_model, without building Python lists.decode_with_info()tries it first for codecs 1 and 4.BC1_QUADRANT,BC4_PAIR) and the confirmed built-in history it would use,history=overrides included.Measured (synthetic chunks, no game files)
The output SHA-256 is identical to pure Python in each case. In 1,200 random BC1/BC4 chunks,
decode_with_inforeturns the same value, or raises the same exception type and message, as with both native paths turned off. The chunks cover back-references into earlier blocks and into built-in history entries (confirmed and unconfirmed), non-zero lane 1, bit flips, and strict and provisional modes.Next
BC3 and BC5 (same structure), then BC6H and BC7.
Tested
python -I tests/test_bcpack_native.py(newNativeBlockRebuildTest: equivalence with pure Python, including errors; BC1 round trip),test_bcpack.py(also withLEONIDA_BCPACK_NATIVE=0),test_bcpack_tables.py,test_bcpack_history_calib.py,test_ttpf_mips.py,test_ttpf_assets.py,test_calibrated_texture_extra.py: pass.cargo build --release --locked --offline --manifest-path tools/bcpack_calibration/Cargo.toml(cargo 1.100.0).AI-assisted (Claude Code).
🤖 Generated with Claude Code