Add jxl-rs decoder - #199
Open
iamcarbon wants to merge 4 commits into
Open
Conversation
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.
Summary
This PR adds an experimental
PhotoSauce.NativeCodecs.JxlRsdecoder plugin backed by the pure-Rust jxl-rs decoder.The change is additive and does not remove the existing libjxl implementation or encoder. Applications can opt in with:
Implementation
Exifboxes.cdylibthrough Cargo and copies it alongside the managed assembly.net8.0andnet472.Input and decoding
MemoryStreamandUnmanagedMemoryStreaminputs are consumed in place.NeedsMoreInputstate machine.EXIF
jxl-rs does not currently expose arbitrary container boxes, so this adds a small allocation-free JPEG XL box parser.
The parser:
IExifSourcedestination when requested.Brotli-compressed
brobmetadata boxes are not supports on .NETFramework (is it time to consider dropping .NETFramework ? :)) .4K decode benchmark
Windows x64, .NET 10.0.10, 64 logical processors. The input was a deterministic 3840×2160 mixed-detail BGR image encoded by libjxl at distance
1.0, effort5(Hare), producing a 6.90 MiB payload.The benchmark performs a complete MagicScaler open-and-full-frame-copy operation, with three warmups and twelve measured iterations in alternating order.
On this workload, jxl-rs had 1.13× libjxl's median latency (
+13.3%) and 0.88× its throughput.The decoded outputs differed only by rounding:
0.2445081These are single-machine directional results rather than a comprehensive cross-platform benchmark.
Validation
cargo test --locked: 3 passed, 0 failed.net8.0andnet472.brobboxesCurrent limitations
brob-compressed EXIF is not exposed.Built with the assistance of GPT-5.6 Sol.