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::parseprobes a header;Configwith cropping, scaling, color mode, flipping, dithering and threads;decodeinto library memory ordecode_intocaller rows or planes;IncrementalDecoderfor data that arrives in pieces;Containerfor theICCP,EXIFandXMPchunks and the animation parameters;AnimationDecoderfor the frames of an animation.webp::api::encode(ADR 0006):Configwith presets and every encoder option;Picturefrom RGB or RGBA rows or from YUVA planes;Encoderwith progress and abort hooks and output throughVec<u8>or a writer closure;encode_lossyandencode_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 exceptsrc/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-sharpyuvconversion 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 anunsafeblock (minimum Rust versions). Thesimdfeature (default) compiles the SIMD modules and selects them at run time;--no-default-featuresis 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:
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.