diff --git a/CHANGELOG.md b/CHANGELOG.md index 91ceaee..dc83b82 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -170,6 +170,9 @@ part was built. Lumen's own float-free code in a dependency-free `lumen-image` crate, with the supported and refused features of each format stated. The crate is built by #195 to #199. (flyingrobots/lumen#184.) +- **`lumen-image`, baseline JPEG** (work in progress): a dependency-free, float-free workspace + crate inside the deterministic core, with a baseline JPEG decoder to RGB8 under the identity + `lumen-jpeg-decode/1`. (flyingrobots/lumen#197.) - **ADR 0011** records that arithmetic for analytic shapes, point lights and the thin lens is versioned Bunny contracts, and that Lumen owns the scene model. (flyingrobots/lumen#183.) - **Dependencies**: Bunny's `bunny-num`, `bunny-linalg`, `bunny-geom`, `bunny-query`, diff --git a/Cargo.lock b/Cargo.lock index 199191b..68d4d54 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -87,6 +87,7 @@ dependencies = [ "bunny-num", "bunny-optics", "bunny-query", + "lumen-image", ] [[package]] @@ -99,6 +100,10 @@ dependencies = [ "bunny-num", ] +[[package]] +name = "lumen-image" +version = "0.1.0" + [[package]] name = "xtask" version = "0.1.0" diff --git a/Cargo.toml b/Cargo.toml index 31545c9..b5c169e 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -1,5 +1,5 @@ [workspace] -members = ["crates/lumen", "xtask", "xtask/clippy-fixture"] +members = ["crates/lumen", "crates/lumen-image", "xtask", "xtask/clippy-fixture"] resolver = "2" [workspace.package] @@ -22,6 +22,8 @@ bunny-linalg = { git = "https://github.com/flyingrobots/bunny", rev = "2cd551e24 bunny-num = { git = "https://github.com/flyingrobots/bunny", rev = "2cd551e248d55407a8f27e84dcb26d1b1d8768bd" } bunny-optics = { git = "https://github.com/flyingrobots/bunny", rev = "2cd551e248d55407a8f27e84dcb26d1b1d8768bd" } bunny-query = { git = "https://github.com/flyingrobots/bunny", rev = "2cd551e248d55407a8f27e84dcb26d1b1d8768bd" } +# Lumen's own image decoders (docs/adr/0012-image-decoding.md): a member with no dependency. +lumen-image = { path = "crates/lumen-image" } [workspace.lints.rust] unsafe_code = "forbid" diff --git a/crates/lumen-image/Cargo.toml b/crates/lumen-image/Cargo.toml new file mode 100644 index 0000000..ff4b8a1 --- /dev/null +++ b/crates/lumen-image/Cargo.toml @@ -0,0 +1,18 @@ +[package] +name = "lumen-image" +description = "Lumen's image decoders: dependency-free, float-free and deterministic (ADR 0012)." +authors.workspace = true +edition.workspace = true +license.workspace = true +repository.workspace = true +rust-version.workspace = true +version.workspace = true +keywords = ["jpeg", "decoder", "deterministic"] +categories = ["multimedia::images"] +publish = false + +# No dependency, not even Bunny's, and no dev-dependency (docs/adr/0012-image-decoding.md). +[dependencies] + +[lints] +workspace = true diff --git a/crates/lumen-image/src/jpeg.rs b/crates/lumen-image/src/jpeg.rs new file mode 100644 index 0000000..87eba95 --- /dev/null +++ b/crates/lumen-image/src/jpeg.rs @@ -0,0 +1,5 @@ +//! A baseline JPEG decoder (work in progress, flyingrobots/lumen#197). + +/// The identity of the decoding rules: the integer inverse DCT, the chroma upsampling rule and +/// the integer colour conversion. Changing any of them makes a new identity. +pub const JPEG_DECODE_ID: &str = "lumen-jpeg-decode/1"; diff --git a/crates/lumen-image/src/lib.rs b/crates/lumen-image/src/lib.rs new file mode 100644 index 0000000..3177229 --- /dev/null +++ b/crates/lumen-image/src/lib.rs @@ -0,0 +1,16 @@ +//! Lumen's image decoders: bytes of an image file in, pixels out, by stated integer rules. +//! +//! The crate has no dependency and no floating point, and it is part of Lumen's deterministic +//! core (docs/adr/0012-image-decoding.md, docs/adr/0006-nondeterminism-gate.md): the same file +//! decodes to the same bytes on every platform and in every build profile. Every decoder +//! follows the same rules: a typed error that names the refused feature or the byte offset, +//! every limit taken from the caller and checked before a large allocation, and no panic and +//! no read past the input on any bytes. +//! +//! - [`jpeg`]: baseline JPEG to RGB8, under the identity [`jpeg::JPEG_DECODE_ID`]. + +// No float in the crate: `clippy.toml` bans the float types; this catches arithmetic on a float +// whose type is only inferred (docs/adr/0006-nondeterminism-gate.md). +#![deny(clippy::float_arithmetic)] + +pub mod jpeg; diff --git a/crates/lumen/Cargo.toml b/crates/lumen/Cargo.toml index 4eac4b8..376b526 100644 --- a/crates/lumen/Cargo.toml +++ b/crates/lumen/Cargo.toml @@ -19,6 +19,7 @@ bunny-linalg.workspace = true bunny-num.workspace = true bunny-optics.workspace = true bunny-query.workspace = true +lumen-image.workspace = true [lints] workspace = true