Appendix CfL - AlexBoswellVCD/gitlab_wiki_test GitHub Wiki

Chroma from Luma (CfL) Prediction Appendix

1. Description of the algorithm

The general idea behind the CfL prediction feature is to exploit the correlation between luma and chroma to express the Intra prediction of chroma pixel values as an affine function of the corresponding reconstructed luma pixels, where the reconstructed luma samples are sub-sampled to match the chroma sub-sampling. The chroma prediction is given by

where and are predicted chroma and reconstructed luma samples, respectively. and can be determined (at least theoretically) using least squares regression. The feature provides gains in screen sharing applications.

In practice, the CfL prediction is performed as illustrated in the diagram given below.

Figure 1. Block diagram of the chroma from luma prediction process.

The steps illustrated in the diagram above can be summarized as follows:

  • Consider the reconstructed luma pixel values.

  • Reconstructed luma samples are sub-sampled to match the chroma sub-sampling.

  • Calculate the (i.e. average) of the reconstructed luma pixel values.

  • Subtract the from the reconstructed luma pixel values to generate the AC reconstructed luma pixel values, , which has a zero average.

  • Compute and using the AC reconstructed luma pixel values.

  • Compute the intra DC mode chroma prediction, , and use that instead of . The final chroma from luma prediction is then given by:

2. Implementation of the algorithm

Inputs: Intra Chroma Mode, Luma Inverse quantized residual

Outputs: Best and Chroma residual

Control macros/flags:

Flag Level Description
chroma_level Picture Describes the Chroma level of the encoder. Indicates which Chroma modes are allowed.

Details of the implementation

The algorithm is implemented in the CflPrediction() function. This function is called when the intra_chroma_mode is set to UV_CFL_PRED. There are four steps in the function:

Step 1: Reconstruct the Luma pixels

Since the algorithm uses luma pixels, the first step is to reconstruct the luma samples. Up to this point, luma samples are transformed, quantized and inverse quantized. In this step, the inverse transform is applied, and added to the prediction to build the reconstructed pixels (**AV1PerformInverseTransformReconLuma).

Step 2: Compute the AC component of the Luma Intra prediction

In this step, the Luma reconstructed pixels are down sampled to match the size of Chroma pixels using cfl_luma_subsampling_420 function. Then the AC values are calculated by subtracting the DC value using eb_subtract_average function. The AC values are stored in pred_buf_q3 buffer.

Step 3: Find the best

The best s for U and V components are calculated by minimizing the overall full cost. The algorithm searches the possible values of and finds the best value that minimizes the joint U and V cost. After the best value for is calculated, the joint cost is compared with DC prediction and the winner is selected. This step is performed in cfl_rd_pick_alpha function.

Step 4: Perform prediction for Chroma

After the best is selected, the prediction using the new mode is performed using eb_cfl_predict function. Then the residual is calculated by residual_kernel.

3. Optimization of the algorithm

Finding the best requires searching different values and calculating a cost for each value. Performing this process of search for every luma mode and block size at MD would be very complex. In order to find the best quality speed trade off, there is an option to perform the selection of best at encode pass and only on the final chosen mode. This option is signaled using evaluate_cfl_ep flag. The flag depends on the Chroma level based as indicated in the following table:

Table 1. Evaluate_cfl_ep as a function of chroma_level.
chroma_level evaluate_cfl_ep
0 α selection at MD
1 α selection at MD
2 α selection at encode pass
3 no CFL mode

As the chroma_level increases, so does the complexity of the feature and the quality of the chroma prediction. The following table shows the chroma levels for the different encoder mode.

Table 2. chroma_level as a function of enc_mode.
Encoder Mode
(enc_mode)
chroma_level
(Case of sc_content_detected = 0)
chroma_level
(Case of sc_content_detected = 1)
0 0 for base layer, otherwise 1 1
1 1 1
2 1 1
3 1 1
4 1 1
5 2 if 8 bit, 3 if 10 bit 1
6 2 if 8 bit, 3 if 10 bit 1
7 2 if 8 bit, 3 if 10 bit 1 for base layer, otherwise 2 if 8 bit, 3 if 10 bit
8 2 if 8 bit, 3 if 10 bit 1 for base layer, otherwise 2 if 8 bit, 3 if 10 bit

4. Signaling

CFL is a chroma mode that is only allowed for blocks with height and width of 32 or smaller. The entropy encoder signals the chroma mode per block and if the mode is CFL, extra parameters are send in the bit stream:

  • cfl_alpha_signs contains the sign of the alpha values for U and V packed together into a single syntax element with 8 possible values. (The combination of two zero signs is prohibited as it is redundant with DC Intra prediction.)

  • cfl_alpha_u contains the absolute value of alpha minus one for the U component.

  • cfl_alpha_v contains the absolute value of alpha minus one for the U component.

References

Luc N. Trudeau and Nathan E. Egge and David Barr, “Predicting Chroma from Luma in AV1”, 2017.

⚠️ **GitHub.com Fallback** ⚠️