AV1 Wedge-Based Prediction Block Segmentation
Wedge-based prediction is a specialized compound inter-prediction tool in the AV1 video codec that segments rectangular coding blocks into two non-rectangular regions using predefined directional dividing lines. By moving beyond traditional horizontal and vertical block partitions, this tool allows AV1 to accurately track moving object boundaries that run diagonally across a block. The two resulting sub-regions are assigned distinct motion vectors, which are then combined using a smooth blending mask along the boundary to prevent visual artifacts and maximize compression efficiency.
Predefined Wedge Codebooks
Rather than transmitting arbitrary boundary coordinates, which would consume significant bitrate, AV1 relies on a fixed codebook of predefined wedge patterns.
- Orientations and Offsets: The codebook defines 16 distinct partition shapes for square blocks (and a mapped set for non-square blocks). These shapes include horizontal, vertical, and oblique angles (roughly ±26.6°, ±45°, and ±63.4°) positioned at different offsets from the block center.
- Block Dimensions: Wedge prediction applies only to compound prediction blocks ranging from 8×8 up to 32×32 pixels, where standard block partitions are less efficient at capturing complex motion boundaries.
Region Assignment and Motion Vectors
During inter coding, an AV1 block evaluated for wedge prediction receives two separate motion vectors (\(MV_0\) and \(MV_1\)). These vectors can reference the same reference frame or two different reference frames:
- Partitioning: The wedge line splits the block area into Region 0 and Region 1.
- Directional Mapping: One motion vector predicts the pixel data for Region 0, while the other predicts the pixel data for Region 1.
- Sign Inversion: The encoder signals a 1-bit direction flag indicating whether \(MV_0\) maps to Region 0 and \(MV_1\) to Region 1, or vice versa.
Soft Blending Masks
To eliminate hard, artificial edges that would otherwise require high-frequency transform coefficients to encode, AV1 implements soft blending along the wedge partition line:
- Weight Distribution: The codec applies a pre-calculated 2D weight mask (\(W\)) where each pixel receives a blending factor ranging from 0 to 64 (representing 0% to 100%).
- Transition Zone: Pixels deep inside Region 0 have a weight of 64 for the first prediction, while pixels deep inside Region 1 have a weight of 0. Pixels adjacent to the partition line receive intermediate weights (e.g., 16, 32, 48), creating a smooth gradient transition.
- Final Reconstruction: The final predicted sample value \(P(x, y)\) is calculated via linear interpolation: \[P(x, y) = \frac{W(x, y) \cdot P_0(x, y) + (64 - W(x, y)) \cdot P_1(x, y)}{64}\] where \(P_0\) and \(P_1\) are the sample values produced by \(MV_0\) and \(MV_1\).
Signaling and Encoder Decision
During the rate-distortion optimization (RDO) search, the encoder tests standard compound prediction alongside the available wedge patterns. If a wedge pattern yields the lowest rate-distortion cost, the encoder signals the compound mode as wedge prediction, followed by the specific wedge index from the codebook, the sign bit, and the two associated motion vectors.