BC1: lane 1 is the index reference #11

Manually merged
github merged 1 commit from gh-pr/11/head into gh-pr/11/base 2026-11-26 18:56:09 +00:00
Owner

@⁠Ahmet-Dedeler on GitHub · 2026-11-26 02:52 UTC · original
Ahmet-Dedeler:fix/bc1-index-reference → master · +122 −18 · 7 files · 1 commits · merged 2026-11-26 02:53 UTC

Fixes #10.

The BC1 assembler ignored lane 1 and took the endpoint reference straight from lane 0. The BC3, BC4 and BC5 path already reads both lanes through format::references, and BC1 works the same way:

  • lane 1 is the index reference x (blocks back, 0 = none)
  • the endpoint reference is x + unzigzag(lane 0), mod 256
  • each pixel's index residual is added along the endpoint line (codes 0, 2, 3, 1 = positions 0, 1, 2, 3), mod 4, to the same pixel of block i - x
  • an index reference before block 0 has no known table yet, so it reads zero and the block counts as unfitted

What changes for real data: nothing that's been measured. Lane 1 was 0 in every retail chunk checked, and with lane 1 = 0 the output is the same by construction. It matters for streams that do use lane 1, like other encoders' output, and for anyone using bcpack-rs as a bit-exact oracle.

Tests

  • New bc1_lane1_index_reference: tyr0nsur's two-block case from #10. With lane 1 = 1 the second block is now a1 17 5d f0 0a 0a 5f f5, the output reported for VIctory's assembler. With lane 1 = 0 it's unchanged (00 00 00 00 aa aa aa aa).
  • The synthetic goldens and the Python vectors use random lane-1 symbols, so they're re-blessed. The Python reference got the same rule and its selftest agrees with Rust on the new vectors.
  • cargo test --release: all pass. python3 python/bcpack.py selftest: ok.
  • Not run: the retail checks in tools/retail/.

Spec section 5.1 and the lane table now describe lane 1.

**@⁠Ahmet-Dedeler** on GitHub · 2026-11-26 02:52 UTC · [original](https://github.com/Ahmet-Dedeler/bcpack-rs/pull/11) `Ahmet-Dedeler:fix/bc1-index-reference` → `master` · +122 −18 · 7 files · 1 commits · merged 2026-11-26 02:53 UTC Fixes #10. The BC1 assembler ignored lane 1 and took the endpoint reference straight from lane 0. The BC3, BC4 and BC5 path already reads both lanes through `format::references`, and BC1 works the same way: - lane 1 is the index reference `x` (blocks back, 0 = none) - the endpoint reference is `x + unzigzag(lane 0)`, mod 256 - each pixel's index residual is added along the endpoint line (codes 0, 2, 3, 1 = positions 0, 1, 2, 3), mod 4, to the same pixel of block `i - x` - an index reference before block 0 has no known table yet, so it reads zero and the block counts as unfitted **What changes for real data:** nothing that's been measured. Lane 1 was 0 in every retail chunk checked, and with lane 1 = 0 the output is the same by construction. It matters for streams that do use lane 1, like other encoders' output, and for anyone using bcpack-rs as a bit-exact oracle. **Tests** - New `bc1_lane1_index_reference`: tyr0nsur's two-block case from #10. With lane 1 = 1 the second block is now `a1 17 5d f0 0a 0a 5f f5`, the output reported for VIctory's assembler. With lane 1 = 0 it's unchanged (`00 00 00 00 aa aa aa aa`). - The synthetic goldens and the Python vectors use random lane-1 symbols, so they're re-blessed. The Python reference got the same rule and its selftest agrees with Rust on the new vectors. - `cargo test --release`: all pass. `python3 python/bcpack.py selftest`: ok. - Not run: the retail checks in `tools/retail/`. Spec section 5.1 and the lane table now describe lane 1.
The BC1 assembler ignored lane 1 and took the endpoint reference straight
from lane 0. Like the BC3/BC4/BC5 lanes (format::references), lane 1 is the
index reference x and the endpoint reference is x + unzigzag(lane 0). Each
pixel's index residual is now added along the endpoint line, modulo 4, to
the same pixel of block i - x. An index reference before block 0 reads zero
and counts as unfitted.

Lane 1 was 0 in every retail chunk measured, and with lane 1 = 0 the output
is unchanged by construction. The synthetic goldens and Python vectors use
random lane-1 symbols, so they were re-blessed; the Python reference gets
the same rule and agrees with Rust on them. New test: tyr0nsur's two-block
case from #10, which now matches the reported VIctory output.

Co-Authored-By: Claude Opus 5.5 <[email protected]>
github-bot locked as GitHub sync and limited conversation to collaborators 2026-11-26 18:56:08 +00:00
github manually merged commit 245e0c751e into gh-pr/11/base 2026-11-26 18:56:09 +00:00
Author
Owner

@⁠coderabbitai[bot] on GitHub · 2026-11-26 02:53 UTC · original

Explain Change →

Caution

Review failed

The pull request is closed.

  • Autofix · Keep fixing CodeRabbit findings and required CI, and resolving merge conflicts

Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out.

Share

**@⁠coderabbitai[bot]** on GitHub · 2026-11-26 02:53 UTC · [original](https://github.com/Ahmet-Dedeler/bcpack-rs/pull/11#issuecomment-7181204386) <!-- coderabbit-ai-generated:v1 --> <!-- This is an auto-generated comment: summarize by coderabbit.ai --> <!-- review_stack_entry_start --> <a href="https://app.coderabbit.ai/change-stack/Ahmet-Dedeler/bcpack-rs/pull/11?scope=ghh_OusAJGA4HG8ljoOV0wJvVx8NmnZIjc2DdjmxOu0xZWA&amp;cs_source=review_comment"><picture><source media="(prefers-color-scheme: dark)" srcset="https://storage.googleapis.com/coderabbit_public_assets/review-stack-buttons-v1/explain-change-dark.svg"><source media="(prefers-color-scheme: light)" srcset="https://storage.googleapis.com/coderabbit_public_assets/review-stack-buttons-v1/explain-change.svg"><img src="https://storage.googleapis.com/coderabbit_public_assets/review-stack-buttons-v1/explain-change.svg" alt="Explain Change →" height="32"></picture></a> <!-- review_stack_entry_end --> <!-- This is an auto-generated comment: failure by coderabbit.ai --> > [!CAUTION] > ## Review failed > > <!-- failure_reason_start --> > The pull request is closed. > <!-- failure_reason_end --> <!-- end of auto-generated comment: failure by coderabbit.ai --> <!-- autopilot:start --> - [ ] <!-- {"checkboxId":"2708ad07-9f24-4260-9c11-7dc76a49f2e3"} --> <strong title="Keep fixing CodeRabbit findings and required CI, and resolving merge conflicts">Autofix</strong> · Keep fixing CodeRabbit findings and required CI, and resolving merge conflicts <!-- autopilot:end --> <!-- tips_start --> Thanks for using [CodeRabbit](https://coderabbit.ai?utm_source=oss&utm_medium=github&utm_campaign=Ahmet-Dedeler/bcpack-rs&utm_content=11)! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out. <details> <summary><strong>Share</strong></summary> <dl> <dd> <br> - [X](https://twitter.com/intent/tweet?text=I%20just%20used%20%40coderabbitai%20for%20my%20code%20review%2C%20and%20it%27s%20fantastic%21%20It%27s%20free%20for%20OSS%20and%20offers%20a%20free%20trial%20for%20the%20proprietary%20code.%20Check%20it%20out%3A&url=https%3A//coderabbit.ai) - [Mastodon](https://mastodon.social/share?text=I%20just%20used%20%40coderabbitai%20for%20my%20code%20review%2C%20and%20it%27s%20fantastic%21%20It%27s%20free%20for%20OSS%20and%20offers%20a%20free%20trial%20for%20the%20proprietary%20code.%20Check%20it%20out%3A%20https%3A%2F%2Fcoderabbit.ai) - [Reddit](https://www.reddit.com/submit?title=Great%20tool%20for%20code%20review%20-%20CodeRabbit&text=I%20just%20used%20CodeRabbit%20for%20my%20code%20review%2C%20and%20it%27s%20fantastic%21%20It%27s%20free%20for%20OSS%20and%20offers%20a%20free%20trial%20for%20proprietary%20code.%20Check%20it%20out%3A%20https%3A//coderabbit.ai) - [LinkedIn](https://www.linkedin.com/sharing/share-offsite/?url=https%3A%2F%2Fcoderabbit.ai&mini=true&title=Great%20tool%20for%20code%20review%20-%20CodeRabbit&summary=I%20just%20used%20CodeRabbit%20for%20my%20code%20review%2C%20and%20it%27s%20fantastic%21%20It%27s%20free%20for%20OSS%20and%20offers%20a%20free%20trial%20for%20proprietary%20code) </dd> </dl> </details> <!-- tips_end -->
Author
Owner

@⁠chatgpt-codex-connector[bot] on GitHub · 2026-11-26 02:53 UTC · original · edited 2026-11-26 02:56 UTC

Codex Review Summary: ✅ Completed

This comment shows the latest Codex review activity on this pull request.

Review Status Commit Review trigger
📝 Code Review ✅ Completed 2026-11-26T02:56:28.138101Z 245e0c7 PR opened
ℹ️ About Codex in GitHub

Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you

  • Open a pull request for review
  • Mark a draft as ready
  • Comment "@⁠codex review" or "@⁠codex security review".

Codex reacts with 👀 while any review is running, comments if it has suggestions, and reacts with 👍 once all reviews finish with no findings.

**@⁠chatgpt-codex-connector[bot]** on GitHub · 2026-11-26 02:53 UTC · [original](https://github.com/Ahmet-Dedeler/bcpack-rs/pull/11#issuecomment-7181204394) · edited 2026-11-26 02:56 UTC <!-- codex-pull-request-review-summary --> <!-- codex-review-state:v1 {"code_review":{"commit_sha":"245e0c751ea54070a27bea50e3b8975800d779ba","has_any_findings":true,"has_unresolved_findings":true,"status":"completed"},"security_review":{"commit_sha":null,"has_any_findings":null,"has_unresolved_findings":null,"status":null}} --> <details> <summary><strong>Codex Review Summary</strong>: ✅ Completed</summary> This comment shows the latest Codex review activity on this pull request. | Review | Status | Commit | Review trigger | | --- | --- | --- | --- | | 📝 **Code Review** | ✅ **Completed** <relative-time datetime="2026-11-26T02:56:28.138101Z">2026-11-26T02:56:28.138101Z</relative-time> | `245e0c7` | PR opened | <details> <summary>ℹ️ About Codex in GitHub</summary> <br/> [Your team has set up Codex to review pull requests in this repo](https://chatgpt.com/codex/cloud/settings/general). Reviews are triggered when you - Open a pull request for review - Mark a draft as ready - Comment "@⁠codex review" or "@⁠codex security review". Codex reacts with 👀 while any review is running, comments if it has suggestions, and reacts with 👍 once all reviews finish with no findings. </details> </details>
Author
Owner

@⁠chatgpt-codex-connector[bot] on GitHub · 2026-11-26 02:56 UTC · original · reviewed

💡 Codex Review

Here are some automated review suggestions for this pull request.

Reviewed commit: 245e0c751e

ℹ️ About Codex in GitHub

Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you

  • Open a pull request for review
  • Mark a draft as ready
  • Comment "@⁠codex review".

If Codex has suggestions, it will comment; otherwise it will react with 👍.

Codex can also answer questions or update the PR. Try commenting "@⁠codex address that feedback".

**@⁠chatgpt-codex-connector[bot]** on GitHub · 2026-11-26 02:56 UTC · [original](https://github.com/Ahmet-Dedeler/bcpack-rs/pull/11#pullrequestreview-6067939602) · **reviewed** <!-- codex-review-receipt:v1 --> ### 💡 Codex Review Here are some automated review suggestions for this pull request. **Reviewed commit:** `245e0c751e` <details> <summary>ℹ️ About Codex in GitHub</summary> <br/> [Your team has set up Codex to review pull requests in this repo](https://chatgpt.com/codex/cloud/settings/general). Reviews are triggered when you - Open a pull request for review - Mark a draft as ready - Comment "@⁠codex review". If Codex has suggestions, it will comment; otherwise it will react with 👍. Codex can also answer questions or update the PR. Try commenting "@⁠codex address that feedback". </details>
@ -233,0 +241,4 @@
let (ref_line, ref_t) = if x == 0 {
(0, false)
} else if x <= i {
(lines[(i - x) & 255], tainted[(i - x) & 255])
Author
Owner

@⁠chatgpt-codex-connector[bot] on GitHub · 2026-11-26 02:56 UTC · original

P2 Badge Track endpoint and index taint separately

When a reference uses a prior block whose tainted bit came only from the other predictor—for example, an index reference to a block with an unfitted endpoint—this propagates uncertainty even though index line positions do not depend on endpoints, and endpoints do not depend on index lines. That overcounts unfitted_blocks and can make the scan’s clean tally reject otherwise fitted output; keep separate taint histories and combine them only when counting the current block.

Useful? React with 👍 / 👎.

**@⁠chatgpt-codex-connector[bot]** on GitHub · 2026-11-26 02:56 UTC · [original](https://github.com/Ahmet-Dedeler/bcpack-rs/pull/11#discussion_r4703384625) **<sub><sub>![P2 Badge](https://img.shields.io/badge/P2-yellow?style=flat)</sub></sub> Track endpoint and index taint separately** When a reference uses a prior block whose `tainted` bit came only from the other predictor—for example, an index reference to a block with an unfitted endpoint—this propagates uncertainty even though index line positions do not depend on endpoints, and endpoints do not depend on index lines. That overcounts `unfitted_blocks` and can make the scan’s `clean` tally reject otherwise fitted output; keep separate taint histories and combine them only when counting the current block. Useful? React with 👍 / 👎. <!-- codex-code-review-finding:v1 -->
This discussion has been locked. Commenting is limited to contributors.
No description provided.