Libvpx Sub-pixel Interpolation Filters
This article provides an overview of the sub-pixel interpolation filters used for motion compensation in the libvpx library, which houses the reference implementations for the VP8 and VP9 video codecs. It explains the technical specifications of the filters used for fractional-pixel motion estimation, contrasting the 6-tap and bilinear approaches of VP8 with the advanced 8-tap switchable filters introduced in VP9.
Motion Compensation and Sub-pixel Precision
In video compression, motion compensation predicts frames by tracking the movement of objects between scenes. Because physical movement does not always align perfectly with the integer pixel grid of a digital sensor, codecs use sub-pixel (fractional-pixel) precision. The libvpx library interpolates virtual pixels between actual pixels to track movement at quarter-pixel (1/4) precision for luma and up to eighth-pixel (1/8) precision for chroma.
To calculate these fractional pixel values, libvpx applies specific digital interpolation filters.
VP8 Sub-pixel Interpolation Filters
The VP8 codec within libvpx utilizes two primary types of interpolation filters depending on the component and desired complexity:
- 6-Tap Filter for Luma: For half-pixel (1/2) and quarter-pixel (1/4) luma interpolation, VP8 uses a 6-tap Wiener-like filter. The filter coefficients (scaled by 128 or 64) are designed to offer a balance between sharpness and complexity.
- Bilinear Filter for Chroma: For chroma channels (which are typically subsampled), VP8 relies on a simpler 2-tap bilinear interpolation filter. Bilinear interpolation is also occasionally used for luma as a lower-complexity fallback mode to reduce CPU usage during decoding.
VP9 Sub-pixel Interpolation Filters
VP9 significantly advances motion compensation by introducing switchable sub-pixel interpolation filters for luma. Instead of relying on a single static filter, the VP9 encoder can choose the most efficient filter for each block from three distinct 8-tap filter families:
1. EIGHTTAP_REGULAR (DCT-based)
This is the default 8-tap filter. It uses a Discrete Cosine Transform (DCT) based interpolation formula. It provides a standard, high-quality reconstruction suitable for most natural video sequences, maintaining a good balance between edge sharpness and smooth gradients.
2. EIGHTTAP_SMOOTH
The smooth 8-tap filter applies a low-pass, smoothing effect during interpolation. It is designed to mitigate aliasing artifacts and high-frequency noise. This filter is highly effective for blurry backgrounds, flat surfaces, or regions where sharp transitions would otherwise cause pixelation or ringing.
3. EIGHTTAP_SHARP
The sharp 8-tap filter is optimized to preserve high-frequency details, sharp edges, and textures. It minimizes blur during motion but can occasionally introduce minor ringing artifacts. It is best utilized in highly detailed, well-focused regions of a frame.
VP9 Chroma Interpolation
For chroma motion compensation, VP9 supports up to 1/8-pixel precision. It interpolates chroma values using either a bilinear filter or an 8-tap filter that corresponds directly to the filter type selected for the co-located luma block.