Sample Adaptive Offset (SAO) is used to eliminate ringing effect. Ringing effect is due to the quantization distortion of high frequency AC coefficient, which will produce ripple around the edge after decoding. The larger the transform block size, the more obvious ringing effect. As shown in the figure below, dashed lines are original pixel values and solid lines are reconstructed pixel values.

 

The fundamental cause of ringing effect is the loss of high frequency information. The basic principle of SAO is to compensate the peak pixels of reconstructed curves by adding negative values, and to supplement the trough pixels by adding positive values.

SAO takes CTB as the basic unit and includes two types of compensation: Edge Offset (EO) and Band Offset (BO). In addition, parameter fusion technology is introduced.

Boundary compensation

The boundary compensation technology is to compare the current pixel with neighboring pixels and then classify them, and then compensate the same value for similar pixels. To balance complexity and coding efficiency, EO uses a 1-d 3-pixel classification scheme.

According to the location difference of selected pixels, EO has four modes: horizontal EO_0, vertical EO_1, 135° EO_2, and 45° EO_3. As shown in the figure below, C is the current pixel and AB is the adjacent pixel.

 

 

The shape of class 4 is shown in the figure below:

 

The boundary compensation technology firstly divides all pixels in CTB into 5 categories according to the above rules, and then compensates the pixels of category 1, 2, 3 and 4 by increasing or decreasing a certain value, and does not compensate the pixels of category 0. The compensation value of different types of pixels may be different, but the compensation value of the same type of pixels must be the same.

The experimental results show that most of the symbols of the compensation values match the types, so the compensation values can be limited according to the types: the compensation values of the types 1 and 2 are greater than or equal to 0, and the compensation values of the types 3 and 4 are less than or equal to 0. Therefore, only the absolute value of the compensation value is transmitted in the code stream, and the decoder can judge the symbol according to the category of the pixel.

Sideband compensation

Sideband compensation is classified according to pixel value size. It divides pixels into 32 equal length sideband. For example, 8-bit pixel with pixel values ranging from 0 to 255, each sideband contains 256/32=8 pixel values, that is, the pixel values in the [8K, 8K +7] range belong to the KTH sideband, k=0… 31. Use the same compensation value for the same sideband.

In general, the fluctuation range of pixel values in a certain region is very small, and most pixels in a CTB belong to a few sideband. H.265/HEVC specifies that a CTB can select only four consecutive sideband, and only the pixels belonging to these four sideband are compensated. The pass rate distortion optimization can determine which 4 sideband to choose, and then transmit the minimum sideband number and 4 compensation values to the decoder.

 

Parameters of the fusion

Parameter Merge refers to that for a CTB, the SAO parameters of adjacent blocks can be directly used. In this case, only the SAO parameters of adjacent blocks can be identified.

 

As shown in the figure above, when the SAO parameter decision of C is made, the SAO parameters of A and B have been determined. At this time, the SAO parameter of C has the following three choices:

  1. Use block A arguments directly.
  2. Use block B arguments directly.
  3. By analyzing the characteristics of its own pixels, parameters different from A and B are selected.
enum SAOModeMergeTypes
{
  SAO_MERGE_LEFT =0,
  SAO_MERGE_ABOVE,
  NUM_SAO_MERGE_TYPES
};
Copy the code

When a CTU uses parameter fusion, its brightness and chromaticity components must use the corresponding parameters of the same adjacent block. Otherwise, using non-parametric fusion technology, brightness and chromaticity can independently select the partition mode and compensation value according to their own pixel characteristics, and the two chromaticity components share the same partition mode.

Grammatical structure

The syntax structure of SAO as defined in H.265/HEVC is shown below:

If you are interested, please pay attention to wechat public account Video Coding