AVIF libraries for C/C++
An AVIF library parses the HEIF container and hands the AV1 data to a codec library. There are 3 container libraries:
- libavif is the reference AVIF library from the Alliance for Open Media. It does only AVIF and does all of it: alpha, 10/12-bit, HDR, grids, gain maps, animation, Exif/XMP. BSD-2-Clause. Pick it for AVIF-only code; Chrome, Pillow and PHP’s GD use it.
- libheif reads and writes any HEIF file: AVIF, HEIC (HEVC), JPEG-in-HEIF and uncompressed HEIF. LGPL-3.0. Pick it when you also need HEIC (iPhone photos).
- heicdec is a decoder in plain C for AVIF (with dav1d) and HEIC (with its own HEVC decoder). One
.c+.hfile. AGPL-3.0 or commercial. SumatraPDF uses it.
Both delegate AV1 coding to codec libraries that you choose at build time:
| Codec | Decode | Encode | License | Notes |
|---|---|---|---|---|
| dav1d | yes | no | BSD-2-Clause | fastest decoder; use it for reading |
| libaom | yes | yes | BSD-2-Clause | reference codec; best compression, slowest encoder |
| SVT-AV1 | no | yes | BSD-3-Clause | fast multi-threaded encoder |
| rav1e | no | yes | BSD-2-Clause | encoder in Rust with a C API |
A common build is dav1d for decoding plus libaom for encoding. The AV1 codecs are covered by the royalty-free AOM patent license.
- heicdec heicdec is a decode-only AVIF and HEIC library in plain C that uses dav1d for AV1. How to build it for AVIF, decode AVIF to RGBA and read image info.
- libavif libavif is the reference C library for AVIF. How to install it, decode AVIF to RGB, encode RGB to AVIF, set quality and speed, read animated AVIF frames.
- libheif libheif is a C/C++ library for HEIF files, including AVIF and HEIC. How to install it, decode AVIF to RGB, encode AVIF with libaom or SVT-AV1, check alpha.