web123456

x264 Loop Filtering Principles Series: Application of i_deblocking_filter_alphac0 and i_deblocking_filter_beta

Application of i_deblocking_filter_alphac0 and i_deblocking_filter_beta

  1. functionality: in x264 loop filtering.i_deblocking_filter_alphac0 respond in singingi_deblocking_filter_beta are two important parameters in the loop filter module that control the behavioral conditions of the deblocking filter. These parameters are usually set in the encoder configuration and have a significant impact on the quality of the final encoded video.
  2. Application Process:
  • As can be seen from the schematic flow, thei_deblocking_filter_alphac0 respond in singingi_deblocking_filter_betaas a threshold for whether or not to perform filtering, as well as modifying different boundary pixels such as thep0p1p2q0q1q2threshold conditions, and the corresponding pixel adjustments are made when different conditions are satisfied.
  • initial step: the default value set in thex264_param_defaultfunction is done;
  • second step: Adjust the value of both according to the video characteristics or needs in theparam_apply_tunefunction is done;
  • third step: Initialize the header to remove block-related variables, primarily by setting thei_deblocking_filter_alphac0 respond in singingi_deblocking_filter_betaconverti_alpha_c0_offseti_beta_offset, a two-fold relationship betweenslice_header_initfunction is done;
  • fourth step: Willi_alpha_c0_offseti_beta_offsetBoth are written to the code stream for decoding and recognition in theslice_header_writefunction is done;
  • fifth step: Willi_alpha_c0_offseti_beta_offsetconvertab Local variables, which are applied to specific filter functions according to different conditions, are used in thex264_frame_deblock_rowfunction is done;rdo modulesx264_macroblock_deblockfunction has a similar operation.
  • sixth step: According to the different components, filter intensity, filter direction to point to the specific filtering algorithm function, such as brightness component ordinary filtering through thedeblock_edge_luma_cfunction is realized, and the luminance component is strongly filtered through thedeblock_edge_luma_intra_cfunction implementation.
  • seventh step: Modify the value of the reconstructed pixel to be filtered by adjusting it to complete the filtering operation.
  • This is illustrated in the figure below:
    在这里插入图片描述

(statistics) correlationfunction (math.)clarification

  1. x264_param_default
    • Sets all encoding parameters in the x264_param_t structure to their default values. This function is very important and must be called as it provides a reasonable set of starting points for the encoding process. These parameters include, but are not limited to, resolution, frame rate, encoding modes (e.g. constant quantization parameter CQP, average bit rate ABR, etc.), de-blocking filter parameters, macroblock tree rate control (MB-tree), quantization matrix, etc.
  2. param_apply_tune
    • Used to adjust encoding parameters to suit specific video content or to optimize visual quality. This function can optimize the encoding parameters according to the specified tune value, e.g., for different types of video content such as film, animation, noise-containing video, still images, and so on. These tune values can be film, animation, grain, stillimage, psnr, ssim, fastdecode, zerolatency, and touhou, etc., where film, animation, grain, stillimage, psnr, and ssim are the visual optimization tunes, and fastdecode, zerolatency are encoding speed optimization tunes. param_apply_tune function can use multiple tunes at the same time if they don't conflict with each other.
    • In practice, theparam_apply_tune Functions are typically called after setting the encoder's default parameters to further refine and optimize the encoding settings. For example, after initializing the encoder parameter structure x264_param_t and setting the preset, it can be called by calling theparam_apply_tune to apply specific tuning values so that the encoding parameters can be adjusted according to the video content to achieve better encoding efficiency and quality
  3. slice_header_init
    • A data structure used to initialize the Slice Header in an x264 encoder. In the H.264/AVC video coding standard, the Slice Header is the metadata portion of each slice that contains important information needed to decode the current slice.
  4. slice_header_write
    • Writes the Slice Header information from the H.264 video encoding to the bitstream. In the H.264 video coding standard, each slice begins with a slice header that carries the necessary information to decode the current slice.
  5. x264_frame_deblock_row
    • Deblocking is used to deblock the rows in a video frame. Deblocking is a technique commonly used in video coding to reduce visual discontinuities at macroblock boundaries, known as block artifacts, which usually occur in video coding with high compression rates.
  6. deblock_edge
    • Used for normal filtering, i.e. the filtering case when the boundary strength (BS) is 1, 2 or 3. This function calculates the threshold for filtering based on the quantization parameter (QP) of the macroblock, the alpha table value, and the beta table value, and then decides whether or not to filter and the strength of the filtering based on these values and the BS value.
  7. deblock_edge_luma_c
    • Regarding the specific implementation of the function related to the filtering operation of the filtering intensities Bs = 1, 2, 3, mainly the filtering operation of the luminance component, and the similar operation of the chrominance component.
  8. deblock_edge_intra
    • Used for strong filtering, i.e. when the boundary strength Bs is 4. This kind of filtering is usually used for Intra macroblocks encoded within a frame or when the boundary of the macroblock is considered to be a strong true boundary. Compared to thedeblock_edge Compare.deblock_edge_intra Stronger filter parameters will be used to minimize visual discontinuities.
    1. deblock_edge_luma_intra_c
    • The specific implementation of the function related to the filtering operation on the filtering intensity Bs=4 is mainly a filtering operation on the luminance component, with similar operations on the chrominance component.

Associated deblocking filter data sheet

/* Deblocking filter */
static const uint8_t i_alpha_table[52+12*3] =
{
     0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,
     0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,
     0,  0,  0,  0,  0,  0,  0,  0,  0,  0,
     0,  0,  0,  0,  0,  0,  4,  4,  5,  6,
     7,  8,  9, 10, 12, 13, 15, 17, 20, 22,
    25, 28, 32, 36, 40, 45, 50, 56, 63, 71,
    80, 90,101,113,127,144,162,182,203,226,
   255,255,
   255,255,255,255,255,255,255,255,255,255,255,255,
};
static const uint8_t i_beta_table[52+12*3] =
{
     0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,
     0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,
     0,  0,  0,  0,  0,  0,  0,  0,  0,  0,
     0,  0,  0,  0,  0,  0,  2,  2,  2,  3,
     3,  3,  3,  4,  4,  4,  6,  6,  7,  7,
     8,  8,  9,  9, 10, 10, 11, 11, 12, 12,
    13, 13, 14, 14, 15, 15, 16, 16, 17, 17,
    18, 18,
    18, 18, 18, 18, 18, 18, 18, 18, 18, 18, 18, 18,
};
static const int8_t i_tc0_table[52+12*3][4] =
{
    {-1, 0, 0, 0 }, {-1, 0, 0, 0 }, {-1, 0, 0, 0 }, {-1, 0, 0, 0 }, {-1, 0, 0, 0 }, {-1, 0, 0, 0 },
    {-1, 0, 0, 0 }, {-1, 0, 0, 0 }, {-1, 0, 0, 0 }, {-1, 0, 0, 0 }, {-1, 0, 0, 0 }, {-1, 0, 0, 0 },
    {-1, 0, 0, 0 }, {-1, 0, 0, 0 }, {-1, 0, 0, 0 }, {-1, 0, 0, 0 }, {-1, 0, 0, 0 }, {-1, 0, 0, 0 },
    {-1, 0, 0, 0 }, {-1, 0, 0, 0 }, {-1, 0, 0, 0 }, {-1, 0, 0, 0 }, {-1, 0, 0, 0 }, {-1, 0, 0, 0 },
    {-1, 0, 0, 0 }, {-1, 0, 0, 0 }, {-1, 0, 0, 0 }, {-1, 0, 0, 0 }, {-1, 0, 0, 0 }, {-1, 0, 0, 0 },
    {-1, 0, 0, 0 }, {-1, 0, 0, 0 }, {-1, 0, 0, 0 }, {-1, 0, 0, 0 }, {-1, 0, 0, 0 }, {-1, 0, 0, 0 },
    {-1, 0, 0, 0 }, {-1, 0, 0, 0 }, {-1, 0, 0, 0 }, {-1, 0, 0, 0 }, {-1, 0, 0, 0 }, {-1, 0, 0, 1 },
    {-1, 0, 0, 1 }, {-1, 0, 0, 1 }, {-1, 0, 0, 1 }, {-1, 0, 1, 1 }, {-1, 0, 1, 1 }, {-1, 1, 1, 1 },
    {-1, 1, 1, 1 }, {-1, 1, 1, 1 }, {-1, 1, 1, 1 }, {-1, 1, 1, 2 }, {-1, 1, 1, 2 }, {-1, 1, 1, 2 },
    {-1, 1, 1, 2 }, {-1, 1, 2, 3 }, {-1, 1, 2, 3 }, {-1, 2, 2, 3 }, {-1, 2, 2, 4 }, {-1, 2, 3, 4 },
    {-1, 2, 3, 4 }, {-1, 3, 3, 5 }, {-1, 3, 4, 6 }, {-1, 3, 4, 6 }, {-1, 4, 5, 7 }, {-1, 4, 5, 8 },
    {-1, 4, 6, 9 }, {-1, 5, 7,10 }, {-1, 6, 8,11 }, {-1, 6, 8,13 }, {-1, 7,10,14 }, {-1, 8,11,16 },
    {-1, 9,12,18 }, {-1,10,13,20 }, {-1,11,15,23 }, {-1,13,17,25 },
    {-1,13,17,25 }, {-1,13,17,25 }, {-1,13,17,25 }, {-1,13,17,25 }, {-1,13,17,25 }, {-1,13,17,25 },
    {-1,13,17,25 }, {-1,13,17,25 }, {-1,13,17,25 }, {-1,13,17,25 }, {-1,13,17,25 }, {-1,13,17,25 },
};
#define alpha_table(x) i_alpha_table[(x)+24]
#define beta_table(x)  i_beta_table[(x)+24]
#define tc0_table(x)   i_tc0_table[(x)+24]
  • 1
  • 2
  • 3
  • 4
  • 5
  • 6
  • 7
  • 8
  • 9
  • 10
  • 11
  • 12
  • 13
  • 14
  • 15
  • 16
  • 17
  • 18
  • 19
  • 20
  • 21
  • 22
  • 23
  • 24
  • 25
  • 26
  • 27
  • 28
  • 29
  • 30
  • 31
  • 32
  • 33
  • 34
  • 35
  • 36
  • 37
  • 38
  • 39
  • 40
  • 41
  • 42
  • 43
  • 44
  • 45
  • 46