BC5/BC7 entropy stage: two symbol vectors per 16-byte block (structural notes) #5
Labels
No labels
accessibility
bug
documentation
duplicate
enhancement
good first issue
help wanted
invalid
question
wontfix
No milestone
No assignees
1 participant
Notifications
Due date
No due date set.
Dependencies
No dependencies set
Reference
github/Ahmet-Dedeler--bcpack-rs#5
Loading…
Reference in a new issue
No description provided.
Delete branch "%!s()"
Deleting a branch is permanent. Although the deleted branch may continue to exist for a short time before it actually gets removed, it CANNOT be undone in most cases. Continue?
@nineforge0 on GitHub · 2026-11-24 08:49 UTC · original
Sharing structural findings from an independent decoder, in case they help extend decode past BC1. All statistics are from 100 BC5 + 27 BC7 + 1 BC3 real BCPack chunks. No fitted tables or values copied from anywhere — structure and statistics only.
Key correction: two vectors per block
Each lane emits
virtual_length / 8symbols (the same 8-byte unit as BC1), so a 16-byte BCn block takes two symbol vectors, not one.virtual_length / 16(one per block)virtual_length / 8With one vector per block the rANS stream stalls after 27-51% of the stored bytes, which is also why individual lane widths look wrong when tested alone. The two vectors of block i are vectors 2i and 2i+1 (confirmed by mutual information: MI(2i,2i+1) >> MI(2i+1,2i+2), e.g. BC7 lane 15: 1.72 vs 0.07 bits).
Confirmed structure
[4,4,8,8,6,6,6,6,6,6,6,6], BC7[4,4,8,8,8,8,8,7,7,5,6,8,8,8,8,5]. Changing any one lane by +-1 breaks every chunk.The remaining gap
The entropy layer is exact; what is missing is the fixed transform from each block's two symbol vectors to its 16 BCn bytes. It is not in the stream (only fragment headers + rANS payload), so it must be fitted against reference data (e.g. the plain zlib mips stored next to the BCPack mip-0 slices).
Full notes (counts and statistics only): https://github.com/nineforge0/forge9/blob/main/docs/bcpack_bc5_bc7_structure.md — reproduce with
forge9 bcpack-analyze store.ttpf --codec bc5.@Ahmet-Dedeler on GitHub · 2026-11-24 13:35 UTC · original
Thanks for writing this up. It matches what I have on the
bc5-bc7branch, which got to the same structure independently: two symbols per lane for 16-byte blocks and the same lane widths. Good to have a second measurement of both.That branch goes one step further than the entropy layer. The block rebuild rules for BC3, BC4, BC5 and BC7 are in
src/bcn.rsandsrc/bc7.rs, and with the format's tables they are byte-identical to a reference decoder on every chunk I have (BC5 4.9 M blocks, BC7 80 M, 0 differing). The writeup is indocs/findings/bc345-bc7.md. Short version of the parts you list as open:It is not on master yet because there is no encoder, CLI or Python mirror for those modes. If you try the branch and something disagrees with your 128 chunks, I'd like to hear it.
@nineforge0 on GitHub · 2026-11-24 14:37 UTC · original
Validated the
bc5-bc7branch (headc55c5fa) against our 129 real chunks (1 BC3, 100 BC5, 28 BC7; 651,264 blocks). Clean, no disagreements.unpack,pack(unpack(b)) == bon every block,unknown_controls = 0everywhere. Modes 0 and 2 are 64,083 of 239,616 BC7 blocks (26.7%); some chunks are ~84% mode 0/2 and still decode cleanly, so your latest control-code fill holds.Two small things from the run:
data/bc7.jsonhas"subsets": nullon all 255 entries, which trips an "unfitted" flag downstream even though those blocks decode correctly — looks like a leftover now that modes are filled in.docs/findings/bc345-bc7.mdstill says the dictionaries / BC3 quadrant ranks / mode 0/2 codes ship as null;c55c5fafills them, so that section is stale.Thanks for the invite to test it — nice work. We pinned forge9's texture decode to this branch.
@Ahmet-Dedeler on GitHub · 2026-11-25 14:16 UTC · original
Thanks for testing it on your 129 chunks and catching those two things.
bc5-bc7is now merged intomaster(7b2dfb7), along with both fixes inf5145dd:"subsets": 1on all 255 entries indata/bc7.json(each dictionary entry is a single-subset state, sofromalready fell back to subset 0 for every row andnullwas just trippingunfitted_blockson multi-subset blocks). Added a test intests/modes.rsto verify multi-subset blocks referencing the dictionary come back withunfitted_blocks == 0.docs/findings/bc345-bc7.md(plusREADME.mdand the crate docs) to reflect the filled tables fromc55c5faand the current library vs CLI status.You can point forge9 back to
masternow. Open a new issue if anything else turns up.