Skip to content

Add a CPU JPEG XR encoder and prepare 0.5.2 - #31

Merged
jcwal1516 merged 2 commits into
mainfrom
feat/cpu-encoder
Nov 19, 2026
Merged

jcwal1516 merged 2 commits into
mainfrom
feat/cpu-encoder

Conversation

@jcwal1516

Copy link
Copy Markdown
Member

Summary

Adds a CPU JPEG XR encoder and prepares the 0.5.2 release.

  • jxr::encode writes an Annex-A .jxr file from a SourceImage; encode_codestream and encode_codestreams return the raw codestreams.
  • Formats: grayscale, RGB and BGR at every depth the decoder returns (1-bit to 32-bit float, packed RGB, RGBE), 8/16-bit CMYK, three- to eight-channel samples, and YUV 4:4:4 / 4:2:2 / 4:2:0 at 8, 10 and 16 bits. Alpha can be separate (the default) or integrated, and can be quantized apart from colour. SourceSamples converts from DecodedSamples, so decoder output can be re-encoded.
  • Coding options: lossless, EncodeRequest::quality (0–100), or per-band quantizers; spatial or frequency bitstream mode (thumbnail decode at 1/4 and 1/16); chroma subsampling to 4:2:2 / 4:2:0; overlap filtering, tiling, flexbits trimming, and packet layout.
  • Full-resolution CPU decodes now run as a stream of row strips, shared with the encoder's analysis stages. This replaces the per-format tile_decode modules.
  • New dev-only crates jxr-alloc-probe (memory tests) and jxr-wasm-size, plus tools/wasm_size_check.py. CI now runs the WebAssembly size gate and the fixed cases of the encode_roundtrip fuzz harness.

Decode output change

With SCALED_FLAG set, every component after the first is now reconstructed at double weight in any colour format, through jxr_core::scaled_after_first_transform. 0.5.1 applied this only to YUV. CPU, Metal and CUDA share the rule. Decoded output changes only for scaled CMYK and N-component images. The T.834 comparisons below are unchanged, so the corpus may not include such files.

Release

cargo semver-checks reports no semver update required for any changed package, so the release stays on the 0.5 line. All eight published crates are re-released because of the exact internal pins. Publish order, also in docs/releasing.md:

# Crate Version
1 jxr-math 0.2.0 → 0.2.1
2 jxr-core 0.5.0 → 0.5.1
3 jxr-native 0.5.1 → 0.5.2
4 jxr-metal 0.5.1 → 0.5.2
5 jxr-cuda 0.5.0 → 0.5.1
6 jxr 0.5.1 → 0.5.2
7 jxr-image 0.5.1 → 0.5.2 (pin only)
8 jxr-mpsgraph 0.6.1 → 0.6.2 (pin only)

Checks run (aarch64 macOS, Rust 1.99.0)

  • All ci.yml gates locally:
    • fmt, plus the CUDA kernel rustfmt check
    • workspace and fuzz clippy with -D warnings
    • cargo test --workspace --all-features and cargo test -p jxr --no-default-features: 699 passed, 0 failed, 16 ignored
    • cargo doc with -D warnings
    • WebAssembly size gate: base 407,889 bytes against a 412,000 budget; simd128 429,842 against 434,100
    • fuzz encode_roundtrip fixed cases
  • T.834/T.835 reference comparisons: CPU, Annex-A writer (--rewrap) and Metal each passed 517 in-scope cases, 179 out of scope, 0 harness-unsupported, 0 failed.
  • cargo package for all eight crates builds each tarball against crates.io dependencies, including J2K 0.14.0. All verified.
  • cargo semver-checks check-release: no semver update required for jxr-math, jxr-core, jxr-native, jxr-metal, jxr-cuda or jxr.

Not yet validated

  • CUDA hardware: not run. Compiles on macOS only, with CUDA Oxide kernels unavailable. Needs the CUDA hardware workflow.
  • Metal hardware workflow: not run. The local Metal T.834 run passed on Apple silicon.

jxr::encode writes an Annex-A file from SourceImage samples;
encode_codestream and encode_codestreams return the raw codestreams. The
encoder takes grayscale, RGB and BGR samples at every depth the decoder
returns, CMYK, three- to eight-channel samples, and YUV 4:4:4, 4:2:2 and
4:2:0, with separate or integrated alpha. It codes losslessly, at a
quality from 0 to 100, or with per-band quantizers, in spatial or
frequency bitstream mode, with optional chroma subsampling.

Full-resolution CPU decodes now run as a stream of row strips shared with
the encoder's analysis stages, replacing the per-format tile_decode
modules. With SCALED_FLAG set, every component after the first is
reconstructed at double weight in any colour format through
jxr_core::scaled_after_first_transform, on CPU, Metal and CUDA; before,
only YUV was.

Coverage: encode round-trip suites in jxr, an encode_roundtrip fuzz
target whose fixed cases CI runs, the dev-only jxr-alloc-probe memory
tests, and a size gate for the decode-only WebAssembly module
(jxr-wasm-size, tools/wasm_size_check.py).
Publish the CPU encoder. cargo semver-checks reports no semver update
required for any changed package, so the release stays on the 0.5 line.
jxr-math moves to 0.2.1, jxr-core and jxr-cuda to 0.5.1, jxr-native,
jxr-metal and jxr to 0.5.2; jxr-image and jxr-mpsgraph follow their exact
pins to 0.5.2 and 0.6.2. Both lockfiles follow.

docs/releasing.md gives the release notes and publish order.
@jcwal1516
jcwal1516 merged commit 393a941 into main Nov 19, 2026
3 checks passed
@jcwal1516
jcwal1516 deleted the feat/cpu-encoder branch November 19, 2026 04:29
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