ferrisma-libwebp 0.1.0

A mechanical Rust port of libwebp, the WebP reference implementation
Documentation
  • Coverage
  • 81.12%
    2153 out of 2654 items documented132 out of 1134 items with examples
  • Size
  • Source code size: 3.7 MB This is the summed size of all the files inside the crates.io package for this release.
  • Documentation size: 25.7 MB This is the summed size of all files generated by rustdoc for all configured targets
  • Ø build duration
  • this release: 7s Average build duration of successful builds.
  • all releases: 7s Average build duration of successful builds in releases after 2024-10-23.
  • Links
  • Homepage
  • sebastian-software/ferrisma
    0 0 105
  • crates.io
  • Dependencies
  • Versions
  • Owners
  • swernerx

libwebp-rs

This port is a workspace member of the Ferrisma monorepo. Start with the project overview, current status, or codec workspace guide. Its local porting contracts and licenses still apply.

A mechanical, behavior-preserving Rust port of libwebp v1.6.0, the WebP reference implementation: decoder, demuxer, animation decoder, encoder, muxer, animation encoder and SharpYUV, in safe Rust except for an audited C ABI module and the SIMD modules. It is maintained alongside libjpeg-turbo-rs, libavif-rs, and libjxl-rs.

Port status: the portable decoder, encoder, container, animation and SharpYUV translations have differential evidence against libwebp v1.6.0. The C ABI is used to run upstream tools; safe Rust APIs cover decoding and encoding. SIMD implementations and their exceptions are documented in ADR 0008: the scalar build matches libwebp's scalar build and the SIMD build matches libwebp's SIMD build at the same instruction-set level (SIMD status). Each module records its deviations and excluded undefined behavior.

Engine integration: Ferrisma does not currently provide WebP input or output adapters. The port's APIs are the intended adoption boundary, subject to the gates in ADR 0010; see the project status for current integration work.

Using the library

The safe API is webp::api:

  • webp::api::decode (ADR 0007): Features::parse probes a header; Config with cropping, scaling, color mode, flipping, dithering and threads; decode into library memory or decode_into caller rows or planes; IncrementalDecoder for data that arrives in pieces; Container for the ICCP, EXIF and XMP chunks and the animation parameters; AnimationDecoder for the frames of an animation.
  • webp::api::encode (ADR 0006): Config with presets and every encoder option; Picture from RGB or RGBA rows or from YUVA planes; Encoder with progress and abort hooks and output through Vec<u8> or a writer closure; encode_lossy and encode_lossless.

The differential suite compares results with libwebp v1.6.0 for its tested inputs and configurations; it is not proof for every possible input. The translated modules (webp::dec, webp::enc, webp::dsp, ...) are public but mirror the C library's shapes; webp::abi exports the C API for the upstream tools and is not meant for Rust callers. What the library promises Ferrisma is ADR 0010.

How it works

  • Each upstream C file is one Rust module with the same name, translated without redesign (porting contract, ADR 0001, ADR 0003).
  • Every unit is compared with the pinned C library, built in a fixed reference configuration and run in separate processes (ADR 0002); upstream's own test scripts run with its unmodified tools linked against this library.
  • #![deny(unsafe_code)] applies everywhere except src/abi, which exports the C API (ADR 0004, ADR 0005), and the SIMD modules, which may load and store vectors and call target-feature functions (ADR 0008).
  • Ordinary builds compile and link no C. The only library dependency is the workspace's small, safe ferrisma-sharpyuv conversion crate, shared with AVIF through a separate adapter (ADR-0033). The crate builds on stable Rust 1.95 or later (rust-version), on its own and independent of the Ferrisma engine's 1.99: the x86 CPU query calls __cpuid_count, which Rust 1.93 still requires inside an unsafe block (minimum Rust versions). The simd feature (default) compiles the SIMD modules and selects them at run time; --no-default-features is the scalar translation.
  • The work was delivered in packages by parallel sessions, and the records live with the code (ADR 0009).

Building and checking

Run from codecs/libwebp-rs:

git submodule update --init upstream/libwebp upstream/libwebp-test-data
cargo fetch --locked
cargo build -p ferrisma-libwebp --locked
python3 tools/check.py            # fmt, Clippy, tests in three profiles, provenance
python3 tools/check.py --oracle   # also builds the C oracle and requires it

The check script uses offline Cargo commands after the fetch; Rust artifacts are in the monorepo root target/. Tests needing an oracle skip without it unless the oracle feature is enabled.

CONTRIBUTING.md lists the prerequisites and focused checks; AGENTS.md has the rules for porting sessions.

License

BSD-3-Clause, as libwebp, with the WebM project's additional patent grant in PATENTS. LICENSE, PATENTS and AUTHORS are unchanged copies of the upstream files; translated modules keep Google's copyright notices (PROVENANCE.md). The crate is not published.