118.21. libavif-1.4.2
AVIF reader and writer — the AV1 still-image format, with avifenc and avifdec
| Version | 1.4.2, release 1 |
| Shelf | image-libs — Raster image formats, codecs, metadata, processing, barcodes, and terminal image output |
| Phase | 41_system (System), 700 of 1047 in build order |
| Licence | BSD-2-Clause AND MIT |
| Homepage | https://github.com/AOMediaCodec/libavif |
| Build time | 0.3 SBU |
| Installed size | 1.3 MiB in 17 files |
| Recipe | ports/core/image-libs/libavif/kpkgbuild |
About
libavif reads and writes AVIF, the still-image format built on the AV1 video codec, with the avifenc and avifdec converters and a gdk-pixbuf loader. Like libheif it codes nothing itself: dav1d decodes and svt-av1 encodes. The web engines, SDL’s image libraries, opencv, gdal, chafa and darktable open AVIF files through it.
Sources
libavif-1.4.2.tar.gz(14.0 MiB)
sha2562b645287340ba5a631d268b551dc2d72bd73ac33335962dd36dcdb6d8366921d
upstream: https://github.com/AOMediaCodec/libavif/archive/refs/tags/v1.4.2.tar.gz
archive copy: sources-3/image-libs--libavif-1.4.2.tar.gzlibargparse-ee74d1b53bd680748af14e737378de57e2a0a954.tar.gz(21.9 KiB)
sha2567727b0498851e5b6a6fcd734eb667a8a231897e2c86a357aec51cc0664813060
upstream: https://github.com/kmurray/libargparse/archive/ee74d1b53bd680748af14e737378de57e2a0a954.tar.gz
archive copy: sources-3/image-libs--libargparse-ee74d1b53bd680748af14e737378de57e2a0a954.tar.gz
Dependencies
Depends on: cmake, pkgconf, dav1d, svt-av1, libyuv, libwebp, libxml2, libjpeg-turbo, libpng, zlib, gdk-pixbuf, lowdown.
Required by (14): celestia, chafa, darktable, endless-sky, gdal, kimageformats, libgd, opencv, python3-pillow, sdl2-image, sdl3-image, swayimg, webkitgtk, webkitgtk6.
Installation
From the repository root, inside the build container, this is the line kdosbuild runs for the port:
script/chroot/exec.sh bash -c 'source script/phases/41_system/phase.env && kpkg install libavif'
What kpkg does
kpkg runs these steps, in this order, as root inside the chroot. The port directory is /ports/core/image-libs/libavif.
1. Verify every declared source. Each file a sha256 = line names, found in the port directory or in /var/cache/kpkg/sources, must hash to its line; a mismatch stops the build before anything is unpacked.
cd /ports/core/image-libs/libavif
echo '2b645287340ba5a631d268b551dc2d72bd73ac33335962dd36dcdb6d8366921d libavif-1.4.2.tar.gz' | sha256sum -c -
echo '7727b0498851e5b6a6fcd734eb667a8a231897e2c86a357aec51cc0664813060 libargparse-ee74d1b53bd680748af14e737378de57e2a0a954.tar.gz' | sha256sum -c -
2. Unpack. The work directory is emptied and the first source is unpacked into $SRC with its top directory stripped; any later tarball lands unstripped beside it in $SRC_ROOT, and a file that is not a tarball is copied into $SRC.
SRC_ROOT=/var/cache/kpkg/work/libavif
SRC=$SRC_ROOT/libavif-1.4.2
PKG=$SRC_ROOT/pkg
rm -rf "$SRC_ROOT"
mkdir -p "$SRC" "$PKG"
tar --no-same-permissions --warning=no-unknown-keyword -xf libavif-1.4.2.tar.gz -C "$SRC" --strip-components=1
tar --no-same-permissions --warning=no-unknown-keyword -xf libargparse-ee74d1b53bd680748af14e737378de57e2a0a954.tar.gz -C "$SRC_ROOT"
Every config.guess and config.sub older than automake’s is then replaced with automake’s, so a configure script recognises the musl target.
3. Build. build.sh is sourced in a subshell under set -e, from $SRC, with name, version, release and the recipe’s helpers _argparse and the five paths PKGNAME, PORT_SRC, SRC_ROOT, SRC and PKG set as shell variables. Its body, verbatim:
mkdir -p build && cd build
cmake .. \
-DCMAKE_BUILD_TYPE=Release \
-DCMAKE_INSTALL_PREFIX=/usr \
-DCMAKE_INSTALL_LIBDIR=lib \
-DBUILD_SHARED_LIBS=ON \
-DFETCHCONTENT_FULLY_DISCONNECTED=ON \
-DFETCHCONTENT_SOURCE_DIR_LIBARGPARSE="$SRC_ROOT/libargparse-$_argparse" \
-DAVIF_CODEC_DAV1D=SYSTEM \
-DAVIF_CODEC_SVT=SYSTEM \
-DAVIF_CODEC_AOM=OFF \
-DAVIF_CODEC_LIBGAV1=OFF \
-DAVIF_CODEC_RAV1E=OFF \
-DAVIF_CODEC_AVM=OFF \
-DAVIF_LIBYUV=SYSTEM \
-DAVIF_LIBSHARPYUV=SYSTEM \
-DAVIF_LIBXML2=SYSTEM \
-DAVIF_JPEG=SYSTEM \
-DAVIF_ZLIBPNG=SYSTEM \
-DAVIF_GTEST=OFF \
-DAVIF_FUZZTEST=OFF \
-DAVIF_BUILD_APPS=ON \
-DAVIF_BUILD_TESTS=OFF \
-DAVIF_BUILD_EXAMPLES=OFF \
-DAVIF_BUILD_GDK_PIXBUF=ON \
-DAVIF_BUILD_MAN_PAGES=OFF
make
make DESTDIR=$PKG install
install -d "$PKG/usr/share/man/man1"
for page in avifenc avifdec; do
lowdown -s -Tman \
-M title=${page^^} -M section=1 -M source="libavif $version" \
-o "$PKG/usr/share/man/man1/$page.1" ../doc/$page.1.md
done
The switches, and why each is set:
-DFETCHCONTENT_FULLY_DISCONNECTED=ON— Never let CMake’s FetchContent download anything.-DFETCHCONTENT_SOURCE_DIR_LIBARGPARSE="$SRC_ROOT/libargparse-$_argparse"— Buildavifgainmaputil’s argument parser, libargparse, from the recipe’s second source, unpacked beside the tree. Without it the configure clones libargparse from GitHub, which the offline build cannot do.-DAVIF_CODEC_DAV1D=SYSTEM— With-DAVIF_CODEC_SVT=SYSTEM, decode through the dav1d port and encode through the svt-av1 port. Each codec option takesOFF,LOCAL(a copy built inext/) orSYSTEM, and every codec defaults toOFF.-DAVIF_CODEC_AOM=OFF— With_LIBGAV1,_RAV1Eand_AVM, build no codec on libaom, libgav1, rav1e or AVM; none of them is a port.-DAVIF_LIBYUV=SYSTEM— WithAVIF_LIBSHARPYUV,AVIF_LIBXML2,AVIF_JPEGandAVIF_ZLIBPNG, use the system’s libyuv for fast colour conversion, libwebp’slibsharpyuvfor higher-quality conversion, libxml2 soavifenccan convert a JPEG with a gain map, and libjpeg-turbo, zlib and libpng for the tools’ JPEG and PNG input and output.AVIF_LIBSHARPYUVandAVIF_LIBXML2default toOFF; the others default toSYSTEMand are named.-DAVIF_GTEST=OFF— With-DAVIF_FUZZTEST=OFF, build neither test framework.-DAVIF_BUILD_APPS=ON— Buildavifenc,avifdecandavifgainmaputil, which upstream builds only when asked.-DAVIF_BUILD_GDK_PIXBUF=ON— Build the gdk-pixbuf loader.-DAVIF_BUILD_MAN_PAGES=OFF— Do not let the build render the manual pages; it would run pandoc.build.shrenders the same Markdown sources,doc/avifenc.1.mdanddoc/avifdec.1.md, withlowdowninstead.
The common switches of each build system are explained in the Flag glossary.
4. Package. kpkg removes libtool archives, the info directory index, mimeinfo.cache and every fonts.dir from $PKG, copies the source’s licence files into /usr/share/licenses/libavif, prunes what the image does not ship, lints the tree and rolls it reproducibly:
tar --sort=name --format=gnu --numeric-owner --owner=0 --group=0 \
--mtime=@$SOURCE_DATE_EPOCH \
--use-compress-program='xz -9 -T0 --block-size=32MiB --no-adjust' \
-cf libavif-1.4.2-1.tar.xz -C "$PKG" .
5. Adopt. kpkgadd installs the package’s files over the root, refusing a path another package owns, records the file list in /var/lib/kpkg/db/libavif, and runs the triggers its paths call for.
Contents
Installed programs: avifdec, avifenc, avifgainmaputil.
Installed libraries: libavif.so.
Installed directories: /usr/include/avif, /usr/lib/cmake/libavif, /usr/share/licenses/libavif.
Short descriptions
avifdec |
decompress an AVIF file to an image file |
avifenc |
compress an image file to an AVIF file |
libavif.pc |
Library for encoding and decoding .avif files |
Notes
The pages’ pandoc title block reads AVIFENC(1) | General Commands Manual, which lowdown does not take apart, so build.sh passes the title, the section and the source line as -M metadata.
The helper _argparse names the libargparse commit, and it must be the one libavif pins: AVIF_LIBARGPARSE_GIT_TAG in cmake/Modules/LocalLibargparse.cmake. A new libavif release that moves that tag needs the helper and the second source’s sha256 = line moved with it.