Quantization transform coefficient-based code rate estimation method, system, device and medium
By constructing the probability density distribution of the weight matrix and quantization transform coefficients, the bitrate calculation in video coding is simplified, solving the problem of excessive time consumption in rate-distortion optimization technology, and realizing efficient bitrate estimation and coding mode decision-making.
Patent Information
- Application Number
- CN202211215465.X
- Authority / Receiving Office
- CN · China
- Patent Type
- Patents(China)
- Current Assignee / Owner
- Filing Date
- 2022-09-30
- Publication Date
- 2026-02-17
- Estimated Expiration
- 2042-09-30
AI Technical Summary
In existing video coding technologies, Rate-Distortion Optimization (RDO) has high computational complexity in determining the optimal coding mode, resulting in excessive time consumption and affecting coding efficiency.
By pre-constructing a weight matrix and based on the probability density distribution of the quantized transform coefficients, the estimated bitrate is calculated using the weight matrix and the coefficient transformation results of the transform block, replacing the traditional actual coding operation and simplifying the bitrate calculation process.
While ensuring the accuracy of bitrate calculation, it significantly improves the efficiency of bitrate calculation, reduces the time spent on bitrate determination, and supports rapid decision-making on the optimal encoding mode.
Smart Images

Figure CN115914633B_ABST
Abstract
Description
TECHNICAL FIELD
[0001] The embodiment of the present application relates to the technical field of video coding, in particular to a code rate estimation method and system based on quantized transform coefficients, a device and a medium. BACKGROUND
[0002] At present, in the video coding scene, the optimal coding mode is decided by using the rate-distortion optimization technology (RDO), which can improve the coding quality and reduce the loss of video quality. The rate-distortion optimization technology calculates the code rate and distortion rate of each coding unit by coding under different coding modes, determines the coding cost of each coding unit under different coding modes based on the code rate and the distortion rate, and then selects the coding mode with the minimum coding cost to perform the coding operation on the corresponding coding unit.
[0003] However, in the process of deciding the optimal coding mode by using the rate-distortion optimization technology (RDO), the content adaptive binary arithmetic coding needs to be performed on each coding unit, and the coding code rate under the corresponding coding mode is calculated according to the coding result. The calculation complexity of the whole code rate calculation process is relatively high, which leads to a long time consumption of the rate-distortion optimization, and then affects the coding efficiency. SUMMARY
[0004] The embodiment of the present application provides a code rate estimation method and system based on quantized transform coefficients, a device and a medium, which can improve the code rate calculation efficiency while ensuring the accuracy of the code rate calculation, and solve the technical problem of long time consumption of code rate calculation in the rate-distortion optimization process.
[0005] In a first aspect, the embodiment of the present application provides a code rate estimation method based on quantized transform coefficients, comprising:
[0006] In the case of completing the coefficient transformation and quantization of the current transform block, a weight matrix of the current transform block is selected, the weight matrix is constructed in advance according to a first coefficient transformation result and a coding code rate of a plurality of coded transform blocks, the first coefficient transformation result is obtained by multiplying a first coefficient vector by a set index, the first coefficient vector includes the absolute values of the first quantized transform coefficients of the coded transform blocks, and the set index is determined according to the probability density distribution law of the quantized transform coefficients in different training images;
[0007] A second coefficient transformation result is obtained by multiplying a second coefficient vector of the current transform block by a set index, the second coefficient vector includes the absolute values of the second quantized transform coefficients of the current transform block;
[0008] An estimated code rate of the current transform block is calculated according to the second coefficient transformation result and the weight matrix.
[0009] In a second aspect, the embodiment of the present application provides a code rate estimation system based on quantized transform coefficients, comprising:
[0010] The selecting module is configured to select a weight matrix of the current transform block in a case that a coefficient transform and quantization of the current transform block are completed, the weight matrix being constructed in advance according to a first coefficient transform result of a plurality of coded transform blocks and a coding bit rate, the first coefficient transform result being obtained by multiplying a first coefficient vector by a set index, the first coefficient vector including absolute values of first quantized transform coefficients of the coded transform blocks, and the set index being determined according to a probability density distribution law of the quantized transform coefficients in different training images.
[0011] The transforming module is configured to obtain a second coefficient transform result by multiplying a second coefficient vector of the current transform block by a set index, the second coefficient vector including absolute values of second quantized transform coefficients of the current transform block.
[0012] The calculating module is configured to calculate an estimated bit rate of the current transform block according to the second coefficient transform result and the weight matrix.
[0013] In a third aspect, an embodiment of the present application provides a bit rate estimation device based on quantized transform coefficients, including:
[0014] a memory and one or more processors;
[0015] The memory is configured to store one or more programs.
[0016] When the one or more programs are executed by the one or more processors, the one or more processors implement the bit rate estimation method based on quantized transform coefficients as described in the first aspect.
[0017] In a fourth aspect, an embodiment of the present application provides a computer readable nonvolatile storage medium, which stores computer executable instructions, and the computer executable instructions are configured to perform the bit rate estimation method based on quantized transform coefficients as described in the first aspect when executed by a computer processor.
[0018] In a fifth aspect, an embodiment of the present application provides a computer program product, which contains instructions, and the instructions make a computer or a processor execute the bit rate estimation method based on quantized transform coefficients as described in the first aspect when the instructions are executed on the computer or the processor.
[0019] The embodiment of the present application constructs the weight matrix in advance according to the first coefficient transformation result and the coding rate of the plurality of coded transform blocks. Subsequently, the weight matrix of the current transform block is selected under the condition that the coefficient transformation and quantization of the current transform block are completed, and the second coefficient transformation result is obtained based on the second coefficient vector of the current transform block and the set index power. Then, the estimated coding rate of the current transform block is calculated according to the second coefficient transformation result and the weight matrix. By using the above technical means, the weight matrix is constructed in advance by the coding rate and the coefficient transformation result of the coded transform block, and then the estimated coding rate of the current transform block is calculated according to the pre-constructed weight matrix and the coefficient transformation result of the current transform block, so that the coding rate calculation efficiency can be improved, and the estimated coding rate of the transform block can be quickly determined. Moreover, the weight matrix is constructed according to the coefficient transformation result and the coding rate of the coded module, and has sufficient universality, so that the estimated coding rate calculated by the weight matrix meets the accuracy requirement of the coding rate calculation.
[0020] In addition, the coefficient value table is pre-constructed, the value of each coefficient in the coefficient vector can be quickly determined, the time consumption can be shortened, and the efficiency of the coding rate estimation is further improved. BRIEF DESCRIPTION OF DRAWINGS
[0021] Figure 1 is a rate-distortion optimization process schematic diagram provided by the embodiment of the present application;
[0022] Figure 2 is a flowchart of a coding rate estimation method based on quantized transform coefficients provided by the embodiment of the present application;
[0023] Figure 3 is a construction flowchart of the weight matrix in the embodiment of the present application;
[0024] Figure 4 is a calculation flowchart of the second coefficient transformation result in the embodiment of the present application;
[0025] Figure 5 is a calculation flowchart of the estimated coding rate of the transform block in the embodiment of the present application;
[0026] Figure 6 is a structure schematic diagram of a coding rate estimation system based on quantized transform coefficients provided by the embodiment of the present application;
[0027] Figure 7 is a structure schematic diagram of a coding rate estimation device based on quantized transform coefficients provided by the embodiment of the present application. DETAILED DESCRIPTION
[0028] To make the objectives, technical solutions, and advantages of this application clearer, specific embodiments of this application will be described in further detail below with reference to the accompanying drawings. It should be understood that the specific embodiments described herein are merely for explaining this application and not for limiting it. It should also be noted that, for ease of description, only the parts relevant to this application are shown in the drawings, not all of them. Before discussing exemplary embodiments in more detail, it should be mentioned that some exemplary embodiments are described as processes or methods depicted as flowcharts. Although the flowcharts describe operations (or steps) as sequential processes, many of these operations can be performed in parallel, concurrently, or simultaneously. Furthermore, the order of the operations can be rearranged. The process can be terminated when its operation is completed, but may also have additional steps not included in the drawings. The process can correspond to a method, function, procedure, subroutine, subprogram, etc.
[0029] The bitrate estimation method based on quantization transform coefficients provided in this application aims to improve bitrate calculation efficiency while ensuring the accuracy of bitrate estimation by pre-constructing a general weight matrix and calculating the estimated bitrate based on the coefficient transform structure of the weight matrix and the transform block.
[0030] In traditional video coding scenarios, when using Rate-Distortion Optimization (RDO) techniques to determine the optimal coding mode, such as... Figure 1 As shown, the complete rate-distortion optimization process involves predicting residuals, transformation, and quantization. Then, based on the quantization transformation coefficients, the CABAC module (Context-based Adaptive Binary Arithmetic Coding) is used to execute the encoding process. The bitrate is calculated based on the encoding results, and then combined with the distortion rate obtained from distortion calculation, the encoding cost of a coding unit can be determined. This process is repeated for different coding modes, and the encoding cost for each mode is determined based on the above cost calculation process. Finally, the coding mode with the lowest encoding cost is selected as the coding mode for the current coding unit for the actual encoding operation.
[0031] Clearly, existing rate-distortion optimization (RDO) techniques require traversing all coding modes and performing coding unit operations to obtain the bitrate for each mode before selecting the optimal mode for encoding. Since each coding mode requires a separate encoding operation, the entire RDO process is relatively time-consuming. In reality, RDO only aims to determine the optimal coding mode and does not require actual bitstream output. Therefore, this application's embodiments optimize the CABAC module by using bitrate estimation instead of the actual bitrate calculation process, thus improving the efficiency of bitrate calculation.
[0032] Embodiment:
[0033] Figure 2 A flow chart of a code rate estimation method based on quantized transform coefficients provided by an embodiment of the present application is given. The code rate estimation method based on quantized transform coefficients provided in the embodiment can be executed by a code rate estimation device based on quantized transform coefficients. The code rate estimation device based on quantized transform coefficients can be realized by software and / or hardware. The code rate estimation device based on quantized transform coefficients can be composed of two or more physical entities or one physical entity. Generally, the code rate estimation device based on quantized transform coefficients can be a coding server, a computer or other computing device.
[0034] The following describes an example in which the code rate estimation device based on quantized transform coefficients is the main body of the code rate estimation method based on quantized transform coefficients. Refer to Figure 2 The code rate estimation method based on quantized transform coefficients specifically includes the following steps.
[0035] S110, selecting a weight matrix of a current transform block in a case where coefficient transformation and quantization of the current transform block are completed.
[0036] The weight matrix is constructed in advance according to first coefficient transformation results of a plurality of coded transform blocks and coding code rates. The first coefficient transformation results are obtained by multiplying a first coefficient vector by a set index. The first coefficient vector includes absolute values of first quantized transform coefficients of the coded transform blocks. The set index is determined according to a probability density distribution law of quantized transform coefficients in different training images.
[0037] In the code rate estimation, a general weight matrix is constructed in advance to be used for code rate estimation of a transform block. For a frame of image to be coded, a plurality of macroblocks, such as 4×4, 8×8, 16×16 and 32×32 Intra blocks and Inter blocks, are included. These macroblocks are transformed and quantized to obtain corresponding transform blocks. After a macroblock is transformed and quantized to obtain a transform block, the code rate of the current transform block can be estimated according to the weight matrix constructed in advance.
[0038] The weight matrix is essentially used to convert the code rate estimation problem of a transform block into a self-information amount problem of quantized transform coefficients, so as to construct a more accurate code rate estimation model.
[0039] Specifically, taking a 4×4 macroblock as an example, a transform block code rate estimation formula is provided as follows:
[0040] R e = α · r e + β (1)
[0041] where r e ≈∑ u ∑ v r uv ,
[0042] In the above formula (1) and formula (2), R e represents the estimated code rate of a transform block, r e represents the self-information quantity after quantization of the transform block, x uv is the quantized transform coefficient (i.e. each coefficient in the macroblock after transform and quantization operation), u, v are the transform block coordinates, and a uv , b uv , are determined by the quantization step Qstep, the generalized Gaussian distribution shape parameter η uv and the scaling parameter σ uv , f is the quantization compensation parameter, and a uv , b uv need to be updated in real time.
[0043] Further, the generalized Gaussian distribution shape parameter η uv and the scaling parameter σ uv are calculated according to the statistical characteristics of the first moment and the second moment of the quantized transform coefficients at each position of the 4x4 block, and a uv , b uv are calculated according to η uv , σ uv , Qstep and the gamma function (gamma function), and the specific formula is as follows:
[0044]
[0045] where R -1 (x) is approximated by the function , N is the sample number of the quantized transform coefficients, and X i is the i-th quantized transform coefficient. The above formula (3) gives the estimation process of the shape parameter η and the scaling parameter σ of the generalized Gaussian distribution to which the quantized transform coefficients of the current transform block conform. The calculation of a uv , b uv , is given by the following formula (4):
[0046]
[0047]
[0048] Where Γ(x) is the gamma function, which needs to be approximated by the lanczos algorithm (an algorithm that transforms a symmetric matrix into a symmetric tridiagonal matrix by an orthogonal similarity transformation).
[0049] From the above equations (1) to (4), it can be seen that by real-time counting the distribution characteristic value of the quantized transform coefficients at each position of all 4x4 macroblocks of the previous encoding frame, the η uv and σ uv of the 16 positions are solved, which can be used for the code rate estimation of the current frame.
[0050] Since the gamma function value, a uv and b uv of each coefficient need to be calculated when the code rate estimation is calculated, a large number of log functions and multiplication and division operations will make the code rate estimation process time-consuming. Therefore, in the embodiments of the present application, the probability density function distribution law of the quantized transform coefficients of most natural images is combined, the generalized Gaussian distribution with a shape parameter η of 0.5 is used to approximate the coefficient distribution law, and η=0.5 is directly taken for the coefficient distribution of each position, so as to simplify the code rate estimation process and reduce the time consumption of the code rate estimation.
[0051] Further, combined with the value of the shape parameter η=0.5, equation (2) is substituted into equation (1) to obtain:
[0052]
[0053] Where,
[0054] In the above equations (5) and (6), X is the coefficient transform result of the 0.5th power of the absolute value of the quantized transform coefficient, W is the matrix constructed by the coefficient weight, and equation (6) gives the specific form of X and W of an 8x8 transform block. Based on the above equations (5) and (6), the solution of a uv and b uv of each coefficient can be directly converted into the solution of the weight matrix W. Further, the estimated code rate R e of a transform block can be calculated in combination with the coefficient transform result.
[0055] Specifically, the least square method can be used to solve the weight matrix W. Taking an 8x8 transform block as an example, according to equations (5) and (6), there are:
[0056]
[0057] Where R i represents the code rate of the i-th 8x8 transform block, and therefore the following can be obtained:
[0058] W=(X T ·X)-1 X T • R (8)
[0059] By exporting the quantized transform coefficients of a large number of transform blocks and their corresponding actual code rates, the universal weight matrix W can be obtained according to formula (8). Then, in a corresponding transform block code rate estimation process, the weight matrix W can be used in combination with the coefficient transform result of the quantized transform coefficients to calculate the estimated code rate according to formula (5) above.
[0060] Based on this characteristic, the embodiments of the present application construct the weight matrix of the transform block in advance for subsequent code rate estimation of the corresponding transform block. Referring to Figure 3 , the construction process of the weight matrix includes:
[0061] S1001, based on the probability density distribution law of the quantized transform coefficients in different training images, determine the shape parameter of the generalized Gaussian distribution of the transform block in each training image as the set index;
[0062] S1002, scan the quantized transform coefficients of each position of the transform block in the training image, and construct each first coefficient vector based on the absolute value of the quantized transform coefficients of each position and a fixed constant;
[0063] S1003, construct the coefficient matrix based on each first coefficient vector, obtain the first coefficient transform result by multiplying the coefficient matrix with the set index, and construct the weight matrix according to the encoding code rate of the transform block in the training image and the first coefficient transform result.
[0064] Referring to formula (8) above, a large number of already encoded natural images are collected as training images to construct a universal weight matrix according to the training images. Among them, according to the probability density distribution law of the quantized transform coefficients of each transform block in the training image, the value of a universal shape parameter η is determined. According to the above determination method of the shape parameter, the probability density distribution law of the quantized transform coefficients of each transform block is approximated by the shape parameter of the generalized Gaussian distribution, and the shape parameter of the generalized Gaussian distribution of the transform block is determined as the set index. The value of the shape parameter η of the embodiments of the present application is 0.5, that is, the set index is 0.5. In actual application, the set index can also be determined in advance according to the probability density distribution law of the quantized transform coefficients in a large number of natural images, without needing to be selected from the training image each time. The determination method of the shape parameter η of the embodiments of the present application is not fixedly limited, and will not be described in detail here.
[0065] Further, based on the training image, by scanning each transform block in the training image, the quantized transform coefficients of each position of the transform block are determined to construct the coefficient vector of each transform block, which is defined as the first coefficient vector.
[0066] Exemplarily, taking an Intra block of 8x8 as an example, the construction manner of the weight matrix is illustrated. Based on the collected training image, encoding is performed according to the normal encoding process. In the encoding process, the quantized transform coefficients of each 8x8 Intra block are derived in real time. In the 8x8 Intra block, the quantized transform coefficients are collected in a row scanning manner, so as to obtain an initial coefficient vector X i , and the last number of the vector is a constant 1, X i =[X i00 X i01 X i02 …X i07 X i10 …X i17 …X i70 X i71 …X i77 1]. For each transform block, the initial quantized coefficient matrix of all transform blocks is obtained by collecting in a row scanning manner:
[0067]
[0068] Since X in the weight matrix calculation formula (8) is the 0.5th power of the absolute value of the quantized transform coefficient, the absolute value of the quantized coefficient matrix X' is calculated element by element, the initial coefficient vector is transformed, and the transformed coefficient vector is defined as the first coefficient vector, and each first coefficient vector is represented as ∣X i ∣=[∣X i00 ∣∣X i01 ∣∣X i02 ∣…∣X i77 ∣1], and the coefficient matrix is constructed based on the first coefficient vector:
[0069]
[0070] The absolute values of the quantized transform coefficients in the first coefficient vector are sorted in the row scanning order of the transform block, and the fixed constant is placed at the end of the first coefficient vector.
[0071] Then, the first coefficient vector of the coefficient matrix is multiplied by the set index η=0.5 to obtain the coefficient transformation result, which is defined as the first coefficient transformation result:
[0072]
[0073] Meanwhile, the encoding code rate of each transform block of the training image after encoding, i.e., the real bit number R i , is derived, and all real bit numbers constitute a bit vector R:
[0074]
[0075] Finally, the weight matrix W of an 8x8 Intra block can be obtained according to the above formula (8) intra_8×8 :
[0076] W intra_8×8 = (X T ·X) -1 X T ·R
[0077] When the estimated code rate of an 8x8 Intra block is calculated subsequently, the general weight matrix W intra_8×8 can be used to perform code rate estimation.
[0078] Optionally, in the embodiments of the present application, the weight matrix is pre-constructed according to different sizes and types of transform blocks. When the weight matrix of the current transform block is selected in the subsequent code rate estimation process, the pre-constructed weight matrix is selected according to the size and type of the current transform block.
[0079] It can be understood that by calculating the general weight matrix W of different macroblock types and different macroblock sizes respectively, the code rate estimation of different transform blocks of different macroblocks can be applied, and the code rate estimation efficiency of the transform blocks is improved.
[0080] Specifically, in the embodiments of the present application, the weight matrix W intra_4×4 , W inter_4×4 , W intra_8×8 , and W inter_8×8 of 4x4 and 8x8 size Intra blocks and Inter blocks are calculated respectively, and the weight matrix of 16x16 and 32x32 transform blocks is obtained by extending the 8x8 weight matrix. Based on the construction method of the above weight matrix W intra_8×8 , the weight matrix W inter_8×8 , W intra_4×4 , and W inter_4×4 can be obtained.
[0081] The weight matrix of other size transform blocks can be obtained by the same method. It should be noted that when the weight matrix of a large size transform block is calculated, the coefficient matrix X T may not be full rank, and thus the inverse matrix of X T ·X does not exist, and thus the weight matrix of a larger size can be obtained by extending the 8x8 weight matrix. The weight matrix of a larger size can be calculated according to the following extension formula:
[0082]
[0083]
[0084]
[0085]
[0086] Based on the construction manner of the weight matrix, by constructing the weight matrix of different sizes and types of transform blocks in advance, when the coefficient transformation and quantization of a transform block are completed, the weight matrix corresponding to the current transform block is selected according to the type and size of the transform block. For example, when the code rate of a 4x4 Inter block is estimated, the weight matrix W inter_4×4 The estimated code rate is further calculated.
[0087] S120, obtaining a second coefficient transformation result by multiplying the second coefficient vector of the current transform block by a set index, the second coefficient vector comprising absolute values of the second quantized transform coefficients of the current transform block.
[0088] On the other hand, referring to the calculation formula of the estimated code rate, when the encoding code rate of the current transform block is calculated, the coefficient transformation result composed of the 0.5th power of the absolute values of the transform coefficients needs to be determined, which is defined as the second coefficient transformation result.
[0089] Then, referring to the determination manner of the first coefficient transformation result, the second coefficient transformation result is obtained by multiplying the second coefficient vector of the current transform block by a set index. Referring to Figure 4 , the determination process of the second coefficient transformation result comprises:
[0090] S1201, determining the second quantized transform coefficients at each position of the current transform block, and constructing a second coefficient vector based on the absolute values of the second quantized transform coefficients and a fixed constant;
[0091] S1202, multiplying the second coefficient vector by a set index to obtain the second coefficient transformation result.
[0092] For example, taking an 8x8 Intra block as an example, the quantized transform coefficients X l00 X l01 X l02 ... of the current transform block are determined element by element in a row scanning manner, which are defined as the second quantized transform coefficients. The initial coefficient vector thereof is X l ′=[X l00 X l01 X l02 …X l07 X l10 …X l17 …X l70 X l71 …X l77 1]. Then, a second coefficient vector is constructed based on the absolute values of the second quantized transform coefficients and a fixed constant, that is, ∣X l ∣=[∣X l00 ∣∣X l01 ∣∣X l02|…|X l77 |1]. Multiplying the second coefficient vector by the set exponent yields the second coefficient transformation result X. l =[|X l00 | 0.5 |X l01 | 0.5 |X l02 | 0.5 …|X l77 | 0.5 [1], thus completing the construction of the second coefficient vector.
[0093] S130. Calculate the estimated code rate of the current transform block based on the transformation result of the second coefficient and the weight matrix.
[0094] Finally, based on the determined second coefficient transformation result and weight matrix, the estimated bitrate of the current transform block can be calculated according to the bitrate estimation formula (5) above. Specifically, each coefficient in the second coefficient transformation result is multiplied by each weight of the weight matrix to obtain an estimated value, and the sum of these estimated values yields the estimated bitrate R of the current transform block. est For example, taking an 8x8 Intra block as an example, the result X based on the second coefficient transformation mentioned above... l and weight matrix W intra_8×8 The estimated code rate R of the current transform block est Represented as:
[0095] R est =X l W intra_8×8
[0096] Understandably, the second coefficient transformation result contains 64 coefficients and a constant 1. By traversing the 64 coefficients and the constant term 1, and comparing them with the weight matrix W... intra_8×8 By multiplying and summing the 65 weights, the estimated number of bits R can be obtained. est This completes the bitrate estimation process for the current transform block.
[0097] For example, such as Figure 5 As shown, referring to steps a1 to a6, when performing bitrate estimation, a pre-constructed weight matrix is selected by the size and type of the transform block, and its coefficient transformation result is calculated. Then, the estimated bitrate of the current transform block can be calculated based on the second coefficient transformation result and the weight matrix.
[0098] The estimated code rate of a transform block is calculated by converting the code rate estimation problem of the transform block into a problem of solving the self-information amount of the quantized transform coefficients of the transform block, using a weight matrix and the coefficient transform result. On the one hand, the weight matrix can accurately represent the self-information amount of each quantized transform coefficient of the transform block, and in combination with the coefficient transform result of the transform block, the encoding code rate of the transform block can be accurately estimated without actually performing the encoding process on the transform block to determine the encoding code rate, thereby reducing the time consumption of code rate determination and improving the code rate estimation efficiency while ensuring the accuracy of code rate estimation. Furthermore, when the rate-distortion optimization technology (RDO) is used to determine the optimal encoding mode, the estimated code rate of a transform block encoded in different encoding modes can be quickly determined, and in combination with the distortion rate of the transform block, the encoding cost of the transform block in different encoding modes can be determined, and finally the optimal encoding mode of the current transform block is determined according to the encoding cost.
[0099] Optionally, in order to further improve the code rate estimation efficiency, the embodiments of the present application also query the pre-constructed coefficient value table based on each coefficient in the second coefficient vector to determine the value of each coefficient in the second coefficient transform result. The coefficient value table is pre-constructed according to the multiplication result of the value range of each coefficient in the second coefficient vector and the set index.
[0100] It can be understood that since the absolute value of each quantized transform coefficient needs to be raised to the power of 0.5, and the quantized coefficient is generally an integer, the absolute value becomes a positive integer after taking the absolute value. At the same time, the value range is small, and the value range is limited to 0-512 in the embodiments of the present application. Therefore, the system can pre-solve the 0.5 power of 0-512 to form a fixed coefficient value table. Then, when calculating the estimated code rate of the current transform block, the value of each coefficient in the second coefficient transform result can be determined according to the initial quantized transform coefficient by querying the coefficient value table. In this way, repeated coefficient square root operations can be saved, and the code rate estimation efficiency is further improved by using the table lookup method. It should be noted that when the value of each coefficient in the second coefficient vector is determined by table lookup, if the amplitude of a certain quantized transform coefficient in the second coefficient vector is greater than 512, the value can be truncated to 512, thereby reducing the time consumption of calculation.
[0101] Optionally, when the estimated code rate of the current transform block is calculated based on the second coefficient transform result and the weight matrix, each non-zero coefficient in the second coefficient transform result is multiplied by the corresponding weight value of the weight matrix to obtain each estimated value, and the coefficient with a value of zero is skipped.
[0102] By optimizing the traversal condition, when traversing the second coefficient transformation result in the scanning order, only the first coefficient to the last non-zero coefficient can be traversed, and the calculation process of the coefficients with a value of 0 is skipped. It can be understood that when the coefficient is 0, the multiplication of the coefficient and the corresponding weight in the weight matrix is still 0, and these coefficients do not contribute to the bit number. By skipping the calculation of these coefficients, the number of calculations can be greatly reduced, the calculation time can be saved, and the efficiency of the code rate estimation can be improved.
[0103] In addition, in an embodiment, the weight matrix can also be enlarged by a first set multiple, so that each weight value of the weight matrix is an integer, and the coefficient value table is enlarged by a second set multiple, so that each coefficient value of the coefficient value table is an integer; then, when calculating the estimated code rate of the current transformation block according to the second coefficient transformation result and the weight matrix, the multiplication result of the second coefficient transformation result and the weight matrix is calculated, and the multiplication result is reduced by the first set multiple and the second set multiple to obtain the estimated code rate.
[0104] It can be understood that if there are decimals in the coefficient value table and the weight matrix, too many floating point operations will be caused. In order to reduce the floating point operations, the coefficient value table and the weight matrix are enlarged, so as to avoid the floating point operations. For example, the weight matrix is enlarged by multiplying 256, so that all the weight values of the weight matrix become integers. Similarly, all the coefficient values of the coefficient value table are enlarged to integers by multiplying 128, so that all the coefficient values are integers. Then, after calculating the multiplication result of the second coefficient transformation result and the weight matrix, the multiplication result is reduced according to the enlargement multiple to obtain the final estimated code rate.
[0105] The above, by pre-constructing the weight matrix according to the first coefficient transformation result and the encoding code rate of a plurality of encoded transformation blocks. Subsequently, in the case that the coefficient transformation and quantization of the current transformation block are completed, the weight matrix of the current transformation block is selected, and the second coefficient transformation result is obtained based on the second coefficient vector of the current transformation block and a set index power. Then, the estimated code rate of the current transformation block is calculated according to the second coefficient transformation result and the weight matrix. By using the above technical means, the weight matrix is pre-constructed by the encoding code rate and the coefficient transformation result of the encoded transformation block, and then the estimated code rate of the current transformation block is calculated according to the pre-constructed weight matrix and the coefficient transformation result of the current transformation block. In this way, the code rate calculation efficiency can be improved, and the estimated code rate of the transformation block can be quickly determined. Moreover, since the weight matrix is constructed according to the coefficient transformation result and the encoding code rate of the encoded module, the weight matrix has sufficient universality, and the estimated code rate calculated by the weight matrix meets the accuracy requirement of the code rate calculation.
[0106] In addition, the present scheme can quickly determine the value of each coefficient in the coefficient vector by pre-constructing the coefficient value table, so as to shorten the calculation time and further improve the efficiency of the code rate estimation.
[0107] On the basis of the above embodiments, Figure 6 A structure diagram of a code rate estimation system based on quantized transform coefficients is provided in the present application. Referring to Figure 6 The code rate estimation system based on quantized transform coefficients provided in the embodiment specifically comprises a selection module 21, a transform module 22 and a calculation module 23.
[0108] The selection module 21 is configured to select a weight matrix of the current transform block in the case that the coefficient transform and quantization of the current transform block are completed, the weight matrix being constructed in advance according to a first coefficient transform result of a plurality of coded transform blocks and a coding code rate, the first coefficient transform result being obtained by multiplying a first coefficient vector by a set index, the first coefficient vector comprising absolute values of first quantized transform coefficients of the coded transform blocks, and the set index being determined according to a probability density distribution law of the quantized transform coefficients in different training images.
[0109] The transform module 22 is configured to obtain a second coefficient transform result by multiplying a second coefficient vector of the current transform block by the set index, the second coefficient vector comprising absolute values of second quantized transform coefficients of the current transform block.
[0110] The calculation module 23 is configured to calculate an estimated code rate of the current transform block according to the second coefficient transform result and the weight matrix.
[0111] Specifically, the construction process of the weight matrix comprises:
[0112] According to the probability density distribution law of the quantized transform coefficients in different training images, shape parameters of generalized Gaussian distribution of the transform blocks in each training image are determined as the set index.
[0113] Quantized transform coefficients at each position of the transform blocks in the training image are scanned, and each first coefficient vector is constructed based on the absolute values of the quantized transform coefficients at each position and a fixed constant.
[0114] A coefficient matrix is constructed based on each first coefficient vector, the first coefficient transform result is obtained by multiplying the coefficient matrix by the set index, and the weight matrix is constructed according to the coding code rate of the transform blocks in the training image and the first coefficient transform result.
[0115] Specifically, the absolute values of each quantized transform coefficient in the first coefficient vector are sorted in the row scanning order of the transform block, and the fixed constant is placed at the end of the first coefficient vector.
[0116] Specifically, the weight matrix is constructed in advance according to the sizes and types of different transform blocks.
[0117] The selection of the weight matrix of the current transform block comprises:
[0118] Select a pre-constructed weight matrix according to the size and type of the current transform block.
[0119] Specifically, the second coefficient transform result is obtained by multiplying the second coefficient vector of the current transform block by a set exponent.
[0120] The second quantized transform coefficient of each position of the current transform block is determined, and a second coefficient vector is constructed based on the absolute value of the second quantized transform coefficient and a fixed constant.
[0121] The second coefficient vector is multiplied by a set exponent to obtain the second coefficient transform result.
[0122] Specifically, the estimated code rate of the current transform block is calculated according to the second coefficient transform result and the weight matrix, including:
[0123] Each coefficient in the second coefficient transform result is multiplied by each weight value in the weight matrix to obtain each estimated value, and the estimated values are accumulated to obtain the estimated code rate of the current transform block.
[0124] Specifically, each coefficient in the second coefficient transform result is multiplied by each weight value in the weight matrix to obtain each estimated value, including:
[0125] According to the scanning order, each non-zero coefficient in the second coefficient transform result is multiplied by the corresponding weight value in the weight matrix to obtain each estimated value, and the coefficient calculation of the value of zero is skipped.
[0126] The second coefficient transform result is obtained by multiplying the second coefficient vector of the current transform block by a set exponent, including:
[0127] Specifically, the value of each coefficient in the second coefficient transform result is determined by querying a pre-constructed coefficient value table based on each coefficient in the second coefficient vector, and the coefficient value table is pre-constructed according to the value range of each coefficient in the second coefficient vector and the multiplication result of the set exponent.
[0128] Specifically, before calculating the estimated code rate of the current transform block according to the second coefficient transform result and the weight matrix, it further includes:
[0129] The weight matrix is enlarged by a first set multiple to make each weight value of the weight matrix an integer, and the coefficient value table is enlarged by a second set multiple to make each coefficient value of the coefficient value table an integer.
[0130] The estimated code rate of the current transform block is calculated according to the second coefficient transform result and the weight matrix, further including:
[0131] The multiplication result of the second coefficient transform result and the weight matrix is calculated, and the multiplication result is reduced by a first set multiple and a second set multiple to obtain the estimated code rate.
[0132] The weight value matrix is constructed in advance according to the first coefficient transformation result and the coding rate of the plurality of coded transform blocks. When the coefficient transformation and quantization of the current transform block are completed, the weight value matrix of the current transform block is selected, and the second coefficient transformation result is obtained based on the second coefficient vector of the current transform block and the set index. Then, the estimated coding rate of the current transform block is calculated according to the second coefficient transformation result and the weight value matrix. By using the above technical means, the weight value matrix is constructed in advance according to the coding rate and the coefficient transformation result of the coded transform block, and then the estimated coding rate of the current transform block is calculated according to the pre-constructed weight value matrix and the coefficient transformation result of the current transform block, so that the coding rate calculation efficiency can be improved, and the estimated coding rate of the transform block can be quickly determined. Moreover, the weight value matrix is constructed according to the coefficient transformation result and the coding rate of the coded module, and has sufficient universality, so that the estimated coding rate obtained by calculation meets the accuracy requirement of the coding rate calculation.
[0133] In addition, the coefficient value table is pre-constructed, so that the values of the coefficients in the coefficient vector can be quickly determined, the time consumption for calculation can be shortened, and the efficiency of the coding rate estimation is further improved.
[0134] The coding rate estimation system based on quantized transform coefficients provided by the embodiments of the present application can be configured to execute the coding rate estimation method based on quantized transform coefficients provided by the above embodiments, and has corresponding functions and advantages.
[0135] On the basis of the above actual examples, the embodiments of the present application further provide a coding rate estimation device based on quantized transform coefficients, which refers to Figure 7 The coding rate estimation device based on quantized transform coefficients includes a processor 31, a memory 32, a communication module 33, an input device 34, and an output device 35. The memory is a computer-readable nonvolatile storage medium, and can be configured to store software programs, computer executable programs, and modules, such as program instructions / modules corresponding to the coding rate estimation method based on quantized transform coefficients (for example, the selection module, the transformation module, and the calculation module in the coding rate estimation system based on quantized transform coefficients) described in any embodiment of the present application. The communication module is configured to perform data transmission. The processor executes the software programs, instructions, and modules stored in the memory, thereby performing various function applications and data processing of the device, that is, implementing the coding rate estimation method based on quantized transform coefficients. The input device can be configured to receive input digital or character information, and generate key signal input related to the user settings and function control of the device. The output device can include a display device such as a display screen. The coding rate estimation device based on quantized transform coefficients provided above can be configured to execute the coding rate estimation method based on quantized transform coefficients provided by the above embodiments, and has corresponding functions and advantages.
[0136] On the basis of the above-mentioned embodiments, the embodiments of the present application further provide a computer readable nonvolatile storage medium, the computer readable nonvolatile storage medium stores computer executable instructions, the computer executable instructions are configured to execute a code rate estimation method based on quantized transform coefficients when executed by a computer processor. The nonvolatile storage medium can be any of various types of memory devices or storage devices. Of course, the computer executable instructions of the computer readable nonvolatile storage medium provided by the embodiments of the present application are not limited to the code rate estimation method based on quantized transform coefficients as described above, but can also execute the related operations in the code rate estimation method based on quantized transform coefficients provided by any of the embodiments of the present application.
[0137] On the basis of the above-mentioned embodiments, the embodiments of the present application further provide a computer program product, the technical solutions of the present application essentially or say the part that contributes to the prior art or the whole or part of the technical solutions can be embodied in the form of a software product. The computer program product is stored in a nonvolatile storage medium and includes a plurality of instructions for causing a computer device, a mobile terminal or a processor therein to execute all or part of the steps of the code rate estimation method based on quantized transform coefficients described in the embodiments of the present application.
Claims
1. A method of bit rate estimation based on quantized transform coefficients, characterized by, The method comprises the following steps: In the case of completing the coefficient transformation and quantization of the current transform block, a weight matrix of the current transform block is selected, the weight matrix being constructed in advance according to a first coefficient transformation result of a plurality of coded transform blocks and a coding code rate, the first coefficient transformation result being obtained by multiplying a first coefficient vector and a set index, the first coefficient vector comprising absolute values of first quantized transform coefficients of the coded transform blocks, the set index being determined according to a probability density distribution law of the quantized transform coefficients in different training images; the construction process of the weight matrix comprises the following steps: determining shape parameters of a generalized Gaussian distribution of the transform blocks in each training image as the set index based on the probability density distribution law of the quantized transform coefficients in the different training images; scanning the quantized transform coefficients of each position of the transform blocks in the training image, and constructing each first coefficient vector based on the absolute values of the quantized transform coefficients of each position and a fixed constant; constructing a coefficient matrix based on each first coefficient vector, multiplying the coefficient matrix and the set index to obtain the first coefficient transformation result, and constructing the weight matrix according to the coding code rate of the transform blocks in the training image and the first coefficient transformation result; a second coefficient transformation result is obtained by multiplying a second coefficient vector of the current transform block and the set index, the second coefficient vector comprising absolute values of second quantized transform coefficients of the current transform block; an estimated code rate of the current transform block is calculated according to the second coefficient transformation result and the weight matrix.
2. The method for quantization transform coefficient based bit rate estimation according to claim 1, wherein, The absolute values of each quantized transform coefficient in the first coefficient vector are arranged in a row scanning order of the transform block, and the fixed constant is arranged at the end of the first coefficient vector.
3. The method for quantization transform coefficient based bit rate estimation according to claim 1, wherein, The weight matrix is constructed in advance according to the size and type of different transform blocks; The selection of the weight matrix of the current transform block comprises the following steps: The pre-constructed weight matrix is selected according to the size and type of the current transform block.
4. The method for quantization transform coefficient based bit rate estimation according to claim 1, wherein, The second coefficient transformation result is obtained by multiplying the second coefficient vector of the current transform block and the set index, which comprises the following steps: Second quantized transform coefficients of each position of the current transform block are determined, and the second coefficient vector is constructed based on the absolute values of the second quantized transform coefficients and a fixed constant; The second coefficient transformation result is obtained by multiplying the second coefficient vector and the set index.
5. The method for quantized transform coefficient based bit rate estimation according to claim 1, wherein, The estimated code rate of the current transform block is calculated according to the second coefficient transformation result and the weight matrix, which comprises the following steps: Each coefficient in the second coefficient transformation result is multiplied by each weight value of the weight matrix to obtain an estimated value, and the estimated code rate of the current transform block is obtained by accumulating the estimated values.
6. The method for bit rate estimation based on quantized transform coefficients according to claim 5, wherein, Each coefficient in the second coefficient transformation result is multiplied by each weight value of the weight matrix to obtain an estimated value, which comprises the following steps: Each non-zero coefficient in the second coefficient transformation result is multiplied by a corresponding weight value of the weight matrix to obtain an estimated value in a scanning order, and the coefficients with a value of zero are skipped.
7. The method of rate estimation based on quantized transform coefficients according to claim 1, wherein, The second coefficient transformation result is obtained by multiplying the second coefficient vector of the current transform block and the set index, which comprises the following steps: querying a pre-constructed coefficient value table according to each coefficient in the second coefficient vector to determine the value of each coefficient in the second coefficient transformation result, the coefficient value table being constructed in advance according to the value range of each coefficient in the second coefficient vector and the power result of a set index.
8. The method for bit rate estimation based on quantized transform coefficients according to claim 7, wherein, Before calculating the estimated code rate of the current transform block according to the second coefficient transformation result and the weight matrix, further comprising: scaling the weight matrix by a first set multiple to make each weight value of the weight matrix an integer, and scaling the coefficient value table by a second set multiple to make each coefficient value of the coefficient value table an integer; calculating the estimated code rate of the current transform block according to the second coefficient transformation result and the weight matrix, further comprising: calculating the multiplication result of the second coefficient transformation result and the weight matrix, and scaling the multiplication result by the first set multiple and the second set multiple to obtain the estimated code rate.
9. A system for code rate estimation based on quantized transform coefficients, characterized in that, comprising: a selecting module configured to select the weight matrix of the current transform block in the case that the coefficient transformation and quantization of the current transform block are completed, the weight matrix being constructed in advance according to the first coefficient transformation result of a plurality of coded transform blocks and the coding code rate, the first coefficient transformation result being obtained by multiplying the first coefficient vector by a set index, the first coefficient vector comprising the absolute value of the first quantized transform coefficient of the coded transform block, and the set index being determined according to the probability density distribution law of the quantized transform coefficient in different training images; the construction process of the weight matrix comprising: determining the shape parameter of the generalized Gaussian distribution of the transform block in each training image as the set index based on the probability density distribution law of the quantized transform coefficient in different training images; scanning the quantized transform coefficient of each position of the transform block in the training image, and constructing each first coefficient vector based on the absolute value of the quantized transform coefficient of each position and a fixed constant; constructing a coefficient matrix based on each first coefficient vector, multiplying the coefficient matrix by the set index to obtain the first coefficient transformation result, and constructing the weight matrix according to the coding code rate of the transform block in the training image and the first coefficient transformation result; a transforming module configured to obtain the second coefficient transformation result by multiplying the second coefficient vector of the current transform block by the set index, the second coefficient vector comprising the absolute value of the second quantized transform coefficient of the current transform block; a calculating module configured to calculate the estimated code rate of the current transform block according to the second coefficient transformation result and the weight matrix.
10. A code rate estimation device based on quantized transform coefficients, characterized by, comprising: a memory and one or more processors; the memory is configured to store one or more programs; when the one or more programs are executed by the one or more processors, the one or more processors implement the quantized transform coefficient-based code rate estimation method according to any one of claims 1-8.
11. A computer-readable non-transitory storage medium, comprising: The computer-readable non-volatile storage medium stores computer-executable instructions which, when executed by a computer processor, are configured to perform the quantized transform coefficient-based code rate estimation method according to any one of claims 1-8.
12. A computer program product, characterised in that, The computer program product comprises instructions which, when executed on a computer or processor, cause the computer or processor to carry out the method of estimating a code rate based on quantized transform coefficients according to any of claims 1-8.
Citation Information
Patent Citations
On-board non-registering multispectral image lossless / lossy encoding system and on-board non-registering multispectral image lossless / lossy encoding method
CN103297776A
H.264 self-adaptation intra-frame mode selection code rate estimated rate-distortion optimization method and device thereof
CN103581670A