Repository navigation
fix(metal): seed never-included code-blocks with zero in the zero-bitplane tree - #302
Merged
Merged
Conversation
…plane tree The Metal packetizer gave a code-block with no coding passes its own zero-bitplane count (all bitplanes) in the zero-bitplane tag tree, while the CPU packetizer seeds it with zero. Decoders never read that leaf, but it lowers or raises the parent minimum, so headers with an empty block beside coded ones differed: all-stage Metal lossy encodes were valid but not byte-identical to the CPU (mosaic qfactor 86: 2 bytes shorter). The Metal tree now seeds such blocks as the CPU does. (cherry picked from commit 575f6d2e2f3b3743d71ce91fbf60c660d55c2873) (cherry picked from commit 6341a18dd2c33d30ece345ddb1b8a2b0c946706b)
jcwal1516
force-pushed
the
fix/metal-zero-bitplane-seed
branch
from
October 29, 2026 05:09
431cdf3 to
a8e8748
Compare
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Stacked on #301. Makes all-stage Metal lossy encodes byte-identical to the CPU encoder.
The Metal packetizer gave a code-block with no coding passes its own zero-bitplane count (all bitplanes) in the zero-bitplane tag tree, while the CPU packetizer seeds it with zero. Decoders never read that leaf, but it lowers or raises its parent's minimum, so packet headers with an empty block beside coded ones differed: the codestreams were valid but not byte-identical to the CPU's. The Metal tree, in both the host-fed and resident classic packetizers, now seeds such blocks with zero as the CPU does.
Testing
metal_all_stage_lossy_encodes_match_cpu_bytes_with_empty_code_blocksencodes a 256 × 256 RGB image whose flat half leaves empty code-blocks beside coded ones, and compares Metal and CPU codestreams byte for byte for HT (default and qfactor 60) and classic. It fails on the previous kernel ("HighThroughput None": header bytes differ) and passes with this change.J2K_REQUIRE_METAL_RUNTIME=1 cargo test -p j2k-metal(587 passed) andcargo xtask metal-compilepass.