Streamed input API

Refactor the code to:
- sequentially read all boxes once into AvifInfoInternalFeatures,
- after "ipma" and "iref", check if AvifInfoInternalFeatures contain
  all necessary information to output AvifInfoFeatures.
This allows to fetch just a few bytes at a time from the stream,
in order, in a contiguous manner and never twice the same data.
The drawback is the ~250-byte long AvifInfoInternalFeatures struct
that is stored on the stack to avoid dynamic allocation. It can be
decreased or increased to adjust the variety of handled input AVIFs.

Change-Id: I98ccf4c55706f6c88d65008ccbcbefc782d2be87
4 files changed
tree: e7431664d5ef5db4eccedaa90840901d5281dae4
  1. tests/
  2. tools/
  3. CMakeLists.txt
  7. avifinfo.c
  8. avifinfo.h


libavifinfo is a standalone library that can be used to extract the width, height, bit depth and number of channels from an AVIF payload.

See avifinfo.h for details on the API and avifinfo.c for the implementation. See for usage examples.


  1. How to use

    1. Build
    2. Test
  2. Development

    1. Coding style
    2. Submitting patches
  3. Bug reports

How to use

libavifinfo can be used when only a few AVIF features are needed and when linking to or including libavif is not an option. For decoding an image or extracting more features, please rely on libavif.

AvifInfoFeatures features;
if (AvifInfoGet(bytes, number_of_available_bytes, &features) == kAvifInfoOk) {
  // Use 'features.width' etc.

Note: AvifInfoGet() is designed to return the same avifImage field values as avifDecoderRead(). However libavifinfo is more permissive and may return features of images considered invalid by libavif.


avifinfo.c is written in C. To build from this directory:

mkdir build && \
cd build && \
cmake .. && \
cmake --build . --config Release


Tests are written in C++. GoogleTest is required.

mkdir build && \
cd build && \
cmake --build . --config Debug && \
ctest .


Coding style

Google C/C++ Style Guide is used in this project.

Submitting patches

If you would like to contribute to libavifinfo, please follow the steps for libaom at

Bug reports

Bug reports can be filed in the Alliance for Open Media issue tracker.