Skip to content
 
 

Latest commit

 

History

11 Commits

Folders and files

NameName
Last commit message
Last commit date
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

About this fork

vaam-avif-decode is vaam-apps' fork of kornelski/avif-decode, maintained for vaam-store/image-resizer (EmgR).

The fork makes exactly one change: rav1d is depended on with default-features = false on every target, rather than only on non-x86 ones.

Why: rav1d's default features include asm, and its build script then invokes a C compiler to assemble .S files and NASM to assemble .asm on x86_64. EmgR has no C or C++ dependencies and its build images ship no C toolchain and no assembler, so an x86_64 build fails outright. Cargo's feature unification is additive, so a downstream cannot turn this off from its own manifest — the dependency declaration itself has to change, which is what this fork is for.

Upstream already disables rav1d's default features for non-x86 targets, but as a workaround for a rav1d packaging bug (missing aarch64 asm headers, rav1d#1449) rather than as a policy. That makes the asm-free aarch64 build incidental — it would come back as soon as that bug is fixed. Here it is deliberate and uniform across targets.

The cost is real, and we have not measured it. dav1d's assembly is a large part of why it is fast, and this gives that up on x86_64. It has not been benchmarked on x86_64 hardware — the fork's author only had aarch64, where upstream was already building without assembly.

The Rust lib target is still named avif_decode, so downstream code and upstream's own tests read use avif_decode::... unchanged and future merges stay clean.

This fork should be retired. An upstream feature flag — something like rav1d-asm, default-on so nothing changes for existing users — would serve this case better than a fork and would let EmgR go back to the crates.io release.

Pure Rust AVIF decoder and AVIF to PNG converter

It can be used as a Rust library for decoding AVIF images (AV1 + HEIF) straight to uncompressed pixels (RGBA, etc). Decoding is done by rav1d, a Rust port of dav1d, so there's no C library to build.

Optionally can be built as a CLI that converts AVIF to standard PNG images. Expect the PNG to bemany times larger than the AVIF input.

Usage

avif_decode input.avif output.png

It always processes one file at a time. If output path is omitted, it'll be the same as the input, except with a .png extension. Add -f to overwrite output files.

Install from source

Requires Rust 1.98 or later.

cargo install avif-decode

Features

Supported AVIF features

  • 8-, 10-, and 12-bit deep images. Images are saved as 16-bit PNG when necessary.
  • RGB and many flavors of YUV color spaces in both full and "studio" range.
  • AV1 film grain synthesis
  • Alpha channel, in both premultiplied and uncorrelated alpha modes.
  • 4:4:4, 4:2:2, 4:2:0 chroma modes. Chroma subsampling uses box upsampling. BTW: The AVIF spec intentionally left chroma upsampling algorithm unspecified, so images using 4:2:0 or 4:2:2 modes will have decoder-dependent distortions. It's best to never use chroma subsampling modes in AVIF.

Unsupported features

  • Any form of HDR. Maybe later.
  • Embedded ICC color profiles. AV1 already supports so many color spaces, it'd be rude to support an extra color conversion layer that's complex and unecessary.
  • The kitchen sink of pointless HEIF features. I'm writing an image decoder, not Photoshop. Lossless cropping (clap) is a dangerous footgun for a Web format. Operating point selection (a1op) is simplified to using the final layer.

License

New BSD

About

Convert AVIF images to PNG (as lossless as possible)

Resources

Stars

0 stars

Watchers

0 watching

Forks

Releases

Packages

Contributors

Languages