AV1 Palette Mode Coding for Computer Graphics
This article provides an overview of how the AV1 video codec implements palette mode coding to optimize the compression of computer-generated graphics and screen content. Traditional video coding tools rely on transforms like DCT, which are designed for continuous-tone photographic imagery and cause severe ringing artifacts when applied to sharp, flat-color computer graphics. AV1 circumvents this by treating blocks with limited color variations as indexed images, storing a small set of representative colors in a local palette and encoding pixels as an index map. Below is a detailed look at how AV1 detects, structures, and encodes palette mode blocks to deliver high fidelity and low bitrates for synthetic imagery.
The Challenge of Computer-Generated Graphics
Synthetic content—such as desktop screen shares, slide presentations, video game user interfaces, and 2D animations—features unique characteristics compared to natural video:
- High-contrast, single-pixel edges (e.g., text, vector lines).
- Expansive regions of completely flat, uniform color.
- A low number of unique colors within localized regions.
When a conventional intra-prediction and frequency-transform pipeline processes these sharp transitions, high-frequency coefficients are heavily quantized, introducing noticeable blur, edge distortion, and "mosquito noise."
Palette Mode Activation and Palette Sizing
AV1 includes palette mode as a specialized intra-coding tool. An encoder evaluates whether a block contains a small enough set of unique colors to justify a palette representation over standard directional intra-prediction.
- Palette Size: An AV1 block can define a palette containing between 2 and 8 unique colors.
- Color Channels: Palettes can be generated for the luma (\(Y\)) channel and chroma (\(U, V\)) channels independently, or evaluated jointly depending on the color format (such as YUV 4:2:0 or YUV 4:4:4).
- Block Dimensions: Palette mode is available across standard square and rectangular block partitions, typically from \(8 \times 8\) up to \(64 \times 64\).
Palette Color Signaling
Once the encoder establishes the palette colors for a block, it must transmit those color values to the decoder with minimal overhead:
- Palette Predictor Cache: AV1 maintains a running cache of recently used palette colors from previously decoded neighboring blocks.
- Bitstream Flags: The bitstream uses binary flags to signal whether a color from the cache is reused in the current block's palette.
- Direct Transmission: Any colors not present in the cache are explicitly transmitted with delta encoding relative to previous entries, taking advantage of monotonic ordering to minimize bit consumption.
Index Map Encoding
After defining the palette table, the block’s pixels are converted into an index map where each pixel corresponds to a palette index (0 through 7). AV1 encodes this 2D grid using an advanced context-adaptive entropy coding process rather than simple raw indices:
- Neighborhood Context: Because adjacent pixels in synthetic graphics frequently share the exact same color, AV1 predicts the current pixel's index based on its top and left neighbors.
- Run-Length Modeling: Consecutive identical indices are represented as runs, drastically reducing data size across flat geometric shapes or background fills.
- Entropy Coding: The indices and run lengths are encoded through AV1's Multi-Symbol Arithmetic Coder using dynamically updated Cumulative Distribution Functions (CDFs).
Impact on Compression and Visual Quality
By bypassing the transform and quantization stages, palette mode provides two primary advantages for computer graphics:
- Mathematical Precision: Flat regions and sharp boundaries are reconstructed perfectly or near-perfectly without rounding errors.
- Bitrate Reductions: Storing a small table of colors and a run-length encoded index map requires significantly fewer bits than coding dense high-frequency transform coefficients.