Skip to content

fix(j2k): decode shared component grids for CPU batches and regions - #393

Merged
jcwal1516 merged 7 commits into
mainfrom
fix/shared-sampling-c-prereqs
Dec 3, 2026
Merged

jcwal1516 merged 7 commits into
mainfrom
fix/shared-sampling-c-prereqs

Conversation

@jcwal1516

@jcwal1516 jcwal1516 commented Dec 3, 2026 •

Copy link
Copy Markdown
Member

What and why

When all JPEG 2000 components are sampled at the same interval, the decoder writes a smaller grid of samples. Rust batch planning used the full image dimensions or rejected the input. A half-sized gray output could also copy SIMD padding into a caller's longer slice.

Report the output sampling from the native header and the Rust reference grid, map image-relative requests to the samples they cover, and prepare and decode CPU batches with that geometry. This gives the C bindings the output dimensions and layouts they need. The CLI keeps its documented input restrictions, and explicit GPU batch requests keep their error contract for these layouts.

Impact

  • Changes caller-visible CPU decode behavior for full, reduced, and region requests on uniformly subsampled images.
  • Changes output-size accounting to use the planned sample grid. An area between samples returns an unsupported error.
  • Adds sampling metadata to the Rust reference grid and hidden native adapter support. Snapshots and the API review are updated.
  • The generated regression fixtures use small synthetic images. The changes preserve mixed-sampling behavior and the C/C++ ABI.

Testing

  • The native grid, gray padding, device-plan, CLI, deep-scale, coding-style, and prepared-batch regressions passed. The affected integration suites included 23 deep-scale tests, 6 coding-style tests and 69 batch tests (1 ignored).
  • Project formatting, Clippy, semver, public support, and the warnings-as-errors no-std check passed.
  • The focused explicit-device test passed on an M5 Max with Metal required. GitHub’s quick CUDA and Metal validation passed on this PR.
  • On the cumulative C/C++ stack, host changed-line coverage was 193/195 (98.97%) and critical-path coverage was 11/11.
  • Regression coverage and an Unreleased changelog entry are included.

Expose the sampling shared by every component on native images and inspected reference grids, while retaining the full image-area size separately for recovered-header callers.
Pack only a gray plane’s decoded samples so component-grid decodes into image-area-sized buffers leave every byte past the decoded grid untouched.
Map full, region, reduced, row, component, and prepared CPU batch outputs onto the grid shared by every component. Report that sampling in reference-grid metadata, reject regions that hold no sample, and preserve the full image area for recovered headers.
Pin that newly preparable metadata-only shared-sampling groups and operations remain explicit Metal or CUDA errors and never decode on the CPU.
Refresh the 0.14 public API snapshots, review fingerprints, and generated diff for the new native and facade output-sampling fields and hidden image geometry accessors.
Reject uniformly subsampled component grids explicitly before the opj_decompress-compatible command can take the newly supported facade path with the wrong output interpretation.
Document that CPU pixel decoding now returns the smaller grid shared by uniformly sampled components and maps regions onto the samples they contain.
@jcwal1516
jcwal1516 added this pull request to stack #395 December 3, 2026 15:13
@jcwal1516
jcwal1516 marked this pull request as ready for review December 3, 2026 15:34
@jcwal1516
jcwal1516 merged commit edf600b into main Dec 3, 2026
42 of 49 checks passed
@jcwal1516
jcwal1516 deleted the fix/shared-sampling-c-prereqs branch December 3, 2026 16:57
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant