AV1 Chroma from Luma Prediction Equations
Chroma from Luma (CfL) is an intra-prediction tool in the AV1 video codec that predicts chroma component samples directly from the reconstructed luma component of the same block. Instead of relying purely on spatial edge extension from neighboring chroma pixels, CfL exploits cross-component correlation by modeling chroma values as a linear function of colocated, downsampled luma samples. The process is governed by specific mathematical operations: luma downsampling, luma AC component extraction, linear scaling, and combining the scaled AC contribution with a conventional chroma DC predictor.
1. Luma Downsampling
Because video signals frequently use 4:2:0 chroma subsampling, the reconstructed luma samples must first be downsampled to match the resolution of the chroma block. For a chroma block of width \(W\) and height \(H\), the colocated reconstructed luma block has dimensions \(2W \times 2H\).
For 4:2:0 subsampling, the downsampled luma value \(L_{ds}(x, y)\) at chroma coordinate \((x, y)\) is computed by averaging a \(2 \times 2\) grid of reconstructed luma samples \(L(i, j)\):
\[L_{ds}(x, y) = \left\lfloor \frac{L(2x, 2y) + L(2x+1, 2y) + L(2x, 2y+1) + L(2x+1, 2y+1) + 2}{4} \right\rfloor\]
where \(0 \le x < W\) and \(0 \le y < H\).
2. AC Luma Extraction
CfL isolates the AC (high-frequency) variations of the downsampled luma signal so that the overall DC level can be predicted separately using spatial boundary samples.
First, the average (DC) value of the downsampled luma block, \(\bar{L}\), is computed:
\[\bar{L} = \left\lfloor \frac{\sum_{y=0}^{H-1} \sum_{x=0}^{W-1} L_{ds}(x, y) + \frac{W \cdot H}{2}}{W \cdot H} \right\rfloor\]
Next, the AC component of the downsampled luma, \(L_{AC}(x, y)\), is obtained by subtracting the block average from each sample:
\[L_{AC}(x, y) = L_{ds}(x, y) - \bar{L}\]
3. Chroma DC Prediction
The DC baseline for the chroma component, denoted as \(DC_{chroma}\), is generated using standard intra DC prediction from reconstructed neighboring chroma samples (above and left boundaries):
\[DC_{chroma} = \left\lfloor \frac{\sum_{x=0}^{W-1} C_{above}(x) + \sum_{y=0}^{H-1} C_{left}(y) + \frac{W + H}{2}}{W + H} \right\rfloor\]
If only one boundary is available, the average is taken over the available boundary. If neither is available, the default midpoint value for the given bit depth (\(2^{\text{BitDepth}-1}\)) is used.
4. Final Chroma Prediction
The continuous mathematical model for the chroma prediction \(\hat{C}(x, y)\) is defined as:
\[\hat{C}(x, y) = DC_{chroma} + \alpha \cdot L_{AC}(x, y)\]
In the AV1 specification, this linear relationship is implemented via fixed-point integer arithmetic. The scaling parameter \(\alpha\) is signaled independently for the Cb (U) and Cr (V) components within the range \([-16, 16]\).
The scaled AC component is computed with a fixed divisor of 64 (a right shift of 6) using signed rounding:
\[\hat{C}_{AC}(x, y) = \text{Round2Signed}(\alpha \cdot L_{AC}(x, y), 6) = \text{Sign}(\alpha \cdot L_{AC}(x, y)) \cdot \left\lfloor \frac{|\alpha \cdot L_{AC}(x, y)| + 32}{64} \right\rfloor\]
The final prediction combines the chroma DC predictor and the scaled AC component, clamped to the valid sample dynamic range:
\[\hat{C}(x, y) = \text{Clip1}\left( DC_{chroma} + \hat{C}_{AC}(x, y) \right)\]
where:
\[\text{Clip1}(v) = \min\left( \max(0, v), 2^{\text{BitDepth}} - 1 \right)\]
5. Encoder-Side Alpha Estimation
To minimize the sum of squared errors between the original chroma block \(C(x, y)\) and the predicted block \(\hat{C}(x, y)\), the optimal continuous scaling factor \(\alpha^*\) is determined via linear regression:
\[\alpha^* = \frac{\sum_{x,y} L_{AC}(x, y) \cdot \left( C(x, y) - DC_{chroma} \right)}{\sum_{x,y} \left( L_{AC}(x, y) \right)^2}\]
The encoder then quantizes \(\alpha^*\) to the closest allowable integer step in the range \([-16, 16]\), corresponding to step sizes of \(\frac{1}{16}\) in the continuous domain.