# Sample-Based Gradient Edge and Angular Prediction for VVC Lossless Intra-Coding
## 3 Proposed Method
### Sample-Based Intra-Gradient Edge Detection and Angular Prediction
#### 3.1.3 Directional Texture Regions: Angular Prediction  
The video images contain massive textures in different directions. The values between image samples on the same texture are typically close. In conventional VVC intra-prediction, angular modes are used to predict these directional texture regions. Considering that the spatial correlation between image samples is enhanced with the decrease in sample distances, reference [17] proposed SAP, which uses adjacent reference samples for angular prediction. SAP has been proven to bring significant performance gains for lossless coding. We Introduce an additional adjacent reference line to extend and improve SAP. The process of improved SAP and the positional relationship between the reference samples and the current sample are shown in Figure 5. The improved SAP projects the current sample onto two adjacent reference lines to obtain two projection points. The prediction sample is generated through these two projection points. In addition, the distance between projection points of adjacent angular modes on the same reference line is relatively short, and the projection points of adjacent prediction modes on the same reference line are spaced relatively small. Therefore, sample-based angular prediction does not need to use too many prediction modes. The improved SAP reduces the VVC angular modes by half and only retains 33 angular modes. In addition, an equidistant prediction method the same as SAP1 is adopted. Figure 4: The process of average prediction and the positional relationship between the reference samples and the current sample. The improved SAP uses the prediction values of two projection points to generate prediction samples according to a certain weight allocation. The projection point closer to the current sample is defined as \(P1\). The projection point farther from the current sample is defined as \(P2\). The prediction values of two projection points are obtained from:  
\[P1=((32-iFact1)\cdot a+iFact1\cdot b+16)>>5 \tag{3}\]  
\[P2=((32-iFact2)\cdot c+iFact2\cdot d+16)>>5 \tag{4}\]  
where \(a\) and \(b\) are the two reference samples closest to the \(P1\), and \(c\) and \(d\) are the two reference samples closest to the \(P2\). The interpolation weight \(iFact1\) is determined by the distances between the \(P1\) and the two reference samples (when \(P1\) is located at \(a\), \(iFact1\) is \(0\), and when \(P1\) is located at \(b\), \(iFact1\) is \(32\)). The interpolation weight \(iFact2\) is determined by the distances between the \(P2\) and the two reference samples (when \(P2\) is located at \(c\), \(iFact2\) is \(0\), and when \(P2\) is located at \(d\), \(iFact2\) is \(32\)). The improved SAP has three types of weight allocations, respectively, named type 0, 1, and 2. Type 0 uses \(P1\) to generate the prediction sample:  
\[P_{(x,y)}=P1 \tag{5}\]  
Type 0 is consistent with the conventional SAP. Type 1 adds half of the difference between \(P1\) and \(P2\) to \(P1\) to generate the prediction sample:  
Figure 5: The process of improved SAP and the positional relationship between the reference samples and the current sample: (**a**) Prediction in the horizontal direction. (**b**) Prediction in the vertical direction. \[P_{(x,y)}=P1+(P1-P2)/2 \tag{6}\]  
The trend of changes between image samples has continuity. There is a correlation between the difference between the current sample and \(P1\) and the difference between \(P1\) and \(P2\). Type 1 uses the difference between \(P1\) and \(P2\) to compensate for \(P1\) to obtain the prediction sample, which expands the scope of application of angular prediction. Type 2 uses the average value of \(P1\) and \(P2\) to generate the prediction sample:  
\[P_{(x,y)}=(P1+P2)/2 \tag{7}\]  
If there are significant fluctuations between adjacent samples on the same texture, type 2 is expected to increase the accuracy of prediction. Different prediction types of a prediction direction share the same prediction mode.