Does libavif support hardware accelerated decoding
This article examines whether libavif, the standard
library for handling AVIF files, supports hardware-accelerated decoding
pipelines. We will look at how libavif processes AV1 image
data, its reliance on software-based decoding libraries, and how
developers can achieve hardware-accelerated AVIF decoding using
alternative workflows.
Understanding libavif’s Architecture
libavif is not a standalone image decoder. Instead, it
serves as a parser (muxer and demuxer) for the AVIF format. The AVIF
format packages AV1-encoded image data inside an ISO Base Media File
Format (ISOBMFF) container.
To actually decode the compressed AV1 bitstream into viewable pixels,
libavif relies on external AV1 decoding libraries, commonly
referred to as “backends.” The most popular software backends used by
libavif are:
- dav1d: A highly optimized software AV1 decoder developed by VideoLAN.
- libaom: The reference encoder and decoder from the Alliance for Open Media.
- libgav1: A software decoder developed by Google.
Native Hardware Acceleration Support
Standard libavif does not natively feature built-in
hardware-accelerated decoding pipelines. It does not contain direct
integrations with GPU-based hardware decoding APIs such as NVIDIA’s
NVDEC, Intel’s QuickSync, Microsoft’s DXVA2/D3D11VA, or Linux’s
VA-API/VDPAU.
Because the default backends (dav1d,
libaom) are CPU-bound software decoders, running
libavif out-of-the-box will utilize software decoding.
How to Achieve Hardware-Accelerated AVIF Decoding
While libavif does not handle hardware decoding
directly, developers can still achieve hardware acceleration for AVIF
images by using a split pipeline:
- Parsing with libavif: Use
libavifstrictly as a demuxer to parse the AVIF container and extract the raw, compressed AV1 video bitstream (often a single keyframe for still images). - Decoding with Hardware APIs: Pass the extracted AV1
bitstream directly to a hardware-accelerated platform API capable of
decoding AV1. Examples include:
- Android: Passing the bitstream to
MediaCodecon devices with AV1 hardware decoder chips. - Windows: Utilizing
DirectX Video Acceleration (DXVA)with compatible GPUs (such as NVIDIA RTX 30/40 series, Intel Xe/Arc, or AMD Radeon RX 6000/7000 series). - Apple platforms: Utilizing
VideoToolboxon Apple Silicon chips with hardware AV1 support (such as M3 and A17 Pro or newer).
- Android: Passing the bitstream to
Is Software Decoding Sufficient?
For the vast majority of AVIF use cases, software decoding via
dav1d is exceptionally fast and highly optimized. Because
still images do not require the continuous 60+ frames-per-second
throughput of video, the overhead of moving image data to and from GPU
memory for hardware decoding often outweighs the speed benefits of
hardware acceleration. Consequently, standard software decoding remains
the industry norm for AVIF.