Method for terminating HEVC (High Efficiency Video Coding) block division in advance
By calculating the variance of CU and Sub_CU and quantization parameter QP to determine the threshold, the HEVC block division is terminated in advance, and the problem of excessive time consumption caused by recursive calculation in HEVC encoding is solved, and the encoding speed is improved.
Patent Information
- Application Number
- CN202310808918.8
- Authority / Receiving Office
- CN · China
- Patent Type
- Applications(China)
- Current Assignee / Owner
- Filing Date
- 2023-06-30
- Publication Date
- 2024-12-31
AI Technical Summary
The existing HEVC encoding technology consumes too much time due to recursive calculation of RDCost during video block division, which affects the encoding speed.
By calculating the variance of the CU, the variance of the four Sub_CUs and the quantization parameter QP, the threshold is determined, and whether to perform Sub_CU division is performed, thereby terminating the recursive division in advance and saving encoding time.
The partition marks are obtained using simple and fast eigenvalue calculations, which significantly improves the encoding speed and reduces unnecessary block partition operations.
Smart Images

Figure CN119232934A_ABST
Abstract
Description
Technical Field
[0001] The present invention belongs to the technical field of video coding and decoding, and in particular relates to a method for terminating HEVC block division in advance. Background Art
[0002] In the prior art, H.265 / HEVC retains the original H.264 / AVC framework and also upgrades and improves some aspects. When encoding a video, HEVC needs to recursively calculate the RDCost of each size CU and its four Sub_CUs, and then compare the RDCost of the CU and its four Sub_CUs. If the RDCost of the CU is smaller, no block division is performed, otherwise it is divided into four Sub_CUs.
[0003] However, the main drawbacks of the prior art are:
[0004] RDCost uses distortion and bits as metrics to select the best partitioning mode, but RDCost calculation is time-consuming. HEVC uses recursion to perform block partitioning until it recurses to the smallest CU. Each CU size uses RDCost to determine whether to divide it. Each possible partition is traversed once, which affects the encoding speed.
[0005] In addition, common terms in the prior art include:
[0006] H.265 / HEVC: It is a video compression coding standard and a lossy compression scheme standard. RDCost (rate-distortion cost): Generally speaking, the higher the video compression bit rate, the lower the distortion; and the lower the bit rate, the greater the distortion. RDCost is an expression for calculating bit rate and distortion, RDCost = D + λR. Where D is distortion, R is bit rate, and λ is external input. Through RDCost comparison, the mode is judged to maintain a balance between bit rate and distortion.
[0007] CU: Coding unit in H.265 / HEVC, with sizes of 64*64, 32*32, 16*16 and 8*8. Recursive function: A function that calls itself within its body is called a recursive call. This type of function is called a recursive function.
[0008] Quantization parameter / QP: reflects the compression of spatial details. The larger the value, the more severe the detail compression. Block division: divide the image into blocks according to the RDCost of the CU. In the official model, whether to perform block division is determined based on the RDCost.
[0009] Quadtree partitioning: The CU is divided into four sub-blocks (Sub_CU) according to the quadtree partitioning rules. Summary of the invention
[0010] In order to solve the above problems, the purpose of this application is: on the basis of recursive division, CU features, four Sub_CU features and QP are used to calculate, a threshold is obtained, and the threshold is compared with the RDCost of the current CU to decide whether the current CU is divided into Sub_CU, so as to terminate the recursive division of CU in advance and save encoding time.
[0011] Specifically, the present invention provides a method for terminating HEVC block partitioning in advance, the method comprising the following steps:
[0012] S1, determine whether the coding unit CU size is less than 8? If yes, proceed to step S3.4; if no, proceed to step S2;
[0013] S2, threshold calculation:
[0014] S2.1, calculate the variance of the current CU:
[0015]
[0016] Among them, x is the mean value of the pixel value in the current CU, x i For each pixel value in the current CU;
[0017] (1) Calculate the average value x of all pixel values in the current CU;
[0018] (2) Subtract the average value x from each pixel in the CU and square the difference;
[0019] (3) Add up the squared values;
[0020] (4) Divide the sum by the number of all pixels in the CU n to get the variance σ of the current CU CU ;
[0021] S2.2, calculate the variance σ of the four Sub_CUs in the CU respectively Sub_CU :
[0022]
[0023] Among them, x is the mean value of the pixel value in the current Sub_CU, x i For each pixel value in the current Sub_CU;
[0024] S2.3, calculate the difference between the CU variance and the variance of each Sub_CU respectively, and compare them to get the maximum variance difference ⊿σ max :
[0025]
[0026] Where i = 1, 2, 3, 4, max is the maximum value function, σ Sub_CUi is the variance of each Sub_CU;
[0027] S2.4 Feature selection: QP of the current CU, current CU variance σ CU With the four Sub_CU variance σ Sub_CU The maximum value of the difference between max ;
[0028] S2.5, take out the features selected in step S2.4, the QP and Δσ of the current CU max , select different threshold calculation formulas according to the size of CU, and obtain the threshold according to the threshold calculation formula. The threshold calculation formula is expressed as follows:
[0029]
[0030] Among them, variables A, B, and C are all constants, and there is a calculation formula for each dimension, as follows:
[0031]
[0032] Among them, the subscript of Threshold represents CUs of different sizes;
[0033] S3, calculation of the division mark:
[0034] S3.1, calculate the RDCost of the current CU;
[0035] S3.2, compared with the threshold value calculated in S2.5, if RDCost is greater than the threshold value, then mark split_flag as 1, otherwise it is 0;
[0036] S3.3, if split_flag is 1, return to step S1 and continue to split the CU, otherwise directly terminate the recursive splitting of the current CU;
[0037] S3.4, split_flag is 0, proceed to step S4;
[0038] S4, end.
[0039] The step S3.1, calculating the RDCost of the current CU further includes:
[0040] (1) Calculate the distortion D between the current CU and the predicted CU;
[0041] (2) Calculate the bits consumed by the current CU during the encoding process, which is the bit rate R;
[0042] (3) Obtaining external input parameter λ;
[0043] (4) Multiply λ by R and add D to get the RDCOST of the current CU:
[0044] RDCost=D+λR;
[0045] Where D is the current CU distortion, R is the bit rate of the current CU, and λ is an external input parameter.
[0046] The step S3.2 further comprises:
[0047] Determine whether CU RDCost>threshold? If not, proceed to step S3.4; if yes, split_flag is 1, and return to step S1:
[0048] (1)RDCost>Threshold, then split_flag=1;
[0049] (2)RDCost<=Threshold, then split_flag=0.
[0050] The step S3.3 further comprises:
[0051] (1) split_flag = 1, return to step S1;
[0052] (2) split_flag = 0, execute subsequent steps.
[0053] Therefore, the advantages of the present application are: using the CU variance, the four Sub_CU variances, the maximum difference between the CU and Sub_CU variances, and the QP feature as the feature value for calculating the split flag, the feature value calculation is simple and fast. Using the empirical threshold calculation formula obtained by using simple features, the value of the split flag can be quickly obtained, making the encoder encoding faster. BRIEF DESCRIPTION OF THE DRAWINGS
[0054] The drawings described herein are used to provide a further understanding of the present invention, constitute a part of this application, and do not constitute a limitation of the present invention.
[0055] Figure 1 It is a flow chart of the present application method.
[0056] Figure 2 It is a flowchart of an embodiment of the present application. DETAILED DESCRIPTION
[0057] In order to more clearly understand the technical content and advantages of the present invention, the present invention is now further described in detail in conjunction with the accompanying drawings.
[0058] like Figure 1As shown, a method for terminating HEVC block division in advance, the method comprising the following steps:
[0059] S1, determine whether the coding unit CU size is less than 8? If yes, proceed to step S3.4; if no, proceed to step S2;
[0060] S2, threshold calculation:
[0061] S2.1, calculate the variance of the current CU:
[0062]
[0063] Among them, x is the mean value of the pixel value in the current CU, x i For each pixel value in the current CU;
[0064] (1) Calculate the average value x of all pixel values in the current CU;
[0065] (2) Subtract the average value x from each pixel in the CU and square the difference;
[0066] (3) Add up the squared values;
[0067] (4) Divide the sum value by the number of all pixels n in the CU to obtain the variance σCU of the current CU;
[0068] S2.2, calculate the variance σ of the four Sub_CUs in the CU respectively Sub_CU :
[0069]
[0070] Among them, x is the mean value of the pixel value in the current Sub_CU, x i For each pixel value in the current Sub_CU;
[0071] S2.3, calculate the difference between the CU variance and the variance of each Sub_CU respectively, and compare them to get the maximum variance difference ⊿σ max :
[0072]
[0073] Where i = 1, 2, 3, 4, max is the maximum value function, σ Sub_CUi is the variance of each Sub_CU;
[0074] S2.4 Feature selection: QP of the current CU, current CU variance σ CU With the four Sub_CU variance σ Sub_CU The maximum value of the difference between max ;
[0075] S2.5, take out the features selected in step S2.4, the QP and Δσ of the current CU max , select different threshold calculation formulas according to the size of CU, and obtain the threshold according to the threshold calculation formula. The threshold calculation formula is expressed as follows:
[0076]
[0077] Among them, variables A, B, and C are all constants, and there is a calculation formula for each dimension, as follows:
[0078]
[0079] Among them, the subscript of Threshold represents CUs of different sizes;
[0080] S3, calculation of the division mark:
[0081] S3.1, calculating the RDCost of the current CU, further includes:
[0082] (1) Calculate the distortion D between the current CU and the predicted CU;
[0083] (2) Calculate the bits consumed by the current CU during the encoding process, which is the bit rate R;
[0084] (3) Obtaining external input parameter λ;
[0085] (4) Multiply λ by R and add D to get the RDCOST of the current CU:
[0086] RDCost=D+λR;
[0087] Where D is the current CU distortion, R is the bit rate of the current CU, and λ is an external input parameter;
[0088] S3.2, compared with the threshold calculated in S2.5, if RDCost is greater than the threshold, then the split_flag is marked as 1, otherwise it is 0:
[0089] (1)RDCost>Threshold, then split_flag=1;
[0090] (2)RDCost<=Threshold, then split_flag=0;
[0091] S3.3, if split_flag is 1, return to step S1 and continue to divide the CU, otherwise directly terminate the recursive division of the current CU:
[0092] (1) split_flag = 1, return to step S1;
[0093] (2) split_flag = 0, execute the subsequent steps;
[0094] S3.4, split_flag is 0, proceed to step S4;
[0095] S4, end.
[0096] Specifically, this method can also be described as follows:
[0097] Feature selection: The feature selection is the QP of the current CU, the current CU variance (σ CU ) and the four Sub_CU variances (σ Sub_CU ) is the maximum value of the difference between max , σ CU , σ Sub_CU and ⊿σ max It can be expressed by the following formula:
[0098]
[0099]
[0100] x is the mean value of the pixel value in the current CU / Sub_CU, x i For each pixel value in the current CU / Sub_CU.
[0101]
[0102] Where i = 1, 2, 3, 4, max is the maximum value function, σ Sub_CUi is the variance σ of each Sub_CU Sub_CU ;
[0103] Calculation formula and process:
[0104] (1) Calculation formula: The maximum value σ of the difference between the QP of the current CU, the variance of the current CU and the variances of the four Sub_CUs max , we can get an empirical threshold calculation formula, which is expressed as follows:
[0105]
[0106] Among them, variables A, B, and C are all constants, and there is a calculation formula for each dimension, as follows:
[0107]
[0108] The subscript of Threshold represents CUs of different sizes.
[0109] (2) The main process is mainly divided into threshold calculation and division mark calculation:
[0110] S2, threshold calculation steps:
[0111] S2.1, calculate the variance σ of the current CU CU ;
[0112] S2.2, calculate the variance σ of four Sub_CUs Sub_CU ;
[0113] S2.3, calculate the difference between the current CU variance and the four Sub_CU variances respectively; find the largest variance difference σ max ;
[0114] S2.4, the feature selects the QP of the current CU and the variance of the current CU σ CU With the four Sub_CU variance σ Sub_CU The maximum value of the difference between max
[0115] S2.5 takes out the features selected by the current CU in S2.4, the QP and Δσ of the current CU max ; According to the size of CU, substitute the above formula to calculate the threshold.
[0116] S3, calculation of the division mark:
[0117] S3.1, calculate the RDCost of the current CU;
[0118] S3.2, compared with the threshold, if RDCost is greater than the threshold, mark split_flag as 1, otherwise it is 0;
[0119] S3.3, if split_flag is 1, return to step S1 and continue to split the CU, otherwise directly terminate the recursive splitting of the current CU;
[0120] S3.4, split_flag is 0, proceed to step S4;
[0121] S4, end.
[0122] like Figure 2 As shown, the algorithm flow in the specific embodiment of this method is:
[0123] 0, start;
[0124] 1. Determine whether the CU size is less than 8. If yes, proceed to step S9; if no, proceed to step 2. Assuming that the CU size is 16 and the QP is 30, proceed to step 2;
[0125] 2. Calculate the variance of CU, assuming it is 100;
[0126] 3. Calculate CU RDCost, assuming it is 1000;
[0127] 4. Calculate the variance of each Sub_CU of CU, assuming it is 100, 110, 120, 130;
[0128] 5. Calculate the difference between the CU variance and the variance of each Sub_CU. From the above data, we can see that the variance differences are 0, 10, 20, and 30 respectively;
[0129] 6. Compare and get the maximum variance difference ⊿σmax. From the above, we can know that the maximum variance difference is 30; 7. According to the threshold calculation formula, the threshold is obtained. According to the threshold formula and the above assumed data, the threshold can be calculated to be 1056.412;
[0130] 8. Determine whether CU RDCost>threshold value. If not, proceed to step 9. If yes, split_flag is 1, and return to step 1. From the above data, it can be seen that CU RDCost<threshold value, and proceed to step 9.
[0131] 9, split_flag is 0. From the above data, we can see that after entering step 9, we enter step 10;
[0132] 10. End. The algorithm ends here.
[0133] The above description is only a preferred embodiment of the present invention and is not intended to limit the present invention. For those skilled in the art, the embodiments of the present invention may have various modifications and variations. Any modification, equivalent replacement, improvement, etc. made within the spirit and principle of the present invention shall be included in the protection scope of the present invention.
Claims
1. A method for terminating HEVC block partitioning in advance, characterized in that: The method comprises the following steps: S1, determine whether the coding unit CU size is less than 8? If yes, proceed to step S3.4; if no, proceed to step S2; S2, threshold calculation: S2.1, calculate the variance of the current CU: Among them, x is the mean value of the pixel value in the current CU, x i For each pixel value in the current CU; (1) Calculate the average value x of all pixel values in the current CU; (2) Subtract the average value x from each pixel in the CU and square the difference; (3) Add up the squared values; (4) Divide the sum value by the number of all pixels n in the CU to obtain the variance σCU of the current CU; S2.2, calculate the variance σ of the four Sub_CUs in the CU respectively Sub_CU : Among them, x is the mean value of the pixel value in the current Sub_CU, x i For each pixel value in the current Sub_CU; S2.3, calculate the difference between the CU variance and the variance of each Sub_CU respectively, and compare them to get the maximum variance difference ⊿σ max : Where i = 1, 2, 3, 4, max is the maximum value function, σ Sub_CUi is the variance of each Sub_CU; S2.4 Feature selection: QP of the current CU, current CU variance σ CU With the four Sub_CU variance σ Sub_CU The maximum value of the difference between max ; S2.5, take out the features selected in step S2.4, the QP and Δσ of the current CU max , select different threshold calculation formulas according to the size of CU, and obtain the threshold according to the threshold calculation formula. The threshold calculation formula is expressed as follows: Among them, variables A, B, and C are all constants, and there is a calculation formula for each dimension, as follows: Among them, the subscript of Threshold represents CUs of different sizes; S3, calculation of the division mark: S3.1, calculate the RDCost of the current CU; S3.2, compared with the threshold value calculated in S2.5, if RDCost is greater than the threshold value, then mark split_flag as 1, otherwise it is 0; S3.3, if split_flag is 1, return to step S1 and continue to split the CU, otherwise directly terminate the recursive splitting of the current CU; S3.4, split_flag is 0, proceed to step S4; S4, end.
2. A method for early termination of HEVC block division according to claim 1, characterized in that: The step S3.1, calculating the RDCost of the current CU further includes: (1) Calculate the distortion D between the current CU and the predicted CU; (2) Calculate the bits consumed by the current CU during the encoding process, which is the bit rate R; (3) Obtaining external input parameter λ; (4) Multiply λ by R and add D to get the RDCOST of the current CU: RDCost=D+λR; Where D is the current CU distortion, R is the bit rate of the current CU, and λ is an external input parameter.
3. The method for early termination of HEVC block division according to claim 1, characterized in that: The step S3.2 further comprises: Determine whether CU RDCost>threshold? If not, proceed to step S3.4; if yes, split_flag is 1, and return to step S1: (1)RDCost>Threshold, then split_flag=1; (2)RDCost<=Threshold, then split_flag=0.
4. The method for early termination of HEVC block division according to claim 1, characterized in that: The step S3.3 further comprises: (1) split_flag = 1, return to step S1; (2) split_flag = 0, execute subsequent steps.
