Rate-distortion optimization quantization method, device, electronic device and storage medium

By quantizing and dividing the transform coefficient matrix, eliminating the dependence between quantized sub-matrixes and processing the quantized coefficients in parallel, the difficulty and delay problems of parallel processing in hardware implementation in the prior art are solved, and processing speed and hardware efficiency are improved.

CN117135354BActive Publication Date: 2025-01-14RONG MING MICROELECTRONICS (JINAN) CO LTD
View PDF 1 Cites 0 Cited by

Patent Information

Application Number
CN202310980785.2
Authority / Receiving Office
CN · China
Patent Type
Patents(China)
Current Assignee / Owner
Filing Date
2023-08-03
Publication Date
2025-01-14
Estimated Expiration
2043-08-03

AI Technical Summary

Technical Problem

The existing rate distortion optimization quantization technology has difficulty in parallel processing in hardware implementation, resulting in processing delays and strong dependence on entropy encoders, making it difficult to operate effectively in low-latency scenarios.

Method used

By quantizing the transform coefficient matrix, dividing it into non-overlapping quantization coefficient submatrix, data statistics are performed to eliminate dependencies, quantization coefficients are processed in parallel, and integer operations are used to reduce hardware complexity.

Benefits of technology

The quantization coefficient of parallel processing is realized, which reduces hardware processing delay, improves processing speed, and reduces the complexity of hardware implementation.

✦ Generated by Eureka AI based on patent content.

Smart Images

  • Figure CN117135354B_ABST
    Figure CN117135354B_ABST
Patent Text Reader

Abstract

The present application relates to a rate-distortion optimized quantization method, device, electronic device and storage medium. The rate-distortion optimized quantization method is applied to an encoder, and the method includes: quantizing a transform coefficient matrix to obtain a first quantization coefficient matrix; the first quantization coefficient matrix includes a first quantization coefficient; dividing the first quantization coefficient matrix into non-overlapping first quantization coefficient sub-matrices; performing data statistics on the first quantization coefficient sub-matrices to obtain quantization statistical data; for each first quantization coefficient sub-matrix, adjusting the coefficients of the non-zero first quantization coefficients to obtain a second quantization coefficient sub-matrix; the second quantization coefficient sub-matrix includes a second quantization coefficient; according to the relationship between the second quantization coefficient sub-matrix and the first quantization coefficient sub-matrix and the first quantization coefficient matrix, obtaining the second quantization coefficient matrix. The technical solution of the present application can process quantization coefficients in parallel and reduce hardware processing delays.
Need to check novelty before this filing date? Find Prior Art

Description

Technical Field

[0001] The present invention relates to the technical field of video compression, and in particular to a rate-distortion optimization quantization method, device, electronic equipment and storage medium. Background Art

[0002] In related technologies, scalar quantization cannot achieve optimal performance because of its fixed dead zone. Rate-distortion optimized quantization (RDOQ) can maximize compression performance because it takes rate-distortion cost into account during the quantization process. RDOQ technology compares the rate-distortion cost from multiple quantization schemes, and finally selects the scheme with the smallest rate-distortion cost to achieve optimal performance. The quantization scheme can be determined by different quantization parameters (QP) or by different quantization offsets. Among them, RDOQ technology originated from the H.264 / AVC video coding standard.

[0003] In the related art, an early RDOQ method was proposed, which selects the optimal QP for each coding block to achieve the optimization purpose. In the related art, a further improved method is also proposed, which removes some unnecessary candidate QPs through some fast algorithms to reduce the number of traversals. However, these methods are not suitable for applications with rate control turned on, because rate control will further change the QP of each block to achieve the effect of balancing the bit rate. Among them, the key to RDOQ is to calculate the rate-distortion cost of each quantization scheme, which can be defined as:

[0004] C=D+ λ×R (1)

[0005] Among them, C is the rate-distortion cost, D is the distortion between the original signal and the decoded signal, R is the encoding bit rate, and λ is the rate-distortion parameter. D can be obtained by calculating the difference between the original signal and the decoded signal. However, due to the sequential execution characteristics of the entropy encoder and the high complexity of the context model, the accurate bit rate R is usually difficult to obtain. A method of directly inputting the quantization coefficient into the entropy encoder to obtain the bit rate R is proposed in the related art, but it still requires a lot of calculations of the entropy encoder, so it is not suitable for low-latency scenarios.

[0006] In order to reduce RDOQ's dependence on the entropy encoder, RDOQ uses many techniques to quickly estimate the distortion D and the bit rate R. First, skip the inverse transform step and directly calculate the distortion D. Then, the bit rate R is estimated by querying a large number of trained entropy coding tables without relying on the entropy encoder. In the related art, a simple and effective RDOQ method applied to H.265 / HEVC is proposed. This method attempts to change the spatial distribution of non-zero coefficients and reduce the absolute value of non-zero coefficients to minimize the rate-distortion cost. For the quantized residual coefficients, the position of the non-zero coefficients and the absolute value of the non-zero coefficients occupy most of the coding bit rate. RDOQ attempts to fine-tune these positions and absolute values ​​so that entropy coding can compress information with higher efficiency. In general, RDOQ can reduce the coding bit rate R, but it will increase the coding distortion D, but it can achieve the purpose of improving the final coding quality by minimizing the rate-distortion cost C.

[0007] In the related art, a fast algorithm is further proposed. Whether RDOQ is needed is determined by checking the product of the quantization coefficient and QP. If the product is less than a certain threshold, RDOQ is activated. Otherwise, RDOQ is turned off.

[0008] However, in the related art, the RDOQ method requires that the quantization coefficients arrive in a predefined order and process them in order, which is feasible for software implementation but not optimal for hardware implementation. Specifically, when the RDOQ module processes a specific quantization coefficient, the processing of the previous quantization coefficient needs to be completed. This dependency makes it difficult to process multiple quantization coefficients in parallel, thus failing to give full play to the parallel capabilities of the hardware. Summary of the invention

[0009] The purpose of the present application is to provide a rate-distortion optimized quantization method, device, electronic device and storage medium, which can process quantization coefficients in parallel and reduce hardware processing delay.

[0010] According to a first aspect of an embodiment of the present application, a rate-distortion optimization quantization method is provided, which is applied to an encoder, and the method includes:

[0011] quantizing a transform coefficient matrix to obtain a first quantization coefficient matrix; wherein the transform coefficient matrix includes at least one transform coefficient, and the first quantization coefficient matrix includes at least one first quantization coefficient;

[0012] Dividing the first quantization coefficient matrix into at least two non-overlapping first quantization coefficient sub-matrices;

[0013] Performing data statistics on at least two of the first quantization coefficient sub-matrices to obtain quantization statistical data; the quantization statistical data is used to eliminate the dependency between the at least two of the first quantization coefficient sub-matrices;

[0014] For each of the first quantization coefficient submatrices, coefficient adjustment is performed on the non-zero first quantization coefficients to obtain a second quantization coefficient submatrix; the second quantization coefficient submatrix includes at least one second quantization coefficient; the coefficient adjustment of at least two of the first quantization coefficient submatrices is performed in parallel;

[0015] According to the second quantization coefficient submatrix and the relationship between the first quantization coefficient submatrix and the first quantization coefficient matrix, a second quantization coefficient matrix is ​​obtained, where the second quantization coefficient matrix includes at least one of the second quantization coefficients.

[0016] In one implementation, quantizing the transform coefficient matrix to obtain a first quantization coefficient matrix includes:

[0017] For each of the transform coefficients in the transform coefficient matrix, a quantization offset parameter is used to quantize the transform coefficient to obtain the first quantization coefficient.

[0018] In one implementation, the first quantization coefficient is calculated using the following formula:

[0019] QCoeff[cIdx][x][y]=sign[cIdx][x][y]×((|TCoeff[cIdx][x][y]|×quantizationScaler[cId x][x][y]+(1<<(quantizationShift[cIdx][x][y]-1)))>>quantizationShift[cIdx][x][y]);

[0020] Among them, QCoeff[cIdx][x][y] is the first quantization coefficient, sign[cIdx][x][y] is the sign of the transform coefficient, TCoeff[cIdx][x][y] is the transform coefficient, quantizationScaler[cIdx][x][y] is the quantization scaling parameter, quantizationShift[cIdx][x][y] is the quantization offset parameter, cIdx is the Y, U, V component index, and x, y are the coordinates of the transform coefficient in the transform coefficient matrix.

[0021] In one implementation, when the encoder is adapted to the HEVC standard, the quantization offset parameter is calculated using the following formula:

[0022]

[0023] Wherein, QP1 is a first quantization parameter when the encoder adapts to the HEVC standard, and transformShift is a parameter describing an internal transform shift of the transform coefficient matrix; and / or,

[0024] When the encoder is adapted to the AV1 standard, the quantization offset parameter is calculated using the following formula:

[0025]

[0026] numBitsDcQP is the number of bits required to represent the quantization index dcQP of the low-frequency transform coefficient, tuSize is the size of the transform coefficient matrix, bitDepth is the bit depth of the video, and numBitsAcQp is the number of bits required to represent the quantization index acQP of the high-frequency transform coefficient.

[0027] In one implementation, when the encoder is adapted to the HEVC standard, the transformShift is calculated using the following formula:

[0028] transformShift=15-bitDepth-log2(tuSize);

[0029] Among them, tuSize is the size of the transform coefficient matrix, and bitDepth is the bit depth of the video.

[0030] In one implementation, when the encoder is adapted to the AV1 standard, the dcQP is calculated using the following formula:

[0031]

[0032] Among them, av1DcQLookUp is the first table, which is used to store the correspondence between the first quantization parameter and the quantization index of the low-frequency transform coefficient when the bit depth of the video is 8, and the av1DcQLoopUp10 is the second table, which is used to store the correspondence between the first quantization parameter and the quantization index of the low-frequency transform coefficient when the bit depth of the video is 10.

[0033] In one implementation, when the encoder is adapted to the AV1 standard, the acQP is calculated using the following formula:

[0034]

[0035] Among them, av1AcQLookUp is the third table, which is used to store the correspondence between the first quantization parameter and the quantization index of the high-frequency transform coefficient when the bit depth of the video is 8, and the av1AcQLoopUp10 is the fourth table, which is used to store the correspondence between the first quantization parameter and the quantization index of the high-frequency transform coefficient when the bit depth of the video is 10.

[0036] In one implementation, when the encoder is adapted to the AV1 standard, before calculating the quantization offset parameter, the encoder includes:

[0037] A second quantization parameter when the encoder is adapted to the AV1 standard is converted into the first quantization parameter.

[0038] In one implementation, the first quantization parameter is calculated using the following formula:

[0039]

[0040] Among them, QP2 is the second quantization parameter, av1ToHevcQp is the fifth table, which is used to store the correspondence between the second quantization parameter and the first quantization parameter when the bit depth of the video is 8, and av1ToHevcQp10 is the sixth table, which is used to store the correspondence between the second quantization parameter and the first quantization parameter when the bit depth of the video is 10.

[0041] In one implementation, when the encoder is adapted to the HEVC standard, the quantizationScaler[cIdx][x][y] is calculated using the following formula:

[0042] quantizationScaler[cIdx][x][y]=hevcScalingList[QP1%6];

[0043] Wherein, hevcScalingList is a seventh table, used to store the corresponding relationship between QP1%6 and the quantization scaling parameter when the encoder adapts to the HEVC standard; and / or,

[0044] When the encoder is adapted to the AV1 standard, the quantizationScaler[cIdx][x][y] is calculated using the following formula:

[0045]

[0046] numBitsDcQP is the number of bits required to represent the quantization index dcQP of the low-frequency transform coefficient, and numBitsAcQp is the number of bits required to represent the quantization index acQP of the high-frequency transform coefficient.

[0047] In one implementation, before performing statistics on the first quantization coefficient matrix to obtain quantization statistical data, the method further includes:

[0048] Creating a corresponding array for at least one context model and initializing the context model to a predefined value; the array is used to store the state of the corresponding context model; each element of the array is an 8-bit integer;

[0049] Wherein, the at least one context model includes a first context model, a second context model, a third context model and a fourth context model; the array corresponding to the at least one context model includes a first array, a second array, a third array and a fourth array;

[0050] The first array is significantCoeffGroupCtx[2], which is used to store the conditional probability state of the first syntax element, and the first syntax element is significantCoeffCroup, which is used to indicate whether the current first quantization coefficient submatrix has a non-zero first quantization coefficient; the first syntax element is the first context model;

[0051] The second array is sigCoeffCtx

[44] , which is used to store the conditional probability state of the second syntax element, the second syntax element is sigCoeffFlag, which is used to indicate whether the current first quantization coefficient is zero; the second syntax element is the second context model;

[0052] The third array is greaterOneCoeffCtx

[24] , which is used to store the conditional probability state of the third syntax element, and the third syntax element is absCoeffGreaterThanOneFlag, which is used to indicate whether the absolute value of the current first quantization coefficient is greater than 1; the third syntax element is the third context model;

[0053] The fourth array is levelAbsCoeffCtx[6], which is used to store the conditional probability state of the fourth syntax element. The fourth syntax element is levelAbsCoeff, which is the absolute value of the current first quantization coefficient; the fourth syntax element is the fourth context model.

[0054] In one implementation, performing data statistics on at least two of the first quantization coefficient sub-matrices to obtain quantization statistical data includes:

[0055] For the first quantization coefficient sub-matrices of the first quantization coefficient matrix, respectively scan at least two of the first quantization coefficient sub-matrices according to a specified first scanning order;

[0056] For each of the first quantization coefficient submatrices, the first quantization coefficients are scanned according to a specified second scanning order to obtain the quantization statistics; the first scanning order is the same as the second scanning order.

[0057] In one embodiment, the quantization statistical data includes: the number of first quantization coefficients with an absolute value of 1 in the first quantization coefficient submatrix, the number of first quantization coefficients with an absolute value greater than 1 in the first quantization coefficient submatrix, the number of first quantization coefficients with an absolute value greater than 2 in the first quantization coefficient submatrix, the position of the first non-zero first quantization coefficient arranged in the first scanning order in the first quantization coefficient matrix, the position of the first first quantization coefficient with an absolute value of 4 arranged in the second scanning order in the first quantization coefficient submatrix, the position of the first first quantization coefficient with an absolute value of 7 arranged in the second scanning order in the first quantization coefficient submatrix, the position of the first first quantization coefficient with an absolute value of 13 arranged in the second scanning order in the first quantization coefficient submatrix, and the position of the first first quantization coefficient with an absolute value of 25 arranged in the second scanning order in the first quantization coefficient submatrix.

[0058] In one embodiment, the number of first quantization coefficients with an absolute value of 1 in the first quantization coefficient submatrix is ​​stored in a fifth array named cgOneCnt

[64] . The fifth array is initialized to an all-zero array before data statistics. During the data statistics process, if the absolute value of the current first quantization coefficient is 1, the corresponding cgOneCnt of the first quantization coefficient submatrix is ​​incremented by 1.

[0059] In one implementation, the number of first quantization coefficients with an absolute value of 1 in the first quantization coefficient submatrix is ​​calculated using the following formula:

[0060]

[0061] Among them, QCoeff[cIdx][x][y] is the first quantization coefficient, cIdx is the Y, U, and V component indexes, x and y are the coordinates of the first quantization coefficient in the first quantization coefficient matrix, and tuSize is the size of the transform coefficient matrix.

[0062] In one embodiment, the number of first quantization coefficients whose absolute values ​​are greater than 1 in the first quantization coefficient submatrix is ​​stored in a sixth array named cgGreaterThanOneCnt

[64] . The sixth array is initialized to an all-zero array before data statistics. During the data statistics process, if the absolute value of the current first quantization coefficient is greater than 1, the corresponding cgGreaterThanOneCnt of the first quantization coefficient submatrix is ​​incremented by 1.

[0063] In one implementation, the number of first quantization coefficients with absolute values ​​greater than 1 in the first quantization coefficient submatrix is ​​calculated using the following formula:

[0064]

[0065] Among them, QCoeff[cIdx][x][y] is the first quantization coefficient, cIdx is the Y, U, and V component indexes, x and y are the coordinates of the first quantization coefficient in the first quantization coefficient matrix, and tuSize is the size of the transform coefficient matrix.

[0066] In one embodiment, the number of first quantization coefficients in the first quantization coefficient submatrix whose absolute value is greater than 2 is stored in a seventh array named cgGreaterThanTwoCnt

[64] . The seventh array is initialized to an all-zero array before data statistics. During the data statistics process, if the absolute value of the current first quantization coefficient is greater than 2, the corresponding cgGreaterThanTwoCnt of the first quantization coefficient submatrix is ​​incremented by 1.

[0067] In one implementation, the number of first quantization coefficients with absolute values ​​greater than 2 in the first quantization coefficient submatrix is ​​calculated using the following formula:

[0068]

[0069] Among them, QCoeff[cIdx][x][y] is the first quantization coefficient, cIdx is the Y, U, and V component indexes, x and y are the coordinates of the first quantization coefficient in the first quantization coefficient matrix, and tuSize is the size of the transform coefficient matrix.

[0070] In one embodiment, the position of the first quantization coefficient whose absolute value is 4 is stored in an eighth array named cgFirst4Loc

[64] [2]. All elements of the eighth array are initialized to -1 before data statistics. The vertical coordinate of the position of the first quantization coefficient whose absolute value is 4 is stored in cgFirst4Loc

[64] [0], and the horizontal coordinate is stored in cgFirst4Loc

[64] [1].

[0071] In one implementation, if Coeff[cIdx][x][y] is the first coefficient in the first quantization coefficient submatrix whose absolute value is 4, cgFirst4Loc is updated as:

[0072]

[0073]

[0074] Among them, cIdx is the Y, U, and V component indexes, x and y are the coordinates of the first coefficient with an absolute value of 4 in the first quantization coefficient matrix, tuSize is the size of the transform coefficient matrix, y1 is the vertical coordinate of the first quantization coefficient with an absolute value of 4 in the first quantization coefficient submatrix, and x1 is the horizontal coordinate of the first quantization coefficient with an absolute value of 4 in the first quantization coefficient submatrix.

[0075] In one embodiment, the position of the first quantization coefficient whose absolute value is 7 is stored in a ninth array named cgFirst7Loc

[64] [2]. All elements of the ninth array are initialized to -1 before data statistics. The vertical coordinate of the position of the first quantization coefficient whose absolute value is 7 is stored in cgFirst7Loc

[64] [0], and the horizontal coordinate is stored in cgFirst7Loc

[64] [1].

[0076] In one implementation, if Coeff[cIdx][x][y] is the first coefficient in the first quantization coefficient submatrix whose absolute value is 7, cgFirst7Loc is updated as:

[0077]

[0078]

[0079] Among them, cIdx is the Y, U, and V component indexes, x and y are the coordinates of the first coefficient with an absolute value of 7 in the first quantization coefficient matrix, tuSize is the size of the transform coefficient matrix, y2 is the vertical coordinate of the first quantization coefficient with an absolute value of 7 in the first quantization coefficient submatrix, and x2 is the horizontal coordinate of the first quantization coefficient with an absolute value of 7 in the first quantization coefficient submatrix.

[0080] In one embodiment, the position of the first quantization coefficient whose absolute value is 13 is stored in a tenth array named cgFirst13Loc

[64] [2]. All elements of the tenth array are initialized to -1 before data statistics. The vertical coordinate of the position of the first quantization coefficient whose absolute value is 13 is stored in cgFirst13Loc

[64] [0], and the horizontal coordinate is stored in cgFirst13Loc

[64] [1].

[0081] In one implementation, if Coeff[cIdx][x][y] is the first coefficient in the first quantization coefficient submatrix whose absolute value is 13, cgFirst13Loc is updated as:

[0082]

[0083]

[0084] Among them, cIdx is the Y, U, and V component indexes, x and y are the coordinates of the first coefficient with an absolute value of 13 in the first quantization coefficient matrix, tuSize is the size of the transform coefficient matrix, y3 is the vertical coordinate of the first quantization coefficient with an absolute value of 13 in the first quantization coefficient submatrix, and x3 is the horizontal coordinate of the first quantization coefficient with an absolute value of 13 in the first quantization coefficient submatrix.

[0085] In one embodiment, the position of the first quantization coefficient whose absolute value is 25 is stored in an eleventh array named cgFirst25Loc

[64] [2]. All elements of the eleventh array are initialized to -1 before data statistics. The vertical coordinate of the position of the first quantization coefficient whose absolute value is 25 is stored in cgFirst25Loc

[64] [0], and the horizontal coordinate is stored in cgFirst25Loc

[64] [1].

[0086] In one implementation, if Coeff[cIdx][x][y] is the first coefficient in the first quantization coefficient submatrix whose absolute value is 25, cgFirst25Loc is updated as:

[0087]

[0088]

[0089] Among them, cIdx is the Y, U, and V component indexes, x and y are the coordinates of the first coefficient with an absolute value of 25 in the first quantization coefficient matrix, tuSize is the size of the transform coefficient matrix, y4 is the vertical coordinate of the first quantization coefficient with an absolute value of 25 in the first quantization coefficient submatrix, and x4 is the horizontal coordinate of the first quantization coefficient with an absolute value of 25 in the first quantization coefficient submatrix.

[0090] In one implementation, for each of the first quantization coefficient submatrices, adjusting the non-zero first quantization coefficients to obtain a second quantization coefficient submatrix includes:

[0091] For each non-zero first quantized coefficient, calculating a first coding cost for coefficient adjustment according to at least two coefficient adjustment schemes;

[0092] For each coefficient adjustment scheme, a second coding cost is obtained according to the sum of all the first coding costs; the second coding cost is the coding cost of adjusting the coefficients of the first quantization coefficient submatrix;

[0093] Determine a target coefficient adjustment scheme from at least two coefficient adjustment schemes, wherein the second encoding cost of the target coefficient adjustment scheme is the minimum encoding cost among the second encoding costs of the at least two coefficient adjustment schemes;

[0094] The non-zero first quantization coefficients in the first quantization coefficient submatrix are adjusted according to a target coefficient adjustment scheme to obtain the second quantization coefficient submatrix.

[0095] In one implementation, the first encoding cost is calculated using the following formula:

[0096] cost1[cIdx][x′][y′]=distortion[cIdx][x′][y′]+rate[cIdx][x′][y′];

[0097] Among them, cost1[cIdx][x'][y'] is the first encoding cost, distortion[cIdx][x'][y'] is the error in the pixel domain, rate[cIdx][x'][y'] is the encoding bit rate, cIdx is the Y, U, V component index, and x', y' are the coordinates of the first quantization coefficient in the first quantization coefficient submatrix.

[0098] In one implementation, the pixel domain error is calculated using the following formula:

[0099] distortion[cIdx][x′][y′]=(mErr[cIdx][x′][y′]>>(2×transformShift+1))×mErr[cIdx][x′][y′];

[0100] Among them, mErr[cIdx][x'][y'] is the inverse restoration value of the quantization error, and transformShift is a parameter describing the internal transformation shift of the transformation coefficient matrix.

[0101] In one implementation, when the encoder is adapted to the HEVC standard and the bit depth of the video is 8, the inverse restoration value of the quantization error is calculated using the following formula:

[0102] mErr[cIdx][x′][y′]=(err[cIdx][x′][y′]>>12)×hevcScaler[QP1%6];

[0103] Wherein, err[cIdx][x'][y'] is a quantization error, hevcScaler is an eighth table for storing a corresponding relationship between QP1%6 and a magnification factor, and QP1 is a first quantization parameter when the encoder adapts to the HEVC standard; and / or,

[0104] When the encoder is adapted to the AV1 standard and the bit depth of the video is 8, the inverse restoration value of the quantization error is calculated using the following formula:

[0105]

[0106] Among them, err[cIdx][x'][y'] is the quantization error, numBitsDcQP is the number of bits required to represent the quantization index dcQP of the low-frequency transform coefficient, and numBitsAcQp is the number of bits required to represent the quantization index acQP of the high-frequency transform coefficient.

[0107] In one implementation, the inverse restoration value of the quantization error when the bit depth of the video is 10 is obtained by the following method:

[0108] Get the inverse restoration value of the quantization error when the bit depth of the video is 8;

[0109] The inverse restored value of the quantization error when the bit depth of the video is 8 is shifted right by two bits to obtain the inverse restored value of the quantization error when the bit depth of the video is 10.

[0110] In one implementation, the quantization error is calculated using the following formula:

[0111] err[cIdx][x′][y′]=||TCoeff[cIdx][x′][y′]|

[0112] Among them, TCoeff[cIdx][x'][y'] is the transformation coefficient, quantizationScaler[cIdx][x'][y'] is the quantization scaling parameter, QCoeff[cIdx][x'][y'] is the first quantization coefficient, and quantizationShift[cIdx][x'][y'] is the quantization offset parameter.

[0113] In one implementation, the encoding bit rate is calculated using the following formula:

[0114] rate[cIdx][x′][y′]=sigCoeffFlagRate[cIdx][x′][y′]+coeffAbsLevelRate[cIdx][x′][y′];

[0115] Among them, sigCoeffFlagRate[cIdx][x'][y'] is the first rate estimate of the second syntax element, the second syntax element is sigCoeffFlag, which is used to indicate whether the current first quantization coefficient is zero, and coeffAbsLevelRate[cIdx][x'][y'] is the second rate estimate of the syntax element that encodes the absolute value of the non-zero first quantization coefficient.

[0116] In one implementation, when the encoder is adapted to HEVC, the first bit rate estimate is calculated using the following formula:

[0117]

[0118] Among them, rateEstTab is a ninth table, and the ninth table is used to store the correspondence between QP1%3, the conditional probability state of the syntax element and the bit rate estimation, QP1 is the first quantization parameter when the encoder adapts to the HEVC standard, sigCoeffFlagTabIdx is the current conditional probability state of the second syntax element, and bitDepth is the bit depth of the video; and / or,

[0119] When the encoder is adapted to the AV1 standard, sigCoeffFlagRate[cIdx][x'][y'] is calculated using the following formula:

[0120]

[0121] Among them, rateEstTab is the ninth table, and the ninth table is used to store the correspondence between QP1%3, the conditional probability state of the syntax element and the bit rate estimation, QP1 is the first quantization parameter of the encoder when it adapts to the HEVC standard, and is converted from the second quantization parameter when the encoder adapts to the AV1 standard, and sigCoeffFlagTabIdx is the current conditional probability state of the second syntax element.

[0122] In one implementation, sigCoeffFlagTabIdx is calculated using the following formula:

[0123]

[0124] Among them, sigCoeffCtx is the second context model, used to store the conditional probability state of the second syntax element, and sigCoeffCtxIdx is comprehensively determined by the values ​​of the first syntax elements of the two adjacent first quantization coefficient submatrices at the top and the two adjacent first quantization coefficient submatrices on the left of the current first quantization coefficient submatrix.

[0125] In one implementation, the second bit rate estimate is calculated using the following formula:

[0126] coeffAbsLevelRate[cIdx][x′][y′]=absCoeffGreaterThanOneFlagRate[cIdx][x′][y′]+absCoeffGreaterThanTwoFlagRate[cIdx][x′][y′]+absCoeffMinusTwoRate[cIdx][x′][y′];

[0127] Among them, absCoeffGreaterThanOneFlagRate[cIdx][x'][y'] is the third rate estimate of the third syntax element, and the third syntax element is absCoeffGreaterThanOneFlag, which is used to indicate whether the absolute value of the current first quantization coefficient is greater than 1, absCoeffGreaterThanTwoFlagRate[cIdx][x'][y'] is the fourth rate estimate of the fifth syntax element, and the fifth syntax element is absCoeffGreaterThanTwo, which is used to indicate whether the absolute value of the current first quantization coefficient is greater than 2, and absCoeffMinusTwoRate[cIdx][x'][y'] is the fifth rate estimate of the sixth syntax element, and the sixth syntax element is absCeoffMinusTwo, which is used to indicate that the absolute value of the current first quantization coefficient is minus 2.

[0128] In one implementation, when |QCoeff[cIdx][x'][y']|<1, the third code rate estimate is equal to 0; QCoeff[cIdx][x'][y'] is the first quantization coefficient;

[0129] When |QCoeff[cIdx][x'][y']|≥1 and the encoder is adapted to the HEVC standard, the third bit rate estimation is calculated using the following calculation formula:

[0130]

[0131] Among them, rateEstTab is a ninth table, and the ninth table is used to store the correspondence between QP1%3, the conditional probability state of the syntax element and the bit rate estimation, QP1 is the first quantization parameter of the encoder when it adapts to the HEVC standard, greaterThanOneTabIdx is the current conditional probability state of the third syntax element, and bitDepth is the bit depth of the video; and / or,

[0132] When |QCoeff[cIdx][x'][y']|≥1 and the encoder is adapted to the AV1 standard, the third bit rate estimation is calculated using the following calculation formula:

[0133]

[0134] Among them, rateEstTab is the ninth table, and the ninth table is used to store the correspondence between QP1%3, the conditional probability state of the syntax element and the bit rate estimation, QP1 is the first quantization parameter of the encoder when it adapts to the HEVC standard, and is converted from the second quantization parameter when the encoder adapts to the AV1 standard, and greaterThanOneTabIdx is the current conditional probability state of the third syntax element.

[0135] In one implementation, when |QCoeff[cIdx][x'][y']|<2, the fourth rate estimate is equal to 0; QCoeff[cIdx][x'][y'] is the first quantization coefficient;

[0136] When |QCoeff[cIdx][x'][y']|≥2 and the encoder is adapted to the HEVC standard, the fourth bit rate estimation is calculated using the following calculation formula:

[0137]

[0138] Among them, rateEstTab is a ninth table, and the ninth table is used to store the correspondence between QP1%3, the conditional probability state of the syntax element and the bit rate estimation, QP1 is the first quantization parameter of the encoder when it adapts to the HEVC standard, greaterThanTwoTabIdx is the current conditional probability state of the fifth syntax element, and bitDepth is the bit depth of the video; and / or,

[0139] When |QCoeff[cIdx][x'][y']|≥2 and the encoder is adapted to the AV1 standard, the fourth bit rate estimation is calculated using the following calculation formula:

[0140]

[0141] Among them, rateEstTab is the ninth table, and the ninth table is used to store the correspondence between QP1%3, the conditional probability state of the syntax element and the bit rate estimation, QP1 is the first quantization parameter of the encoder when it adapts to the HEVC standard, and is converted from the second quantization parameter when the encoder adapts to the AV1 standard, and greaterThanTwoTabIdx is the current conditional probability state of the fifth syntax element.

[0142] In one implementation, when |QCoeff[cIdx][x'][y']|<3, the fifth rate estimate is equal to 0; QCoeff[cIdx][x'][y'] is the first quantization coefficient;

[0143] When |QCoeff[cIdx][x'][y']|≥3 and the encoder is adapted to the HEVC standard, the fifth bit rate estimation is calculated using the following calculation formula:

[0144] absCoeffMinusTwoRate[cIdx][x′][y′]=(GolombCodeLength×eqProbRateEstTab[QP1-6*(bitDepth-8)]);

[0145] Wherein, GolombCodeLength is the code length required for encoding the sixth syntax element using the Golomb-Rice code, eqProbRateEstTab is a tenth table, used to store the correspondence between the index value and the bit rate estimation when the conditional probability of the sixth syntax element is uniformly distributed, and the index value is determined according to the first quantization parameter and the bit depth, and the first quantization parameter is the quantization parameter when the encoder adapts to the HEVC standard; and / or,

[0146] When |QCoeff[cIdx][x'][y']|≥3 and the encoder is adapted to the AV1 standard, the fifth bit rate estimation is calculated using the following calculation formula:

[0147] absCoeffMinusTwoRate[cIdx][x′][y′]=GolombCodeLength×(eqProbRateEstTab[QP1]-(eqProbRateEstTab[QP1]>>2));

[0148] Among them, GolombCodeLength is the code length required for encoding the sixth syntax element using the Golomb-Rice code, eqProbRateEstTab is the tenth table, which is used to store the correspondence between the first quantization parameter and the bit rate estimation when the conditional probability of the sixth syntax element is uniformly distributed, the first quantization parameter is converted from the second quantization parameter, the first quantization parameter is the quantization parameter when the encoder adapts to the HEVC standard, and the second quantization parameter is the quantization parameter when the encoder adapts to the AV1 standard.

[0149] In one implementation, for each of the first quantization coefficient submatrices, adjusting the non-zero first quantization coefficients to obtain a second quantization coefficient submatrix includes:

[0150] For each non-zero first quantized coefficient, if the first quantized coefficient is located after the first non-zero first quantized coefficient in the first scanning order, calculating a third encoding cost for returning the first quantized coefficient to zero;

[0151] Fine-tune the first quantization coefficient to obtain the corresponding second quantization coefficient, and calculate a fourth encoding cost for fine-tuning the first quantization coefficient;

[0152] Obtaining a sum of all the third coding costs to obtain a fifth coding cost; the fifth coding cost is a coding cost for returning the first quantization coefficient submatrix to zero;

[0153] Obtaining a sum of all the fourth coding costs to obtain a sixth coding cost; the sixth coding cost is a coding cost for fine-tuning coefficients of the first quantization coefficient submatrix;

[0154] If the fifth coding cost is less than the sixth coding cost, setting the first quantization coefficient submatrix to zero to obtain the second quantization coefficient submatrix;

[0155] If the sixth encoding cost is less than the fifth encoding cost, the second quantization coefficient submatrix is ​​obtained according to the second quantization coefficient.

[0156] In one implementation, the obtaining of the sum of all the third encoding costs to obtain the fifth encoding cost is calculated using the following formula:

[0157]

[0158] Among them, cgCost0 is the fifth coding cost, zeroOutCost[cIdx][x'][y'] is the third coding cost, cIdx is the Y, U, V component index, x', y' are the coordinates of the first quantization coefficient in the first quantization coefficient submatrix, and CGSize is the size of the first quantization coefficient submatrix.

[0159] In one implementation, the third encoding cost is calculated using the following formula:

[0160] zeroOutCost[cIdx][x′][y′]=distortion[cIdx][x′][y′];

[0161] Among them, distortion[cIdx][x'][y'] is the error in the pixel domain.

[0162] In one implementation, the obtaining of the sum of all the fourth coding costs to obtain the sixth coding cost is calculated using the following formula:

[0163]

[0164] Among them, cgCost1 is the sixth coding cost, tweakedCoeffCost[cIdx][x'][y'] is the fourth coding cost, cIdx is the Y, U, V component index, x', y' are the coordinates of the first quantization coefficient in the first quantization coefficient submatrix, and CGSize is the size of the first quantization coefficient submatrix.

[0165] In one implementation, the fine-tuning the first quantization coefficient to obtain the corresponding second quantization coefficient, and calculating a fourth encoding cost for fine-tuning the first quantization coefficient includes:

[0166] Adjusting the first quantization coefficient to a first candidate quantization coefficient, and calculating a first candidate coding cost for adjusting the first quantization coefficient, wherein the first candidate quantization coefficient is 0;

[0167] If the absolute value of the first quantization coefficient is greater than 1, adjusting the first quantization coefficient to a second candidate quantization coefficient, and calculating a second candidate coding cost for adjusting the first quantization coefficient, wherein the sign of the second candidate quantization coefficient is the same as the sign of the first quantization coefficient, and the absolute value of the second candidate quantization coefficient is equal to the absolute value of the first quantization coefficient minus 1;

[0168] Calculating a third candidate coding cost of the first quantization coefficient, wherein no adjustment is made to the first quantization coefficient;

[0169] Selecting the smallest coding cost among the first candidate coding cost, the second candidate coding cost and the third candidate coding cost as the fourth coding cost;

[0170] A quantization coefficient corresponding to the smallest coding cost among the first candidate coding cost, the second candidate coding cost and the third candidate coding cost is selected as the second quantization coefficient.

[0171] In one implementation, the second quantization coefficient is calculated using the following formula:

[0172]

[0173] Among them, newQCoeff[cIdx][x'][y'] is the second quantization coefficient, sign[cIdx][x'][y'] is the sign of the first quantization coefficient, cost0[cIdx][x'][y'] is the first candidate coding cost, cost1[cIdx][x'][y'] is the second candidate coding cost, and cost2[cIdx][x'][y'] is the third candidate coding cost.

[0174] In one implementation, the fourth encoding cost is calculated using the following formula:

[0175] tweakedCoeffCost[cIdx][x′][y′]=min(cost0[cIdx][x′][y′],cost1[cIdx][x′][y′],cost2[cIdx][x′][y′]));

[0176] Among them, tweakedCoeffCost[cIdx][x'][y'] is the fourth coding cost.

[0177] According to a second aspect of an embodiment of the present application, a rate-distortion optimization quantization device is provided, which is applied to an encoder, and the device includes:

[0178] A quantization module, configured to quantize a transform coefficient matrix to obtain a first quantization coefficient matrix; wherein the transform coefficient matrix includes at least one transform coefficient, and the first quantization coefficient matrix includes at least one first quantization coefficient;

[0179] a decomposition module, configured to divide the first quantization coefficient matrix into at least two non-overlapping first quantization coefficient sub-matrices;

[0180] a statistical module configured to perform data statistics on at least two of the first quantization coefficient sub-matrices to obtain quantitative statistical data; the quantitative statistical data is used to eliminate the dependency between the at least two of the first quantization coefficient sub-matrices;

[0181] an adjustment module, configured to, for each of the first quantization coefficient submatrices, perform coefficient adjustment on the non-zero first quantization coefficients to obtain a second quantization coefficient submatrix; the second quantization coefficient submatrix includes at least one second quantization coefficient; and coefficient adjustment of at least two of the first quantization coefficient submatrices is performed in parallel;

[0182] The acquisition module is configured to acquire a second quantization coefficient matrix according to the second quantization coefficient submatrix and the relationship between the first quantization coefficient submatrix and the first quantization coefficient matrix, wherein the second quantization coefficient matrix includes at least one of the second quantization coefficients.

[0183] According to a third aspect of an embodiment of the present application, an electronic device is provided, comprising a memory and a processor, wherein the memory is used to store a computer program executable by the processor; and the processor is used to execute the computer program in the memory to implement the above method.

[0184] According to a fourth aspect of an embodiment of the present application, a computer-readable storage medium is provided, on which a computer program is stored, characterized in that when the executable computer program in the storage medium is executed by a processor, the above method can be implemented.

[0185] Compared with the prior art, the beneficial effect of the present application is that after the transform coefficient matrix is ​​quantized to obtain the first quantization coefficient matrix, the first quantization coefficient matrix is ​​divided into at least two non-overlapping first quantization coefficient sub-matrices, and data statistics are performed on at least two first quantization coefficient sub-matrices to obtain quantization statistical data. In this way, the quantization statistical data can be used to eliminate the dependency between at least two first quantization coefficient sub-matrices, and the quantization coefficients can be processed in parallel in units of the first quantization coefficient sub-matrices. Then, for each first quantization coefficient sub-matrix, the non-zero first quantization coefficient is adjusted to obtain a second quantization coefficient sub-matrix, the second quantization coefficient sub-matrix includes at least one second quantization coefficient, wherein the coefficient adjustment of at least two first quantization coefficient sub-matrices is performed in parallel. Then, according to the relationship between the second quantization coefficient sub-matrix and the first quantization coefficient sub-matrix and the first quantization coefficient matrix, the second quantization coefficient matrix is ​​obtained, and the second quantization coefficient matrix includes at least one second quantization coefficient. In summary, the technical solution provided by the present application can process quantization coefficients in parallel, improve the processing speed of hardware, and reduce the processing delay of hardware. BRIEF DESCRIPTION OF THE DRAWINGS

[0186] Figure 1 It is a block diagram of an encoder according to an exemplary embodiment.

[0187] Figure 2 The figure is a flow chart of a rate-distortion optimized quantization method according to an exemplary embodiment.

[0188] Figure 3 The figure is a flow chart of a rate-distortion optimized quantization method according to another exemplary embodiment.

[0189] Figure 4 The figure is a schematic diagram of scanning a first quantization coefficient matrix according to an exemplary embodiment.

[0190] Figure 5 The figure is a flow chart of a rate-distortion optimized quantization method according to another exemplary embodiment.

[0191] Figure 6 The figure is a flow chart of a rate-distortion optimized quantization method according to another exemplary embodiment.

[0192] Figure 7 The figure is a flow chart of a rate-distortion optimized quantization method according to another exemplary embodiment.

[0193] Figure 8 The figure is a flow chart of a rate-distortion optimized quantization method according to another exemplary embodiment.

[0194] Fig. 9 The figure is a flow chart of a rate-distortion optimized quantization method according to another exemplary embodiment.

[0195] Fig.10 The figure is a flow chart of a rate-distortion optimized quantization method according to another exemplary embodiment.

[0196] Fig.11 The figure is a block diagram of a rate-distortion optimized quantization device according to an exemplary embodiment.

[0197] Fig.12 It is a block diagram of an electronic device according to an exemplary embodiment. DETAILED DESCRIPTION

[0198] Unless otherwise defined, the technical terms or scientific terms used in this specification and claims shall have the usual meanings understood by persons with ordinary skills in the technical field to which the invention belongs. The specific embodiments of the present invention will be described below in conjunction with the accompanying drawings. It should be noted that in the specific description of these embodiments, in order to provide a concise description, it is impossible for this specification to provide a detailed description of all the features of the actual embodiments. Without departing from the spirit and scope of the present invention, those skilled in the art may modify and replace the embodiments of the present invention, and the resulting embodiments are also within the scope of protection of the present invention.

[0199] Before introducing the rate-distortion optimization quantization method provided by this application, the encoder and the position of the rate-distortion optimization quantization module in the encoder are first introduced. Figure 1 As shown, the encoder includes a transform module 11, a rate-distortion optimization quantization module 12 and an entropy coding module 13. The rate-distortion optimization quantization module 12 is located between the transform module 11 and the entropy coding module 13.

[0200] The encoder in this application is a video encoder. When a new video frame enters the encoder, the encoder usually divides the video frame into a series of non-overlapping square or rectangular blocks. The "block" here actually refers to a matrix. Given a target block, the encoder will try to find the best prediction block for it, and then subtract the prediction block from the target block to obtain a residual block.

[0201] The transform module 11 is configured to perform a frequency domain transform (generally a discrete cosine transform, but not limited to this) on the residual block. The output of the transform module 11 is a transform coefficient block (transform coefficient matrix). In most modern video compression standards (such as HEVC and AV1), the transform coefficient block is called a transform unit (TU).

[0202] The rate-distortion optimized quantization module 12 is used to perform rate-distortion optimized quantization on the transform coefficient matrix output by the transform module 11, and output the quantization coefficient matrix (hereinafter referred to as the second quantization coefficient matrix) to the entropy coding module 13. The rate-distortion optimized quantization module 12 may include a quantization module 121, a decomposition module 122, a statistics module 123, an adjustment module 124, and an acquisition module 125. The quantization module 121 is configured to quantize the transform coefficient matrix to obtain a first quantization coefficient matrix; wherein the transform coefficient matrix includes at least one transform coefficient, and the first quantization coefficient matrix includes at least one first quantization coefficient. The decomposition module 122 is configured to divide the first quantization coefficient matrix into at least two non-overlapping first quantization coefficient sub-matrices; the statistical module 123 is configured to perform data statistics on at least two first quantization coefficient sub-matrices to obtain quantitative statistical data; the quantitative statistical data is used to eliminate the dependency between at least two first quantization coefficient sub-matrices; the adjustment module 124 is configured to adjust the coefficients of the non-zero first quantization coefficients for each first quantization coefficient sub-matrix to obtain a second quantization coefficient sub-matrix; the second quantization coefficient sub-matrix includes at least one second quantization coefficient; the coefficient adjustment of at least two first quantization coefficient sub-matrices is performed in parallel; the acquisition module 125 is configured to obtain a second quantization coefficient matrix according to the second quantization coefficient sub-matrix and the relationship between the first quantization coefficient sub-matrix and the first quantization coefficient matrix, and the second quantization coefficient matrix includes at least one second quantization coefficient. Here, only a brief introduction is given to the rate-distortion optimization quantization module 12, and the rate-distortion optimization quantization module 12 will be introduced in detail below.

[0203] The entropy coding module 13 is configured to encode the quantization coefficient matrix output by the rate-distortion optimization quantization module 12, for example, CABAC (Context-Based Adaptive Binary Arithmetic Coding) coding method can be used for encoding, but is not limited thereto.

[0204] The above briefly introduces the encoder and the position of the rate-distortion optimization quantization module 12 in the encoder. The following is a detailed introduction to the rate-distortion optimization quantization module 12 and its functions.

[0205] Figure 2 is a flow chart of a rate-distortion optimization quantization method according to an exemplary embodiment. The rate-distortion optimization quantization method can be applied to an encoder. Figure 2 , the rate-distortion optimization quantization method may include the following steps:

[0206] Step 201, quantize the transform coefficient matrix to obtain a first quantization coefficient matrix; wherein the transform coefficient matrix includes at least one transform coefficient, and the first quantization coefficient matrix includes at least one first quantization coefficient.

[0207] In this embodiment, the transform coefficient matrix is ​​a transform coefficient matrix of multiple rows and columns composed of multiple transform coefficients. For example, the size of the transform coefficient matrix may be 32*32, but is not limited thereto.

[0208] In this embodiment, quantizing the transform coefficient matrix can be understood as quantizing each transform coefficient in the transform coefficient matrix. By quantizing a transform coefficient, a corresponding first quantization coefficient can be obtained.

[0209] In this embodiment, for each transform coefficient in the transform coefficient matrix, the transform coefficient may be quantized using a quantization offset parameter to obtain a first quantization coefficient. The first quantization coefficient may be calculated using the following formula:

[0210] QCoeff[cIdx][x][y]=sign[cIdx][x][y]×((|TCoeff[cIdx][x][y]|×quantizationScaler[cId x][x][y]+(1<<(quantizationShift[cIdx][x][y]-1)))>>quantizationShift[cIdx][x][y]); (2)

[0211] Among them, QCoeff[cIdx][x][y] is the first quantization coefficient, sign[cIdx][x][y] is the sign of the transform coefficient, TCoeff[cIdx][x][y] is the transform coefficient, quantizationScaler[cIdx][x][y] is the quantization scaling parameter, quantizationShift[cIdx][x][y] is the quantization offset parameter, cIdx is the Y, U, V component index, and x, y are the coordinates of the transform coefficient in the transform coefficient matrix.

[0212] In this embodiment, the encoder can adapt to the HEVC standard and the AV1 standard at the same time. In other embodiments, the encoder can adapt to the HEVC standard or the AV1 standard alone. In this article, in order to avoid content redundancy, only the solution in which the encoder can adapt to the HEVC standard and the AV1 standard at the same time is described in detail.

[0213] In this embodiment, the quantization offset parameter can be calculated using the following formula:

[0214]

[0215] Among them, QP1 is the first quantization parameter when the encoder adapts to the HEVC standard, transformShift is a parameter describing the internal transform shift of the transform coefficient matrix, numBitsDcQP is the number of bits required to represent the quantization index dcQP of the low-frequency transform coefficient, tuSize is the size of the transform coefficient matrix, bitDepth is the bit depth of the video, and numBitsAcQp is the number of bits required to represent the quantization index acQP of the high-frequency transform coefficient.

[0216] It can be seen from formula (3) that when the encoder adapts to the HEVC standard, the quantization offset parameter is calculated using the following formula:

[0217]

[0218] Among them, transformShift can be calculated using the following formula:

[0219] transformShift=15-bitDepth-log2(tuSize) (5)

[0220] When the encoder is adapted to the AV1 standard, the quantization offset parameter is calculated using the following formula:

[0221]

[0222] Among them, dcQP is calculated using the following formula:

[0223]

[0224] Among them, av1DcQLookUp is the first table, which is used to store the correspondence between the first quantization parameter and the quantization index of the low-frequency transform coefficient when the bit depth of the video is 8, and av1DcQLoopUp10 is the second table, which is used to store the correspondence between the first quantization parameter and the quantization index of the low-frequency transform coefficient when the bit depth of the video is 10.

[0225] It can be seen from formula (7) that when the bit depth of the video is 8, the first table can be queried according to the first quantization parameter (QP1) to obtain the value of dcQP. When the bit depth of the video is 10, the second table can be queried according to the first quantization parameter (QP1) to obtain the value of dcQP.

[0226] Among them, the first table is as follows:

[0227] Table 1. av1DcQLookUp

[0228]

[0229]

[0230] The second table is as follows:

[0231] Table 2. av1DcQLookUp10

[0232] QP QUR 0 4 1 9 2 10 3 13 4 15 5 17 6 20 … … 250 4394 251 4559 252 4737 253 4929 254 5130 255 5347

[0233] Among them, acQP is calculated using the following formula:

[0234]

[0235] Among them, av1AcQLookUp is the third table, which is used to store the correspondence between the first quantization parameter and the quantization index of the high-frequency transform coefficient when the bit depth of the video is 8, and av1AcQLoopUp10 is the fourth table, which is used to store the correspondence between the first quantization parameter and the quantization index of the high-frequency transform coefficient when the bit depth of the video is 10.

[0236] It can be seen from formula (8) that when the bit depth of the video is 8, the third table can be queried according to the first quantization parameter (QP1) to obtain the value of acQP. When the bit depth of the video is 10, the fourth table can be queried according to the first quantization parameter (QP1) to obtain the value of acQP.

[0237] Among them, the third table is as follows:

[0238] Table 3. av1AcQLookUp

[0239] QP QUR 0 4 1 8 2 9 3 10 4 11 5 12 6 13 … … 250 1660 251 1692 252 1725 253 1759 254 1793 255 1828

[0240] The fourth table is as follows:

[0241] Table 4. av1AcQLookUp10

[0242] QP QUR 0 4 1 9 2 11 3 13 4 16 5 18 6 21 … … 250 6640 251 6768 252 6900 253 7036 254 7172 255 7321

[0243] It should be noted that since AV1 and HEVC share a unified RDOQ design and implementation, and the rate estimation and distortion estimation of this RDOQ are implemented based on the transform quantization algorithm of HEVC, when the encoder is adapted to the AV1 standard, the quantization parameter used in equations (7) and (8) is the first quantization parameter when the encoder is adapted to the HEVC standard, rather than the second quantization parameter (QP2) when the encoder is adapted to the AV1 standard. Therefore, when the encoder is adapted to the AV1 standard, before calculating the quantization offset parameter, it is necessary to convert the second quantization parameter (QP2) when the encoder is adapted to the AV1 standard into the first quantization parameter (QP1). Among them, the following calculation formula can be used to convert QP2 to QP1:

[0244]

[0245] Among them, QP2 is the second quantization parameter, av1ToHevcQp is the fifth table, which is used to store the correspondence between the second quantization parameter and the first quantization parameter when the bit depth of the video is 8, and av1ToHevcQp10 is the sixth table, which is used to store the correspondence between the second quantization parameter and the first quantization parameter when the bit depth of the video is 10.

[0246] It can be seen from formula (9) that when the bit depth of the video is 8, the fifth table can be queried according to QP2 to obtain the value of QP1. When the bit depth of the video is 10, the sixth table can be queried according to QP2 to obtain the value of QP1.

[0247] Among them, the fifth table is as follows:

[0248] Table 5. av1ToHevcQp

[0249] QP2 QP1 0 0 1 2 2 5 3 6 4 7 5 8 6 8 … … 250 51 251 51 252 51 253 51 254 51 255 51

[0250] The sixth table is as follows:

[0251] Table 6. av1ToHevcQp10

[0252]

[0253]

[0254] quantizationScaler[cIdx][x][y] can be calculated using the following formula:

[0255]

[0256] Among them, hevcScalingList is the seventh table, which is used to store the correspondence between QP1%6 and the quantization scaling parameter when the encoder adapts to the HEVC standard, numBitsDcQP is the number of bits required to represent the quantization index dcQP of the low-frequency transform coefficient, and numBitsAcQp is the number of bits required to represent the quantization index acQP of the high-frequency transform coefficient.

[0257] It can be seen from formula (10) that when the encoder adapts to the HEVC standard, it can be calculated using the following formula:

[0258] quantizationScaler[cIdx][x][y]=hevcScalingList[QP1%6]; (11)

[0259] That is, when the encoder adapts to the HEVC standard, the seventh table is queried according to QP1%6 to obtain the corresponding quantization scaling parameters. The seventh table is as follows:

[0260] Table 7. hevcScalingList

[0261] QP1%6 quantizationScaler 0 26214 1 23302 2 20560 3 18396 4 16384 5 14564

[0262] When the encoder is adapted to the AV1 standard, quantizationScaler[cIdx][x][y] is calculated using the following formula:

[0263]

[0264] Step 202: divide the first quantization coefficient matrix into at least two non-overlapping first quantization coefficient sub-matrices.

[0265] In this embodiment, the size of the first quantization coefficient matrix is ​​32*32 as an example for illustration. When dividing the first quantization coefficient matrix, the size of the divided first quantization coefficient submatrix (CG) can be determined according to actual needs. Among them, the sizes of at least two first quantization coefficient submatrices obtained by division are the same. In this embodiment, the size of the first quantization coefficient submatrix is ​​4*4 as an example for illustration. Of course, in other embodiments, the size of the first quantization coefficient submatrix can also be 8*8 or 16*16.

[0266] Step 203: Perform data statistics on at least two first quantization coefficient sub-matrices to obtain quantization statistical data. The quantization statistical data is used to eliminate the dependency between the at least two first quantization coefficient sub-matrices.

[0267] In this embodiment, if Figure 3 As shown, step 203 may include the following steps:

[0268] Step 301 : For a first quantization coefficient sub-matrix of a first quantization coefficient matrix, at least two first quantization coefficient sub-matrices are scanned respectively according to a specified first scanning order.

[0269] Step 302: For each first quantization coefficient submatrix, the first quantization coefficients are scanned according to a specified second scanning order to obtain quantization statistics; the first scanning order is the same as the second scanning order.

[0270] like Figure 4 As shown, for the first quantization coefficient submatrices 411 of the first quantization coefficient matrix 41, all the first quantization coefficient submatrices 411 are scanned respectively according to the specified first scanning order S1. The first scanning order S1 is similar to the CABAC processing order and can also be called a zig-zag scanning order. Start from the first quantization coefficient submatrix 411 in the lower right corner, then move upward, then move downward along the diagonal line, and repeat this diagonal pattern until the upper left corner of the first quantization coefficient matrix 41 is reached.

[0271] like Figure 4 As shown, for each first quantization coefficient submatrix 411, the first quantization coefficient 4111 is scanned according to the specified second scanning order S2 to obtain quantization statistics; the first scanning order S1 is the same as the second scanning order S2. After the first quantization coefficient matrix is ​​scanned, quantization statistics can be obtained.

[0272] In this embodiment, before step 203, a corresponding array is created for at least one context model, and the context model is initialized to a predefined value; the array is used to store the state of the corresponding context model; each element of the array is an 8-bit integer. Among them, at least one context model is fixed during the rate-distortion optimization quantization process.

[0273] The at least one context model may include a first context model, a second context model, a third context model and a fourth context model. The array corresponding to the at least one context model includes a first array, a second array, a third array and a fourth array.

[0274] The first array is significantCoeffGroupCtx[2], which is used to store the conditional probability state of the first syntax element, and the first syntax element is significantCoeffCroup, which is used to indicate whether the current first quantization coefficient submatrix has a non-zero first quantization coefficient. The first syntax element is the first context model.

[0275] The second array is sigCoeffCtx

[44] , which is used to store the conditional probability state of the second syntax element, and the second syntax element is sigCoeffFlag, which is used to indicate whether the current first quantization coefficient is zero. The second syntax element is the second context model.

[0276] The third array is greaterOneCoeffCtx

[24] , which is used to store the conditional probability state of the third syntax element, and the third syntax element is absCoeffGreaterThanOneFlag, which is used to indicate whether the absolute value of the current first quantization coefficient is greater than 1. The third syntax element is the third context model.

[0277] The fourth array is levelAbsCoeffCtx[6], which is used to store the conditional probability state of the fourth syntax element, the fourth syntax element is levelAbsCoeff, which is the absolute value of the current first quantization coefficient. The fourth syntax element is the fourth context model.

[0278] In this embodiment, the quantization statistical data includes: the number of first quantization coefficients with an absolute value of 1 in the first quantization coefficient submatrix, the number of first quantization coefficients with an absolute value greater than 1 in the first quantization coefficient submatrix, the number of first quantization coefficients with an absolute value greater than 2 in the first quantization coefficient submatrix, the position of the first non-zero first quantization coefficient arranged in the first quantization coefficient matrix according to the first scanning order, the position of the first first quantization coefficient with an absolute value of 4 arranged in the second scanning order in the first quantization coefficient submatrix, the position of the first first quantization coefficient with an absolute value of 7 arranged in the second scanning order in the first quantization coefficient submatrix, the position of the first first quantization coefficient with an absolute value of 13 arranged in the second scanning order in the first quantization coefficient submatrix, and the position of the first first quantization coefficient with an absolute value of 25 arranged in the second scanning order in the first quantization coefficient submatrix.

[0279] The number of first quantization coefficients with an absolute value of 1 in the first quantization coefficient submatrix is ​​stored in a fifth array named cgOneCnt

[64] . The fifth array is initialized to an all-zero array before processing the transformation coefficient matrix or before data statistics. During the data statistics process, if the absolute value of the current first quantization coefficient is 1, the cgOneCnt of the corresponding first quantization coefficient submatrix is ​​incremented by 1. The number of first quantization coefficients with an absolute value of 1 in the first quantization coefficient submatrix is ​​calculated using the following formula:

[0280]

[0281] Among them, QCoeff[cIdx][x][y] is the first quantization coefficient, cIdx is the Y, U, and V component indexes, x and y are the coordinates of the first quantization coefficient in the first quantization coefficient matrix, and tuSize is the size of the transform coefficient matrix.

[0282] The number of first quantization coefficients with absolute values ​​greater than 1 in the first quantization coefficient submatrix is ​​stored in a sixth array named cgGreaterThanOneCnt

[64] . The sixth array is initialized to an all-zero array before processing the transform coefficient matrix or before data statistics. During the data statistics process, if the absolute value of the current first quantization coefficient is greater than 1, the cgGreaterThanOneCnt of the corresponding first quantization coefficient submatrix is ​​incremented by 1. The number of first quantization coefficients with absolute values ​​greater than 1 in the first quantization coefficient submatrix is ​​calculated using the following formula:

[0283]

[0284] Among them, QCoeff[cIdx][x][y] is the first quantization coefficient, cIdx is the Y, U, and V component indexes, x and y are the coordinates of the first quantization coefficient in the first quantization coefficient matrix, and tuSize is the size of the transform coefficient matrix.

[0285] The number of first quantization coefficients with absolute values ​​greater than 2 in the first quantization coefficient submatrix is ​​stored in a seventh array named cgGreaterThanTwoCnt

[64] . The seventh array is initialized to an all-zero array before processing the transform coefficient matrix or before data statistics. During the data statistics process, if the absolute value of the current first quantization coefficient is greater than 2, the cgGreaterThanTwoCnt of the corresponding first quantization coefficient submatrix is ​​incremented by 1. The number of first quantization coefficients with absolute values ​​greater than 2 in the first quantization coefficient submatrix is ​​calculated using the following formula:

[0286]

[0287] Among them, QCoeff[cIdx][x][y] is the first quantization coefficient, cIdx is the Y, U, and V component indexes, x and y are the coordinates of the first quantization coefficient in the first quantization coefficient matrix, and tuSize is the size of the transform coefficient matrix.

[0288] The position of the first quantized coefficient with an absolute value of 4 is stored in the eighth array named cgFirst4Loc

[64] [2]. All elements of the eighth array are initialized to -1 before processing the transform coefficient matrix or before data statistics. The ordinate of the position of the first quantized coefficient with an absolute value of 4 is stored in cgFirst4Loc

[64] [0], and the abscissa is stored in cgFirst4Loc

[64] [1]. If Coeff[cIdx][x][y] is the first coefficient with an absolute value of 4 in the first quantized coefficient submatrix, cgFirst4Loc is updated as follows:

[0289]

[0290]

[0291] Among them, cIdx is the Y, U, and V component indexes, x and y are the coordinates of the first coefficient with an absolute value of 4 in the first quantization coefficient matrix, tuSize is the size of the transform coefficient matrix, y1 is the vertical coordinate of the first quantization coefficient with an absolute value of 4 in the first quantization coefficient submatrix, and x1 is the horizontal coordinate of the first quantization coefficient with an absolute value of 4 in the first quantization coefficient submatrix.

[0292] The position of the first quantized coefficient with an absolute value of 7 is stored in the ninth array named cgFirst7Loc

[64] [2]. All elements of the ninth array are initialized to -1 before processing the transform coefficient matrix or before data statistics. The ordinate of the position of the first quantized coefficient with an absolute value of 7 is stored in cgFirst7Loc

[64] [0], and the abscissa is stored in cgFirst7Loc

[64] [1]. If Coeff[cIdx][x][y] is the first coefficient with an absolute value of 7 in the first quantized coefficient submatrix, cgFirst7Loc is updated as follows:

[0293]

[0294]

[0295] Among them, cIdx is the Y, U, and V component indexes, x and y are the coordinates of the first coefficient with an absolute value of 7 in the first quantization coefficient matrix, tuSize is the size of the transform coefficient matrix, y2 is the vertical coordinate of the first quantization coefficient with an absolute value of 7 in the first quantization coefficient submatrix, and x2 is the horizontal coordinate of the first quantization coefficient with an absolute value of 7 in the first quantization coefficient submatrix.

[0296] The position of the first quantized coefficient with an absolute value of 13 is stored in the tenth array named cgFirst13Loc

[64] [2]. All elements of the tenth array are initialized to -1 before processing the transform coefficient matrix or before data statistics. The ordinate of the position of the first quantized coefficient with an absolute value of 13 is stored in cgFirst13Loc

[64] [0], and the abscissa is stored in cgFirst13Loc

[64] [1]. If Coeff[cIdx][x][y] is the first coefficient with an absolute value of 13 in the first quantized coefficient submatrix, cgFirst13Loc is updated as follows:

[0297]

[0298]

[0299] Among them, cIdx is the Y, U, and V component indexes, x and y are the coordinates of the first coefficient with an absolute value of 13 in the first quantization coefficient matrix, tuSize is the size of the transform coefficient matrix, y3 is the vertical coordinate of the first quantization coefficient with an absolute value of 13 in the first quantization coefficient submatrix, and x3 is the horizontal coordinate of the first quantization coefficient with an absolute value of 13 in the first quantization coefficient submatrix.

[0300] The position of the first quantized coefficient with an absolute value of 25 is stored in the eleventh array named cgFirst25Loc

[64] [2]. All elements of the eleventh array are initialized to -1 before processing the transform coefficient matrix or before data statistics. The ordinate of the position of the first quantized coefficient with an absolute value of 25 is stored in cgFirst25Loc

[64] [0], and the abscissa is stored in cgFirst25Loc

[64] [1]. If Coeff[cIdx][x][y] is the first coefficient with an absolute value of 25 in the first quantized coefficient submatrix, cgFirst25Loc is updated as follows:

[0301]

[0302]

[0303] Among them, cIdx is the Y, U, and V component indexes, x and y are the coordinates of the first coefficient with an absolute value of 25 in the first quantization coefficient matrix, tuSize is the size of the transform coefficient matrix, y4 is the vertical coordinate of the first quantization coefficient with an absolute value of 25 in the first quantization coefficient submatrix, and x4 is the horizontal coordinate of the first quantization coefficient with an absolute value of 25 in the first quantization coefficient submatrix.

[0304] The position of the first non-zero first quantization coefficient in the first quantization coefficient matrix is ​​defined as firstSigCoeffX and firstSigCoeffY, wherein firstSigCoeffX is the horizontal coordinate of the first non-zero first quantization coefficient in the first quantization coefficient matrix, and firstSigCoeffY is the vertical coordinate of the first non-zero first quantization coefficient in the first quantization coefficient matrix.

[0305] In this embodiment, each element of each array is an 8-bit integer. In this application, integer operations are adopted to propose an RDOQ module mainly based on 32-bit integer calculations, thereby significantly reducing hardware area and processing delay.

[0306] It should be noted that traditional RDOQ requires a large number of floating-point operations and a large number of multiplications to calculate the encoding cost. This may increase the hardware complexity exponentially. Floating-point operations will greatly increase the hardware overhead because the circuit based on floating-point operations requires a larger area and requires more cycles to run.

[0307] Step 204, for each first quantization coefficient submatrix, adjust the non-zero first quantization coefficient to obtain a second quantization coefficient submatrix; the second quantization coefficient submatrix includes at least one second quantization coefficient; the coefficient adjustment of at least two first quantization coefficient submatrices is performed in parallel.

[0308] In this embodiment, if Figure 5 As shown, step 204 may include the following steps:

[0309] Step 501 : For each non-zero first quantized coefficient, calculate a first coding cost for coefficient adjustment according to at least two coefficient adjustment schemes.

[0310] Step 502: For each coefficient adjustment scheme, a second coding cost is obtained according to the sum of all first coding costs; the second coding cost is the coding cost of coefficient adjustment of the first quantized coefficient submatrix.

[0311] Step 503 : determining a target coefficient adjustment scheme from at least two coefficient adjustment schemes, wherein the second coding cost of the target coefficient adjustment scheme is the minimum coding cost among the second coding costs of the at least two coefficient adjustment schemes.

[0312] Step 504: perform coefficient adjustment on the non-zero first quantization coefficients in the first quantization coefficient submatrix according to the target coefficient adjustment scheme to obtain a second quantization coefficient submatrix.

[0313] In this embodiment, the at least two coefficient adjustment schemes may include three coefficient adjustment schemes: a first coefficient adjustment scheme, a second coefficient adjustment scheme, and a third coefficient adjustment scheme. The three coefficient adjustment schemes have different adjustment amplitudes for the non-zero first quantization coefficient. For example, the first coefficient adjustment scheme may be to set the first quantization coefficient to zero, the second coefficient adjustment scheme may be to keep the sign of the first quantization coefficient unchanged, and to subtract 1 from the absolute value, and the third coefficient adjustment scheme may be to keep the sign of the first quantization coefficient unchanged, and to subtract 2 from the absolute value, but is not limited thereto.

[0314] In this embodiment, the non-zero first quantization coefficient is adjusted according to each coefficient adjustment scheme to generate a corresponding first coding cost. For each first quantization coefficient submatrix, for each non-zero first quantization coefficient, the first coding cost of coefficient adjustment according to at least two coefficient adjustment schemes is calculated. For example, for each non-zero first quantization coefficient, the first coding cost of coefficient adjustment according to the first coefficient adjustment scheme, the second coefficient adjustment scheme, and the third coefficient adjustment scheme is calculated, and three first coding costs can be obtained.

[0315] Then, for each coefficient adjustment scheme, a second coding cost is obtained according to the sum of all first coding costs; the second coding cost is the coding cost of the first quantized coefficient submatrix for coefficient adjustment. For example, for each coefficient adjustment scheme in the first coefficient adjustment scheme, the second coefficient adjustment scheme, and the third coefficient adjustment scheme, a corresponding second coding cost can be obtained, and a total of three second coding costs are obtained.

[0316] Then, the minimum coding cost is selected from the second coding costs of at least two coefficient adjustment schemes, and then the coefficient adjustment scheme corresponding to the minimum coding cost is used as the target coefficient adjustment scheme, so as to determine the target coefficient adjustment scheme from the at least two coefficient adjustment schemes. For example, if the second coding cost corresponding to the first coefficient adjustment scheme is the minimum among the three second coding costs, the first coefficient adjustment scheme is the target coefficient adjustment scheme.

[0317] Then, the non-zero first quantization coefficients in the first quantization coefficient submatrix are adjusted according to the target coefficient adjustment scheme to obtain a second quantization coefficient submatrix.

[0318] In this embodiment, the first encoding cost is calculated using the following formula:

[0319] cost1[cIdx][x′][y′]=distortion[cIdx][x′][y′]+rate[cIdx][x′][y′] (24)

[0320] Wherein, cost1[cIdx][x'][y'] is the first coding cost, distortion[cIdx][x'][y'] is the error in the pixel domain, rate[cIdx][x'][y'] is the coding bit rate, cIdx is the Y, U, V component index, and x', y' are the coordinates of the first quantization coefficient in the first quantization coefficient submatrix.

[0321] It should be noted that the above formula (24) is a general calculation formula for calculating all coding costs in this article.

[0322] Among them, the error in the pixel domain can be calculated using the following formula:

[0323] distortion[cIdx][x′][y′]=(mErr[cIdx][x′][y′]>>(2×transformShift+1))×mErr[cIdx][x′][y′] (25)

[0324] Among them, mErr[cIdx][x'][y'] is the inverse restoration value of the quantization error, and transformShift is a parameter describing the internal transform shift of the transform coefficient matrix.

[0325] When the bit depth of the video is 8, mErr[cIdx][x'][y'] can be calculated using the following formula:

[0326]

[0327] It can be seen from formula (26) that when the encoder adapts to the HEVC standard and the bit depth of the video is 8, the reverse restoration value of the quantization error is calculated using the following formula:

[0328] mErr[cIdx][x′][y′]=(err[cIdx][x′][y′]>>12)×hevcScler[QP1%6] (27)

[0329] Among them, err[cIdx][x'][y'] is the quantization error, hevcScaler is the eighth table, which is used to store the correspondence between QP1%6 and the amplification factor. The corresponding amplification factor (Scaler) can be obtained by querying the eighth table according to QP1%6, and QP1 is the first quantization parameter when the encoder adapts to the HEVC standard.

[0330] The distortion in the pixel domain can be obtained by multiplying the quantization error by an amplification factor. For HEVC and AV1 encoders, since their transform bases are different, the amplification factors are also different.

[0331] Among them, the eighth table is as follows:

[0332] Table 8. hevcScaler

[0333] QP1%6 Scaler 0 40 1 45 2 51 3 57 4 64 5 72

[0334] When the encoder is adapted to the AV1 standard and the bit depth of the video is 8, the inverse restoration value of the quantization error is calculated using the following formula:

[0335]

[0336] Among them, err[cIdx][x'][y'] is the quantization error, numBitsDcQP is the number of bits required to represent the quantization index dcQP of the low-frequency transform coefficient, and numBitsAcQp is the number of bits required to represent the quantization index acQP of the high-frequency transform coefficient.

[0337] When the bit depth of the video is 10, the reverse restoration value of the quantization error is obtained by the following method: first, the reverse restoration value of the quantization error when the bit depth of the video is 8 is obtained, and the reverse restoration value of the quantization error when the bit depth of the video is 8 is shifted right by two bits to obtain the reverse restoration value of the quantization error when the bit depth of the video is 10. Among them, the reverse restoration value of the quantization error when the bit depth of the video is 8 is shifted right by two bits to obtain the reverse restoration value of the quantization error when the bit depth of the video is 10. The calculation formula is as follows:

[0338] mErr[cIdx][x′][y′]>>=(bitDepth-8) (29)

[0339] Among them, the quantization error is calculated using the following formula:

[0340] err[cIdx][x′][y′]=||TCoeff[cIdx][x′][y′]|

[0341] Among them, TCoeff[cIdx][x'][y'] is the transformation coefficient, quantizationScaler[cIdx][x'][y'] is the quantization scaling parameter, QCoeff[cIdx][x'][y'] is the first quantization coefficient, and quantizationShift[cIdx][x'][y'] is the quantization offset parameter.

[0342] Among them, |TCoeff[cIdx][x'][y']|×quantizationScaler[cIdx][x'][y'] is to multiply the transform coefficient by a quantization scaling parameter to approximate the original quantized input, (|QCoeff[cIdx][x'][y']|<<quantizationShift[cIdx][x'][y']) is the inverse quantized value, and subtracting them is the quantization error. Since the quantization error is amplified by the transform, it is necessary to reversely restore the quantization error and calculate the reverse restoration value of the quantization error mentioned above.

[0343] Since the quantization error is based on the distortion in the frequency domain, the encoder needs to know the distortion in the pixel domain to calculate the final coding cost, so the quantization error in the frequency domain is converted into the error in the pixel domain according to the above formula (25).

[0344] The encoding bit rate is calculated using the following formula:

[0345] rate[cIdx][x′][y′]=sigCoeffFlagRate[cIdx][x′][y′]+coeffAbsLevelRate[cIdx][x′][y′] (31)

[0346] Among them, sigCoeffFlagRate[cIdx][x'][y'] is the first rate estimate of the second syntax element, the second syntax element is sigCoeffFlag, which is used to indicate whether the current first quantization coefficient is zero, and coeffAbsLevelRate[cIdx][x'][y'] is the second rate estimate of the syntax element that encodes the absolute value of the non-zero first quantization coefficient.

[0347] Among them, sigCoeffFlagRate[cIdx][x'][y'] can be calculated using the following formula:

[0348]

[0349] Among them, rateEstTab is the ninth table, which is used to store the correspondence between QP1%3, the conditional probability state of the syntax element and the bit rate estimation, QP1 is the first quantization parameter when the encoder adapts to the HEVC standard, sigCoeffFlagTabIdx is the current conditional probability state of the second syntax element, and bitDepth is the bit depth of the video.

[0350] It can be seen from formula (32) that when the encoder adapts to HEVC, the first bit rate estimation is calculated using the following calculation formula:

[0351]

[0352] The bit rate estimate obtained by querying the ninth table according to QP1%3 and sigCoeffFlagTabIdx is further scaled according to QP1 and bitDepth to obtain the first bit rate estimate.

[0353] Among them, the ninth form is as follows:

[0354] Table 9. rateEstTab

[0355]

[0356]

[0357] In the ninth table, Context index is the conditional probability state of the syntax element, and Rate estimation is the bit rate estimation.

[0358] Since both HEVC and AV1 use an entropy encoder based on arithmetic coding, the present application designs a general rate estimation table as shown in Table 9. Table 9 requires two inputs, QP1 and the probability state of the syntax element. According to the input, the rate cost required to encode the syntax element is queried from Table 9. For example, the Context index can be the conditional probability state of the second syntax element or the conditional probability state of the third syntax element. That is, the corresponding rate estimate can be obtained by querying the ninth table according to the conditional probability state of QP1%3 and the second syntax element, or the corresponding rate estimate can be obtained by querying the ninth table according to the conditional probability state of QP1%3 and the third syntax element.

[0359] sigCoeffFlagTabIdx is calculated using the following formula:

[0360]

[0361] Among them, sigCoeffCtx is the second context model, which is used to store the conditional probability state of the second syntax element, and sigCoeffCtxIdx is comprehensively determined by the values ​​of the first syntax elements of the two adjacent first quantization coefficient submatrices at the top of the current first quantization coefficient submatrix and the two adjacent first quantization coefficient submatrices on the left.

[0362] When the encoder is adapted to the AV1 standard, sigCoeffFlagRate[cIdx][x'][y'] is calculated using the following formula:

[0363]

[0364] In order to encode the non-zero first quantization coefficient, the encoder introduces three syntax elements: the third syntax element, the fifth syntax element and the sixth syntax element. The third syntax element is absCoeffGreaterThanOneFlag, which is used to indicate whether the absolute value of the current first quantization coefficient is greater than 1, the fifth syntax element is absCoeffGreaterThanTwo, which is used to indicate whether the absolute value of the current first quantization coefficient is greater than 2, and the sixth syntax element is absCeoffMinusTwo, which is used to indicate the absolute value of the current first quantization coefficient minus 2.

[0365] coeffAbsLevelRate[cIdx][x'][y'] is calculated using the following formula:

[0366] coeffAbsLevelRate[cIdx][x′][y′]=absCoeffGreaterThanOneFlagRate[cIdx][x′][y′]+absCoeffGreaterThanTwoFlagRate[cIdx][x′][y′]+absCoeffMinusTwoRate[cIdx][x′][y′]; (36)

[0367] Among them, absCoeffGreaterThanOneFlagRate[cIdx][x'][y'] is the third rate estimate of the third syntax element, absCoeffGreaterThanTwoFlagRate[cIdx][x'][y'] is the fourth rate estimate of the fifth syntax element, and absCoeffMinusTwoRate[cIdx][x'][y'] is the fifth rate estimate of the sixth syntax element.

[0368] Among them, absCoeffGreaterThanOneFlagRate[cIdx][x'][y'] is calculated using the following formula:

[0369]

[0370] Among them, rateEstTab is the ninth table, greaterThanOneTabIdx is the current conditional probability state of the third syntax element, which is determined by the statistical data collected in cgGreaterThanOneCnt

[64] , cIdx and the position of CG in TU.

[0371] It can be seen from formula (37) that when |QCoeff[cIdx][x'][y']|<1, the third code rate estimate is equal to 0; QCoeff[cIdx][x'][y'] is the first quantization coefficient.

[0372] When |QCoeff[cIdx][x'][y']|≥1 and the encoder is adapted to the HEVC standard, the third bit rate estimate is calculated using the following formula:

[0373]

[0374] When |QCoeff[cIdx][x'][y']|≥1 and the encoder is adapted to the AV1 standard, the third bitrate estimate is calculated using the following formula:

[0375]

[0376] Among them, QP1 is the first quantization parameter when the encoder adapts to the HEVC standard, which is converted from the second quantization parameter when the encoder adapts to the AV1 standard, and greaterThanOneTabIdx is the current conditional probability state of the third syntax element.

[0377] absCoeffGreaterThanTwoFlagRate[cIdx][x'][y'] is calculated using the following formula:

[0378]

[0379] Among them, greaterThanTwoTabIdx is the current conditional probability state of the fifth syntax element.

[0380] It can be seen from formula (40) that when |QCoeff[cIdx][x'][y']|<2, the fourth code rate estimate is equal to 0.

[0381] When |QCoeff[cIdx][x'][y']|≥2 and the encoder is adapted to the HEVC standard, the fourth bit rate estimation is calculated using the following formula:

[0382]

[0383] When |QCoeff[cIdx][x'][y']|≥2 and the encoder is adapted to the AV1 standard, the fourth bitrate estimate is calculated using the following formula:

[0384]

[0385]

[0386] Among them, QP1 is the first quantization parameter when the encoder adapts to the HEVC standard, which is converted from the second quantization parameter when the encoder adapts to the AV1 standard.

[0387] absCoeffMinusTwoRate[cIdx][x'][y'] is calculated using the following formula:

[0388]

[0389] Among them, GolombCodeLength is the code length required for encoding the sixth syntax element using the Golomb-Rice code, which is determined by the absolute value of the first quantization coefficient. eqProbRateEstTab is the tenth table, which is used to store the correspondence between the first quantization parameter and the bit rate estimation when the conditional probability of the sixth syntax element is uniformly distributed.

[0390] It can be seen from formula (43) that when |QCoeff[cIdx][x'][y']|<3, the fifth code rate estimate is equal to 0.

[0391] When |QCoeff[cIdx][x'][y']|≥3 and the encoder conforms to the HEVC standard, absCoeffMinusTwoRate[cIdx][x'][y'] is calculated using the following formula:

[0392] absCoeffMinusTwoRate[cIdx][x′][y′]=(GolombCodeLength×eqProbRateEstTab[QP1-6*(bitDepth-8)]) (44)

[0393] Among them, GolombCodeLength is the code length required for encoding the sixth syntax element using the Golomb-Rice code, eqProbRateEstTab is the tenth table, which is used to store the correspondence between the index value and the bit rate estimation when the conditional probability of the sixth syntax element is uniformly distributed, and the index value is determined according to the first quantization parameter and the bit depth, and the first quantization parameter is the quantization parameter when the encoder adapts to the HEVC standard.

[0394] When |QCoeff[cIdx][x'][y']|≥3 and the encoder is compliant with the AV1 standard, absCoeffMinusTwoRate[cIdx][x'][y'] is calculated using the following formula:

[0395] absCoeffMinusTwoRate[cIdx][x′][y′]=GolombCodeLength×(eqProbRateEstTab[QP1]-(eqProbRateEstTab[QP1]>>2)) (45)

[0396] Among them, GolombCodeLength is the code length required for encoding the sixth syntax element using the Golomb-Rice code, eqProbRateEstTab is the tenth table, which is used to store the correspondence between the first quantization parameter and the bit rate estimation when the conditional probability of the sixth syntax element is uniformly distributed, the first quantization parameter is converted from the second quantization parameter, the first quantization parameter is the quantization parameter when the encoder adapts to the HEVC standard, and the second quantization parameter is the quantization parameter when the encoder adapts to the AV1 standard.

[0397] Among them, the tenth table is as follows:

[0398] Table 10.eqProbRateEstTab

[0399]

[0400]

[0401] Among them, index is the index value and Value is the bit rate estimate.

[0402] Step 205: Obtain a second quantization coefficient matrix according to the second quantization coefficient submatrix and the relationship between the first quantization coefficient submatrix and the first quantization coefficient matrix, where the second quantization coefficient matrix includes at least one second quantization coefficient.

[0403] In this embodiment, the coefficients of at least two first quantization coefficient sub-matrices are adjusted to obtain corresponding at least two second quantization coefficient sub-matrices, and a second quantization coefficient matrix can be generated based on the relationship between the at least two second quantization coefficient sub-matrices and the at least two first quantization coefficient sub-matrices and the first quantization coefficient matrix.

[0404] In the present application, after the transform coefficient matrix is ​​quantized to obtain the first quantization coefficient matrix, the first quantization coefficient matrix is ​​divided into at least two non-overlapping first quantization coefficient sub-matrices, and data statistics are performed on at least two first quantization coefficient sub-matrices to obtain quantization statistical data. In this way, the quantization statistical data can be used to eliminate the dependency between at least two first quantization coefficient sub-matrices, and the quantization coefficients can be processed in parallel in units of the first quantization coefficient sub-matrices. Then, for each first quantization coefficient sub-matrix, the coefficient adjustment of the non-zero first quantization coefficient is performed to obtain a second quantization coefficient sub-matrix, and the coefficient adjustment of at least two first quantization coefficient sub-matrices is performed in parallel. Then, according to the relationship between the second quantization coefficient sub-matrix and the first quantization coefficient sub-matrix and the first quantization coefficient matrix, the second quantization coefficient matrix is ​​obtained. In summary, the technical solution provided by the present application can process quantization coefficients in parallel, improve the processing speed of hardware, and reduce the processing delay of hardware.

[0405] In the present application, integer operations are used instead of floating-point operations, which can reduce the complexity of hardware implementation and reduce the area of ​​the rate-distortion optimization quantization module 12.

[0406] In the present application, the rate-distortion optimization quantization module 12 is a universal rate-distortion optimization quantization module 12. For the HEVC standard and the AV1 standard, only some parameter values ​​are different, but the main hardware modules can be universal, and can adapt to both the H.265 / HEVC and AV1 standards, and share hardware resources as much as possible. Therefore, the technical solution provided by the present application can reduce the area of ​​the rate-distortion optimization quantization module 12.

[0407] It should be noted that H.265 / HEVC and AV1 are two different video compression standards. Although they share most of the top-level design, the specific implementation of each module is different. Traditionally, a dedicated RDOQ module is designed for the H.265 / HEVC encoder to adapt to the quantization and encoding strategies unique to H.265 / HEVC. And another RDOQ module is designed for the AV1 encoder to adapt to the quantization and encoding strategies of AV1. These two different RDOQ modules may increase the circuit area and cannot share resources between them.

[0408] Another exemplary embodiment of the present application further provides a rate-distortion optimization quantization method. This embodiment provides another implementation of the above step 204. Figure 6 As shown, in this embodiment, step 204 may include the following steps:

[0409] Step 601 : for each non-zero first quantized coefficient, if the first quantized coefficient is located after the first non-zero first quantized coefficient in the first scanning order, calculate a third encoding cost for setting the first quantized coefficient to zero.

[0410] In this embodiment, the third encoding cost is calculated using the following formula:

[0411] zeroOutCost[cIdx][x′][y′]=distortion[cIdx][x′][y′] (46)

[0412] Wherein, distortion[cIdx][x'][y'] is the error in the pixel domain. Under the condition that QCoeff[cIdx][x'][y']=0, the above formula (25) can be used to calculate distortion[cIdx][x'][y'].

[0413] Step 602: fine-tune the first quantization coefficient to obtain a corresponding second quantization coefficient, and calculate a fourth encoding cost for fine-tuning the first quantization coefficient.

[0414] In this embodiment, fine-tuning the first quantization coefficient may be to keep the sign of the first quantization coefficient unchanged and reduce the absolute value by 1, or to keep the sign of the first quantization coefficient unchanged and reduce the absolute value by 2.

[0415] In this embodiment, the calculation method of the fourth coding cost is the same as that of the first coding cost, so the fourth coding cost can be calculated using the above formula (24).

[0416] Step 603, obtain the sum of all third coding costs to obtain a fifth coding cost; the fifth coding cost is the coding cost of returning the first quantization coefficient submatrix to zero.

[0417] In this embodiment, for each CG, the following calculation formula is used to obtain the sum of all third coding costs to obtain the fifth coding cost:

[0418]

[0419] Among them, cgCost0 is the fifth coding cost, zeroOutCost[cIdx][x'][y'] is the third coding cost, cIdx is the Y, U, V component index, x', y' are the coordinates of the first quantization coefficient in the first quantization coefficient submatrix, and CGSize is the size of the first quantization coefficient submatrix.

[0420] Step 604, obtaining the sum of all fourth coding costs to obtain a sixth coding cost; the sixth coding cost is the coding cost of fine-tuning the coefficients of the first quantization coefficient submatrix.

[0421] In this embodiment, for each CG, the following calculation formula is used to obtain the sum of all fourth coding costs to obtain the sixth coding cost:

[0422]

[0423] Among them, cgCost1 is the sixth coding cost, and tweakedCoeffCost[cIdx][x'][y'] is the fourth coding cost.

[0424] Step 605: If the fifth coding cost is less than the sixth coding cost, the first quantization coefficient sub-matrix is ​​set to zero to obtain a second quantization coefficient sub-matrix.

[0425] Step 606: If the sixth coding cost is less than the fifth coding cost, obtain a second quantization coefficient sub-matrix according to the second quantization coefficient.

[0426] In this embodiment, for each CG, if the coding cost of setting the first quantization coefficient submatrix to zero is small, the first quantization coefficient submatrix is ​​set to zero, and if the coding cost of the first quantization coefficient submatrix is ​​small when fine-tuning the first quantization coefficient, the first quantization coefficient is fine-tuned to obtain the second quantization coefficient submatrix. In this way, coefficient adjustment can be achieved with the minimum coding cost.

[0427] Another exemplary embodiment of the present application further provides a rate-distortion optimization quantization method. This embodiment provides another implementation of the above step 602. Figure 7 As shown, in this embodiment, step 602 may include the following steps:

[0428] Step 701: adjust a first quantization coefficient to a first candidate quantization coefficient, and calculate a first candidate coding cost of adjusting the first quantization coefficient, wherein the first candidate quantization coefficient is 0.

[0429] Step 702, if the absolute value of the first quantization coefficient is greater than 1, adjust the first quantization coefficient to a second candidate quantization coefficient, and calculate the second candidate encoding cost of adjusting the first quantization coefficient, wherein the sign of the second candidate quantization coefficient is the same as the sign of the first quantization coefficient, and the absolute value of the second candidate quantization coefficient is equal to the absolute value of the first quantization coefficient minus 1.

[0430] Step 703, adjust the first quantization coefficient to a third candidate quantization coefficient, and calculate the third candidate coding cost of adjusting the first quantization coefficient, wherein the third candidate quantization coefficient is the first quantization coefficient. That is, calculate the third candidate coding cost of the first quantization coefficient, wherein no adjustment is made to the first quantization coefficient.

[0431] Step 704 , selecting the smallest coding cost among the first candidate coding cost, the second candidate coding cost and the third candidate coding cost as the fourth coding cost.

[0432] Step 705: The quantization coefficient corresponding to the smallest coding cost among the first candidate coding cost, the second candidate coding cost and the third candidate coding cost is the second quantization coefficient.

[0433] In this embodiment, for a non-zero first quantization coefficient, the rate-distortion optimization quantization module attempts to set the first quantization coefficient to zero, or reduce its absolute value by 1 or 2 to reduce the encoding bit rate. Therefore, there are three candidate quantization coefficients: a first candidate quantization coefficient, a second candidate quantization coefficient, and a third candidate quantization coefficient. Among them, the first candidate quantization coefficient is 0, the sign of the second candidate quantization coefficient is the same as the sign of the first quantization coefficient, the absolute value of the second candidate quantization coefficient is equal to the absolute value of the first quantization coefficient minus 1, the sign of the third candidate quantization coefficient is the same as the sign of the first quantization coefficient, and the absolute value of the third candidate quantization coefficient is equal to the absolute value of the first quantization coefficient minus 2.

[0434] In this embodiment, first, the first quantization coefficient is set to zero, and the first candidate coding cost for adjusting the first quantization coefficient is calculated. Then, if the absolute value of the first quantization coefficient is greater than 1, the first quantization coefficient is adjusted to the second candidate quantization coefficient, and the second candidate coding cost for adjusting the first quantization coefficient is calculated. If the absolute value of the first quantization coefficient is greater than 2, the first quantization coefficient is adjusted to the third candidate quantization coefficient, and the third candidate coding cost for adjusting the first quantization coefficient is calculated. Then, the smallest coding cost among the first candidate coding cost, the second candidate coding cost and the third candidate coding cost is selected as the fourth coding cost, wherein the fourth coding cost is the coding cost for fine-tuning the first quantization coefficient. Then, the quantization coefficient corresponding to the smallest coding cost among the first candidate coding cost, the second candidate coding cost and the third candidate coding cost is selected as the second quantization coefficient.

[0435] The fourth coding cost is calculated using the following formula:

[0436] tweakedCoeffCost[cIdx][x′][y′]=min(cost0[cIdx][x′][y′],cost1[cIdx][x′][y′],cost2[cIdx][x′][y′])) (49)

[0437] Among them, tweakedCoeffCost[cIdx][x'][y'] is the fourth coding cost.

[0438] The second quantization coefficient is calculated using the following formula:

[0439]

[0440] Among them, newQCoeff[cIdx][x'][y'] is the second quantization coefficient, sign[cIdx][x'][y'] is the sign of the first quantization coefficient, cost0[cIdx][x'][y'] is the first candidate coding cost, cost1[cIdx][x'][y'] is the second candidate coding cost, and cost2[cIdx][x'][y'] is the third candidate coding cost.

[0441] Among them, sign[cIdx][x'][y']×(|QCoeff[cIdx][x'][y']|-1) is the second candidate quantization coefficient, and sign[cIdx][x'][y']×(|QCoeff[cIdx][x'][y']|-2) is the third candidate quantization coefficient.

[0442] Another exemplary embodiment of the present application also provides a rate-distortion optimization quantization method. Figure 8 As shown, the rate-distortion optimization quantization method may include the following steps:

[0443] Step 801, initializing RDOQ parameters. The RDOQ parameters here are RDOQ global parameters.

[0444] When the encoder is capable of adapting to the HEVC standard, the RDOQ global parameters include: QP1, bitDepth, transformShift, quantizationShift, quantizationScaler, and QCoeff[cIdx][x][y].

[0445] When the encoder is capable of adapting to the AV1 standard, the RDOQ global parameters include QP2, dcQP, and acQP in addition to the above global parameters.

[0446] Step 802: Initialize a context model for each grammatical element.

[0447] In this embodiment, the first context model, the second context model, the third context model and the fourth context model corresponding to the first syntax element, the second syntax element, the third syntax element and the fourth syntax element are initialized.

[0448] Step 803, quantize the transform coefficients.

[0449] In this embodiment, each transform coefficient in the transform coefficient matrix is ​​quantized. This step is similar to the above step 201 and will not be described in detail here.

[0450] Step 804: Update and quantize various statistical indicators of the current TU.

[0451] In this step, the TU is divided into at least two non-overlapping CGs, data statistics are performed on at least two CGs, and various statistical indicators of the current TU are updated. This step is similar to the above steps 202 to 203 and will not be repeated here.

[0452] The various statistical indicators here include the number of first quantization coefficients with absolute values ​​of 1 in the above-mentioned first quantization coefficient submatrix, the number of first quantization coefficients with absolute values ​​greater than 1 in the first quantization coefficient submatrix, the number of first quantization coefficients with absolute values ​​greater than 2 in the first quantization coefficient submatrix, the position of the first non-zero first quantization coefficient arranged in the first scanning order in the first quantization coefficient matrix, the position of the first first quantization coefficient with an absolute value of 4 arranged in the second scanning order in the first quantization coefficient submatrix, the position of the first first quantization coefficient with an absolute value of 7 arranged in the second scanning order in the first quantization coefficient submatrix, the position of the first first quantization coefficient with an absolute value of 13 arranged in the second scanning order in the first quantization coefficient submatrix, and the position of the first first quantization coefficient with an absolute value of 25 arranged in the second scanning order in the first quantization coefficient submatrix.

[0453] Step 805, obtain a CG of the current TU.

[0454] In this embodiment, each CG of the TU may be identified to distinguish each CG. The rate-distortion optimization quantization module 12 may include multiple adjustment modules 124, and the multiple adjustment modules 124 may obtain a CG of the TU in parallel to process the CGs in parallel.

[0455] Step 806, fine-tune each non-zero coefficient of CG.

[0456] In this embodiment, each adjustment module 124 fine-tunes each non-zero first quantization coefficient of the corresponding CG. This step is similar to the above-mentioned step 204 and will not be repeated here.

[0457] Step 807, if necessary, force CG to zero.

[0458] In this embodiment, the adjustment module 124 determines whether the current CG meets the conditions for forced zeroing, and if so, forces the CG to be set to zero.

[0459] Step 808, determine whether the current CG is the last CG of the current TU.

[0460] In this embodiment, the adjustment module 124 determines whether the current CG is the last CG of the current TU. If not, step 805 is executed to obtain the next CG. If yes, step 809 is executed to end the process.

[0461] Step 809, end.

[0462] In the present application, after quantizing the TU to obtain the first quantization coefficient matrix, the first quantization coefficient matrix is ​​divided into at least two non-overlapping CGs, and data statistics are performed on at least two CGs to obtain quantization statistical data. In this way, the quantization statistical data can be used to eliminate the dependency between at least two CGs, and the quantization coefficients can be processed in parallel in units of CGs. Then, for each CG, the coefficient of the non-zero first quantization coefficient is adjusted to obtain a second quantization coefficient sub-matrix, and the coefficient adjustment of at least two CGs is performed in parallel. Then, based on the second quantization coefficient sub-matrix and the relationship between the CG and the first quantization coefficient matrix, the second quantization coefficient matrix is ​​obtained. In summary, the technical solution provided by the present application can process quantization coefficients in parallel, improve the processing speed of hardware, and reduce the processing delay of hardware.

[0463] Another exemplary embodiment of the present application also provides a rate-distortion optimization quantization method. In this embodiment, a processing flow of the CG layer is provided. At the same time, it is also a specific implementation of the above step 204. Fig. 9 As shown, the rate-distortion optimization quantization method may include the following steps:

[0464] Step 901, input CG.

[0465] In this step, a CG of TU is input to the adjustment module 124.

[0466] Step 902, determine whether the current first quantization coefficient is the last first quantization coefficient of the current CG.

[0467] In this step, it is determined whether the current first quantization coefficient is the last first quantization coefficient of the current CG scanned in the second scanning order. If yes, step 903 is executed; if not, step 907 is executed.

[0468] Step 903: determine whether the current first quantization coefficient is before the first non-zero first quantization coefficient in the first scanning order.

[0469] In this step, it is determined whether the current first quantization coefficient is before the first non-zero first quantization coefficient in the first scanning order, if yes, step 902 is executed, if no, step 904 is executed. That is, when the current first quantization coefficient is after the first non-zero first quantization coefficient in the first scanning order, step 904 is executed.

[0470] Step 904: Calculate the coding cost of forcibly setting the current first quantized coefficient to zero.

[0471] In this step, for each first quantization coefficient submatrix, the coding cost of forcing the current first quantization coefficient to zero is calculated to obtain the third coding cost, and the sum of all third coding costs is obtained to obtain the fifth coding cost; the fifth coding cost is the coding cost of returning the first quantization coefficient submatrix to zero.

[0472] Step 905 , fine-tune the non-zero first quantization coefficient and calculate the encoding cost.

[0473] In this step, for each first quantization coefficient submatrix, the non-zero first quantization coefficient is fine-tuned and the coding cost is calculated to obtain the second quantization coefficient and the fourth coding cost, and the sum of all fourth coding costs is obtained to obtain the sixth coding cost; the sixth coding cost is the coding cost for fine-tuning the coefficients of the first quantization coefficient submatrix.

[0474] Step 906: Update the parameters of the Golomb-Rice code.

[0475] In this step, the parameters of the Golomb-Rice code are defaulted to 0. If the current first quantization coefficient is the first coefficient with an absolute value of 4 in the first quantization coefficient submatrix, the parameters of the Golomb-Rice code are updated to 1; if the current first quantization coefficient is the first coefficient with an absolute value of 7 in the first quantization coefficient submatrix, the parameters of the Golomb-Rice code are updated to 2; if the current first quantization coefficient is the first coefficient with an absolute value of 13 in the first quantization coefficient submatrix, the parameters of the Golomb-Rice code are updated to 3; if the current first quantization coefficient is the first coefficient with an absolute value of 25 in the first quantization coefficient submatrix, the parameters of the Golomb-Rice code are updated to 4.

[0476] Step 907: Calculate the context model of the syntax element significance_cg_flag.

[0477] In this step, the context model of significance_cg_flag is calculated based on the values ​​of the first syntax elements of the two adjacent 4x4 coefficient blocks on the top and the two adjacent 4x4 coefficient blocks on the left (first quantization coefficient submatrix) of the current 4x4 coefficient block (first quantization coefficient submatrix).

[0478] Step 908, decide whether to force the current CG to zero.

[0479] In this step, it is determined whether to force the current CG to zero based on the fifth coding cost and the sixth coding cost. If the fifth coding cost is less than the sixth coding cost, the CG is forced to zero. If not, the non-zero first quantization coefficient is fine-tuned to obtain the second quantization coefficient.

[0480] Step 909, output CG'.

[0481] In this step, CG' is the second quantization coefficient submatrix obtained after adjusting CG.

[0482] Another exemplary embodiment of the present application further provides a rate-distortion optimization quantization method. This embodiment provides another implementation of the above step 602. Fig.10 As shown, in this embodiment, step 602 may include the following steps:

[0483] Step 1001, input QCoeff[cIdx][x'][y'].

[0484] In this step, a QCoeff[cIdx][x'][y'] in CG is input.

[0485] Step 1002 , determine whether |QCoeff[cIdx][x'][y']| is less than 3. If yes, execute step 1003 , if not, execute step 1004 .

[0486] Step 1003: If Cand0QCeff[cIdx][x'][y']=0, calculate the coding cost cost0.

[0487] Among them, Cand0QCeff[cIdx][x'][y'] is the first candidate quantization coefficient, and the coding cost cost0 is the above-mentioned first candidate coding cost.

[0488] Step 1004 , determine whether |QCoeff[cIdx][x'][y']| is greater than 1. If yes, execute step 1005 , if not, execute step 1006 .

[0489] Step 1005: If Cand1QCeff[cIdx][x'][y']=|QCoeff[cIdx][x'][y']|-1, calculate the coding cost cost1.

[0490] Wherein, Cand1QCeff[cIdx][x'][y'] is the second candidate quantization coefficient. The coding cost cost1 is the above-mentioned second candidate coding cost.

[0491] Step 1006 , determine whether |QCoeff[cIdx][x'][y']| is greater than 0. If yes, execute step 1007 , if not, execute step 1008 .

[0492] Step 1007: If Cand2QCeff[cIdx][x'][y']=QCoeff[cIdx][x'][y'], calculate the coding cost cost2.

[0493] Among them, Cand2QCeff[cIdx][x'][y'] is the third candidate quantization coefficient, and the coding cost cost2 is the third candidate coding cost.

[0494] Step 1008, select the one with the smallest coding cost from Cand0QCeff[cIdx][x'][y'], Cand1QCeff[cIdx][x'][y'] and Cand2QCeff[cIdx][x'][y'] as the second quantization coefficient.

[0495] In this step, the above formula (50) is used to select the one with the smallest coding cost from Cand0QCeff[cIdx][x'][y'], Cand1QCeff[cIdx][x'][y'] and Cand2QCeff[cIdx][x'][y'] as the second quantization coefficient.

[0496] Step 1009: output the second quantization coefficient.

[0497] Fig.11 FIG. 1 is a block diagram of a rate-distortion optimization quantization device according to an exemplary embodiment. Fig.11 As shown, in this embodiment, the rate-distortion optimization quantization device includes:

[0498] The quantization module 121 is configured to quantize the transform coefficient matrix to obtain a first quantization coefficient matrix; wherein the transform coefficient matrix includes at least one transform coefficient, and the first quantization coefficient matrix includes at least one first quantization coefficient;

[0499] A decomposition module 122, configured to divide the first quantization coefficient matrix into at least two non-overlapping first quantization coefficient sub-matrices;

[0500] The statistics module 123 is configured to perform data statistics on at least two first quantization coefficient sub-matrices to obtain quantization statistics data; the quantization statistics data is used to eliminate the dependency between the at least two first quantization coefficient sub-matrices;

[0501] The adjustment module 124 is configured to adjust the coefficients of the non-zero first quantization coefficients for each first quantization coefficient submatrix to obtain a second quantization coefficient submatrix; the second quantization coefficient submatrix includes at least one second quantization coefficient; the coefficient adjustment of at least two first quantization coefficient submatrices is performed in parallel;

[0502] The acquisition module 125 is configured to acquire a second quantization coefficient matrix according to the second quantization coefficient submatrix and the relationship between the first quantization coefficient submatrix and the first quantization coefficient matrix, where the second quantization coefficient matrix includes at least one second quantization coefficient.

[0503] An embodiment of the present application also proposes an electronic device, including a processor and a memory; the memory is used to store a computer program executable by the processor; the processor is used to execute the computer program in the memory to implement the rate-distortion optimization quantization method of any of the above embodiments.

[0504] The embodiments of the present application further provide a computer-readable storage medium. When the executable computer program in the storage medium is executed by a processor, the rate-distortion optimization quantization method of any of the above embodiments can be implemented.

[0505] Regarding the device in the above embodiment, the specific manner in which the processor performs the operation has been described in detail in the embodiment of the method, and will not be elaborated here.

[0506] Fig.12 1 is a block diagram of an electronic device according to an exemplary embodiment. For example, the electronic device 1200 may be provided as a server. Fig.12 , the device 1200 includes a processing component 1222, which further includes one or more processors, and a memory resource represented by a memory 1232 for storing instructions, such as applications, that can be executed by the processing component 1222. The application stored in the memory 1232 may include one or more modules, each corresponding to a set of instructions. In addition, the processing component 1222 is configured to execute instructions to perform the above-mentioned method for rate-distortion optimization quantization.

[0507] The device 1200 may also include a power component 1226 configured to perform power management of the device 1200, a wired or wireless network interface 1250 configured to connect the device 1200 to a network, and an input / output (I / O) interface 1258. The device 1200 may operate based on an operating system stored in the memory 1232, such as Windows Server™, MacOS X™, Unix™, Linux™, FreeBSD™, or the like.

[0508] In an exemplary embodiment, a non-transitory computer-readable storage medium including instructions is also provided, such as a memory 1232 including instructions, which can be executed by the processing component 1222 of the device 1200 to perform the above method. For example, the non-transitory computer-readable storage medium can be a ROM, a random access memory (RAM), a CD-ROM, a magnetic tape, a floppy disk, an optical data storage device, etc.

[0509] In the present invention, the terms "first" and "second" are used for descriptive purposes only and cannot be understood as indicating or implying relative importance. The term "plurality" refers to two or more than two, unless otherwise clearly defined.

[0510] The above description of the embodiments is to facilitate those of ordinary skill in the art to understand and apply the present application. It is obvious that those familiar with the art can easily make various modifications to these embodiments and apply the general principles described herein to other embodiments without having to pay creative labor. Therefore, the present application is not limited to the embodiments herein, and improvements and modifications made by those skilled in the art based on the contents disclosed in the present application without departing from the scope and spirit of the present application are within the scope of the present application.

Claims

1. A rate-distortion optimization quantization method, characterized in that: Applied to an encoder, the method comprises: quantizing a transform coefficient matrix to obtain a first quantization coefficient matrix; wherein the transform coefficient matrix includes at least one transform coefficient, and the first quantization coefficient matrix includes at least one first quantization coefficient; Dividing the first quantization coefficient matrix into at least two non-overlapping first quantization coefficient sub-matrices; Performing data statistics on at least two of the first quantization coefficient sub-matrices to obtain quantization statistical data; the quantization statistical data is used to eliminate the dependency between the at least two of the first quantization coefficient sub-matrices; Performing data statistics on at least two of the first quantization coefficient sub-matrices to obtain quantization statistical data includes: For the first quantization coefficient sub-matrices of the first quantization coefficient matrix, at least two of the first quantization coefficient sub-matrices are scanned respectively according to a specified first scanning order, and the scanning object is the first quantization coefficient sub-matrix; For each of the first quantization coefficient submatrices, coefficient adjustment is performed on the non-zero first quantization coefficients to obtain a second quantization coefficient submatrix; the second quantization coefficient submatrix includes at least one second quantization coefficient; the coefficient adjustment of at least two of the first quantization coefficient submatrices is performed in parallel; According to the second quantization coefficient submatrix and the relationship between the first quantization coefficient submatrix and the first quantization coefficient matrix, a second quantization coefficient matrix is ​​obtained, where the second quantization coefficient matrix includes at least one of the second quantization coefficients; The step of adjusting the coefficients of the non-zero first quantization coefficients for each of the first quantization coefficient sub-matrices to obtain a second quantization coefficient sub-matrix includes: determining a target coefficient adjustment scheme from at least two coefficient adjustment schemes; or, For each non-zero first quantized coefficient, if the first quantized coefficient is located after the first non-zero first quantized coefficient in the first scanning order, calculating a third encoding cost for returning the first quantized coefficient to zero; Fine-tune the first quantization coefficient to obtain the corresponding second quantization coefficient, and calculate a fourth encoding cost for fine-tuning the first quantization coefficient; Obtaining a sum of all the third coding costs to obtain a fifth coding cost; the fifth coding cost is a coding cost for returning the first quantization coefficient submatrix to zero; Obtaining a sum of all the fourth coding costs to obtain a sixth coding cost; the sixth coding cost is a coding cost for fine-tuning coefficients of the first quantization coefficient submatrix; If the fifth coding cost is less than the sixth coding cost, setting the first quantization coefficient submatrix to zero to obtain the second quantization coefficient submatrix; If the sixth coding cost is less than the fifth coding cost, obtaining the second quantization coefficient submatrix according to the second quantization coefficient; The at least two coefficient adjustment schemes include: a first coefficient adjustment scheme, a second coefficient adjustment scheme, or a third coefficient adjustment scheme; The first coefficient adjustment scheme is to set the first quantization coefficient to zero, the second coefficient adjustment scheme is to keep the sign of the first quantization coefficient unchanged and reduce the absolute value by 1; the third coefficient adjustment scheme is to keep the sign of the first quantization coefficient unchanged and reduce the absolute value by 2.

2. The rate-distortion optimization quantization method according to claim 1, characterized in that: The step of quantizing the transform coefficient matrix to obtain a first quantization coefficient matrix includes: For each of the transform coefficients in the transform coefficient matrix, a quantization offset parameter is used to quantize the transform coefficient to obtain the first quantization coefficient.

3. The rate-distortion optimization quantization method according to claim 2, characterized in that: The first quantization coefficient is calculated using the following formula: QCoeff[cIdx][x][y]=sign[cIdx][x][y]×((|TCoeff[cIdx][x][y]|×quantizationScaler[cId x][x][y]+(1<<(quantizationShift[cIdx][x][y]-1)))>>quantizationShift[cIdx][x][y]); Among them, QCoeff[cIdx][x][y] is the first quantization coefficient, sign[cIdx][x][y] is the sign of the transform coefficient, TCoeff[cIdx][x][y] is the transform coefficient, quantizationScaler[cIdx][x][y] is the quantization scaling parameter, quantizationShift[cIdx][x][y] is the quantization offset parameter, cIdx is the Y, U, V component index, and x, y are the coordinates of the transform coefficient in the transform coefficient matrix.

4. The rate-distortion optimization quantization method according to claim 1, characterized in that: Before performing statistics on the first quantization coefficient matrix to obtain quantization statistical data, the method further includes: Creating a corresponding array for at least one context model and initializing the context model to a predefined value; the array is used to store the state of the corresponding context model; each element of the array is an 8-bit integer; Wherein, the at least one context model includes a first context model, a second context model, a third context model and a fourth context model; the array corresponding to the at least one context model includes a first array, a second array, a third array and a fourth array; The first array is significantCoeffGroupCtx[2], which is used to store the conditional probability state of the first syntax element, and the first syntax element is significantCoeffCroup, which is used to indicate whether the current first quantization coefficient submatrix has a non-zero first quantization coefficient; the first syntax element is the first context model; The second array is sigCoeffCtx[44], which is used to store the conditional probability state of the second syntax element, the second syntax element is sigCoeffFlag, which is used to indicate whether the current first quantization coefficient is zero; the second syntax element is the second context model; The third array is greaterOneCoeffCtx[24], which is used to store the conditional probability state of the third syntax element, and the third syntax element is absCoeffGreaterThanOneFlag, which is used to indicate whether the absolute value of the current first quantization coefficient is greater than 1; the third syntax element is the third context model; The fourth array is levelAbsCoeffCtx[6], which is used to store the conditional probability state of the fourth syntax element. The fourth syntax element is levelAbsCoeff, which is the absolute value of the current first quantization coefficient; the fourth syntax element is the fourth context model.

5. The rate-distortion optimization quantization method according to claim 1, characterized in that: Performing data statistics on at least two of the first quantization coefficient sub-matrices to obtain quantization statistical data also includes: For each of the first quantization coefficient submatrices, scanning the first quantization coefficients according to a specified second scanning order, the scanning object is the first quantization coefficient, and obtaining the quantization statistical data; The first scanning order is the same as the second scanning order.

6. The rate-distortion optimization quantization method according to claim 5, characterized in that: The quantization statistical data include: the number of first quantization coefficients with an absolute value of 1 in the first quantization coefficient submatrix, the number of first quantization coefficients with an absolute value greater than 1 in the first quantization coefficient submatrix, the number of first quantization coefficients with an absolute value greater than 2 in the first quantization coefficient submatrix, the position of the first non-zero first quantization coefficient arranged in the first scanning order in the first quantization coefficient matrix, the position of the first first quantization coefficient with an absolute value of 4 arranged in the second scanning order in the first quantization coefficient submatrix, the position of the first first quantization coefficient with an absolute value of 7 arranged in the second scanning order in the first quantization coefficient submatrix, the position of the first first quantization coefficient with an absolute value of 13 arranged in the second scanning order in the first quantization coefficient submatrix, and the position of the first first quantization coefficient with an absolute value of 25 arranged in the second scanning order in the first quantization coefficient submatrix.

7. The rate-distortion optimization quantization method according to claim 6, characterized in that: The number of first quantization coefficients with an absolute value of 1 in the first quantization coefficient submatrix is ​​stored in a fifth array named cgOneCnt[64]. The fifth array is initialized to an all-zero array before data statistics. During the data statistics process, if the absolute value of the current first quantization coefficient is 1, the corresponding cgOneCnt of the first quantization coefficient submatrix is ​​incremented by 1.

8. The rate-distortion optimization quantization method according to claim 7, characterized in that: The number of first quantization coefficients with an absolute value of 1 in the first quantization coefficient submatrix is ​​calculated using the following formula: Among them, QCoeff[cIdx][x][y] is the first quantization coefficient, cIdx is the Y, U, and V component indexes, x and y are the coordinates of the first quantization coefficient in the first quantization coefficient matrix, and tuSize is the size of the transform coefficient matrix.

9. The rate-distortion optimization quantization method according to claim 6, characterized in that: The number of first quantization coefficients in the first quantization coefficient submatrix whose absolute value is greater than 1 is stored in a sixth array named cgGreaterThanOneCnt[64]. The sixth array is initialized to an all-zero array before data statistics. During the data statistics process, if the absolute value of the current first quantization coefficient is greater than 1, the corresponding cgGreaterThanOneCnt of the first quantization coefficient submatrix is ​​incremented by 1.

10. The rate-distortion optimization quantization method according to claim 9, characterized in that: The number of first quantization coefficients with absolute values ​​greater than 1 in the first quantization coefficient submatrix is ​​calculated using the following formula: Among them, QCoeff[cIdx][x][y] is the first quantization coefficient, cIdx is the Y, U, and V component indexes, x and y are the coordinates of the first quantization coefficient in the first quantization coefficient matrix, and tuSize is the size of the transform coefficient matrix.

11. The rate-distortion optimization quantization method according to claim 6, characterized in that: The number of first quantization coefficients in the first quantization coefficient submatrix whose absolute value is greater than 2 is stored in a seventh array named cgGreaterThanTwoCnt[64]. The seventh array is initialized to an all-zero array before data statistics. During the data statistics process, if the absolute value of the current first quantization coefficient is greater than 2, the corresponding cgGreaterThanTwoCnt of the first quantization coefficient submatrix is ​​incremented by 1.

12. The rate-distortion optimization quantization method according to claim 11, characterized in that: The number of first quantization coefficients with absolute values ​​greater than 2 in the first quantization coefficient submatrix is ​​calculated using the following formula: Among them, QCoeff[cIdx][x][y] is the first quantization coefficient, cIdx is the Y, U, and V component indexes, x and y are the coordinates of the first quantization coefficient in the first quantization coefficient matrix, and tuSize is the size of the transform coefficient matrix.

13. The rate-distortion optimization quantization method according to claim 6, characterized in that: The position of the first quantization coefficient with an absolute value of 4 is stored in the eighth array named cgFirst4Loc[64][2]. All elements of the eighth array are initialized to -1 before data statistics. The vertical coordinate of the position of the first quantization coefficient with an absolute value of 4 is stored in cgFirst4Loc[64][0], and the horizontal coordinate is stored in cgFirst4Loc[64][1].

14. The rate-distortion optimization quantization method according to claim 13, characterized in that: If Coeff[cIdx][x][y] is the first coefficient with an absolute value of 4 in the first quantization coefficient submatrix, cgFirst4Loc is updated to: Among them, cIdx is the Y, U, and V component indexes, x and y are the coordinates of the first coefficient with an absolute value of 4 in the first quantization coefficient matrix, tuSize is the size of the transform coefficient matrix, y1 is the vertical coordinate of the first quantization coefficient with an absolute value of 4 in the first quantization coefficient submatrix, and x1 is the horizontal coordinate of the first quantization coefficient with an absolute value of 4 in the first quantization coefficient submatrix.

15. The rate-distortion optimized quantization method according to claim 6, characterized in that: The position of the first quantization coefficient whose absolute value is 7 is stored in a ninth array named cgFirst7Loc[64][2]. All elements of the ninth array are initialized to -1 before data statistics. The vertical coordinate of the position of the first quantization coefficient whose absolute value is 7 is stored in cgFirst7Loc[64][0], and the horizontal coordinate is stored in cgFirst7Loc[64][1].

16. The rate-distortion optimized quantization method according to claim 15, characterized in that: If Coeff[cIdx][x][y] is the first coefficient with an absolute value of 7 in the first quantization coefficient submatrix, cgFirst7Loc is updated to: Among them, cIdx is the Y, U, and V component indexes, x and y are the coordinates of the first coefficient with an absolute value of 7 in the first quantization coefficient matrix, tuSize is the size of the transform coefficient matrix, y2 is the vertical coordinate of the first quantization coefficient with an absolute value of 7 in the first quantization coefficient submatrix, and x2 is the horizontal coordinate of the first quantization coefficient with an absolute value of 7 in the first quantization coefficient submatrix.

17. The rate-distortion optimized quantization method according to claim 6, characterized in that: The position of the first quantization coefficient whose absolute value is 13 is stored in the tenth array named cgFirst13Loc[64][2]. All elements of the tenth array are initialized to -1 before data statistics. The vertical coordinate of the position of the first quantization coefficient whose absolute value is 13 is stored in cgFirst13Loc[64][0], and the horizontal coordinate is stored in cgFirst13Loc[64][1].

18. The rate-distortion optimized quantization method according to claim 17, characterized in that: If Coeff[cIdx][x][y] is the first coefficient with an absolute value of 13 in the first quantized coefficient submatrix, cgFirst13Loc is updated to: Among them, cIdx is the Y, U, and V component indexes, x and y are the coordinates of the first coefficient with an absolute value of 13 in the first quantization coefficient matrix, tuSize is the size of the transform coefficient matrix, y3 is the vertical coordinate of the first quantization coefficient with an absolute value of 13 in the first quantization coefficient submatrix, and x3 is the horizontal coordinate of the first quantization coefficient with an absolute value of 13 in the first quantization coefficient submatrix.

19. The rate-distortion optimized quantization method according to claim 6, characterized in that: The position of the first quantization coefficient whose absolute value is 25 is stored in the eleventh array named cgFirst25Loc[64][2]. All elements of the eleventh array are initialized to -1 before data statistics. The vertical coordinate of the position of the first quantization coefficient whose absolute value is 25 is stored in cgFirst25Loc[64][0], and the horizontal coordinate is stored in cgFirst25Loc[64][1].

20. The rate-distortion optimized quantization method according to claim 19, characterized in that: If Coeff[cIdx][x][y] is the first coefficient with an absolute value of 25 in the first quantization coefficient submatrix, cgFirst25Loc is updated to: Among them, cIdx is the Y, U, and V component indexes, x and y are the coordinates of the first coefficient with an absolute value of 25 in the first quantization coefficient matrix, tuSize is the size of the transform coefficient matrix, y4 is the vertical coordinate of the first quantization coefficient with an absolute value of 25 in the first quantization coefficient submatrix, and x4 is the horizontal coordinate of the first quantization coefficient with an absolute value of 25 in the first quantization coefficient submatrix.

21. The rate-distortion optimized quantization method according to claim 1, wherein: The step of adjusting the coefficients of the non-zero first quantization coefficients for each of the first quantization coefficient sub-matrices to obtain a second quantization coefficient sub-matrix includes: For each non-zero first quantized coefficient, calculating a first coding cost for coefficient adjustment according to at least two coefficient adjustment schemes; For each coefficient adjustment scheme, a second coding cost is obtained according to the sum of all the first coding costs; the second coding cost is the coding cost of adjusting the coefficients of the first quantization coefficient submatrix; The second coding cost of the target coefficient adjustment scheme is the smallest coding cost among the second coding costs of at least two coefficient adjustment schemes; The non-zero first quantization coefficients in the first quantization coefficient submatrix are adjusted according to a target coefficient adjustment scheme to obtain the second quantization coefficient submatrix.

22. The rate-distortion optimized quantization method according to claim 21, characterized in that: The first coding cost is calculated using the following formula: cost1[cIdx][x′][y′]=distortion[cIdx][x′][y′]+rate[cIdx][x′][y′]; Among them, cost1[cIdx][x'][y'] is the first encoding cost, distortion[cIdx][x'][y'] is the error in the pixel domain, rate[cIdx][x'][y'] is the encoding bit rate, cIdx is the Y, U, V component index, and x', y' are the coordinates of the first quantization coefficient in the first quantization coefficient submatrix.

23. The rate-distortion optimized quantization method according to claim 22, characterized in that: The pixel domain error is calculated using the following formula: distortion[cIdx][x′][y′]=(mErr[cIdx][x′][y′]>>(2×transformShift+1))×mErr[cIdx][x′][y′]; Among them, mErr[cIdx][x'][y'] is the inverse restoration value of the quantization error, and transformShift is a parameter describing the internal transformation shift of the transformation coefficient matrix.

24. The rate-distortion optimized quantization method according to claim 23, characterized in that: The inverse restoration value of the quantization error when the bit depth of the video is 10 is obtained by the following method: Get the inverse restoration value of the quantization error when the bit depth of the video is 8; The inverse restoration value of the quantization error when the bit depth of the video is 8 is shifted right by two bits to obtain the inverse restoration value of the quantization error when the bit depth of the video is 10.

25. The rate-distortion optimized quantization method according to claim 23, characterized in that: The quantization error is calculated using the following formula: err[cIdx][x′][y′]=||TCoeff[cIdx][x′][y′]|×quantizationScaler[cIdx][x′][y′]―(|QCoeff[cIdx][x′][y′]|< <quantizationShift[cIdx][x′][y′])|; Among them, TCoeff[cIdx][x'][y'] is the transformation coefficient, quantizationScaler[cIdx][x'][y'] is the quantization scaling parameter, QCoeff[cIdx][x'][y'] is the first quantization coefficient, and quantizationShift[cIdx][x'][y'] is the quantization offset parameter.

26. The rate-distortion optimized quantization method according to claim 22, wherein: The encoding bit rate is calculated using the following formula: rate[cIdx][x′][y′]=sigCoeffFlagRate[cIdx][x′][y′]+coeffAbsLevelRate[cIdx][x′][y′]; Among them, sigCoeffFlagRate[cIdx][x'][y'] is the first rate estimate of the second syntax element, the second syntax element is sigCoeffFlag, which is used to indicate whether the current first quantization coefficient is zero, and coeffAbsLevelRate[cIdx][x'][y'] is the second rate estimate of the syntax element that encodes the absolute value of the non-zero first quantization coefficient.

27. The rate-distortion optimized quantization method according to claim 26, characterized in that: The second bit rate estimation is calculated using the following formula: coeffAbsLevelRate[cIdx][x′][y′]=absCoeffGreaterThanOneFlagRate[cIdx][x′][y′]+absCoeffGreaterThanTwoFlagRate[cIdx][x′][y′]+absCoeffMinusTwoRate[cIdx][x′][y ′ ]; Among them, absCoeffGreaterThanOneFlagRate[cIdx][x'][y'] is the third rate estimate of the third syntax element, and the third syntax element is absCoeffGreaterThanOneFlag, which is used to indicate whether the absolute value of the current first quantization coefficient is greater than 1, absCoeffGreaterThanTwoFlagRate[cIdx][x'][y'] is the fourth rate estimate of the fifth syntax element, and the fifth syntax element is absCoeffGreaterThanTwo, which is used to indicate whether the absolute value of the current first quantization coefficient is greater than 2, and absCoeffMinusTwoRate[cIdx][x'][y'] is the fifth rate estimate of the sixth syntax element, and the sixth syntax element is absCeoffMinusTwo, which is used to indicate that the absolute value of the current first quantization coefficient is minus 2.

28. The rate-distortion optimized quantization method according to claim 6, characterized in that: The fifth coding cost is obtained by obtaining the sum of all the third coding costs, and is calculated using the following formula: Among them, cgCost0 is the fifth coding cost, zeroOutCost[cIdx][x'][y'] is the third coding cost, cIdx is the Y, U, V component index, x', y' are the coordinates of the first quantization coefficient in the first quantization coefficient submatrix, and CGSize is the size of the first quantization coefficient submatrix.

29. The rate-distortion optimized quantization method according to claim 28, characterized in that: The third encoding cost is calculated using the following formula: zeroOutCost[cIdx][x′][y′]=distortion[cIdx][x′][y′]; Among them, distortion[cIdx][x'][y'] is the error in the pixel domain.

30. The rate-distortion optimized quantization method according to claim 6, characterized in that: The sum of all the fourth coding costs is obtained to obtain the sixth coding cost, which is calculated using the following formula: Among them, cgCost1 is the sixth coding cost, tweakedCoeffCost[cIdx][x'][y'] is the fourth coding cost, cIdx is the Y, U, V component index, x', y' are the coordinates of the first quantization coefficient in the first quantization coefficient submatrix, and CGSize is the size of the first quantization coefficient submatrix.

31. The rate-distortion optimized quantization method according to claim 6, characterized in that: The fine-tuning the first quantization coefficient to obtain the corresponding second quantization coefficient, and calculating a fourth encoding cost for fine-tuning the first quantization coefficient, includes: Adjusting the first quantization coefficient to a first candidate quantization coefficient, and calculating a first candidate coding cost for adjusting the first quantization coefficient, wherein the first candidate quantization coefficient is 0; If the absolute value of the first quantization coefficient is greater than 1, adjusting the first quantization coefficient to a second candidate quantization coefficient, and calculating a second candidate coding cost for adjusting the first quantization coefficient, wherein the sign of the second candidate quantization coefficient is the same as the sign of the first quantization coefficient, and the absolute value of the second candidate quantization coefficient is equal to the absolute value of the first quantization coefficient minus 1; Calculating a third candidate coding cost of the first quantization coefficient, wherein no adjustment is made to the first quantization coefficient; Selecting the smallest coding cost among the first candidate coding cost, the second candidate coding cost and the third candidate coding cost as the fourth coding cost; A quantization coefficient corresponding to the smallest coding cost among the first candidate coding cost, the second candidate coding cost and the third candidate coding cost is selected as the second quantization coefficient.

32. The rate-distortion optimized quantization method of claim 31, wherein: The second quantization coefficient is calculated using the following formula: Among them, newQCoeff[cIdx][x'][y'] is the second quantization coefficient, sign[cIdx][x'][y'] is the sign of the first quantization coefficient, cost0[cIdx][x'][y'] is the first candidate coding cost, cost1[cIdx][x'][y'] is the second candidate coding cost, and cost2[cIdx][x'][y'] is the third candidate coding cost.

33. The rate-distortion optimized quantization method according to claim 32, characterized in that: The fourth coding cost is calculated using the following formula: tweakedCoeffCost[cIdx][x′][y′]=min(cost0[cIdx][x′][y′],cost1[cIdx][x′][y′],cost2[cIdx][x′][y′])); Among them, tweakedCoeffCost[cIdx][x'][y'] is the fourth coding cost.

34. A rate-distortion optimization quantization device, characterized in that: Applied to an encoder, the device comprises: A quantization module, configured to quantize a transform coefficient matrix to obtain a first quantization coefficient matrix; wherein the transform coefficient matrix includes at least one transform coefficient, and the first quantization coefficient matrix includes at least one first quantization coefficient; A decomposition module, configured to divide the first quantization coefficient matrix into at least two non-overlapping first quantization coefficient sub-matrices; a statistics module configured to perform data statistics on at least two of the first quantization coefficient sub-matrices to obtain quantization statistics data; the quantization statistics data are used to eliminate the dependency between the at least two of the first quantization coefficient sub-matrices; Performing data statistics on at least two of the first quantization coefficient sub-matrices to obtain quantization statistical data includes: For the first quantization coefficient sub-matrices of the first quantization coefficient matrix, at least two of the first quantization coefficient sub-matrices are scanned respectively according to a specified first scanning order, and the scanning object is the first quantization coefficient sub-matrix; an adjustment module, configured to, for each of the first quantization coefficient submatrices, perform coefficient adjustment on the non-zero first quantization coefficients to obtain a second quantization coefficient submatrix; the second quantization coefficient submatrix includes at least one second quantization coefficient; and coefficient adjustment of at least two of the first quantization coefficient submatrices is performed in parallel; an acquisition module, configured to acquire a second quantization coefficient matrix according to the second quantization coefficient submatrix and a relationship between the first quantization coefficient submatrix and the first quantization coefficient matrix, wherein the second quantization coefficient matrix includes at least one second quantization coefficient; The step of adjusting the coefficients of the non-zero first quantization coefficients for each of the first quantization coefficient sub-matrices to obtain a second quantization coefficient sub-matrix includes: determining a target coefficient adjustment scheme from at least two coefficient adjustment schemes; or, For each non-zero first quantized coefficient, if the first quantized coefficient is located after the first non-zero first quantized coefficient in the first scanning order, calculating a third encoding cost for returning the first quantized coefficient to zero; Fine-tune the first quantization coefficient to obtain the corresponding second quantization coefficient, and calculate a fourth encoding cost for fine-tuning the first quantization coefficient; Obtaining a sum of all the third coding costs to obtain a fifth coding cost; the fifth coding cost is a coding cost for returning the first quantization coefficient submatrix to zero; Obtaining a sum of all the fourth coding costs to obtain a sixth coding cost; the sixth coding cost is a coding cost for fine-tuning coefficients of the first quantization coefficient submatrix; If the fifth coding cost is less than the sixth coding cost, setting the first quantization coefficient submatrix to zero to obtain the second quantization coefficient submatrix; If the sixth coding cost is less than the fifth coding cost, obtaining the second quantization coefficient submatrix according to the second quantization coefficient; The at least two coefficient adjustment schemes include: a first coefficient adjustment scheme, a second coefficient adjustment scheme, or a third coefficient adjustment scheme; The first coefficient adjustment scheme is to set the first quantization coefficient to zero, the second coefficient adjustment scheme is to keep the sign of the first quantization coefficient unchanged and reduce the absolute value by 1; the third coefficient adjustment scheme is to keep the sign of the first quantization coefficient unchanged and reduce the absolute value by 2.

35. An electronic device, characterized in that: It comprises a memory and a processor, the memory is used to store a computer program executable by the processor; the processor is used to execute the computer program in the memory to implement the method according to any one of claims 1 to 33.

36. A computer-readable storage medium having a computer program stored thereon, characterized in that: When the executable computer program in the storage medium is executed by a processor, the method according to any one of claims 1 to 33 can be implemented.

Citation Information

Patent Citations

  • Rate distortion optimization quantization method and device, electronic equipment and storage medium

    CN116886913A