Validate variable BCPack lanes against a reproducible BC7 block reference #15

Closed
opened 2026-11-21 08:29:28 +00:00 by R0Y00 · 8 comments
R0Y00 commented 2026-11-21 08:29:28 +00:00 (Migrated from github.com)
Contributor

Imported from R0Y00/Xbox2Windows. Originally posted by R0Y00 on 2026-11-21T08:29:28Z.


The fixed-symbol prefix probe reproduces an initial state and byte budget for a small subset of lanes. Recovering a BC7 block also requires the variable-symbol distributions, the order in which lanes consume refill bytes, and the mapping from lane outputs to block fields.

Use an original or redistributable test packet and independently known BC7 block rows. Record the block count and expected output. Verify the initial state, each refill and terminal state before comparing complete block rows byte for byte. A prefix match alone leaves pixel reconstruction open.

Reference: the published SixNG BCPack experiments, section 6.

<!-- greyfinch-sync:R0Y00/Xbox2Windows:issue:6526572682 --> Imported from [R0Y00/Xbox2Windows](https://github.com/R0Y00/Xbox2Windows/issues/15). Originally posted by [R0Y00](https://github.com/R0Y00) on 2026-11-21T08:29:28Z. --- The fixed-symbol prefix probe reproduces an initial state and byte budget for a small subset of lanes. Recovering a BC7 block also requires the variable-symbol distributions, the order in which lanes consume refill bytes, and the mapping from lane outputs to block fields. Use an original or redistributable test packet and independently known BC7 block rows. Record the block count and expected output. Verify the initial state, each refill and terminal state before comparing complete block rows byte for byte. A prefix match alone leaves pixel reconstruction open. Reference: the published SixNG BCPack experiments, section 6.
R0Y00 commented 2026-11-24 06:47:32 +00:00 (Migrated from github.com)
Author
Contributor

Imported from R0Y00/Xbox2Windows. Originally posted by R0Y00 on 2026-11-21T08:42:00Z.


PR #17 adds a first-round check using original synthetic inputs. Run python -B tests/bcpack_check.py to exercise an explicit eight-lane participation mask and a deliberately swapped byte. For a source-owned packet, tools/bcpack_probe.py accepts an independently known symbol count and an optional --prefetch-mask to test the first refill position. Later refill positions, variable-symbol decoding and verification against known BC7 blocks remain open.

<!-- greyfinch-sync:R0Y00/Xbox2Windows:comment:7060091207 --> Imported from [R0Y00/Xbox2Windows](https://github.com/R0Y00/Xbox2Windows/issues/15#issuecomment-7060091207). Originally posted by [R0Y00](https://github.com/R0Y00) on 2026-11-21T08:42:00Z. --- PR #17 adds a first-round check using original synthetic inputs. Run `python -B tests/bcpack_check.py` to exercise an explicit eight-lane participation mask and a deliberately swapped byte. For a source-owned packet, `tools/bcpack_probe.py` accepts an independently known symbol count and an optional `--prefetch-mask` to test the first refill position. Later refill positions, variable-symbol decoding and verification against known BC7 blocks remain open.
mesterember104-cpu commented 2026-11-24 06:47:33 +00:00 (Migrated from github.com)
Author
Contributor

Imported from R0Y00/Xbox2Windows. Originally posted by mesterember104-cpu on 2026-11-21T13:39:49Z.


Aggregate observations from a local copy of the same case-study build (the CYBERLEEK November Xbox package referenced in the README). Reproduction script inline at the bottom; no game data is shared.

AI disclosure: this comment was drafted, and all measurements below were collected, by an AI agent (GLM, operated by the account owner). The script is deterministic and self-contained, so anyone with a local build can verify every number independently.

Independently established inputs

data/ttdb/graphics/ttdb_graphics.ttpf (32.8 MB RDS5 store): 1,549 chunks per the SixNG §5 chunk-table formulas — 1,402 zlib, 100 BC5, 27 BC7/BCPack (codec 0x1C), 19 BC1, 1 BC3?. Block counts for the 27 BC7 streams come from chunk virtual extents (next entry's virtual offset minus this one, divided by 16): 2×1024, 1×2048, 14×4096, 10×16384 blocks. Stored sizes run 13.5–257.8 KB, ≈12% under virtual size.

Why the probe finds zero lanes on BC7

tools/bcpack_probe.py reads lane records as prefix[lane::8] and accepts only the BC1 constant modes dc/dd/de. On all 27 real streams it reports zero lanes. Reading the first 48 bytes as 8 lane records of 6 bytes (stride 6) — which is the SixNG §6 header layout — changes the statistics completely:

stride lane slots plane-type modes (low5 in 1a–1e)
6 216 40
8 162 11

Lane 1 is a plane-type parameter lane in BC7

At stride 6, lane 1 carries a plane-type mode in 25/27 streams — the structural analogue of BC1's constant lane 1 (de), but from a different family:

0x7b×8, 0x7a×6, 0x3c×5, 0xfa×2, 0xba×2, and 0x97/0x3b/0x5b/0xb9 once each — types 0x1a/0x1b/0x1c with parameters 1–7 (BC1's constant lanes are types 0x1c–0x1e, parameter 6).

Two record shapes:

  • budget (byte at +1) in {59, 122, 123} for 23/27 streams — several 4096- and 16384-block streams share the same budget, so it is not a simple block function;
  • state prefix 0x0303 in 14/27 streams (cf. BC1's fixed-parameter records 10 03 40 00 xx 00).

The remaining budgets correlate with the derived block counts (1024 → 59/186; 16384 → 91/122), which constrains lane-length models the same way --blocks verifies BC1 constant lanes.

Open

  • Whether stride-6 lane 1 is constant-with-parameter-dependent K or a fixed-parameter record; a byte-for-byte re-encode needs the BC7 K values.
  • Lanes 0 and 2–7: mode histograms vary per stream; nothing stable yet.

Reproduction

# ttpf_lane_fixture.py - prints the aggregates above and can export the raw
# chunk streams (named by derived block count) for use with bcpack_probe.py.
# Reads only from the supplied local file; embeds no game data.
import argparse, hashlib, os, struct
from collections import Counter

CODECS = {0x00: "stored", 0x20: "zlib", 0x04: "BC1", 0x0C: "BC3?", 0x10: "BC4?",
          0x14: "BC5", 0x18: "BC6H", 0x1C: "BC7"}

ap = argparse.ArgumentParser()
ap.add_argument("ttpf"); ap.add_argument("--export")
args = ap.parse_args()
data = open(args.ttpf, "rb").read()
assert data[:4] == b"RDS5"
n = struct.unpack_from("<I", data, 4)[0]
entries = []
for i in range(n):
    a, b = struct.unpack_from("<II", data, 0x18 + 8 * i)
    if a == 0 and b == 0: continue
    entries.append(((a & 0xFFFFFF) << 8,
                    0x1000 + (b & 0xFFFFF) * 0x4000 + (a >> 30) * 0x1000,
                    (a >> 24) & 0x3F))
print("chunks:", len(entries), dict(Counter(c for _, _, c in entries)))
bc7 = []
for j, (off, voff, codec) in enumerate(entries):
    if codec != 0x1C: continue
    end = entries[j + 1][0] if j + 1 < len(entries) else len(data)
    vend = entries[j + 1][1] if j + 1 < len(entries) else voff + (end - off)
    bc7.append((off, end, (vend - voff) // 16))
print("BC7 streams:", len(bc7), "blocks:", sorted(b for _, _, b in bc7))
for stride, lanes in ((6, 8), (8, 6)):
    plane = sum(1 for off, _, _ in bc7 for lane in range(lanes)
                if (data[off + lane * stride] & 0x1F) in range(0x1A, 0x1F))
    l1 = Counter(data[off + stride] for off, _, _ in bc7)
    print(f"stride {stride}: plane-type={plane}/{len(bc7)*lanes}, "
          f"lane1={['0x%02x x%d' % kv for kv in l1.most_common(5)]}")
if args.export:
    os.makedirs(args.export, exist_ok=True)
    for off, end, blocks in bc7:
        blob = data[off:end]
        name = f"bc7_off{off:08x}_{blocks}blocks_{len(blob)}B.bin"
        open(os.path.join(args.export, name), "wb").write(blob)
        print("exported", name, "sha256[:16]", hashlib.sha256(blob).hexdigest()[:16])

Run: python ttpf_lane_fixture.py <build>/data/ttdb/graphics/ttdb_graphics.ttpf [--export out], then python -B tools/bcpack_probe.py <exported-file> --blocks <count-from-filename>.

A stride-6 reader in the probe plus one verified K for 0x7a/0x7b/0x3c that re-encodes a real lane-1 record byte for byte would close the identification half of this issue.

<!-- greyfinch-sync:R0Y00/Xbox2Windows:comment:7063469482 --> Imported from [R0Y00/Xbox2Windows](https://github.com/R0Y00/Xbox2Windows/issues/15#issuecomment-7063469482). Originally posted by [mesterember104-cpu](https://github.com/mesterember104-cpu) on 2026-11-21T13:39:49Z. --- Aggregate observations from a local copy of the same case-study build (the CYBERLEEK November Xbox package referenced in the README). Reproduction script inline at the bottom; no game data is shared. **AI disclosure:** this comment was drafted, and all measurements below were collected, by an AI agent (GLM, operated by the account owner). The script is deterministic and self-contained, so anyone with a local build can verify every number independently. ## Independently established inputs `data/ttdb/graphics/ttdb_graphics.ttpf` (32.8 MB RDS5 store): 1,549 chunks per the SixNG §5 chunk-table formulas — 1,402 zlib, 100 BC5, 27 **BC7/BCPack (codec 0x1C)**, 19 BC1, 1 BC3?. Block counts for the 27 BC7 streams come from chunk **virtual extents** (next entry's virtual offset minus this one, divided by 16): 2×1024, 1×2048, 14×4096, 10×16384 blocks. Stored sizes run 13.5–257.8 KB, ≈12% under virtual size. ## Why the probe finds zero lanes on BC7 `tools/bcpack_probe.py` reads lane records as `prefix[lane::8]` and accepts only the BC1 constant modes `dc/dd/de`. On all 27 real streams it reports zero lanes. Reading the first 48 bytes as **8 lane records of 6 bytes (stride 6)** — which is the SixNG §6 header layout — changes the statistics completely: | stride | lane slots | plane-type modes (low5 in 1a–1e) | |---|---|---| | 6 | 216 | **40** | | 8 | 162 | 11 | ## Lane 1 is a plane-type parameter lane in BC7 At stride 6, **lane 1 carries a plane-type mode in 25/27 streams** — the structural analogue of BC1's constant lane 1 (`de`), but from a different family: `0x7b`×8, `0x7a`×6, `0x3c`×5, `0xfa`×2, `0xba`×2, and `0x97/0x3b/0x5b/0xb9` once each — types 0x1a/0x1b/0x1c with parameters 1–7 (BC1's constant lanes are types 0x1c–0x1e, parameter 6). Two record shapes: - budget (byte at +1) in {59, 122, 123} for 23/27 streams — several 4096- and 16384-block streams share the same budget, so it is not a simple block function; - state prefix `0x0303` in 14/27 streams (cf. BC1's fixed-parameter records `10 03 40 00 xx 00`). The remaining budgets correlate with the derived block counts (1024 → 59/186; 16384 → 91/122), which constrains lane-length models the same way `--blocks` verifies BC1 constant lanes. ## Open - Whether stride-6 lane 1 is constant-with-parameter-dependent K or a fixed-parameter record; a byte-for-byte re-encode needs the BC7 K values. - Lanes 0 and 2–7: mode histograms vary per stream; nothing stable yet. ## Reproduction ```python # ttpf_lane_fixture.py - prints the aggregates above and can export the raw # chunk streams (named by derived block count) for use with bcpack_probe.py. # Reads only from the supplied local file; embeds no game data. import argparse, hashlib, os, struct from collections import Counter CODECS = {0x00: "stored", 0x20: "zlib", 0x04: "BC1", 0x0C: "BC3?", 0x10: "BC4?", 0x14: "BC5", 0x18: "BC6H", 0x1C: "BC7"} ap = argparse.ArgumentParser() ap.add_argument("ttpf"); ap.add_argument("--export") args = ap.parse_args() data = open(args.ttpf, "rb").read() assert data[:4] == b"RDS5" n = struct.unpack_from("<I", data, 4)[0] entries = [] for i in range(n): a, b = struct.unpack_from("<II", data, 0x18 + 8 * i) if a == 0 and b == 0: continue entries.append(((a & 0xFFFFFF) << 8, 0x1000 + (b & 0xFFFFF) * 0x4000 + (a >> 30) * 0x1000, (a >> 24) & 0x3F)) print("chunks:", len(entries), dict(Counter(c for _, _, c in entries))) bc7 = [] for j, (off, voff, codec) in enumerate(entries): if codec != 0x1C: continue end = entries[j + 1][0] if j + 1 < len(entries) else len(data) vend = entries[j + 1][1] if j + 1 < len(entries) else voff + (end - off) bc7.append((off, end, (vend - voff) // 16)) print("BC7 streams:", len(bc7), "blocks:", sorted(b for _, _, b in bc7)) for stride, lanes in ((6, 8), (8, 6)): plane = sum(1 for off, _, _ in bc7 for lane in range(lanes) if (data[off + lane * stride] & 0x1F) in range(0x1A, 0x1F)) l1 = Counter(data[off + stride] for off, _, _ in bc7) print(f"stride {stride}: plane-type={plane}/{len(bc7)*lanes}, " f"lane1={['0x%02x x%d' % kv for kv in l1.most_common(5)]}") if args.export: os.makedirs(args.export, exist_ok=True) for off, end, blocks in bc7: blob = data[off:end] name = f"bc7_off{off:08x}_{blocks}blocks_{len(blob)}B.bin" open(os.path.join(args.export, name), "wb").write(blob) print("exported", name, "sha256[:16]", hashlib.sha256(blob).hexdigest()[:16]) ``` Run: `python ttpf_lane_fixture.py <build>/data/ttdb/graphics/ttdb_graphics.ttpf [--export out]`, then `python -B tools/bcpack_probe.py <exported-file> --blocks <count-from-filename>`. A stride-6 reader in the probe plus one verified K for 0x7a/0x7b/0x3c that re-encodes a real lane-1 record byte for byte would close the identification half of this issue.
R0Y00 commented 2026-11-24 06:47:33 +00:00 (Migrated from github.com)
Author
Contributor

Imported from R0Y00/Xbox2Windows. Originally posted by R0Y00 on 2026-11-21T14:38:21Z.


Thanks for the reproducible measurements. I independently read the local RDS5 table and confirmed 1,549 data segments and 27 mode-7 segments. At six-byte spacing I also get 40/216 candidate mode positions and 25/27 hits at position 1. One discrepancy worth resolving before fitting the decoder: using the table beginning at byte 16, its final sentinel and successive logical offsets, I get 2 × 1,024, 1 × 2,048, 13 × 4,096 and 11 × 16,384 blocks. Our reader treats the final table record as an end sentinel. Can you compare the final mode-7 segment using its declared logical end rather than its stored byte length? The histogram supports investigating the six-byte interpretation. The decisive next test is an independently known BC7 block or a byte-exact lane re-encode. Aggregate counts are sufficient for comparing the local inputs.

<!-- greyfinch-sync:R0Y00/Xbox2Windows:comment:7064239462 --> Imported from [R0Y00/Xbox2Windows](https://github.com/R0Y00/Xbox2Windows/issues/15#issuecomment-7064239462). Originally posted by [R0Y00](https://github.com/R0Y00) on 2026-11-21T14:38:21Z. --- Thanks for the reproducible measurements. I independently read the local RDS5 table and confirmed 1,549 data segments and 27 mode-7 segments. At six-byte spacing I also get 40/216 candidate mode positions and 25/27 hits at position 1. One discrepancy worth resolving before fitting the decoder: using the table beginning at byte 16, its final sentinel and successive logical offsets, I get 2 × 1,024, 1 × 2,048, 13 × 4,096 and 11 × 16,384 blocks. Our reader treats the final table record as an end sentinel. Can you compare the final mode-7 segment using its declared logical end rather than its stored byte length? The histogram supports investigating the six-byte interpretation. The decisive next test is an independently known BC7 block or a byte-exact lane re-encode. Aggregate counts are sufficient for comparing the local inputs.
MarlomMedeiros commented 2026-11-24 06:47:34 +00:00 (Migrated from github.com)
Author
Contributor

Imported from R0Y00/Xbox2Windows. Originally posted by MarlomMedeiros on 2026-11-21T15:21:44Z.


Extending the published BCPack format notes (06-bcpack.md) to BC7, under
the spec's ttpf parse. Corpus: the GTA VI Xbox ttpf set, 46 files, 45 with
codec-0x1C chunks, 5,120 chunks total; single package, no second source.

Main-lane records [mode=0xde][budget-1][state4] with budget-1 = 3 contain
32-bit values identical to the encoder-final states of pure constant rANS
runs under the published constant-lane model (M=2^16, L=2^24,
repeated-symbol freq M-K, slot 1).

  • Every mode-0xde record with budget-1=3 matches at its lane's K:
    1,252/1,252, on every lane where such records occur (2-7), across the
    38 stores that contain them (167 distinct states; one repeats 466x).
  • Refill-consistent population among mode-0xde records is exactly 1,281
    of 1,737: the 1,252 plus 29 header matches whose budgets equal the
    model's renorm count at their recovered symbol counts. For all 29 the
    model's predicted first emitted byte equals the stream byte at the
    deduced round-1 position (consistent, though those bytes are locally
    common, so supporting rather than decisive).
  • The only K in an exhaustive scan (1..65,535) fitting every record of a
    lane is K=32 on lanes 2-6 and K=16 on lane 7. Individual records can
    sit on a second chain; the per-lane intersection is unique. Lane 7's
    K=16 departs from the spec's BC1-derived mode->K table.
  • For the dominant family the recovered symbol count equals 2x the chunk
    block count from the spec's virtual-offset deltas (827 records; 4 at
    1x; the other 421 verified records carry counts 7-9,703 untied to
    blocks, e.g. fixed 128-symbol runs in multi-stream chunks).
  • Chance floor: a stored state hitting a zero-refill chain state at a
    fixed lane K is ~3e-6 to 5e-6 per record; expected false hits among
    1,252 is ~0.004. For calibration, the same formal test yields ~11 hits
    among the ~39k non-0xde param-6 records.
  • Reproduction: unmodified tools/bcpack_probe.py reports
    verified_constant_lane on real prefixes for lanes 2-6 with --blocks set
    to the recovered symbol count. Example: ttdb_interiors_0_3.ttpf,
    chunk-table entry 1604 (1536 blocks), --blocks 3072 reports lane 6.
    Lane-7 records verify by changing EXCEPTIONS[0xde] to 16 in a separate
    run (one K per mode per run). Reproducing needs the same package, which
    cannot be redistributed; the full hit list is countable from the rules
    above.

Actionable for this issue: in chunks carrying these records, the named
lanes appear to be constant runs and can likely be pruned from the
variable-lane search, and the recovered symbol counts (2x and 1x blocks,
plus fixed 128-symbol sub-stream runs) are hard checks for any candidate
BC7 decoder.

Not yet established: the semantic role of these lanes (endpoint/subset
planes); the remaining 456 mode-0xde records with budget-1>3 that do not
fit the lane-K model (one sits on a K=8 chain at a mismatched budget;
deeper scans may move a few more onto non-lane chains); and the nature of
the type-0x1b records concentrated on lanes 0-1 (formally chain states at
K=2 with degenerate n~128; possibly packed parameter fields).

<!-- greyfinch-sync:R0Y00/Xbox2Windows:comment:7064814358 --> Imported from [R0Y00/Xbox2Windows](https://github.com/R0Y00/Xbox2Windows/issues/15#issuecomment-7064814358). Originally posted by [MarlomMedeiros](https://github.com/MarlomMedeiros) on 2026-11-21T15:21:44Z. --- Extending the published BCPack format notes (06-bcpack.md) to BC7, under the spec's ttpf parse. Corpus: the GTA VI Xbox ttpf set, 46 files, 45 with codec-0x1C chunks, 5,120 chunks total; single package, no second source. Main-lane records [mode=0xde][budget-1][state4] with budget-1 = 3 contain 32-bit values identical to the encoder-final states of pure constant rANS runs under the published constant-lane model (M=2^16, L=2^24, repeated-symbol freq M-K, slot 1). - Every mode-0xde record with budget-1=3 matches at its lane's K: 1,252/1,252, on every lane where such records occur (2-7), across the 38 stores that contain them (167 distinct states; one repeats 466x). - Refill-consistent population among mode-0xde records is exactly 1,281 of 1,737: the 1,252 plus 29 header matches whose budgets equal the model's renorm count at their recovered symbol counts. For all 29 the model's predicted first emitted byte equals the stream byte at the deduced round-1 position (consistent, though those bytes are locally common, so supporting rather than decisive). - The only K in an exhaustive scan (1..65,535) fitting every record of a lane is K=32 on lanes 2-6 and K=16 on lane 7. Individual records can sit on a second chain; the per-lane intersection is unique. Lane 7's K=16 departs from the spec's BC1-derived mode->K table. - For the dominant family the recovered symbol count equals 2x the chunk block count from the spec's virtual-offset deltas (827 records; 4 at 1x; the other 421 verified records carry counts 7-9,703 untied to blocks, e.g. fixed 128-symbol runs in multi-stream chunks). - Chance floor: a stored state hitting a zero-refill chain state at a fixed lane K is ~3e-6 to 5e-6 per record; expected false hits among 1,252 is ~0.004. For calibration, the same formal test yields ~11 hits among the ~39k non-0xde param-6 records. - Reproduction: unmodified tools/bcpack_probe.py reports verified_constant_lane on real prefixes for lanes 2-6 with --blocks set to the recovered symbol count. Example: ttdb_interiors_0_3.ttpf, chunk-table entry 1604 (1536 blocks), --blocks 3072 reports lane 6. Lane-7 records verify by changing EXCEPTIONS[0xde] to 16 in a separate run (one K per mode per run). Reproducing needs the same package, which cannot be redistributed; the full hit list is countable from the rules above. Actionable for this issue: in chunks carrying these records, the named lanes appear to be constant runs and can likely be pruned from the variable-lane search, and the recovered symbol counts (2x and 1x blocks, plus fixed 128-symbol sub-stream runs) are hard checks for any candidate BC7 decoder. Not yet established: the semantic role of these lanes (endpoint/subset planes); the remaining 456 mode-0xde records with budget-1>3 that do not fit the lane-K model (one sits on a K=8 chain at a mismatched budget; deeper scans may move a few more onto non-lane chains); and the nature of the type-0x1b records concentrated on lanes 0-1 (formally chain states at K=2 with degenerate n~128; possibly packed parameter fields).
R0Y00 commented 2026-11-24 06:47:34 +00:00 (Migrated from github.com)
Author
Contributor

Imported from R0Y00/Xbox2Windows. Originally posted by R0Y00 on 2026-11-21T15:22:58Z.


Thanks @descent81. #69 is merged. For an explicitly supplied second-round participation mask, the probe now checks the predicted offset and value of the second refill byte. The regression changes only that byte and verifies that the first check still passes. The variable-symbol model, mask inference and independently checked BC7 block output remain open here.

<!-- greyfinch-sync:R0Y00/Xbox2Windows:comment:7064830032 --> Imported from [R0Y00/Xbox2Windows](https://github.com/R0Y00/Xbox2Windows/issues/15#issuecomment-7064830032). Originally posted by [R0Y00](https://github.com/R0Y00) on 2026-11-21T15:22:58Z. --- Thanks @descent81. #69 is merged. For an explicitly supplied second-round participation mask, the probe now checks the predicted offset and value of the second refill byte. The regression changes only that byte and verifies that the first check still passes. The variable-symbol model, mask inference and independently checked BC7 block output remain open here.
MarlomMedeiros commented 2026-11-24 06:47:51 +00:00 (Migrated from github.com)
Author
Contributor

Imported from R0Y00/Xbox2Windows. Originally posted by MarlomMedeiros on 2026-11-21T18:53:58Z.


Corpus-wide follow-up on the refill-order and lane-model questions. All measurements below come from the local archive's 5,120 BC7 chunks plus two extracted packet prefixes (512 and 1,536 blocks), read-only. Every claim has a runnable Python check behind it; happy to share them.

Constant-lane model: the K table is lane-dependent

The mode -> escape-slot count map is not global; the same mode carries different alphabet sizes on different lanes:

mode lane K corpus evidence
0xde 2-6 32 908 verified pure-constant hits
0xde 7 16 373/373 hits; one extracted prefix decodes bit-exact to LOWER with K=16 and fails with K=32 at an escape near step 2579
0xdb 0-1 2 184 verified hits
0xdc secondary s1 4 verified, 3,072 symbols in the 1,536-block prefix
0xdd secondary s2 8 verified, 3,072 symbols

Symbol counts: endpoint lanes encode 2*blocks symbols, not blocks (843 of the verified hits: N_sym=1024 in the 512-block prefix, N_sym=3072 in the 1,536-block prefix). The remaining verified lanes are fixed 128-symbol lanes, and 65,536-block chunks split into two independent 32,768-block streams.

The published EXCEPTIONS table covers only the lane-2..6 K=32 case, so roughly a third of the corpus-verifiable constant lanes are out of reach of the current model.

Header records decoded

Mode byte bit 5 is a length-width flag, not a parameter field:

bit5 = 0:  [mode][len8][state4]          len8 >= 3, state >= 0x01000000
           total = len8 + 3 bytes

bit5 = 1:  [mode][len16-LE][state_hi3]   4th state byte + 1-byte prefetch
           total = len16 + 4 bytes       read from the stream

Validation: zero negative stream budgets across all 5,120 chunks; zero violations across 11,225 bit5=0 records; 3,354 bit5=1 records have a zero high length byte, consistent with a real 16-bit field.

Physical layout: fixed 8-byte rounds, secondary headers fill gaps

Rounds are fixed 8-byte slots, not packed reads. Round 6 carries 4th state bytes for bit5=1 lanes plus first refill/prefetch bytes; secondary lane headers immediately claim any slot a main lane frees. Round 7 always starts at offset 56, regardless of how many main lanes read in Round 6.

Verified byte-by-byte on a real 4,096-block chunk (prefetch_mask = 0xef):

Round 6 (48-55):  3b  69  fb  fc  11  2b  ce  de
                  l0  l1  l2  l3r l5  l6  l7r s0_mode
                      st4 st4 st4 ref st4 st4 ref

Round 7 (56-63):  c6  24  ff  ff  ff  af  03  dc
                  l0  l1  l2  l3r l5  l7r s0b1 s1_mode
                      pf  pf  pf  ref pf  ref
  • lane 3 refills [0xfc, 0xff] at offsets 51 and 59
  • lane 7 refills [0xce, 0xaf] at offsets 54 and 61
  • secondary lane s0 (0xde, K=16) header interleaves at 55 (mode) and 62 (len8); s1 (0xdc, K=4) mode lands at 63

Later refills are demand-driven: refill[i+1] surfaces mid-stream only at the decode step where refill[i] is consumed. Confirmed on a 16,384-block stream and on both halves of a dual-32,768-block stream: five refills each land as multi-lane byte clusters at stream fractions within ~0.001 of the predicted decode-step fraction.

Audit of the merged #175 model

Confirmed: per-lane FIFO refill consumption and the unbudgeted-read reporting both match real streams.

Refuted on real streams:

  • Round 2 does not start at 48 + popcount(mask). Secondary headers fill freed Round-6 slots, so Round 7 always begins at offset 56. The formula lands off by one on the verified chunk above (it computes 55, which sits on the s0 mode byte).
  • "Skip Round 1, take refill[0] in Round 2" never occurs on a constant lane: 59/59 take refill[0] in Round 6, while bit5=1 lanes read their prefetch byte in Round 7.
  • --next-mask matches reality only for lanes whose escape sits at decode step 0. Later escapes consume their byte mid-stream at the demand point, not in Round 2.
  • The inherited EXCEPTIONS table misses K=16 (0xde lane 7) and K=2 (0xdb), which limits real-lane coverage for anything built on it, including the supplied-refills decode path in #214.

What stays open

Variable-lane zero-refill states (0xda, 0x5f, 0x1f) do not fit the constant recurrence for any K in {1,2,4,...,1024} or any start offset; the variable symbol models are still unknown. Observable signatures so far: 0xda states advance in exact +4.0101-bit steps, and 0x5f states cluster in delta-2 pairs. Lane-to-BC7-field assignment is also unresolved, though the per-lane mode alphabets strongly suggest each lane streams a different block field.

<!-- greyfinch-sync:R0Y00/Xbox2Windows:comment:7067597230 --> Imported from [R0Y00/Xbox2Windows](https://github.com/R0Y00/Xbox2Windows/issues/15#issuecomment-7067597230). Originally posted by [MarlomMedeiros](https://github.com/MarlomMedeiros) on 2026-11-21T18:53:58Z. --- Corpus-wide follow-up on the refill-order and lane-model questions. All measurements below come from the local archive's 5,120 BC7 chunks plus two extracted packet prefixes (512 and 1,536 blocks), read-only. Every claim has a runnable Python check behind it; happy to share them. ## Constant-lane model: the K table is lane-dependent The mode -> escape-slot count map is not global; the same mode carries different alphabet sizes on different lanes: | mode | lane | K | corpus evidence | |---|---|---|---| | `0xde` | 2-6 | 32 | 908 verified pure-constant hits | | `0xde` | 7 | **16** | 373/373 hits; one extracted prefix decodes bit-exact to `LOWER` with K=16 and fails with K=32 at an escape near step 2579 | | `0xdb` | 0-1 | **2** | 184 verified hits | | `0xdc` | secondary s1 | 4 | verified, 3,072 symbols in the 1,536-block prefix | | `0xdd` | secondary s2 | 8 | verified, 3,072 symbols | Symbol counts: endpoint lanes encode `2*blocks` symbols, not `blocks` (843 of the verified hits: `N_sym=1024` in the 512-block prefix, `N_sym=3072` in the 1,536-block prefix). The remaining verified lanes are fixed 128-symbol lanes, and 65,536-block chunks split into two independent 32,768-block streams. The published `EXCEPTIONS` table covers only the lane-2..6 K=32 case, so roughly a third of the corpus-verifiable constant lanes are out of reach of the current model. ## Header records decoded Mode byte bit 5 is a length-width flag, not a parameter field: ``` bit5 = 0: [mode][len8][state4] len8 >= 3, state >= 0x01000000 total = len8 + 3 bytes bit5 = 1: [mode][len16-LE][state_hi3] 4th state byte + 1-byte prefetch total = len16 + 4 bytes read from the stream ``` Validation: zero negative stream budgets across all 5,120 chunks; zero violations across 11,225 bit5=0 records; 3,354 bit5=1 records have a zero high length byte, consistent with a real 16-bit field. ## Physical layout: fixed 8-byte rounds, secondary headers fill gaps Rounds are fixed 8-byte slots, not packed reads. Round 6 carries 4th state bytes for bit5=1 lanes plus first refill/prefetch bytes; secondary lane headers immediately claim any slot a main lane frees. Round 7 always starts at offset 56, regardless of how many main lanes read in Round 6. Verified byte-by-byte on a real 4,096-block chunk (`prefetch_mask = 0xef`): ``` Round 6 (48-55): 3b 69 fb fc 11 2b ce de l0 l1 l2 l3r l5 l6 l7r s0_mode st4 st4 st4 ref st4 st4 ref Round 7 (56-63): c6 24 ff ff ff af 03 dc l0 l1 l2 l3r l5 l7r s0b1 s1_mode pf pf pf ref pf ref ``` - lane 3 refills `[0xfc, 0xff]` at offsets 51 and 59 - lane 7 refills `[0xce, 0xaf]` at offsets 54 and 61 - secondary lane `s0` (`0xde`, K=16) header interleaves at 55 (mode) and 62 (len8); `s1` (`0xdc`, K=4) mode lands at 63 Later refills are **demand-driven**: `refill[i+1]` surfaces mid-stream only at the decode step where `refill[i]` is consumed. Confirmed on a 16,384-block stream and on both halves of a dual-32,768-block stream: five refills each land as multi-lane byte clusters at stream fractions within ~0.001 of the predicted decode-step fraction. ## Audit of the merged #175 model **Confirmed:** per-lane FIFO refill consumption and the unbudgeted-read reporting both match real streams. **Refuted on real streams:** - Round 2 does not start at `48 + popcount(mask)`. Secondary headers fill freed Round-6 slots, so Round 7 always begins at offset 56. The formula lands off by one on the verified chunk above (it computes 55, which sits on the `s0` mode byte). - "Skip Round 1, take `refill[0]` in Round 2" never occurs on a constant lane: 59/59 take `refill[0]` in Round 6, while bit5=1 lanes read their prefetch byte in Round 7. - `--next-mask` matches reality only for lanes whose escape sits at decode step 0. Later escapes consume their byte mid-stream at the demand point, not in Round 2. - The inherited `EXCEPTIONS` table misses K=16 (`0xde` lane 7) and K=2 (`0xdb`), which limits real-lane coverage for anything built on it, including the supplied-refills decode path in #214. ## What stays open Variable-lane zero-refill states (`0xda`, `0x5f`, `0x1f`) do not fit the constant recurrence for any `K` in `{1,2,4,...,1024}` or any start offset; the variable symbol models are still unknown. Observable signatures so far: `0xda` states advance in exact +4.0101-bit steps, and `0x5f` states cluster in delta-2 pairs. Lane-to-BC7-field assignment is also unresolved, though the per-lane mode alphabets strongly suggest each lane streams a different block field.
mesterember104-cpu commented 2026-11-24 06:47:55 +00:00 (Migrated from github.com)
Author
Contributor

Imported from R0Y00/Xbox2Windows. Originally posted by mesterember104-cpu on 2026-11-21T19:27:59Z.


Thanks for the independent confirmation of the stride-6 counts (40/216, 25/27) — and for the pointer on the final segment. Recounted, with one open difference left.

(Same AI-agent disclosure as before: numbers collected by GLM on the account owner's local copy; plain static table facts.)

Block-count recount

Reading the chunk table including its zero terminator (n = 1,550 records; last record a=b=0), and taking every mode-7 segment's virtual extent from the next table entry's virtual offset — i.e. only the final non-zero entry would need the sentinel — I still get 2 × 1,024, 1 × 2,048, 14 × 4,096, 10 × 16,384. The final mode-7 segment is not the final table entry here (BC1 entries follow it), so its extent comes from the next entry either way.

Per-segment table for direct alignment (stored bytes, blocks from next-entry virtual offsets, ratio = stored/decoded, stream sha256 prefix):

# stored B blocks ratio sha256[:12]
1 31,232 2,048 0.953 c8f0d85df5c1
2 13,568 1,024 0.828 c15de481bb79
3 53,504 4,096 0.816 ac01f8adb869
4 200,704 16,384 0.766 638ab4545289
5 51,200 4,096 0.781 20b86e8c5ede
6 49,152 4,096 0.750 5dea6e8ddd0f
7 64,768 4,096 0.988 1086bad51675
8 62,720 4,096 0.957 94a62c6310f4
9 58,368 4,096 0.891 3049440a301b
10 57,600 4,096 0.879 f675bb9b2a67
11 61,696 4,096 0.941 529d8f92f646
12 65,024 4,096 0.992 2a9639248c6b
13 60,672 4,096 0.926 3333a10f3081
14 51,456 4,096 0.785 db29fe873a7e
15 204,032 16,384 0.778 fb9e07f640ba
16 196,352 16,384 0.749 dcbddbc481dd
17 247,296 16,384 0.943 10ffdb2ef308
18 218,624 16,384 0.834 582bdeff3962
19 207,616 16,384 0.792 31aaac178fe0
20 256,768 16,384 0.979 043da3a1eee2
21 257,792 16,384 0.983 d7fe9de81c8f
22 244,480 16,384 0.933 75a876e43951
23 247,808 16,384 0.945 d341d107acde
24 13,824 1,024 0.844 b73dc0132578
25 55,296 4,096 0.844 590c5ab0ebdc
26 212,480 16,384 0.811 d18bec9af4dd
27 61,184 4,096 0.934 0e1ce50db820

Median ratio 0.879 (the "≈12% under virtual size" in my first comment = this 0.88 family).

The one differing segment

If your recount assigns 16,384 blocks to the final mode-7 segment, that segment is presumably #27 above (0e1ce50db820, 61,184 stored bytes). Two observations for aligning:

  • Its stored/decoded ratio is 0.934 as a 4,096-block stream — inside the 0.75–0.99 family of the other 26. As a 16,384-block stream its ratio would be 0.233, a ~3.3× outlier versus every other segment.
  • If the declared logical end you read for it differs from the next-entry virtual offset, comparing against stream 0e1ce50db820 directly would pin whether we are segmenting the same bytes (my extent for it runs to the next entry's virtual offset; BC1 entries follow it in the table, and the store's zero terminator closes the table).

Also: appreciation for the lane-dependent K table upthread (0xde lane 7 → K=16 etc.) — that plus these headers should make the graphics-store streams a compact test corpus for the refills.

If it helps, I can re-run with your exact sentinel semantics (e.g. last mode-7 segment ending at the terminator's declared logical end) and post the resulting per-segment deltas.

<!-- greyfinch-sync:R0Y00/Xbox2Windows:comment:7068040735 --> Imported from [R0Y00/Xbox2Windows](https://github.com/R0Y00/Xbox2Windows/issues/15#issuecomment-7068040735). Originally posted by [mesterember104-cpu](https://github.com/mesterember104-cpu) on 2026-11-21T19:27:59Z. --- Thanks for the independent confirmation of the stride-6 counts (40/216, 25/27) — and for the pointer on the final segment. Recounted, with one open difference left. (Same AI-agent disclosure as before: numbers collected by GLM on the account owner's local copy; plain static table facts.) ## Block-count recount Reading the chunk table including its zero terminator (n = 1,550 records; last record `a=b=0`), and taking every mode-7 segment's virtual extent from the **next table entry's virtual offset** — i.e. only the final non-zero entry would need the sentinel — I still get **2 × 1,024, 1 × 2,048, 14 × 4,096, 10 × 16,384**. The final mode-7 segment is not the final table entry here (BC1 entries follow it), so its extent comes from the next entry either way. Per-segment table for direct alignment (stored bytes, blocks from next-entry virtual offsets, ratio = stored/decoded, stream sha256 prefix): | # | stored B | blocks | ratio | sha256[:12] | |---|---|---|---|---| | 1 | 31,232 | 2,048 | 0.953 | `c8f0d85df5c1` | | 2 | 13,568 | 1,024 | 0.828 | `c15de481bb79` | | 3 | 53,504 | 4,096 | 0.816 | `ac01f8adb869` | | 4 | 200,704 | 16,384 | 0.766 | `638ab4545289` | | 5 | 51,200 | 4,096 | 0.781 | `20b86e8c5ede` | | 6 | 49,152 | 4,096 | 0.750 | `5dea6e8ddd0f` | | 7 | 64,768 | 4,096 | 0.988 | `1086bad51675` | | 8 | 62,720 | 4,096 | 0.957 | `94a62c6310f4` | | 9 | 58,368 | 4,096 | 0.891 | `3049440a301b` | | 10 | 57,600 | 4,096 | 0.879 | `f675bb9b2a67` | | 11 | 61,696 | 4,096 | 0.941 | `529d8f92f646` | | 12 | 65,024 | 4,096 | 0.992 | `2a9639248c6b` | | 13 | 60,672 | 4,096 | 0.926 | `3333a10f3081` | | 14 | 51,456 | 4,096 | 0.785 | `db29fe873a7e` | | 15 | 204,032 | 16,384 | 0.778 | `fb9e07f640ba` | | 16 | 196,352 | 16,384 | 0.749 | `dcbddbc481dd` | | 17 | 247,296 | 16,384 | 0.943 | `10ffdb2ef308` | | 18 | 218,624 | 16,384 | 0.834 | `582bdeff3962` | | 19 | 207,616 | 16,384 | 0.792 | `31aaac178fe0` | | 20 | 256,768 | 16,384 | 0.979 | `043da3a1eee2` | | 21 | 257,792 | 16,384 | 0.983 | `d7fe9de81c8f` | | 22 | 244,480 | 16,384 | 0.933 | `75a876e43951` | | 23 | 247,808 | 16,384 | 0.945 | `d341d107acde` | | 24 | 13,824 | 1,024 | 0.844 | `b73dc0132578` | | 25 | 55,296 | 4,096 | 0.844 | `590c5ab0ebdc` | | 26 | 212,480 | 16,384 | 0.811 | `d18bec9af4dd` | | 27 | 61,184 | 4,096 | 0.934 | `0e1ce50db820` | Median ratio 0.879 (the "≈12% under virtual size" in my first comment = this 0.88 family). ## The one differing segment If your recount assigns **16,384** blocks to the final mode-7 segment, that segment is presumably #27 above (`0e1ce50db820`, 61,184 stored bytes). Two observations for aligning: - Its stored/decoded ratio is **0.934** as a 4,096-block stream — inside the 0.75–0.99 family of the other 26. As a 16,384-block stream its ratio would be 0.233, a ~3.3× outlier versus every other segment. - If the declared logical end you read for it differs from the next-entry virtual offset, comparing against stream `0e1ce50db820` directly would pin whether we are segmenting the same bytes (my extent for it runs to the next entry's virtual offset; BC1 entries follow it in the table, and the store's zero terminator closes the table). Also: appreciation for the lane-dependent K table upthread (0xde lane 7 → K=16 etc.) — that plus these headers should make the graphics-store streams a compact test corpus for the refills. If it helps, I can re-run with your exact sentinel semantics (e.g. last mode-7 segment ending at the terminator's declared logical end) and post the resulting per-segment deltas.
Ahmet-Dedeler commented 2026-11-24 06:48:09 +00:00 (Migrated from github.com)
Author
Contributor

Imported from R0Y00/Xbox2Windows. Originally posted by Ahmet-Dedeler on 2026-11-21T22:45:42Z.


Hey, we got BC1 BCPack decoding end to end, and the entropy layer now converges on every codec in the GTA VI pools (BC1, BC3, BC4, BC5, BC6H, BC7). Code and notes: https://github.com/Ahmet-Dedeler/bcpack-rs

What unlocked it: Microsoft published the MDU rANS decoder as MIT Verilog in 2023, https://github.com/microsoft/silicon-rans (mdu_minirans.v). It has the exact base/freq tables for 9 alphabet widths x 16 models, the 2/3 byte fragment header and the legal end states. It leaves out the feeder and the symbol vector assembly, which is the part this thread was mapping.

What fills those gaps (each checked by exact convergence: every lane ends in a legal state and bytes consumed = stored length minus pad):

  • Feeder: each clock, lanes that need a byte get one in lane order, max 8 bytes per clock. Symbol vector: lockstep, all lanes release together. This reproduces the 48 byte interleaved header, round 7 at offset 56 and the demand driven refills MarlomMedeiros measured, without modelling them separately.
  • The Verilog's alphabet_bits is lane width minus 1, which is why K depends on the lane (K = 2^(width - z)).
  • BC1: 12 lanes, widths 8,8,5,6,5,5,6,5,8,8,8,8, N = blocks. 15,000/15,000 chunks converge. Window 7 or 9, free symvec, N±1 or reversed lane order all give 0/120.
  • BC7: 16 lanes, widths 4,4,8,8,8,8,8,7,7,5,6,8,8,8,8,5, N = 2*blocks on every lane, one stream even for 65,536 block chunks (no 2x32,768 split). 4,600+ chunks converge, 0/1,180 controls.
  • The 3 byte header length is u16+257 like in the Verilog, not +1.
  • BC7 lane 15 (both symbols together) takes exactly 285 states, which is BC7's count of mode/partition/rotation combinations, and they cluster by mode. Lane layout per mode is mapped. The BC7 endpoint predictor isn't solved yet, still on it.

BC1 semantics, in case it helps with BC7:

  • Lane 0 is a back reference, d = unzigzag(v) mod 256, predictor = block i-d in stored Gfx10 order. References before block 0 read a fixed 256 slot preset endpoint table (fitted from data, in the repo).
  • Lanes 2-7 are R0 G0 B0 R1 G1 B1 zigzag residuals mod 2^width.
  • Lanes 8-11 are the 2x2 quadrants (TL TR BL BR). Each symbol indexes a fixed frequency ordered table of all 256 2x2 patterns (also fitted, in the repo).
  • Checked against the plain mip 1 of 3,000 textures: fitting the tables on half the pools and decoding the other half gives 34.7 / 34.0 dB median. Plain BC1 scores 37.9 on the same test.

Thanks to MarlomMedeiros for the round schedule work and to the SixNG notes, they made the search a lot smaller.

<!-- greyfinch-sync:R0Y00/Xbox2Windows:comment:7070407414 --> Imported from [R0Y00/Xbox2Windows](https://github.com/R0Y00/Xbox2Windows/issues/15#issuecomment-7070407414). Originally posted by [Ahmet-Dedeler](https://github.com/Ahmet-Dedeler) on 2026-11-21T22:45:42Z. --- Hey, we got BC1 BCPack decoding end to end, and the entropy layer now converges on every codec in the GTA VI pools (BC1, BC3, BC4, BC5, BC6H, BC7). Code and notes: https://github.com/Ahmet-Dedeler/bcpack-rs What unlocked it: Microsoft published the MDU rANS decoder as MIT Verilog in 2023, https://github.com/microsoft/silicon-rans (`mdu_minirans.v`). It has the exact base/freq tables for 9 alphabet widths x 16 models, the 2/3 byte fragment header and the legal end states. It leaves out the feeder and the symbol vector assembly, which is the part this thread was mapping. What fills those gaps (each checked by exact convergence: every lane ends in a legal state and bytes consumed = stored length minus pad): - Feeder: each clock, lanes that need a byte get one in lane order, max 8 bytes per clock. Symbol vector: lockstep, all lanes release together. This reproduces the 48 byte interleaved header, round 7 at offset 56 and the demand driven refills MarlomMedeiros measured, without modelling them separately. - The Verilog's `alphabet_bits` is lane width minus 1, which is why K depends on the lane (K = 2^(width - z)). - BC1: 12 lanes, widths 8,8,5,6,5,5,6,5,8,8,8,8, N = blocks. 15,000/15,000 chunks converge. Window 7 or 9, free symvec, N±1 or reversed lane order all give 0/120. - BC7: 16 lanes, widths 4,4,8,8,8,8,8,7,7,5,6,8,8,8,8,5, N = 2*blocks on every lane, one stream even for 65,536 block chunks (no 2x32,768 split). 4,600+ chunks converge, 0/1,180 controls. - The 3 byte header length is u16+257 like in the Verilog, not +1. - BC7 lane 15 (both symbols together) takes exactly 285 states, which is BC7's count of mode/partition/rotation combinations, and they cluster by mode. Lane layout per mode is mapped. The BC7 endpoint predictor isn't solved yet, still on it. BC1 semantics, in case it helps with BC7: - Lane 0 is a back reference, d = unzigzag(v) mod 256, predictor = block i-d in stored Gfx10 order. References before block 0 read a fixed 256 slot preset endpoint table (fitted from data, in the repo). - Lanes 2-7 are R0 G0 B0 R1 G1 B1 zigzag residuals mod 2^width. - Lanes 8-11 are the 2x2 quadrants (TL TR BL BR). Each symbol indexes a fixed frequency ordered table of all 256 2x2 patterns (also fitted, in the repo). - Checked against the plain mip 1 of 3,000 textures: fitting the tables on half the pools and decoding the other half gives 34.7 / 34.0 dB median. Plain BC1 scores 37.9 on the same test. Thanks to MarlomMedeiros for the round schedule work and to the SixNG notes, they made the search a lot smaller.
Sign in to join this conversation.
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
R0Y00/Xbox2Windows#15
No description provided.