dav1d 1.5.4

dav1d 1.5.4 “Sonic”

We just released dav1d 1.5.4, the latest version of the 1.5 Sonic series of releases of dav1d, the best AV1 software decoder.

dav1d is our open source AV1 decoder: it is small, fast and portable, and it decodes AV1, the royalty-free video codec from the Alliance for Open Media, in VLC, FFmpeg, Firefox, Chrome, Safari, Android, Windows and many other applications and platforms, whenever hardware decoding is not available. It is probably running on billions of devices.

When the Sonic series started, dav1d had reached maturity: the important optimizations for desktop and mobile were done, and development was shifting to a quieter pace. Back then, I said the remaining work was on the less common architectures, notably RISC-V. This is exactly what happened.

1.5.3 focused mostly on RISC-V assembly and maintenance.
1.5.4 brings more RISC-V and ARM optimizations, better threading, and improved portability, including OS/2 support.

What is new in 1.5.3 and 1.5.4

RISC-V

A large part of the recent work targets RISC-V.

RISC-V is an open, royalty-free instruction set architecture, quickly gaining traction, from embedded devices to laptops and servers. RISC-V chips rarely ship with AV1 hardware decoding, so fast software decoding matters even more there. For that, dav1d relies on the RISC-V Vector extension (RVV).

Writing RVV code is harder than classic SIMD: unlike SSE/AVX or NEON, the vector length (VLEN) is not fixed and varies between implementations. This changes the loop structure, the tail handling, the unrolling strategy and, of course, the testing matrix. This is also why some kernels now get VLEN-specialized variants, where the generic vector-length-agnostic code was correct but not optimal.

1.5.4 adds RISC-V optimizations for:

  • intra prediction (dc, h, v, pal), in 8 and 16 bit depths;
  • generate_grain_y for film grain, in 8bpc;
  • the motion compensation paths (prep/put_8tap, 6-tap and copy).

1.5.3 had already added assembly for ipred, emu_edge and w_mask, plus VLEN 512 specializations for the blend functions.

The results are worth it. On real RVV hardware like the Kendryte K230 or the SpacemiT K1, individual kernels are several times faster than the C code: around 10-12x for w_mask, up to 7.5x for high bit-depth blend (and much more for the VLEN=512 variants), around 5x for emu_edge, and 2.5-4.6x for CDEF. Overall, decoding on current RISC-V systems is now at least twice as fast as with the C code alone, with more headroom as CPUs and vector lengths improve.

Part of this RISC-V work was supported by the Sovereign Tech Fund, as part of their investment in the VideoLAN ecosystem.

ARM

On AArch64, this release optimizes the ipred_v, ipred_h and ipred_smooth_* 8bpc functions and reduces the .text size. On ARM32, prep_neon was optimized.

GCS

This release also adds support for Armv9.3-A GCS (Guarded Control Stack).

GCS is a hardware security feature that protects return addresses on the stack, to mitigate ROP-style attacks. Supporting it in a project with this much hand-written assembly is not free, but dav1d is now ready for the platforms that will enforce it.

Threading and generic code

Beyond assembly, 1.5.4 improves the threading model by scheduling tile tasks for all passes at once. The quantization matrix tables are now precomputed at build time, and several loop-invariant computations were moved out of hot loops. This benefits all architectures.

Portability

dav1d has always cared about portability, and this release goes further than most: it adds support for OS/2, including API exports and assembly. It also improves portability for non-POSIX systems, with a signal() fallback.

Finally, dav1d now uses the external checkasm project. checkasm is the framework we created to validate and benchmark assembly against the C reference. It historically existed as multiple forks embedded in different multimedia projects, and it is now a unified standalone VideoLAN project, with better statistics, outlier rejection and clearer output. This matters even more for RISC-V, where every VLEN adds a dimension to the testing matrix. It is also the framework that dav2d benefits from since day one.

What is next?

The goal of dav1d has always been clear: be the best open source AV1 software decoder possible. That mission is achieved, and maintenance continues, with more RISC-V and SVE2 work still to do. Patches welcome.

In the Sonic post, I wrote that the next chapter might be AV2. It is no longer a maybe: dav2d, our AV2 decoder, is announced and progressing fast. This is where most of the new energy is going.

Until then, enjoy dav1d 1.5.4, faster and smoother than ever, from VideoLAN with love.