Commit Graph

4 Commits

Author SHA1 Message Date
4695bb398e tools/bcpack: add pure-stdlib local history calibrator (bcpack_history_calib.py)
Add `tools/bcpack_history_calib.py` to derive external `--history <path>` JSON
tables (`bc1.json`..`bc7.json` or combined JSON) locally from a player's own
texture pools or exact reference block/DDS pairs using only the Python
standard library (`python -I`):

- Exact reference inversion (`--ref-dds POOL:INDEX=REF.dds`, `--ref-pairs`):
  algebraically inverts direct built-in history references (`d > i` in blocks
  0..255) across BC1/BC3/BC4/BC5/BC6H/BC7 into confirmed strict-mode entries.
- Read-only TTPF pool self-calibration (`inputs ...`): uses a prefix rANS lane
  decoder (`decode_lanes_prefix`) together with exact BC6H/BC7 anchor MSB and
  BC7 Mode-1 shared p-bit parity constraints, intra-block index smoothness
  voting, and sibling raw/zlib mip endpoint fitting to derive provisional
  tables usable with `--history <path> --allow-provisional`.
- Extend `tools/bcpack_tables_bptc.py`, `tools/bcpack.py`, and
  `tools/ttpf_mips.py` so `--history` also accepts optional BC1-BC5 JSON
  tables (`confirmed`, `provisional`, optional `replace`) alongside BC6H/BC7.
- Add synthetic unit tests in `tests/test_bcpack_history_calib.py` and document
  the schemas and CLI workflow in `docs/textures.md`.
2026-11-22 07:21:13 -08:00
d944af2d04 bcpack: count a BC6H/BC7 block once against the provisional gate
The provisional gate allows up to _loose_limit(n) undetermined blocks. For BC6H and BC7 it summed,
per unknown history entry, the blocks whose endpoint root used it and the blocks whose index root
used it, so a block with both roots unknown counted twice: refusals read like "8/4 blocks", and
the gate was up to twice as strict as _loose_limit means. BC3 and BC5 already keep one flag per
block.

_unknown_blocks counts the blocks whose endpoint or index root is an unknown entry, once each;
BC6H (eroot/iroot) and BC7 (er/ir) both use it. The per-entry counts in the provisional notes are
unchanged.

Tests: _unknown_blocks on blocks with one, both or no unknown roots, and a 4-block BC7 chunk whose
endpoint and index all reach history entry 255, with the table check reporting it unknown: the
refusal must say 4/4 (main says 8/4).

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
2026-11-22 08:29:10 -03:00
03d1e118a6 bcpack: add BC6H and BC7 decoders with external runtime history loader (ASSET-5) 2026-11-21 18:27:01 -08:00
80fb7f2e41 Textures: add clean-room BCPack decoder (rANS + BC1/BC3/BC4/BC5) 2026-11-21 14:44:27 -08:00