Detailed Description
In order to make the objects, technical solutions and advantages of the present application more apparent, the following detailed description of specific embodiments of the present application is given with reference to the accompanying drawings. It is to be understood that the specific embodiments described herein are merely illustrative of the application and are not limiting thereof. It should be further noted that, for convenience of description, only some, but not all of the matters related to the present application are shown in the accompanying drawings. 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 a flowchart depicts operations (or steps) as a sequential process, many of the operations can be performed in parallel, concurrently, or at the same time. Furthermore, the order of the operations may be rearranged. The process may be terminated when its operations are completed, but may have additional steps not included in the figures. The processes may correspond to methods, functions, procedures, subroutines, and the like.
The application provides a rate distortion optimization quantization method for video coding, which aims at selecting a bit consumption estimation step with less influence on coding quality by a skipped part in the entropy coding bit estimation process of rate distortion optimization quantization, and using a fixed value to represent a bit estimation result so as to shorten the time consumption of rate distortion optimization quantization and realize the optimization of a rate distortion optimization quantization flow on the premise of ensuring the coding quality.
In the related video coding scene, the computational complexity of the coding process is relatively large for the benefit of video coding performance. For the rate-distortion optimized quantization flow therein, the whole process takes a long time. However, in specific applications, there are some encoders and encoding scenes that have near-severe requirements on real-time performance, and due to different services, the features of the sequences to be encoded are different, such as natural video with intense and irregular motion and video based on live broadcast, and the effects of using different algorithms are different. For the scenes with higher real-time requirements of the video coding, the complex rate-distortion optimization quantization flow is difficult to reach the real-time requirements. Based on the above, the rate distortion optimization quantization method for video coding provided by the embodiment of the application optimizes the rate distortion optimization quantization flow, improves video coding efficiency, and solves the technical problem that the correlation rate distortion optimization quantization scheme takes longer time.
Examples:
Fig. 1 is a flowchart of a rate-distortion optimization quantization method for video coding according to an embodiment of the present application, where the rate-distortion optimization quantization method for video coding provided in the embodiment may be implemented by a rate-distortion optimization quantization device for video coding, where the rate-distortion optimization quantization device for video coding may be implemented by software and/or hardware, and the rate-distortion optimization quantization device for video coding may be configured by two or more physical entities or may be configured by one physical entity. In general, the rate-distortion optimized quantization device for video encoding may be an encoder device, a computer, a mobile phone, a tablet, or the like.
The following description will take the main body of the rate-distortion optimized quantization apparatus for video encoding as an example to perform the rate-distortion optimized quantization method for video encoding. Referring to fig. 1, the rate-distortion optimized quantization method for video coding specifically includes:
S110, in the entropy coding bit estimation process of rate distortion optimization quantization, according to the set first fixed value, representing first bit consumption information required by coding when the coefficient to be coded of the current pixel point is greater than 1, and calculating the optimal quantization coefficient of the current pixel point based on the first fixed value;
S120, calculating the rate distortion cost of the current pixel point code as the last non-zero coefficient based on the second fixed value according to the second bit consumption information which is set to the second fixed value and indicates the current pixel point to be marked as the last non-zero bit of the current transformation unit.
In the rate-distortion optimization quantization process of video coding, partial steps of the entropy coding bit estimation process are screened and skipped, partial bit estimation steps with less influence on the video coding quality, which are the result of rate-distortion optimization quantization, are selected and skipped, so that the optimization of the rate-distortion optimization quantization process is realized, the time consumption of rate-distortion optimization quantization is shortened, and the video coding efficiency is improved.
The Rate distortion optimization quantization algorithm combines the quantization process of video coding with the Rate distortion optimization principle, and determines the optimal quantization value of each non-zero coefficient and the position of the last non-zero coefficient by utilizing the RDO (Rate-distortion optimization) criterion, so that the coding distortion is as small as possible under the condition that the code Rate meets the target code Rate. In the rate-distortion optimization quantization process, for the accuracy of the result, the coding coefficient of each pixel point is respectively provided with an entropy coding context environment so as to calculate the accurate rate consumption. Because the entropy coding bit estimation process needs to consume a certain time, according to the actual test, the application discovers that omitting some entropy coding bit estimation steps can obtain better cost performance, namely, the coding quality is ensured not to be excessively lost, and meanwhile, the rate distortion optimization quantization process can be optimized, and the coding efficiency is improved. Therefore, the application sets the bit consumption estimation result as a fixed value by adaptively selecting the corresponding bit consumption estimation flow of the entropy coding bit estimation process, thereby omitting the calculation of the bit consumption estimation result and realizing the simplification of the rate distortion optimization quantization process.
As shown in fig. 2, in the rate-distortion optimization quantization process, each pixel of the transform unit is uniformly quantized first, and candidate quantization values of coding coefficients of each pixel are determined, and then non-zero coefficients are counted numsig. If numsig =0, direct return 0 (the number of non-zero coefficients of the function return value), otherwise, the algorithm continues to determine the preliminary position of the last non-zero coefficient in the transform unit from the result of uniform quantization. The transform unit TU is segmented into a plurality of 4x4 unit quantized blocks CG, and the quantization is performed block by block starting from the quantized block CG where the last non-zero coefficient is located. The quantization block CG and its internal scan order are determined by the variable scantype and are divided into horizontal, vertical and diagonal. For intra blocks, variable scantype relates to the angle of intra prediction, and for inter blocks, variable scantype is fixed to diag. Rate-distortion optimized quantization is performed for each quantization block CG. Firstly, calculating rate distortion cost of different candidate quantized values according to a candidate quantized value table, selecting an optimal quantized value, and then hiding data needed by a symbol after calculation. The update context model then attempts to quantize the current quantized block CG to all zero CG. If the rate-distortion cost decreases, the previous optimal quantization value is discarded and the quantization coefficients are set to all zeros. And then judging whether the transformation unit TU is quantized into all-zero blocks, fine-tuning the position of the last non-zero coefficient in each quantized block CG, recalculating the number numsig of the non-zero coefficients, and hiding the symbol by 0.
In the rate-distortion optimized quantization process, all zeros of the coding coefficient are detected first. If the transform unit is not all zeros, entropy encoding bit estimation is started to determine the optimal quantization coefficients and rate distortion costs based on the result. Since the rate distortion optimization quantization is large in calculation amount, bit consumption required for coding different symbols is calculated through the pre-reading entropy coding model.
Wherein, the following four entropy coding contexts need to be estimated in the process:
struct EstBitsSbacSimple
{
int32_t greaterOneBits[16][2];
int32_t significantBits[2][8];
int32_t significantCoeffGroupBits[NUM_SIG_CG_FLAG_CTX][2];
int32_t lastBits[2][10];
};
Wherein significantBits and significantCoeffGroupBits represent the context of coding significant bits, and practical tests show that the coding significant bits cannot be optimized, and have a large influence on coding quality. And greaterOneBits represents bit consumption of the pixel point when the coefficient to be encoded is greater than 1, namely the first bit consumption information, and experiments prove that omitting the part of bit estimation flow, the influence on encoding quality is smaller by using a specified value instead. In addition, in the assembly realization of codes, operations such as rearrangement, shuffling and the like are needed for processing the syntax elements, the realization is not easy in an arm instruction set, and the delay is high. Therefore, the embodiment of the application sets a fixed value instead of the bit consumption information greaterOneBits, and defines the fixed value as the first fixed value, so as to reduce the time consumption of rate-distortion optimization quantization. In addition, lastBits indicates the bit consumption required for marking the current pixel point as the last non-zero bit of the current transformation unit, namely the second bit consumption information, and the entropy coding estimation flow of the symbol has less influence on the coding quality, which is omitted. The fixed value is defined as a second fixed value by setting a fixed value instead of the bit consumption information lastBits.
The optimal quantization coefficients of the current pixel point are then calculated directly using the contexts significantBits and significantCoeffGroupBits of the encoded significant bits of the above bit estimation operation, in combination with the above set first fixed value (i.e., the first bit consumption information corresponding to greaterOneBits). Since greaterOneBits has a small influence on the final result, the influence on the calculation result of the optimal quantization coefficient is small, and the coding quality is not excessively reduced. Likewise, using the second fixed value to represent the second bit consumption information, a rate-distortion cost for encoding the current pixel point into the last non-zero coefficient is calculated. Therefore, simplification of the entropy coding bit estimation flow can be realized, and the time consumption of rate distortion optimization quantization is shortened.
Illustratively, the bits consumed here are directly replaced with 0's by skipping the estimation model loading of the two-part bit consumption information at the time of bit estimation and deleting the corresponding data structure. The method is used for carrying out the subsequent optimal quantization coefficient calculation and rate distortion cost calculation, so that better coding acceleration can be obtained, assembly acceleration is facilitated, and unnecessary calculation amount is reduced. It should be noted that, in practical application, according to an actual test result, the first bit consumption property and the second bit consumption information adaptability may be set to corresponding fixed values, where the fixed values are combined with the actual coding acceleration requirement adaptability according to the bit consumption information of the actual test.
Specifically, as shown in fig. 3, calculating the rate-distortion cost of the current pixel point code as the last non-zero coefficient based on the second fixed value includes:
s1201, traversing each non-zero pixel point of the current transformation unit, and determining an estimated code rate required for coding the current pixel point;
s1202, calculating the rate distortion cost of the current pixel point coded as the last non-zero coefficient based on the estimated code rate and the second fixed value.
Based on the set second fixed value, when the last non-zero coefficient of the transformation unit is positioned later, the rate distortion cost of the last non-zero coefficient coded at the corresponding position of each pixel point needs to be calculated. The present application therefore uses this second fixed value to calculate the rate-distortion cost for the pixel-point code to be the last non-zero coefficient. And (3) calculating the rate distortion cost of the last non-zero coefficient coded by the current pixel point by determining the estimated code rate of the current pixel point and combining the second fixed value.
Wherein determining an estimated code rate required for encoding a current pixel point includes:
Determining a pixel value of a current pixel point, inquiring a pre-constructed mapping relation table based on the pixel value, determining an estimated code rate required for encoding the current pixel point, and constructing the mapping relation table in advance according to mapping relations between different pixel values and corresponding estimated code rates.
And estimating the code rate required by coding the current pixel point by using a table look-up method according to the numerical value of the pixel point, namely, the estimated code rate. It will be appreciated that the code rate consumption of different pixel values when encoding is different. The mapping relation is constructed by testing the code rate consumption of different pixel values in advance for coding. And then, the estimated code rate required by coding the current pixel point can be quickly determined by inquiring the mapping relation, so that the coding efficiency is further improved.
Calculating the rate distortion cost of the current pixel point coded as the last non-zero coefficient based on the estimated code rate and the second fixed value, including:
And acquiring the set rate-distortion cost influence coefficient and the set coefficient amplification information, determining initial rate consumption information according to the sum of the estimated code rate and the second fixed value, and calculating the rate-distortion cost of the last non-zero coefficient coded by the current pixel point based on the initial rate consumption information, the rate-distortion cost influence coefficient and the coefficient amplification information.
Based on the queried estimated code rate, adding bit consumption information (second fixed value) of lastBits flag bits, namely the code rate consumption of the current pixel point position code non-0, and defining the initial code rate consumption information. Based on the initial code rate consumption information, the set rate distortion cost influence coefficient and the set coefficient amplification information are combined, so that the rate distortion cost of the current pixel point coded as the last non-zero coefficient can be calculated. In addition, the original rate distortion cost calculation flow is complex, and the coding efficiency is further improved by simplifying the rate distortion cost calculation process. The original rate distortion cost calculation formula is as follows:
lastCoeffCost=lambda*(IEP_RATE*suffixLen+estBitsSbac.lastBits)>>bitsCostShift
Wherein lastCoeffCost represents the RATE distortion cost of the last non-zero coefficient encoded by the current pixel, suffixLen is the estimated code RATE of the pixel, estButssbac. Lastbits is the second bit consumption information of the last non-zero bit of the current conversion unit marked by the current pixel, lambda and bitsCostShift are both RATE distortion cost influence coefficients set in the RATE distortion calculation process, IEP_RATE is the original coefficient amplification information, and the value is 1< <15. Since the entropy coding model calculates the second bit consumption information consumption for calculation accuracy, the result is multiplied by iep_rate. Correspondingly, iep_rate also needs to be multiplied when calculating the RATE-distortion cost.
The present application optimizes the above calculation formula in view of its great influence on the coding complexity. Because the second bit consumption information estbmissbac.lastbits takes the value of the second fixed value, the embodiment of the application takes the value of the second fixed value as 0, and the estimated code rate suffixLen of the pixel point is used as the initial code rate consumption information to calculate the rate distortion cost. It can be seen that in the original RATE-distortion cost calculation formula, the estimated code RATE suffixLen is multiplied by iep_rate and lambda and then right shift has obvious calculation redundancy, and the reason is that the estBItssbac. In the above we have simplified the entropy coding model of estbmtssbac. Lastbits, using the second fixed value as the estbmtssbac. Lastbits, so the entropy coding bit consumption here is not calculated any more, and thus iep_rate can no longer be multiplied, as long as bitsCostShift minus 15, reducing the computational effort, essentially lossless. And in the actual consumption code RATE, IEP_RATE is not needed to be multiplied, so that the corresponding RATE distortion calculation formula is modified, the calculated amount can be obviously reduced, and the load of an encoder is reduced. The optimized rate distortion cost calculation formula is as follows:
lastcoeffcost=lambda*suffixLen>>(bitscostshift-log2_IEP_RATE)
after calculating the rate distortion cost of the current pixel point coded as the last non-zero coefficient based on the second fixed value, the method further comprises:
Traversing the non-zero pixel point forwards from the last non-zero pixel point of the current transformation unit, and selecting the non-zero pixel point corresponding to the rate distortion cost with the minimum value as the last non-zero coefficient position of the current transformation unit.
When the last non-zero coefficient is positioned, traversing from the last non-zero pixel point of the current transformation unit to the beginning all the way forward, and determining the rate distortion cost of each non-zero pixel point by referring to the rate distortion cost calculation mode. And then selecting the pixel point with the minimum rate distortion cost as the last non-zero coefficient position of the current transformation unit.
The method comprises the steps of traversing a set number of non-zero pixel points forwards from the last non-zero pixel point of a current transformation unit, determining the minimum cost from rate distortion costs corresponding to the set number of non-zero pixel points, and taking the non-zero pixel point corresponding to the minimum cost as the last non-zero coefficient position of the current transformation unit.
The last non-zero coefficient of most transform units is easier to locate at the later position of the block for statistical considerations, and the rate-distortion optimization process has initially decided whether the pixel point is to be quantized to all zeros, so it is not necessary to traverse all pixels completely. Based on this, the embodiment of the application traverses up to K non-zero coefficients for each transformation unit, from which the best last non-zero coefficient point is calculated. Therefore, the influence on the coding quality is extremely small, the last non-zero coefficient position of the current transformation unit can be accurately determined, and the coding efficiency is accelerated to a certain extent. Optionally, the application takes K as a value of 3, traverses 3 pixel points forwards from the last non-zero pixel point of the current transformation unit, selects the pixel point with the minimum rate distortion cost as the last non-zero coefficient position of the current transformation unit, and can better promote the coding efficiency while guaranteeing the coding quality according to the actual test.
According to the method, in the entropy coding bit estimation process of rate distortion optimization quantization, the optimal quantization coefficient of the current pixel point is calculated based on the first fixed value according to the first bit consumption information which is set by the first fixed value and is required by coding when the coefficient to be coded is larger than 1, and the rate distortion cost of the current pixel point coded as the last non-zero coefficient is calculated based on the second fixed value according to the second bit consumption information which is set by the second fixed value and is used for indicating that the current pixel point is marked as the last non-zero bit of the current conversion unit. By adopting the technical means, the bit consumption estimation step with less influence on the coding quality by the skipped part is selected in the entropy coding bit estimation process of rate-distortion optimization quantization, and the bit estimation result is represented by a fixed value, so that the time consumption of rate-distortion optimization quantization can be shortened on the premise of ensuring the coding quality, the optimization of the rate-distortion optimization quantization flow is realized, and the video coding efficiency is further improved.
Based on the above embodiments, fig. 4 is a schematic structural diagram of a rate-distortion optimization quantization system for video coding according to the present application. Referring to fig. 4, the rate-distortion optimized quantization system for video coding provided in this embodiment specifically includes a first optimizing module 21 and a second optimizing module 22.
The first optimizing module 21 is configured to skip bit consumption estimation of the current pixel point when the coefficient to be encoded is greater than 1 in the entropy encoding bit estimation process of rate distortion optimization quantization, and calculate an optimal quantization coefficient of the current pixel point based on the first fixed value according to the first bit consumption information required by the first fixed value to indicate that the current pixel point is encoded when the coefficient to be encoded is greater than 1;
The second optimization module 22 is configured to skip the bit consumption estimation of the current pixel marked as the last non-zero bit of the current transform unit, calculate the rate-distortion cost of the current pixel encoded as the last non-zero coefficient based on the second fixed value according to the second bit consumption information set to the second fixed value to indicate that the current pixel is marked as the last non-zero bit of the current transform unit.
Specifically, calculating the rate-distortion cost of the current pixel point code as the last non-zero coefficient based on the second fixed value includes:
And traversing each non-zero pixel point of the current transformation unit, determining an estimated code rate required for encoding the current pixel point, and calculating the rate distortion cost of the current pixel point encoded as the last non-zero coefficient based on the estimated code rate and the second fixed value.
Determining an estimated code rate required to encode a current pixel, comprising:
Determining a pixel value of a current pixel point, inquiring a pre-constructed mapping relation table based on the pixel value, determining an estimated code rate required for encoding the current pixel point, and constructing the mapping relation table in advance according to mapping relations between different pixel values and corresponding estimated code rates.
Calculating the rate distortion cost of the current pixel point coded as the last non-zero coefficient based on the estimated code rate and the second fixed value, including:
And acquiring the set rate-distortion cost influence coefficient and the set coefficient amplification information, determining initial rate consumption information according to the sum of the estimated code rate and the second fixed value, and calculating the rate-distortion cost of the last non-zero coefficient coded by the current pixel point based on the initial rate consumption information, the rate-distortion cost influence coefficient and the coefficient amplification information.
Specifically, after calculating the rate distortion cost of the current pixel point encoded as the last non-zero coefficient based on the second fixed value, the method further includes:
Traversing the non-zero pixel point forwards from the last non-zero pixel point of the current transformation unit, and selecting the non-zero pixel point corresponding to the rate distortion cost with the minimum value as the last non-zero coefficient position of the current transformation unit.
Traversing the non-zero pixel point forwards from the last non-zero pixel point of the current transformation unit, selecting the non-zero pixel point corresponding to the rate distortion cost with the minimum value as the last non-zero coefficient position of the current transformation unit, and comprising the following steps:
Traversing the set number of non-zero pixel points forwards from the last non-zero pixel point of the current transformation unit, determining the minimum cost from the rate distortion cost corresponding to the set number of non-zero pixel points, and taking the non-zero pixel point corresponding to the minimum cost as the last non-zero coefficient position of the current transformation unit.
According to the method, in the entropy coding bit estimation process of rate distortion optimization quantization, the optimal quantization coefficient of the current pixel point is calculated based on the first fixed value according to the first bit consumption information which is set by the first fixed value and is required by coding when the coefficient to be coded is larger than 1, and the rate distortion cost of the current pixel point coded as the last non-zero coefficient is calculated based on the second fixed value according to the second bit consumption information which is set by the second fixed value and is used for indicating that the current pixel point is marked as the last non-zero bit of the current conversion unit. By adopting the technical means, the bit consumption estimation step with less influence on the coding quality by the skipped part is selected in the entropy coding bit estimation process of rate-distortion optimization quantization, and the bit estimation result is represented by a fixed value, so that the time consumption of rate-distortion optimization quantization can be shortened on the premise of ensuring the coding quality, the optimization of the rate-distortion optimization quantization flow is realized, and the video coding efficiency is further improved.
The rate distortion optimization quantization system for video coding provided by the embodiment of the application can be configured to execute the rate distortion optimization quantization method for video coding provided by the embodiment of the application, and has corresponding functions and beneficial effects.
On the basis of the actual embodiment, the embodiment of the application also provides rate distortion optimization quantization equipment for video coding, which comprises a processor, a memory, a communication module, an input device and an output device. The memory is used as a computer readable storage medium and can be configured to store a software program, a computer executable program and a module, and the program instructions/modules (for example, a first optimization module and a second optimization module in a rate distortion optimization quantization system of video coding) corresponding to the rate distortion optimization quantization method of video coding according to any embodiment of the present application. The communication module is configured to perform data transmission. The processor executes various functional applications of the device and data processing by running software programs, instructions and modules stored in the memory, i.e., implements the rate-distortion optimized quantization method for video coding described above. The input means may be configured to receive input numeric or character information and to generate key signal inputs related to user settings and function control of the device. The output means may comprise a display device such as a display screen. The rate-distortion optimized quantization device for video coding provided above may be configured to execute the rate-distortion optimized quantization method for video coding provided in the above embodiment, and has corresponding functions and beneficial effects.
On the basis of the above embodiments, the present application further provides a computer-readable storage medium storing computer-executable instructions that, when executed by a computer processor, are configured to perform a rate-distortion optimized quantization method for video encoding, where the storage medium may be any of various types of memory devices or storage devices. Of course, the computer-readable storage medium provided by the embodiments of the present application has computer-executable instructions not limited to the rate-distortion optimization quantization method for video coding described above, but may also perform related operations in the rate-distortion optimization quantization method for video coding provided by any of the embodiments of the present application.
On the basis of the above embodiments, the embodiments of the present application further provide a computer program product, where the technical solution of the present application is essentially or a part contributing to the prior art or all or part of the technical solution may be embodied in the form of a software product, and the computer program product is stored in a storage medium, and includes several instructions to cause a computer device, a mobile terminal or a processor therein to execute all or part of the steps of the rate-distortion optimization quantization method for video coding according to the embodiments of the present application.