How libdav1d Verifies Output Against AV1 Spec

This article explains how libdav1d, the popular open-source AV1 video decoder developed by VideoLAN, ensures its decoding output complies perfectly with the official AV1 specification. It explores the use of official Alliance for Open Media (AOM) conformance streams, cryptographic hash verification, cross-platform assembly validation, and continuous integration testing to guarantee pixel-perfect accuracy.

Official AV1 Conformance Streams

The primary method libdav1d uses to verify compliance is decoding the official AV1 conformance bitstreams. These test vectors are curated by the Alliance for Open Media (AOMedia), the consortium behind the AV1 standard.

These streams are specifically engineered to test every feature, profile, level, and edge case defined in the AV1 specification, including complex coding tools like film grain synthesis, obmc (overlapped block motion compensation), and various intra-prediction modes. By successfully decoding these streams without errors, libdav1d proves its theoretical adherence to the standard.

Frame-by-Frame Hash Verification

To ensure that the decoded video is pixel-perfect and free of rendering artifacts, the libdav1d test suite does not rely on visual inspection. Instead, it utilizes cryptographic checksums (typically MD5 or SHA-256).

For every official conformance stream, AOMedia provides a reference hash of the expected output YUV frames. During testing, libdav1d decodes the bitstream, generates a hash of its own output frames, and compares it to the reference hash. If the hashes match, the decoder has rendered the video exactly as the specification intended.

Assembly vs. C Reference Comparison

A major feature of libdav1d is its extreme speed, achieved through heavily optimized hand-written assembly code for various architectures (including x86-64 AVX2/AVX-512 and ARM NEON). To ensure these optimizations do not introduce subtle math errors or rendering bugs, the test suite employs strict cross-verification:

Fuzzing and Regression Testing

To catch edge cases that official conformance streams might miss, libdav1d is integrated into Google’s OSS-Fuzz project. Fuzz testing feeds the decoder with millions of corrupted, malformed, or randomized bitstreams.

While these streams do not produce viewable video, they force the decoder to handle errors gracefully without crashing, leaking memory, or entering infinite loops. This ensures that the decoder remains stable and compliant even when encountering non-compliant or malicious input in the real world.