feat(imaging): default to pure-Rust codecs
Some checks failed
CI / rust-skia (Rust only) (push) Successful in 2m51s
CI / required (push) Failing after 3m23s

This commit is contained in:
2026-08-13 11:24:38 +00:00
parent e16ad04dbd
commit 25fdffbd3b
25 changed files with 124 additions and 103 deletions

View File

@@ -49,20 +49,22 @@ python3 tools/check_test_parity.py
python3 tools/audit_red_suite.py
```
### Optional codec features
### Image codec features
The default build needs no system image-codec library. It includes the
project-owned TGA and DDS implementations; the default `dds-bc67` feature uses
the pure-Rust `bcdec_rs` dependency for BC6H and BC7. Build without BC6H/BC7
support with `cargo build -p libremetaverse --no-default-features`.
project-owned TGA and DDS implementations, pure-Rust J2K/JP2 through
`rust-j2k`, and pure-Rust common-raster decoding through the default
`libremetaverse-imaging-skia` `rust-skia` feature. The default `dds-bc67`
feature uses the pure-Rust `bcdec_rs` dependency for BC6H and BC7. Use
`--no-default-features` only for a deliberately minimal codec-free build.
The currently available opt-in codec backends are:
The available default and optional codec backends are:
| Capability | Feature | Build command | External prerequisite |
| --- | --- | --- | --- |
| Raw J2K and JP2 decoding/encoding through OpenJPEG | `libremetaverse/jpeg2000` | `cargo build -p libremetaverse --features jpeg2000` | OpenJPEG 2.5.4 or newer |
| Raw J2K and JP2 decoding/encoding in pure Rust | `libremetaverse/rust-j2k` | `cargo build -p libremetaverse --no-default-features --features rust-j2k` | none |
| BMP, GIF, ICO, JPEG, PNG, WBMP, and WebP decoding in pure Rust | `libremetaverse-imaging-skia/rust-skia` | `cargo build -p libremetaverse-imaging-skia --features rust-skia` | None |
| Raw J2K and JP2 decoding/encoding in pure Rust (default) | `libremetaverse/rust-j2k` | `cargo build -p libremetaverse` | none |
| BMP, GIF, ICO, JPEG, PNG, WBMP, and WebP decoding in pure Rust (default) | `libremetaverse-imaging-skia/rust-skia` | `cargo build -p libremetaverse-imaging-skia` | none |
| Raw J2K and JP2 decoding/encoding through OpenJPEG (optional) | `libremetaverse/jpeg2000` | `cargo build -p libremetaverse --features jpeg2000` | OpenJPEG 2.5.4 or newer |
| BMP, GIF, ICO, JPEG, PNG, WBMP, and WebP decoding through native Skia | `libremetaverse-imaging-skia/skia` | `cargo build -p libremetaverse-imaging-skia --features skia` | A matching rust-skia binary cache, or the documented native source-build tools |
| PCM to Ogg Vorbis encoding | `libremetaverse/vorbis` | `cargo build -p libremetaverse --features vorbis` | `vorbis_rs` 0.5.6 and its native encoder build prerequisites |
@@ -70,9 +72,9 @@ Run their focused test suites with:
```sh
cargo test -p libremetaverse-imaging --features jpeg2000
cargo test -p libremetaverse-imaging --no-default-features --features rust-j2k
cargo test -p libremetaverse-imaging
cargo test -p libremetaverse-imaging-skia --features skia
cargo test -p libremetaverse-imaging-skia --features rust-skia
cargo test -p libremetaverse-imaging-skia
cargo test -p libremetaverse --no-default-features --features vorbis
```
@@ -95,10 +97,11 @@ Deterministic task, socket, file, subscription, cancellation, and allocation
baselines are documented in the
[concurrency hardening guide](docs/concurrency-hardening.md).
The independent `rust-j2k` backend is off by default and never enables the
native OpenJPEG adapter. Its explicit `RustJ2kCodec` preserves the existing
`J2kCodec` meaning when both features are enabled. Use the combined feature set
to run backend-interoperability tests without changing application selection.
The default `rust-j2k` backend never enables the native OpenJPEG adapter. Its
explicit `RustJ2kCodec` preserves the existing `J2kCodec` meaning when both
features are enabled. Likewise, default `RustSkiaTextureCodec` selection does
not rename or enable native `SkiaTextureCodec`. The native features remain
available for backend-interoperability testing or explicit application use.
`tests/upstream-tests.json` is the machine-readable NUnit parity catalog.
Translated tests live in hand-written Rust files with the `parity-case` marker
@@ -208,8 +211,14 @@ Legacy and DX10 BC1 through BC5 decoding is built in. The default `dds-bc67`
feature adds BC6H/BC7 decoding through the safe, pure-Rust `bcdec_rs` crate;
disabling default features removes that optional dependency and makes those
two formats return a typed unsupported-format error.
JPEG 2000 is available through the opt-in `jpeg2000` feature. It provides raw
J2K and JP2 lossless/lossy encoding and decoding, preserves one through five
The default `rust-j2k` feature provides raw J2K and JP2 lossless/lossy encoding
and decoding through `RustJ2kCodec`, backed by the exact pure-Rust `j2k` 0.8.1
release. It supports native component precision/signedness/order,
reduced-resolution and progressive quality-layer decoding, and strict or
explicitly permissive truncation handling. It has no C/C++ codec, CMake,
pkg-config, vcpkg, CLR, or platform-specific API.
The optional `jpeg2000` feature provides the native OpenJPEG alternative. It
provides raw J2K and JP2 lossless/lossy encoding and decoding, preserves one through five
component order, precision, signedness, and alpha metadata until explicit byte
conversion, and bounds encoded input, output, dimensions, and decoded samples.
The compatibility encoder reproduces CoreJ2K's four-plane RGB/alpha view,
@@ -217,20 +226,15 @@ including its alpha-only and opaque-alpha substitutions. See
[`crates/libremetaverse-openjpeg/README.md`](crates/libremetaverse-openjpeg/README.md)
for OpenJPEG prerequisites, licensing, and deployment details. Default builds
do not discover or link OpenJPEG.
The independent opt-in `rust-j2k` feature provides the same bounded public
options through `RustJ2kCodec`, backed by the exact pure-Rust `j2k` 0.8.1
release. It supports J2K and JP2, reversible and irreversible encoding,
native component precision/signedness/order, reduced-resolution and progressive
quality-layer decoding, and strict or explicitly permissive truncation handling.
It has no C/C++ codec, CMake, pkg-config, vcpkg, CLR, or platform-specific API.
The optional Skia adapter decodes BMP, GIF, ICO, JPEG, PNG, WBMP, and WebP into
the same checked planar representation. Its `skia` feature uses pinned
The default pure-Rust raster adapter decodes BMP, GIF, ICO, JPEG, PNG, WBMP,
and WebP into the same checked planar representation through
`RustSkiaTextureCodec`. Its optional native `skia` feature uses pinned
rust-skia binary-cache configurations on macOS, Linux, and Windows, normalizes
premultiplied color at the imaging boundary, and keeps encoded input, decoded
dimensions, strides, and allocations bounded. See
[`crates/libremetaverse-imaging-skia/README.md`](crates/libremetaverse-imaging-skia/README.md)
for native prerequisites, cache/source-build controls, licenses, and packaging
details. Default workspace builds do not compile or link Skia.
details. Default workspace builds compile neither OpenJPEG nor native Skia.
Primitive profile and path meshing is implemented in native Rust from the
pinned `PrimMesher.cs` reference. It covers checked linear, flexible, and
circular extrusion; profile cuts and hollows; twist, taper, shear, skew,