Skip to content

Add native span paths for JPEG XL - #394

Merged
Hawkynt merged 2 commits into
mainfrom
feat/native-span-jxl
Sep 28, 2026
Merged

Hawkynt merged 2 commits into
mainfrom
feat/native-span-jxl

Conversation

@Hawkynt

@Hawkynt Hawkynt commented Sep 25, 2026 •

Copy link
Copy Markdown
Owner

What changed

  • Add native zero-copy ListSpan / ExtractSpan paths for JPEG XL.
  • Refactor JXL archive entries around source-range layouts instead of owned payload arrays.
  • Represent multipart jxlp codestreams as one logical codestream.jxl entry backed by multiple source ranges.
  • Preserve the existing stream API by materializing the same layouts into owned byte[] values.
  • Keep OpenEntrySpan on the owning compatibility path.

Why

JPEG XL containers may carry the codestream either in one jxlc box or split across multiple jxlp boxes. The existing implementation concatenated all partial codestream payloads into a MemoryStream and then called ToArray(). For span callers, that defeats the point of the native path.

The new layout stores:

  • generated metadata.ini as owned bytes;
  • FULL.jxl, metadata boxes, and single jxlc as direct source ranges;
  • multipart jxlp codestreams as an ordered list of source ranges, excluding each 4-byte partial-index field.

Validation added

NativeSpanArchiveInputTests now covers 16 native-span formats and adds a multipart JXL case with two jxlp boxes.

The shared suite verifies:

  • span listings match the existing stream listings;
  • selected-entry extraction is byte-identical;
  • 4 MiB listing avoids whole-image copies;
  • 4 MiB multipart JXL extraction stays below the 1 MiB allocation ceiling while producing the exact concatenated codestream.

References / licensing

libjxl is BSD-3-Clause. No source code was copied or translated; the implementation is an independent refactor of the repository's existing parser and preserves its current box-order concatenation semantics. No dependencies were added.

Validation

CI run 36110823481 completed successfully on the repository README job, Ubuntu, and Windows. This includes Release builds, Core tests (including the 16-format native-span equivalence/allocation suite and multipart JXL extraction), NuGet/meta-package validation, structured-format oracles, end-to-end and external interoperability, external filesystem interoperability, OS integration, polyglot interoperability, performance tests, and package README checks.

@Hawkynt
Hawkynt merged commit 17200a6 into main Sep 28, 2026
5 checks passed
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