It uses bit-packing for easy encoding and decoding on top of providing a fixed header size.
All remaining data is stored sequentially in regular chunks, whether it is a preview, pixels, XMP etc. A chunk is preceded by its size encoded as a variable-length integer, limiting it to ~500 megabytes.
Work in progress. See container.h.
WrapContainer()
and UnwrapContainer()
functions can be used to encapsulate encoded pixels in any format into a minimal image container. EncodeRawPixels()
and DecodeRawPixels()
are just a convenient demo for a generic “codec”.
mkdir ../container_build && \ cd ../container_build && \ cmake -DCMAKE_BUILD_TYPE=Debug ../container && \ make && \ ctest .
AVIF is a MIAF/ISOBMFF wrapper around an OBU bitstream, which is itself usually made of a sequence header, a frame header and an AV1 tile group.
Stripping everything but the AV1 tile group and the necessary fields in the sequence and frame headers would produce lighter web image files:
Work in progress.
Start with an AVIF file (avifenc img.png -o img.avif -c aom
).
Convert from AVIF:
./convert img.avif -o img.pic
Convert back to AVIF:
./convert img.pic -o img.avif
Taken from https://aomediacodec.github.io/av1-spec.
Comparison between a minimal header (left) and a Sequence Header OBU (right):
Frame header OBU: