How the dav1d Decoder Powers Fast AV1 Playback in Firefox

This article provides an overview of how the Mozilla Firefox web browser achieves smooth, efficient AV1 video playback using the dav1d decoder. AV1 is a modern, royalty-free video format that offers superior compression, but it originally required immense processing power to decode. By integrating dav1d—an open-source decoder engineered for speed by the VideoLAN and FFmpeg communities—Firefox overcomes these hardware limitations. Below, we examine the specific technologies inside dav1d, including handwritten assembly code, advanced multi-threading, and memory optimizations, that make fast AV1 streaming possible on everyday devices.

The AV1 Decoding Challenge

The AV1 video codec was created by the Alliance for Open Media (AOMedia) to deliver high-quality video at significantly lower bitrates than older formats like H.264 and VP9. While AV1 excels at compressing video, it is computationally complex.

When AV1 first launched, browsers relied on a reference decoder called libaom. Because libaom was built primarily for research and encoding validation rather than playback speed, it struggled to play high-definition AV1 videos smoothly on standard consumer CPUs. To fix this, Mozilla partnered with VideoLAN and FFmpeg to adopt dav1d (which stands for "dav1d is an AV1 decoder") as Firefox’s default AV1 decoder.

Handwritten Assembly Optimizations

The primary reason dav1d is so fast inside Firefox is its extensive use of Single Instruction, Multiple Data (SIMD) assembly code.

Most software is written in high-level programming languages and relies on a compiler to translate that code into instructions the CPU can understand. While efficient for general tasks, compilers are rarely optimal for heavy video decoding. The developers behind dav1d bypassed this limitation by writing a massive portion of the decoder directly in assembly language.

  • Desktop Performance: On Intel and AMD processors, dav1d uses AVX2 and SSSE3 instruction sets to process large blocks of video data simultaneously.
  • Mobile Performance: On ARM processors (used in Android devices and Apple Silicon Macs), dav1d utilizes NEON instructions to maximize speed while minimizing battery drain.

By tailoring the code directly to the physical architecture of the CPU, dav1d performs mathematical calculations for video rendering several times faster than standard compiled code.

Advanced Multi-Threading

Video decoding historically struggled to utilize modern multi-core processors effectively. dav1d solves this by implementing a highly unified threading model that splits the workload across all available CPU cores.

Previously, decoders separated "tile threading" (decoding different sections of a single video frame at once) and "frame threading" (decoding multiple sequential frames at once). dav1d combines these into a single thread pool.

When you play an AV1 video in Firefox, dav1d breaks the video stream down into smaller tasks—such as reconstruction, loop filtering, and entropy decoding—and dynamically assigns them to whichever CPU core is currently free. This prevents CPU cores from sitting idle and eliminates playback stuttering, even during complex, high-bitrate scenes.

Low Memory Footprint

Web browsers are already memory-intensive applications. A video decoder that consumes too much RAM can cause browser tabs to crash or slow down the user's operating system.

dav1d was designed from the ground up to be lightweight. Its codebase is small, and it manages memory buffers strictly. By reusing memory allocations from frame to frame rather than constantly requesting new memory from the system, dav1d keeps Firefox's RAM usage low, even when streaming 4K AV1 video.

Software Decoding Without Dedicated Hardware

Newer graphics cards and processors include dedicated silicon built specifically to decode AV1 video (hardware acceleration). However, millions of Firefox users still browse the web on older computers and smartphones that lack this hardware.

Because dav1d is a software decoder, it runs entirely on the device's general-purpose CPU. Its extreme efficiency bridges the gap for older hardware, allowing users without the latest graphics cards to watch high-definition AV1 streams on platforms like YouTube and Netflix without dropped frames or excessive fan noise.