waozi f5f186bb13 Convert 8-bit AVIF chroma exactly as libavif does
The fixed-point conversion landed within one level of libavif, so Kryon's
strict AVIF digests failed for 4:4:4 and 4:2:0 photos. The fast path now
repeats libavif's float arithmetic in the same order: its lookup tables,
the bilinear chroma sum with weights 9/16, 3/16, 3/16 and 1/16, the matrix
formulas, clamping and rounding. Every byte matches libavif and the
reference digests, and the rows still split across the cores. 4:4:4 has no
chroma to upsample and keeps libavif's own fast path.
2026-11-18 15:08:34 -03:00
2026-11-05 18:25:49 -03:00

AVIF

Optional, headless Ziran image package. Handwritten decoder policy, transforms, API and CLI are .zi. The initial AV1/container decoding engine is a pinned external libavif bridge; this is not an authored AV1 decoder or a speed claim. No Kryon, window system, browser, or GUI library is required.

#import "avif/api"
options := DefaultOptions()
result := Decode(BorrowBytes(bytes), options)
// Check result.is_ok before using result.image, an owned std/image.Image.

From a consumer, add https://github.com/ziranlang/avif.git with ziran add. The manifest pins libavif, dav1d (the default engine) and libaom (the oracle) source packages, plus the av1 package with the authored AV1 decoder. Local canonical checkout overrides belong in ignored ziran.local.toml. Production lockfiles resolve committed package and toolchain revisions.

Run the package suite in this checkout:

build-queue -- sh tests/avif.sh
build-queue -- sh tests/bmff.sh

The test harness uses the canonical sibling Ziran checkout when available; otherwise set ZIRAN_ROOT to a built current toolchain. It builds a real consumer of this package, resolves its exports and requests its native artifact through ziran pkg artifact avif:native --platform linux-x86_64-gnu. Standalone module-path tests additionally verify source and saved .zir.

The stable headless command produced by the suite is:

build/bin/avif tests/fixtures/rgba8.avif build/output.rgba

It writes tight straight-alpha RGBA8 and prints dimensions, source depth, source frame count and alpha presence. Errors have stable shared error codes. See implementation and verification status, API, native recipe and fixture provenance.

S
Description
AVIF image decoder and command-line tools.
Readme BSD-3-Clause
531 KiB
0 Stars 1 Watchers 0 Forks
No results found.
Languages
Ziran 63.7%
Python 19.4%
Shell 9.3%
CMake 4.5%
C 2.8%
Other 0.3%