Imaging: implement JPEG2000 codec adapter #40

Closed
opened 2026-08-08 08:17:25 +00:00 by hugo · 1 comment
Owner

Objective

Implement J2K/JP2 encode/decode behavior through the imaging codec boundary.

Deliverables

  • Validate the selected OpenJPEG-backed Rust crate and native build requirements.
  • Preserve dimensions, component precision, channel order, alpha, discard levels, lossless/lossy settings, and failure behavior.
  • Apply decode limits before allocation and document native licensing/deployment.

Validation

  • All J2K and texture golden tests pass on supported platforms.
  • Cross-platform CI builds the feature explicitly.
  • Default core crates remain usable without J2K prerequisites.

Prerequisite

Types and StructuredData are implemented and the global API/test gates are complete.

Project constraints

  • Native Rust implementation only; optional third-party native codecs stay behind documented features.
  • Keep mapped signatures fixed and preserve translated geometry/pixel assertions exactly.
  • Enforce checked sizes and indices, then update docs and coverage status.
## Objective Implement J2K/JP2 encode/decode behavior through the imaging codec boundary. ## Deliverables - Validate the selected OpenJPEG-backed Rust crate and native build requirements. - Preserve dimensions, component precision, channel order, alpha, discard levels, lossless/lossy settings, and failure behavior. - Apply decode limits before allocation and document native licensing/deployment. ## Validation - All J2K and texture golden tests pass on supported platforms. - Cross-platform CI builds the feature explicitly. - Default core crates remain usable without J2K prerequisites. ## Prerequisite Types and StructuredData are implemented and the global API/test gates are complete. ## Project constraints - Native Rust implementation only; optional third-party native codecs stay behind documented features. - Keep mapped signatures fixed and preserve translated geometry/pixel assertions exactly. - Enforce checked sizes and indices, then update docs and coverage status.
hugo added this to the 06 - Imaging and PrimMesher implementation milestone 2026-08-08 08:17:25 +00:00
hugo added the enhancement label 2026-08-08 08:17:25 +00:00
Author
Owner

Implemented and pushed in commit 16501f2.

Implementation:

  • Added the opt-in jpeg2000 feature with a safe Rust codec API and a private, bounded OpenJPEG 2.5.4+ ABI adapter; default crates do not discover or link OpenJPEG.
  • Implemented raw J2K and JP2 decode/encode, reversible lossless and irreversible lossy modes, discard/quality layers, precision/signedness/component/alpha preservation, C#-compatible channel order and alpha substitutions, and typed failure behavior.
  • Added Rust-side JP2 box/SIZ validation and checked byte, pixel, component, sample, and output limits before decoded sample-plane allocation.
  • Replaced the mapped ManagedImageCreator and interleaved shims with native Rust behavior matching the pinned C# reference, including 1-5 component mapping and CoreJ2K DC offsets.
  • Documented OpenJPEG licensing/deployment and added explicit Linux, macOS, and Windows feature CI.

Verification:

  • cargo test -p libremetaverse-imaging --features jpeg2000: 15 passed, including an exact 16-bit OpenJPEG 2.5.4 golden, J2K/JP2 lossless round trips, lossy encode/decode, alpha, discard, bounds, and malformed inputs.
  • cargo test -p libremetaverse --features jpeg2000 j2k: 3 passed for the pinned C# creator/interleaved/block-source behavior.
  • Required formatting, mapping, API coverage, compile, clippy, and documentation gates passed; the private FFI crate was also linted and documented independently.
  • Controlled suite audit passed: 204 passed, 1200 expected standardized failures, 0 ignored, 0 nonstandard failures.
Implemented and pushed in commit 16501f2. Implementation: - Added the opt-in `jpeg2000` feature with a safe Rust codec API and a private, bounded OpenJPEG 2.5.4+ ABI adapter; default crates do not discover or link OpenJPEG. - Implemented raw J2K and JP2 decode/encode, reversible lossless and irreversible lossy modes, discard/quality layers, precision/signedness/component/alpha preservation, C#-compatible channel order and alpha substitutions, and typed failure behavior. - Added Rust-side JP2 box/SIZ validation and checked byte, pixel, component, sample, and output limits before decoded sample-plane allocation. - Replaced the mapped ManagedImageCreator and interleaved shims with native Rust behavior matching the pinned C# reference, including 1-5 component mapping and CoreJ2K DC offsets. - Documented OpenJPEG licensing/deployment and added explicit Linux, macOS, and Windows feature CI. Verification: - `cargo test -p libremetaverse-imaging --features jpeg2000`: 15 passed, including an exact 16-bit OpenJPEG 2.5.4 golden, J2K/JP2 lossless round trips, lossy encode/decode, alpha, discard, bounds, and malformed inputs. - `cargo test -p libremetaverse --features jpeg2000 j2k`: 3 passed for the pinned C# creator/interleaved/block-source behavior. - Required formatting, mapping, API coverage, compile, clippy, and documentation gates passed; the private FFI crate was also linted and documented independently. - Controlled suite audit passed: 204 passed, 1200 expected standardized failures, 0 ignored, 0 nonstandard failures.
hugo closed this issue 2026-08-09 03:43:06 +00:00
Sign in to join this conversation.