BC6H: avoid negative zero after signed final scaling #24

Manually merged
github merged 1 commit from gh-pr/24/head into gh-pr/24/base 2026-11-26 20:03:47 +00:00
Owner

@⁠ifBars on GitHub · 2026-11-23 01:57 UTC · original
ifBars:fix/bc6h-signed-zero → claude/interesting-mcclintock-bff8f2 · +16 −3 · 1 files · 1 commits · merged 2026-11-23 02:20 UTC

Found a small edge case while checking #23 against bcdec and Microsoft's BC6H decoder rules. finish(-1, true) returns 0x8000, but scaling first should give 0x0000.

This moves sign selection after scaling and adds a synthetic block regression. It changes the half-float bits; the clamped PNG looks the same.

I based this on #23's branch to keep the diff small. The new test fails before the fix. With it, cargo test --locked -p sixng-core --no-default-features --lib passes 84 tests, with one existing real-data test ignored. I also checked the adapted decoder against bcdec across 147,456 synthetic blocks for each signedness, and all 14,155,776 half values match.

**@⁠ifBars** on GitHub · 2026-11-23 01:57 UTC · [original](https://github.com/holdmysocks/SixNG/pull/24) `ifBars:fix/bc6h-signed-zero` → `claude/interesting-mcclintock-bff8f2` · +16 −3 · 1 files · 1 commits · merged 2026-11-23 02:20 UTC Found a small edge case while checking #23 against bcdec and [Microsoft's BC6H decoder rules](https://learn.microsoft.com/en-us/windows/win32/direct3d11/bc6h-format#unquantization-of-color-endpoints). `finish(-1, true)` returns `0x8000`, but scaling first should give `0x0000`. This moves sign selection after scaling and adds a synthetic block regression. It changes the half-float bits; the clamped PNG looks the same. I based this on #23's branch to keep the diff small. The new test fails before the fix. With it, `cargo test --locked -p sixng-core --no-default-features --lib` passes 84 tests, with one existing real-data test ignored. I also checked the adapted decoder against bcdec across 147,456 synthetic blocks for each signedness, and all 14,155,776 half values match.
github-bot locked as GitHub sync and limited conversation to collaborators 2026-11-26 20:03:46 +00:00
github manually merged commit 36058e0fbf into gh-pr/24/base 2026-11-26 20:03:47 +00:00
Author
Owner

@⁠holdmysocks on GitHub · 2026-11-23 02:22 UTC · original

Thanks for the fix. This PR targeted #23's branch, which had already been merged, so it was cherry-picked onto master as e0ebb4b with your authorship kept.

**@⁠holdmysocks** on GitHub · 2026-11-23 02:22 UTC · [original](https://github.com/holdmysocks/SixNG/pull/24#issuecomment-7089887559) Thanks for the fix. This PR targeted #23's branch, which had already been merged, so it was cherry-picked onto `master` as e0ebb4b with your authorship kept.
This discussion has been locked. Commenting is limited to contributors.
No description provided.