CN115278244A - Video quantization method and device, electronic equipment and storage medium - Google Patents

Video quantization method and device, electronic equipment and storage medium Download PDF

Info

Publication number
CN115278244A
CN115278244A CN202210945992.XA CN202210945992A CN115278244A CN 115278244 A CN115278244 A CN 115278244A CN 202210945992 A CN202210945992 A CN 202210945992A CN 115278244 A CN115278244 A CN 115278244A
Authority
CN
China
Prior art keywords
target
rate
coding
block
quantization
Prior art date
Legal status (The legal status is an assumption and is not a legal conclusion. Google has not performed a legal analysis and makes no representation as to the accuracy of the status listed.)
Pending
Application number
CN202210945992.XA
Other languages
Chinese (zh)
Inventor
简云瑞
黄跃
闻兴
Current Assignee (The listed assignees may be inaccurate. Google has not performed a legal analysis and makes no representation or warranty as to the accuracy of the list.)
Beijing Dajia Internet Information Technology Co Ltd
Original Assignee
Beijing Dajia Internet Information Technology Co Ltd
Priority date (The priority date is an assumption and is not a legal conclusion. Google has not performed a legal analysis and makes no representation as to the accuracy of the date listed.)
Filing date
Publication date
Application filed by Beijing Dajia Internet Information Technology Co Ltd filed Critical Beijing Dajia Internet Information Technology Co Ltd
Priority to CN202210945992.XA priority Critical patent/CN115278244A/en
Publication of CN115278244A publication Critical patent/CN115278244A/en
Pending legal-status Critical Current

Links

Images

Classifications

    • HELECTRICITY
    • H04ELECTRIC COMMUNICATION TECHNIQUE
    • H04NPICTORIAL COMMUNICATION, e.g. TELEVISION
    • H04N19/00Methods or arrangements for coding, decoding, compressing or decompressing digital video signals
    • H04N19/10Methods or arrangements for coding, decoding, compressing or decompressing digital video signals using adaptive coding
    • H04N19/102Methods or arrangements for coding, decoding, compressing or decompressing digital video signals using adaptive coding characterised by the element, parameter or selection affected or controlled by the adaptive coding
    • H04N19/124Quantisation
    • HELECTRICITY
    • H04ELECTRIC COMMUNICATION TECHNIQUE
    • H04NPICTORIAL COMMUNICATION, e.g. TELEVISION
    • H04N19/00Methods or arrangements for coding, decoding, compressing or decompressing digital video signals
    • H04N19/10Methods or arrangements for coding, decoding, compressing or decompressing digital video signals using adaptive coding
    • H04N19/134Methods or arrangements for coding, decoding, compressing or decompressing digital video signals using adaptive coding characterised by the element, parameter or criterion affecting or controlling the adaptive coding
    • H04N19/146Data rate or code amount at the encoder output
    • H04N19/147Data rate or code amount at the encoder output according to rate distortion criteria
    • HELECTRICITY
    • H04ELECTRIC COMMUNICATION TECHNIQUE
    • H04NPICTORIAL COMMUNICATION, e.g. TELEVISION
    • H04N19/00Methods or arrangements for coding, decoding, compressing or decompressing digital video signals
    • H04N19/10Methods or arrangements for coding, decoding, compressing or decompressing digital video signals using adaptive coding
    • H04N19/169Methods or arrangements for coding, decoding, compressing or decompressing digital video signals using adaptive coding characterised by the coding unit, i.e. the structural portion or semantic portion of the video signal being the object or the subject of the adaptive coding
    • H04N19/18Methods or arrangements for coding, decoding, compressing or decompressing digital video signals using adaptive coding characterised by the coding unit, i.e. the structural portion or semantic portion of the video signal being the object or the subject of the adaptive coding the unit being a set of transform coefficients

Landscapes

  • Engineering & Computer Science (AREA)
  • Multimedia (AREA)
  • Signal Processing (AREA)
  • Compression Or Coding Systems Of Tv Signals (AREA)

Abstract

The disclosure relates to a video quantization method, a video quantization device, an electronic device and a storage medium. The method comprises the following steps: under the condition of meeting preset optimization conditions, determining an optimal quantization value of each transformation coefficient of a target transformation block in video data according to a preset rate distortion optimization strategy, and determining a first rate distortion cost corresponding to the target transformation block, and under the condition that a component type corresponding to the target transformation block is a chrominance component, calculating a cost adjustment factor according to the target number of non-target values in each optimal quantization value and the area of the target transformation block. And adjusting the first rate distortion cost based on the cost adjustment factor to obtain a second rate distortion cost, and quantizing the target transform block based on the second rate distortion cost. By adjusting the first rate-distortion cost, the accuracy of determining the rate-distortion cost can be improved, thereby improving the encoding performance when video encoding is performed on the chrominance components.

Description

Video quantization method and device, electronic equipment and storage medium
Technical Field
The present disclosure relates to the field of video coding technologies, and in particular, to a video quantization method and apparatus, an electronic device, and a storage medium.
Background
With the development of the technical field of video coding, a video coding algorithm appears. In the video coding algorithm, quantization is a core process for achieving a good compression effect, and refers to mapping a continuous signal corresponding to video data into a plurality of discrete values.
In the related art, a rate distortion Optimization Quantization algorithm (RDOQ) is usually adopted for Quantization to improve video coding performance. In the calculation process of the algorithm, for each transform block of video data, the number of coded prediction bits corresponding to the transform block needs to be calculated, and the number of coded prediction bits represents the number of bits required for coding the all-zero flag of the transform block. Then, a rate-distortion cost is calculated from the number of coded prediction bits, thereby quantizing and coding the transform block based on the rate-distortion cost.
However, when determining the number of predicted bits for coding the transform block on the chroma component, a code rate estimation function is usually used for calculation, which results in a large error, resulting in relatively inaccurate rate-distortion cost obtained by calculation, and thus poor coding performance of RDOQ on coding the chroma component.
Disclosure of Invention
The disclosure provides a video quantization method, a video quantization device, an electronic device, and a storage medium, which are used for at least solving the problem that the coding performance of a chroma component is poor by an RDOQ algorithm in the related art. The technical scheme of the disclosure is as follows:
according to a first aspect of the embodiments of the present disclosure, there is provided a video quantization method, including:
under the condition of meeting a preset optimization condition, determining an optimal quantization value of each transformation coefficient of a target transformation block in video data according to a preset rate distortion optimization strategy, wherein the target transformation block is any one of a plurality of transformation blocks contained in the video data;
acquiring a first rate distortion cost corresponding to the target transform block, wherein the first rate distortion cost is obtained under the condition that the quantization values of the transform coefficients are all target values;
under the condition that the component type corresponding to the target transformation block is a chrominance component, calculating a cost adjustment factor according to the target number of non-target values in each optimal quantization value and the area of the target transformation block;
and adjusting the first rate distortion cost based on the cost adjustment factor to obtain a second rate distortion cost, and performing quantization processing on the target transformation block based on the second rate distortion cost.
In one embodiment, the obtaining the first rate-distortion cost corresponding to the target transform block includes:
calculating the number of distortion bits according to the difference between the optimal quantization value of each transformation coefficient and the target value;
determining a target coding identifier of the target transformation block corresponding to the situation that the quantization values of all transformation coefficients of the target transformation block are target values, and calculating a first coding prediction bit number for coding the target coding identifier through a preset coding bit number calculation model corresponding to a brightness component;
and calculating the first rate-distortion cost according to the distortion bit number and the first coding prediction bit number.
In one embodiment, the obtaining the first rate-distortion cost corresponding to the target transform block includes:
calculating the number of distortion bits according to the difference between the optimal quantization value of each transformation coefficient and the target value;
determining a target coding bit number calculation model corresponding to the target classification type according to the target component type corresponding to the target transformation block;
determining a target coding identifier of the target transformation block corresponding to the situation that the quantization values of all transformation coefficients of the target transformation block are target values, and calculating a second coding prediction bit number for coding the target coding identifier through the target coding bit number calculation model;
and calculating the first rate-distortion cost according to the distortion bit number and the second coding prediction bit number.
In one embodiment, before the step of determining the optimal quantization value of each transform coefficient of the target transform block in the video data according to a preset rate-distortion optimization strategy if a preset optimization condition is satisfied, the method further includes:
determining an optimization strategy threshold corresponding to the target transformation block according to the area of the target transformation block, wherein the optimization strategy threshold is in forward correlation with the area of the target transformation block;
counting the target number of the optimal quantization values of the non-target values in the optimal quantization values of the transformation coefficients of the target transformation block;
determining that the preset optimization condition is satisfied if the target number is less than or equal to the optimization policy threshold.
In one embodiment, the method further comprises:
if the target number is larger than the optimization strategy threshold value, determining that the preset optimization condition is not met;
under the condition that the preset optimization condition is not met, determining the optimal quantization value of each transformation coefficient of a target transformation block in the video data according to a preset rate distortion optimization strategy;
calculating the number of distortion bits according to the difference between the optimal quantization value and the target value of each transformation coefficient;
determining a target coding identifier of the target transformation block corresponding to the situation that the quantization values of all transformation coefficients of the target transformation block are target values, and calculating a first coding prediction bit number for coding the target coding identifier through a preset coding bit number calculation model corresponding to a brightness component;
and calculating the first rate distortion cost according to the distortion bit number and the first coding prediction bit number, and carrying out quantization processing on the target transformation block based on the first rate distortion cost.
In one embodiment, the calculating a cost adjustment factor according to the target number of non-target values in each optimal quantization value and the area of the target transform block includes:
calculating a target ratio of the target number of non-target values in each optimal quantized value to the area of the target transform block;
and determining a cost adjustment factor corresponding to the target ratio according to the corresponding relation between the preset ratio and the adjustment factor.
In one embodiment, the adjusting the first rate-distortion cost based on the cost adjustment factor to obtain a second rate-distortion cost includes:
and taking the product of the cost adjustment factor and the first rate-distortion cost as the second rate-distortion cost.
According to a second aspect of the embodiments of the present disclosure, there is provided a video quantization apparatus, including:
a first determining unit, configured to perform, in a case where a preset optimization condition is satisfied, determining an optimal quantization value of each transform coefficient of a target transform block in video data according to a preset rate-distortion optimization policy, where the target transform block is any one of a plurality of transform blocks included in the video data;
an obtaining unit configured to perform obtaining a first rate-distortion cost corresponding to the target transform block, where the first rate-distortion cost is obtained when the quantized value of each transform coefficient is a target value;
a first calculation unit configured to perform, in a case where the component type corresponding to the target transform block is a chroma component, calculating a cost adjustment factor according to a target number of non-target values in each of the optimal quantization values and an area of the target transform block;
and the adjusting unit is configured to perform adjustment on the first rate distortion cost based on the cost adjusting factor to obtain a second rate distortion cost, and perform quantization processing on the target transform block based on the second rate distortion cost.
In one embodiment, the obtaining unit includes:
a first calculation subunit configured to perform calculation of the number of distortion bits from a difference between the optimal quantization value of each transform coefficient and the target value;
a second calculation subunit configured to perform determining a target coding identifier of the target transform block corresponding to a case where quantization values of respective transform coefficients of the target transform block are all target values, and calculate a first coding prediction bit number for coding the target coding identifier through a coding bit number calculation model corresponding to a preset luminance component;
a third computing subunit configured to perform computing the first rate-distortion cost from the distortion bit number and a first code prediction bit number.
In one embodiment, the obtaining unit includes:
a fourth calculation subunit configured to perform calculation of the number of distortion bits according to a difference between the optimal quantization value of each transform coefficient and the target value;
a first determining subunit, configured to execute determining, according to a target component type corresponding to the target transform block, a target coding bit number calculation model corresponding to the target classification type, determine a target coding identifier of the corresponding target transform block when quantization values of transform coefficients of the target transform block are all target values, and calculate, through the target coding bit number calculation model, a second coding prediction bit number for coding the target coding identifier;
a fifth calculating subunit configured to perform calculating the first rate-distortion cost according to the distortion bit number and a second coding prediction bit number.
In one embodiment, the apparatus further comprises:
a second determining unit configured to determine an optimization strategy threshold corresponding to the target transform block according to the area of the target transform block, wherein the optimization strategy threshold is in forward correlation with the area of the target transform block;
a counting unit configured to perform counting of a target number of optimal quantization values of non-target values among the optimal quantization values of the respective transform coefficients of the target transform block;
an execution unit configured to execute determining that the preset optimization condition is satisfied if the target number is less than or equal to the optimization policy threshold.
In one embodiment, the apparatus further comprises:
a third determining unit configured to perform determining that the preset optimization condition is not satisfied if the target number is greater than the optimization policy threshold;
a second calculation unit configured to perform calculation of the number of distortion bits according to a difference between the optimal quantization value and a target value of each of the transform coefficients, in a case where the preset optimization condition is not satisfied;
a third calculation unit configured to perform determining a target coding identifier of the target transform block corresponding to a case where quantization values of respective transform coefficients of the target transform block are all target values, and calculating a first coding prediction bit number for coding the target coding identifier through a coding bit number calculation model corresponding to a preset luminance component;
a fourth calculation unit configured to calculate the first rate-distortion cost from the distortion bit number and the first coding prediction bit number, and perform quantization processing on the target transform block based on the first rate-distortion cost.
In one embodiment, the first computing unit includes:
a sixth calculation subunit configured to perform calculation of a target ratio of a target number of non-target values to an area of the target transform block in each of the optimal quantization values;
and the second determining subunit is configured to determine a cost adjustment factor corresponding to the target ratio according to a preset corresponding relationship between the ratio and the adjustment factor.
In one embodiment, the adjusting unit includes:
an adjusting subunit configured to perform a multiplication of the cost adjustment factor and the first rate-distortion cost as the second rate-distortion cost.
According to a third aspect of the embodiments of the present disclosure, there is provided an electronic apparatus including:
a processor;
a memory for storing the processor-executable instructions;
wherein the processor is configured to execute the instructions to implement the video quantization method of any of the first aspects.
According to a fourth aspect of embodiments of the present disclosure, there is provided a computer-readable storage medium, wherein instructions, when executed by a processor of an electronic device, enable the electronic device to perform the video quantization method according to any one of the first aspects.
According to a fifth aspect of embodiments of the present disclosure, there is provided a computer program product comprising instructions which, when executed by a processor of an electronic device, enable the electronic device to perform the video quantization method according to any one of the first aspects.
The technical scheme provided by the embodiment of the disclosure at least brings the following beneficial effects:
under the condition that preset optimization conditions are met, cost adjustment factors are calculated according to the area of a target transformation block and targets, which are not target values, in the optimal quantization values of all transformation coefficients of the target transformation block, under the condition that the component type corresponding to the current target transformation block is a chrominance component, first rate distortion costs corresponding to the target value quantization of all the transformation coefficients are adjusted based on the cost adjustment factors, the adjusted first rate distortion costs, namely second rate distortion costs, are obtained, and the target transformation block is quantized based on the second rate distortion costs. Thus, by adjusting the first rate-distortion cost, the accuracy of determining the rate-distortion cost can be improved, thereby improving the encoding performance when video encoding is performed on the chroma components.
It is to be understood that both the foregoing general description and the following detailed description are exemplary and explanatory only and are not restrictive of the disclosure.
Drawings
The accompanying drawings, which are incorporated in and constitute a part of this specification, illustrate embodiments consistent with the present disclosure and, together with the description, serve to explain the principles of the disclosure and are not to be construed as limiting the disclosure.
Fig. 1 is a flow diagram illustrating a method of video quantization according to an example embodiment.
Fig. 2 is a flowchart illustrating a step of calculating a first rate-distortion cost according to an exemplary embodiment.
Fig. 3 is a flowchart illustrating a step of calculating a first rate-distortion cost according to an exemplary embodiment.
Fig. 4 is a flowchart illustrating a step of determining an optimal quantization value for each transform coefficient according to an exemplary embodiment.
Fig. 5 is a flow chart illustrating steps of a quantization process in accordance with an exemplary embodiment.
Fig. 6 is a flowchart illustrating a step of calculating a first rate-distortion cost according to an exemplary embodiment.
Fig. 7 is a flowchart illustrating a step of determining an optimal quantization value according to an exemplary embodiment.
Fig. 8 is a schematic diagram illustrating according to an example embodiment.
Fig. 9 is a schematic diagram illustrating an exemplary embodiment.
Fig. 10 is a block diagram illustrating a video quantization apparatus according to an example embodiment.
FIG. 11 is a block diagram illustrating an electronic device in accordance with an example embodiment.
Detailed Description
In order to make the technical solutions of the present disclosure better understood by those of ordinary skill in the art, the technical solutions in the embodiments of the present disclosure will be clearly and completely described below with reference to the accompanying drawings.
It should be noted that the terms "first," "second," and the like in the description and claims of the present disclosure and in the above-described drawings are used for distinguishing between similar elements and not necessarily for describing a particular sequential or chronological order. It is to be understood that the data so used is interchangeable under appropriate circumstances such that the embodiments of the disclosure described herein are capable of operation in other sequences than those illustrated or described herein. The implementations described in the exemplary embodiments below are not intended to represent all implementations consistent with the present disclosure. Rather, they are merely examples of apparatus and methods consistent with certain aspects of the disclosure, as detailed in the appended claims.
It should also be noted that the user information (including but not limited to user device information, user personal information, etc.) and data (including but not limited to data for presentation, analyzed data, etc.) referred to in the present disclosure are both information and data that are authorized by the user or sufficiently authorized by various parties.
Video coding techniques include intra/inter prediction, transform, quantization, entropy coding, and the like. In the video encoding and decoding process, quantization is a core process for realizing a good compression effect of video data. Video data is generally transmitted in a continuous signal mode, and quantization refers to a process of mapping a signal corresponding to the video data into a plurality of discrete amplitudes, so that many-to-one mapping of the signal is realized, the dynamic range of the signal is reduced, and further, video data compression is realized, which is also an important reason for generating distortion.
Since quantization affects the distortion and the code rate of the video, a quantization algorithm with superior performance needs to be selected at the encoding end to improve the video encoding performance. The rate distortion optimization quantization algorithm is a quantization algorithm adopted by many Coding standards such as High Efficiency Video Coding (HEVC), general Video Coding (VVC), and inter-frame Coding (ECM). The RDOQ algorithm can select an optimal quantization value for each coefficient in the transform block through a Rate Distortion Optimized (RDO) algorithm, thereby significantly improving the encoding performance. However, since HEVC encoders, the coding performance of RDOQ on the luminance component is far higher than that of the chrominance component, and this characteristic continues into VVC and ECM encoders, mainly because RDOQ calculates, for each transform block of video data, the number of prediction bits for coding the transform block. Then, a rate-distortion cost is calculated from the number of coded prediction bits, thereby quantizing and coding the transform block based on the rate-distortion cost. However, when the number of predicted bits for coding a transform block on a chrominance component is calculated by using a rate estimation function, a large error exists, and RDOQ is poor in coding performance on the chrominance component. Accordingly, the present disclosure proposes a video quantization method that can improve the coding performance of a chrominance component.
Fig. 1 is a flowchart illustrating a video quantization method according to an exemplary embodiment, where the video quantization method is used in an electronic device as illustrated in fig. 1 and includes the following steps.
In step S110, in the case that a preset optimization condition is satisfied, an optimal quantization value of each transform coefficient of a target transform block in video data is determined according to a preset rate-distortion optimization strategy.
The target Transform block is any one of a plurality of Transform blocks included in the video data, and the target Transform block is a TU (Transform Unit) block, which is a Unit of quantization, that is, each TU block can be quantized in a video quantization process, so that quantization processing on all video data is realized. A target transform block may include information on a luminance component and information on a chrominance component. The preset rate-distortion optimization strategy may be predetermined by the electronic device.
In an implementation, an electronic device may obtain video data to be quantized. In this way, for video data to be quantized, the electronic device may obtain a plurality of transform blocks corresponding to the video data to be quantized, and randomly determine a target transform block among the plurality of transform blocks, so that, under the condition that the electronic device satisfies a preset optimization condition, the electronic device may determine, for each transform coefficient of a plurality of transform coefficients included in the target transform block, at least one optional quantization value corresponding to the transform coefficient, and calculate a rate distortion cost corresponding to each optional quantization value, respectively, and use an optional quantization value corresponding to a minimum rate distortion cost as an optimal quantization value of the transform coefficient. In this way, the electronic device can determine the optimal quantized values of the respective transform coefficients contained in the target transform block.
Optionally, the electronic device may also determine, according to an actual application scenario, a transform block from among a plurality of transform blocks corresponding to video data to be quantized, as a target transform block.
In step S120, a first rate-distortion cost corresponding to the target transform block is obtained.
Wherein the first rate-distortion cost is obtained when the quantization values of the transform coefficients are all target values, for example, the target value may be zero.
In an implementation, the electronic device may set quantization values of respective transform coefficients of the target transform block to target values. In this way, in the video coding standard of HEVC, when the electronic device determines that the quantization values of the transform coefficients of the target transform block are all target values, the electronic device may encode the all-zero flag of the target transform block. The electronic device may calculate a bit number required for encoding the all-zero flag and a distortion bit number corresponding to the target transform block, so that the electronic device may calculate a first rate-distortion cost0 of the target transform block according to the bit number required for encoding and the distortion bit number. Wherein, the all-zero flag is used to represent the quantization value of each transform coefficient as a target value.
In step S130, in the case where the component type corresponding to the target transform block is a chroma component, a cost adjustment factor is calculated according to the target number of non-target values in each optimal quantization value and the area of the target transform block.
In an implementation, the target transform block includes a luma component and a chroma component, and the process of quantizing the luma component and the process of quantizing the chroma component are performed independently of each other by the electronic device. In this way, the electronic device can determine the component type currently being quantized. In a case where it is determined that the type of a component currently subjected to quantization processing is a chrominance component, the electronic device may screen an obtained optimal quantization value of each transform coefficient of the target transform block, determine the number of non-target values (hereinafter referred to as a target number), acquire size information of the target transform block, and calculate an area of the target transform block according to the size information. In this way, the electronic device may calculate a cost adjustment factor based on the target number and the area of the target transform block, where the cost adjustment factor is a value greater than 1. The execution order of step 120 and step 130 is not limited in this disclosure.
In step S140, the first rate-distortion cost is adjusted based on the cost adjustment factor to obtain a second rate-distortion cost, and the target transform block is quantized based on the second rate-distortion cost.
In an implementation, the electronic device may adjust the first rate-distortion cost based on the calculated cost adjustment factor. Due to the texture of the image data of the video signal, the electronic device may not accurately obtain the coding prediction bit number of the chrominance component corresponding to the target transform block, for example, the calculated coding prediction bit number may be smaller, and the rate distortion cost obtained according to the coding prediction bit number may be smaller. Therefore, the electronic equipment can amplify and adjust the first rate distortion cost based on the cost adjustment factor to obtain more accurate rate distortion cost, and therefore the electronic equipment can quantize the target transformation block based on the second rate distortion cost.
In one embodiment, the electronic device may adjust the first rate-distortion cost according to the following formula:
Cost0’=Cost0*scale_factor
where Cost0' represents the second rate-distortion Cost, cost0 represents the first rate-distortion Cost, and scale _ factor represents the Cost adjustment factor.
In one embodiment, the specific process of the electronic device performing quantization processing on the target transform block based on the second rate-distortion Cost0' may include:
the electronic device calculates a second rate-distortion Cost as Cost0' by the method provided in the above embodiment. The electronic device may determine, in the optimal quantization values of the transform coefficients corresponding to the target transform block, a position of an optimal quantization value of the last non-target value, set the optimal quantization value as a target value (i.e., set to zero), obtain an updated optimal quantization value of each transform coefficient, and calculate a third rate-distortion Cost in this case as Cost1. If Cost1> Cost0', it indicates that the coding effect corresponding to the target transform block quantized to the all-zero block is better than the coding effect corresponding to the target transform block quantized to the non-all-zero block, so that the electronic device can determine that the quantization values of the transform coefficients of the target transform block are all target values, and perform quantization processing on the target transform block based on the quantization values of the transform coefficients of the target transform block.
If Cost1 is less than or equal to Cost0', it indicates that the coding effect of the target transform block quantized to all-zero block is worse than the coding effect of the target transform block quantized to non-all-zero block, so the electronic device can use the third rate distortion Cost as Cost0'. In this way, the electronic device may re-determine the position of the last non-target optimal quantization value in the updated optimal quantization values of the transform coefficients, set the optimal quantization value as a target value, re-calculate the rate distortion Cost in this case as Cost1, and compare Cost1 with Cost0 'until Cost1> Cost0', where the rate distortion Cost calculated by the electronic device at this time is the optimal rate distortion Cost, and thus, the electronic device may perform quantization processing on the target transform block based on the current optimal quantization value of each transform coefficient corresponding to Cost1.
If Cost1 ≦ Cost0', it indicates that the coding effect of quantizing the target transform block to the all-zero block is worse than the coding effect of quantizing the target transform block to the non-all-zero block, so that the electronic device may use the third rate distortion Cost as Cost0'. In this way, the electronic device may re-determine the position of the last non-target value of the optimal quantization values of the updated transform coefficients, set the optimal quantization values as target values, re-calculate the rate distortion Cost in this case as Cost1, and compare Cost1 with Cost0' until the first non-target value of the optimal quantization values of the updated transform coefficients has been set as a target value, so that the electronic device may perform quantization processing on the target transform block based on the optimal quantization values corresponding to the transform coefficients in the current situation.
In the video quantization method, under the condition that a preset optimization condition is met, the optimal quantization value of each transformation coefficient of a target transformation block in video data is determined according to a preset rate distortion optimization strategy. And determining a first rate distortion cost corresponding to the target transformation block, wherein the first rate distortion cost is obtained under the condition that the quantization values of all the transformation coefficients are target values. And under the condition that the component type corresponding to the target transformation block is a chrominance component, calculating a cost adjustment factor according to the target number of non-target values in each optimal quantization value and the area of the target transformation block. And adjusting the first rate distortion cost based on the cost adjustment factor to obtain a second rate distortion cost, and performing quantization processing on the target transform block based on the second rate distortion cost. And calculating a cost adjustment factor according to the area of the target transformation block and a target of a non-target value in the optimal quantization value of each transformation coefficient of the target transformation block, under the condition that the component type corresponding to the current target transformation block is a chrominance component, adjusting a first rate distortion cost corresponding to the target value quantized by each transformation coefficient based on the cost adjustment factor to obtain an adjusted first rate distortion cost, namely a second rate distortion cost, and quantizing the target transformation block based on the second rate distortion cost. Thus, by adjusting the first rate-distortion cost, the accuracy of determining the rate-distortion cost can be improved, thereby improving the encoding performance when video encoding is performed on the chroma components.
In an exemplary embodiment, as shown in fig. 2, in step 120, obtaining the first rate-distortion cost corresponding to the target transform block may specifically be implemented by the following steps:
in step 1211, the number of distorted bits is calculated from the difference between the optimal quantization value and the target value for each transform coefficient.
Wherein the target value may be zero.
In this embodiment, the number of distortion bits indicates the number of bits in which distortion occurs in the target transform block when each transform coefficient of the target transform block is quantized to the target value. For each transform coefficient, the electronic device may calculate a difference between the optimal quantization value of the transform coefficient and the target value, square the difference, and use the result as the number of distorted sub-bits of the transform coefficient. In this way, the electronic device may perform the superposition processing on the number of distorted sub-bits corresponding to each transform coefficient, and use the obtained sum as the total number of distorted bits, that is, the number of distorted bits of the target transform block.
In step 1212, a target coding flag of the corresponding target transform block is determined when the quantization value of each transform coefficient of the target transform block is a target value, and a first coding prediction bit number for coding the target coding flag is calculated through a coding bit number calculation model corresponding to a preset luminance component.
The preset coding bit number calculation model corresponding to the luminance component may be an entropy coding context model (lumaCbfContext) of the luminance component, or may be another coding bit number model for calculating the luminance component, which is not limited in this disclosure, and the target coding identifier indicates that the quantization value of each transform coefficient of the target transform block is a target value.
In implementation, in the case that the quantization values of the respective transform coefficients of the transform block are all target values, the coding identifier of the transform block is an all-zero identifier, in which case, the electronic device only needs to code the coding identifier (i.e., all-zero identifier) of the transform block when performing entropy coding on the transform block; in the case where the quantization value indices of the respective transform coefficients of a transform block are not all target values, the coding index of the transform block is a non-all-zero index, in which case the electronic device needs to code the non-all-zero index and the magnitude of the respective transform coefficients.
The electronic device may determine the quantized value of each transform coefficient of the target transform block as a target value, and the electronic device may determine that the coding flag of the target transform block is a target coding flag (e.g., an all-zero flag) when each transform coefficient of the target transform block is the target value. In the case where the corresponding component type of the target transform block is a chroma component, the electronic device may calculate a first encoding prediction bit number R (cbf (0)) based on a preset encoding bit number calculation model corresponding to a luma component. Wherein, R (cbf (0)) represents the number of bits required by the electronic device to encode the target coding flag, cbf is the coding flag, cbfValue is the value of cbf, cbf =0 is that the quantized values of the transform coefficients of the target transform block are all zero, that is cbf =0 is the all-zero flag; cbf =1 is a quantized value indicating that a non-zero quantized value exists among quantized values of transform coefficients of the target transform block.
In step 1213, a first rate-distortion cost is calculated based on the number of distorted bits and the number of first coded prediction bits.
In implementation, the electronic device may perform superposition processing on the distortion bit number and the coding prediction bit number, and use the obtained sum as the first rate-distortion cost0, where a specific calculation process may be shown as the following formula:
Figure BDA0003787476680000091
wherein, N represents the number of the transformation coefficients in the target transformation block; d (Ci, 0) represents the corresponding distortion when the transform coefficient Ci is quantized to 0, i.e., the number of distorted sub-bits corresponding to the ith transform coefficient; when each transform coefficient of the current target transform Block is quantized to zero, in the field of video coding and decoding, the coefficient of the target transform Block does not need to be Coded, and only a Coded Block Flag (CBF) of the current target transform Block needs to be written to be equal to 0, that is, CBF =0. That is, if the coding flag cbf =0 of the target transform block indicates that the quantized values of all transform coefficients of the target transform block are zero. In this way, the electronic device may determine that the coding flag of the transform block is the target coding flag, that is, cbf =0, and the electronic device only needs to code cbf =0, so that the coding prediction bit number R (cbf (0)) represents the number of bits that the electronic device calculates to be consumed for coding the target coding flag.
In this embodiment, the electronic device may adopt an entropy coding context model (lumaCbfContext) corresponding to the luminance luma component when the component types corresponding to the target transform block are the chroma Cb component and the chroma Cr component, so as to avoid adopting a context model (chromacbbcontext/ChromaCrContext) carried in the encoder itself, thereby effectively reducing an error generated when the electronic device estimates a coding prediction bit number corresponding to the chroma component, and improving accuracy of calculating the first rate distortion cost corresponding to the chroma component.
In an exemplary embodiment, as shown in fig. 3, in step 120, obtaining the first rate-distortion cost corresponding to the target transform block may specifically be implemented by:
in step 1221, the number of distortion bits is calculated from the difference between the optimal quantization value of each transform coefficient and the target value.
In this embodiment, the number of distorted bits indicates the number of bits corresponding to distortion generated in the target transform block when each transform coefficient of the target transform block is quantized to the target value. For each transform coefficient, the electronic device may calculate a difference between the optimal quantization value of the transform coefficient and a target value, square the difference, and use the result as the number of distorted sub-bits of the transform coefficient. In this way, the electronic device may perform the superposition processing on the number of distorted sub-bits corresponding to each transform coefficient, and use the obtained sum as the total number of distorted bits, that is, the number of distorted bits of the target transform block.
At step 1222, a target coding bit number calculation model corresponding to the target class type is determined according to the target component type corresponding to the target transform block, a target coding flag of the corresponding target transform block is determined when the quantization value of each transform coefficient of the target transform block is a target value, and a second coding prediction bit number for coding the target coding flag is calculated through the target coding bit number calculation model.
In an implementation, the transform block corresponding component type may include a chrominance component type and a luminance component type, and the chrominance component type may include a chrominance Cb component type and a chrominance Cr component type. The electronic equipment can determine a target component type corresponding to the current target transformation block, and determine a target coding bit number calculation model corresponding to the target component type based on the corresponding relation between the component type and the coding bit number calculation model; in this way, the electronic device may determine the target encoding flag of the corresponding target transform block when the quantization values of the respective transform coefficients of the target transform block are all target values. In this way, the electronic device can calculate the second predicted encoding bit number for encoding the target encoding identifier through the target encoding bit number calculation model.
In one example, the correspondence between the component type and the coding bit number calculation model may include: the calculation model of the number of coded bits corresponding to the luminance component may be lumaCbfContext, the calculation model of the number of coded bits corresponding to the chrominance Cb component may be ChromaCbContext, and the calculation model of the number of coded bits corresponding to the chrominance Cr component may be ChromaCrContext.
Thus, the number of coded prediction bits R (cbf (0)) can be determined by:
R(cbf(0))=estimateCbfBits(cbfContext,cbfValue)
where estimatebfbbits is a rate estimation function for estimating R (cbf (0)), and cbfContext is a coding bit number calculation model.
In this way, the rate estimation function calculates the number of bits that need to be consumed by simulating the way an actual entropy coding engine encodes the code stream. In the same way as in the actual entropy coding, the input parameters of the estimatebfbbibs include different context models (cbfContext) corresponding to different types of components and the value (cbfValue) of cbf, for example, 0 or 1.
In step 1223, a first rate-distortion cost is calculated based on the number of distorted bits and the number of second coded prediction bits.
In implementation, the electronic device may perform superposition processing on the distortion bit number and the coding prediction bit number, and use the obtained sum as the first rate-distortion cost0, and the specific calculation process may be the same as the formula (1) provided in the foregoing embodiment, which is not described herein again.
In this embodiment, the electronic device may select a corresponding coding bit number calculation model based on the component type corresponding to the current target transform block, so as to improve the efficiency of calculating the coding prediction bit number.
In an exemplary embodiment, the electronic device may determine whether the target transform quickly meets a preset optimization condition according to an actual condition of the target transform block, and select different optimization strategies to optimize the target transform block when the preset optimization condition is met and when the preset optimization condition is not met.
As shown in fig. 4, before the step of determining an optimal quantization value of each transform coefficient of a target transform block in video data according to a preset rate-distortion optimization strategy when a preset optimization condition is satisfied, the video quantization method further includes:
in step 410, an optimization strategy threshold corresponding to the target transform block is determined according to the area of the target transform block.
Wherein the optimization strategy threshold is positively correlated to the area of the target transform block.
In implementations, the electronic device can determine different optimization strategies based on the comparison of the target number to the optimization strategy threshold. When the component type corresponding to the target transform block is a chrominance component, the electronic device may obtain size information of the target transform block, where the size information includes a height and a width, and perform multiplication processing based on the height and the width of the target transform block to obtain an area of the target transform block. In the field of video encoding and decoding, the area of the target transform block has the same value as the number of transform coefficients contained in the target transform block, so that the electronic device can determine the number of transform coefficients contained in the target transform block according to the area of the target transform block.
The electronic device may be preconfigured with a scaling factor (i.e., a preset scaling factor), so that the electronic device may calculate the optimization strategy threshold based on the preset scaling factor and the area of the target transform block. For example, the electronic device may multiply a preset scaling factor and the area of the target transform block, and use the resulting product as the optimization strategy threshold. That is, in a case where the component type corresponding to the target transform block is a chroma component, the electronic device may calculate an optimization policy threshold corresponding to the target transform block based on an area of the target transform block, and determine a different optimization policy based on a comparison result of the optimization policy threshold and the target number of the target transform blocks.
In one embodiment, the preset scaling factor may be one-half, and a person skilled in the art may determine a specific value of the preset scaling factor according to an actual application scenario, which is not limited by the present disclosure.
In step 420, a target number of optimal quantized values of the non-target values among the optimal quantized values of the respective transform coefficients of the target transform block is counted.
Where the target value may be preconfigured by the technician, in one example, the target value may be zero.
In an implementation, the electronic device may filter the optimal quantized values of the respective transform coefficients of the target transform block to determine a target number of non-target values contained therein. In this way, the electronic device may compare the target number to an optimization strategy threshold and select a different optimization strategy based on the comparison.
In step 430, it is determined that the preset optimization condition is satisfied if the target number is less than or equal to the optimization strategy threshold.
In an implementation, if the target number is less than or equal to the optimization policy threshold, the electronic device may determine that the actual condition of the target transform block satisfies a preset optimization condition, i.e., the preset optimization condition may be that the target number of the target transform block is less than or equal to the optimization policy threshold. In this way, the electronic device may obtain a plurality of target transform blocks corresponding to video data to be quantized, where the target transform blocks correspond to a plurality of transform coefficients, when the preset optimization condition is satisfied. For each transform coefficient, the electronic device may determine at least one selectable quantization value corresponding to the transform coefficient, and calculate rate distortion costs corresponding to the selectable quantization values based on a preset rate distortion optimization strategy, respectively, and use the selectable quantization value corresponding to the smallest rate distortion cost as the optimal quantization value of the transform coefficient. In this way, the electronic device may determine optimal quantization values for the respective transform coefficients contained by the target transform block.
In this embodiment, the electronic device may determine different optimization strategies according to a comparison result between the target number and the optimization strategy threshold, and increase adaptability between the different optimization strategies and the target transform block.
In an exemplary embodiment, as shown in fig. 5, the method further comprises:
in step 510, if the target number is greater than the optimization policy threshold, determining that a preset optimization condition is not satisfied; and under the condition that the preset optimization condition is not met, determining the optimal quantization value of each transformation coefficient of the target transformation block in the video data according to a preset rate distortion optimization strategy.
In an embodiment, if the target number is greater than the optimization policy threshold, the electronic device may determine that the target transform block does not satisfy a preset optimization condition. In this way, under the condition that the preset optimization condition is not satisfied, the electronic device may determine, for each transform coefficient corresponding to the target transform block, at least one optional quantization value corresponding to the transform coefficient, and calculate rate distortion costs corresponding to the optional quantization values, respectively, and use the optional quantization value corresponding to the minimum rate distortion cost as the optimal quantization value of the transform coefficient. In this way, the electronic device can determine the optimal quantized values of the respective transform coefficients contained in the target transform block.
In step 520, the number of distortion bits is calculated from the difference between the optimal quantization value of each transform coefficient and the target value.
Wherein the target value may be zero.
In this embodiment, the number of distortion bits indicates the number of bits in which distortion occurs in the target transform block when each transform coefficient of the target transform block is quantized to the target value. For each transform coefficient, the electronic device may calculate a difference between the optimal quantization value of the transform coefficient and the target value, square the difference, and use the result as the number of distorted sub-bits of the transform coefficient. In this way, the electronic device may perform the superposition processing on the distortion sub-bit numbers corresponding to the respective transform coefficients, and use the sum as the total distortion bit number, that is, the distortion bit number of the target transform block.
In step 530, a first predicted encoding bit number for encoding the target encoding identifier is calculated according to a predetermined encoding bit number calculation model corresponding to the luminance component.
The preset coding bit number calculation model corresponding to the luma component may be an entropy coding context model (lumaCbfContext) of the luma component, or may be other models.
In implementation, in the case that the quantization values of the respective transform coefficients of the transform block are all target values, the coding identifier of the transform block is an all-zero identifier, in which case, the electronic device only needs to code the coding identifier (i.e., all-zero identifier) of the transform block when performing entropy coding on the transform block; in the case where the quantization value indices of the respective transform coefficients of a transform block are not all target values, the coding index of the transform block is a non-all-zero index, in which case the electronic device needs to code the non-all-zero index and the magnitude of the respective transform coefficient.
In step 540, a first rate-distortion cost is calculated according to the distortion bit number and the first encoding prediction bit number, and the target transform block is quantized based on the first rate-distortion cost.
In implementation, the electronic device may perform superposition processing on the distortion bit number and the coding prediction bit number, and use the obtained sum as the first rate distortion cost, where a process of performing quantization processing on the target transform block by the electronic device based on the first rate distortion cost is similar to a process of performing quantization processing on the target transform block based on the second rate distortion cost in the above embodiment, and details of this disclosure are not repeated here.
In this embodiment, the electronic device may determine the optimization policy threshold according to the size information of the target transform block, and determine different optimization policies according to a comparison result between the optimization policy threshold and the target number of the non-target values in the optimal quantization values of the transform coefficients of the target transform block, so as to improve the encoding performance of the RDOQ algorithm in different application scenarios and increase the flexibility of the application scenario of the RDOQ algorithm.
In a possible implementation manner, the target number is compared with the optimization strategy threshold to obtain a comparison result, and selecting different optimization strategies according to the comparison result can be specifically implemented by the following steps:
under the condition that the target number is less than or equal to the optimization strategy threshold, the electronic equipment can determine the optimal quantization value of each transformation coefficient of a target transformation block in the video data according to a preset rate distortion optimization strategy; acquiring a first rate distortion cost corresponding to a target transformation block, wherein the first rate distortion cost is acquired under the condition that the quantization values of all transformation coefficients are target values; under the condition that the component type corresponding to the target transformation block is a chrominance component, calculating a cost adjustment factor according to the target number of non-target values in each optimal quantization value and the area of the target transformation block; and adjusting the first rate distortion cost based on the cost adjustment factor to obtain a second rate distortion cost, and performing quantization processing on the target transform block based on the second rate distortion cost.
Or, in the case that the number of targets is less than or equal to the optimization policy threshold, the electronic device may further determine an optimal quantization value of each transform coefficient of a target transform block in the video data according to a preset rate-distortion optimization policy; calculating the number of distortion bits according to the difference between the optimal quantization value of each transformation coefficient and the target value; calculating a first coding prediction bit number for coding a target coding identifier through a coding bit number calculation model corresponding to a preset brightness component, wherein the target coding identifier is used for indicating that the quantization values of all transformation coefficients of a target transformation block are target values; and calculating a first rate distortion cost according to the distortion bit number and the first coding prediction bit number, and carrying out quantization processing on the target transformation block based on the first rate distortion cost.
Under the condition that the target number is larger than the threshold value of the optimization strategy, the electronic equipment can determine the optimal quantization value of each transformation coefficient of a target transformation block in the video data according to a preset rate distortion optimization strategy; acquiring a first rate distortion cost corresponding to a target transformation block, wherein the first rate distortion cost is obtained under the condition that the quantization values of all transformation coefficients are target values; calculating the number of distortion bits according to the difference between the optimal quantization value of each transformation coefficient and the target value; calculating a first coding prediction bit number for coding a target coding identifier through a coding bit number calculation model corresponding to a preset brightness component, wherein the target coding identifier is used for indicating that the quantization values of all transformation coefficients of a target transformation block are target values; calculating a first rate-distortion cost according to the distortion bit number and the first coding prediction bit number; and adjusting the first rate distortion cost based on the cost adjustment factor to obtain a second rate distortion cost, and performing quantization processing on the target transform block based on the second rate distortion cost.
In an exemplary embodiment, as shown in fig. 6, in step 130, calculating the cost adjustment factor according to the target number of non-target values in each optimal quantization value and the area of the target transform block may specifically be implemented by:
in step 131, a target ratio of the target number of non-target values to the area of the target transform block in each optimal quantization value is calculated.
In implementation, the electronic device determines an optimal quantization value of each transform coefficient of a target transform block in video data according to a preset distortion optimization strategy. In this way, the electronic device can determine the number of non-target values, i.e., the target number, in the optimal quantized values of the respective transform coefficients. The electronic device may also obtain size information of the target transform block, and calculate an area of the target transform block according to the size information. In this way, the electronic device can calculate the target ratio according to the target number and the area of the target transform block. The electronic device can determine the number of the transformation coefficients corresponding to the target change speed according to the area value of the target transformation block.
In one example, the target value may be zero, such that the electronic device may count numSig for a non-zero quantization value of the optimal quantization values for the target transform block. The electronic device may calculate a duty ratio chromaRatio of the non-zero quantized value, which may be calculated by the following formula:
chromaRatio=numSig/TUArea,
where TUArea denotes an area of a target transform block, which may be calculated by the following formula:
TUArea=TUHeight*TUWidth,
where TUHeight denotes the height of the target transform block and TUWidth denotes the width of the target transform block.
In step 132, a cost adjustment factor corresponding to the target ratio is determined according to a preset corresponding relationship between the ratio and the adjustment factor.
In implementation, the electronic device may determine a corresponding relationship between a preset ratio and an adjustment factor according to an actual application scenario, for example, scale _ factor = chroma ratio × 2+1, scale _factorrepresents a cost adjustment factor, and chroma ratio represents a target ratio. The electronic equipment can determine that the range of the cost adjustment factor is 1.0-3.0 according to the corresponding relation between the preset ratio and the adjustment factor.
In this embodiment, the cost adjustment factor may be calculated in real time based on the size information of the target transform block and the target number, so that the calculated cost adjustment factor may be more adapted to the target transform block, and the accuracy of the cost adjustment factor is ensured.
In an exemplary embodiment, in step 140, the first rate-distortion cost is adjusted based on the cost adjustment factor, and the obtaining of the second rate-distortion cost may specifically be implemented by the following steps:
and taking the product of the cost adjustment factor and the first rate distortion cost as a second rate distortion cost.
In implementation, the process of the electronic device adjusting the first rate-distortion cost0 based on the cost adjustment factor may be: the electronic device may multiply the first rate-distortion cost0 and the cost adjustment factor, and use the product as the second rate-distortion cost0'.
In this embodiment, the first rate-distortion cost may be adjusted in time based on the cost adjustment factor, so that the calculated first rate-distortion cost may be more accurate.
In an exemplary embodiment, in step 410, determining the optimization strategy threshold corresponding to the target transform block according to the area of the target transform block may specifically be implemented by the following steps:
and performing product processing on the area of the target transformation block and a preset proportional coefficient, and determining an optimization strategy threshold corresponding to the target transformation block.
Wherein the area of the target transform block may be determined according to the height and width of the target transform block. The preset scaling factor may be one-half, and a person skilled in the art may determine a specific value of the preset scaling factor according to an actual application scenario, which is not limited in the present disclosure.
In implementation, the electronic device may perform product processing on the area of the target transform block and a preset scaling factor, and use the obtained product as an optimization strategy threshold corresponding to the target transform block.
In this embodiment, the optimization policy threshold may be calculated based on the actual situation of the target transform block, so that the obtained optimization policy threshold may be more accurate.
In an exemplary embodiment, as shown in fig. 7, in step 110, determining an optimal quantization value of each transform coefficient of a target transform block in video data according to a preset rate-distortion optimization strategy may specifically be implemented by:
in step 710, at least one selectable quantized value of a transform coefficient is obtained for each transform coefficient of a target transform block.
In an implementation, the target transform block TU includes a plurality of transform coefficients, for each of which the terminal may calculate an optional quantized value of the transform coefficient from its value. Specifically, the selectable quantized value of the ith transform coefficient may be calculated by the following formula:
|l i |=round(|C i |/Q step ),
wherein, C i For the value of the ith transform coefficient, l, of the target transform block TU i Is represented by C i Pre-quantization to obtain a quantization value, round (indicates rounding), absolute (Q) indicates absolute processing step Representing the quantization step size.
Optionally, the quantization step size Q step Can be passed through Q step =2 (QP-4)/6, where QP represents the value of QPThe specific value of the quantization parameter may be determined by those skilled in the art according to an actual application scenario, which is not limited in this disclosure. For example, the quantization parameter takes on an integer value and the range is [0,51 ]]。
Thus, the electronic device can be based on | l i Determining an optional quantization value according to the size of l i The correspondence of the size of | determining the optional quantization value may be as shown in table 1 below:
TABLE 1
|l i | 0 1 2 3 N
Selectable quantized values 0 0,1 0,1,2 2,3 N-1,N
For example, | l for the 2 nd transform coefficient i I =2, so that,the electronics can determine that the selectable quantized values for the 2 nd transform coefficient can include 0,1,2.
In step 720, rate distortion costs corresponding to the selectable quantization values are respectively calculated, and the selectable quantization value corresponding to the minimum rate distortion cost is used as the optimal quantization value of the transform coefficient.
In an implementation, the electronic device determines one or more selectable quantized values for respective transform coefficients. In this way, for each transform coefficient, the electronic device needs to calculate the rate-distortion cost when the transform coefficient is quantized into each selectable quantization value, and use the selectable quantization value corresponding to the smallest rate-distortion cost as the optimal quantization value of the transform coefficient among multiple rate-distortion costs corresponding to the transform coefficient quantized into each selectable quantization value.
In one example, the preset rate-distortion optimization strategy may be the RDO criterion. The electronic device may calculate the optimal quantization value corresponding to each transform coefficient by the following formula:
J(l i,k )=D(c i ,l i,k )+λ*R(l i,k )
wherein D (c) i ,l i,k ) Is shown by c i Quantified as l i,k The total distortion bit number of the target transformation block; r (l) i,k ) Denotes c i Quantified as l i,k Then, the total coding bit number of the target transformation block; j (l) i,k ) Is shown by c i Quantified as l i,k The rate distortion cost of the target transform block.
For example, the selectable quantized values of the 2 nd transform coefficient may include 0,1,2. The electronic device may calculate a rate-distortion cost a1 of the corresponding target transform block when the 2 nd transform coefficient is quantized to 0, calculate a rate-distortion cost a2 of the corresponding target transform block when the 2 nd transform coefficient is quantized to 1, and calculate a rate-distortion cost a3 of the corresponding target transform block when the 2 nd transform coefficient is quantized to 2; in this way, the electronic device may compare the magnitudes of the rate-distortion cost a1, the rate-distortion cost a2, and the rate-distortion cost a3, determine the minimum rate-distortion cost, and use the selectable quantization value corresponding to the minimum rate-distortion cost as the optimal quantization value of the 2 nd transform coefficient. For example, the comparison result may be a 1< a2, and a 1< a3, so that the electronic device may determine that the optimal quantization value of the 2 nd transform coefficient may be 0. The process of determining the optimal quantization value of the target transform block is similar to the process of determining the optimal quantization value of the 2 nd transform coefficient, and is not described herein again.
In this embodiment, the optimal quantization value of each transform coefficient of the target transform block may be accurately and efficiently determined by a rate-distortion optimization strategy.
In one example, the process by which the electronic device quantizes the target transform block may be as shown in fig. 8:
the electronic device calculates a rate-distortion optimization cost (which may be denoted as RDCOST) for the case where the quantized values of all transform coefficients of the target transform block (current TU block) are zero: the first rate-distortion Cost (which may be denoted as Cost 0) and let the position of the optimal last non-zero coefficient in the current case (which may be denoted as BestLastNZPos) be initialized, i.e. BestLastNZPos =0. The electronic device determines whether the component type of the currently processed target transform block is a chroma component, and calculates a second rate distortion Cost (which may be denoted as Cost0 ') based on the Cost adjustment factor scale _ factor and the first rate distortion Cost0 to obtain a second rate distortion Cost (which may be denoted as Cost0 '), that is, cost0' = Cost0 × scale _ factor, when determining that the component type of the currently processed target transform block is the chroma component. At this time, the current coefficient position (which may be denoted as nzPos) is the position of the last non-zero quantized value among the respective optimal quantized values of the respective transform coefficients, i.e., nzPos = LastNZPos.
The electronic device may determine that, when the current coefficient position is greater than or equal to 0, the electronic device may set a last non-zero quantized value of each optimal quantized value of each transform coefficient of the current TU block to 0, obtain each updated optimal quantized value of each transform coefficient, and calculate a third rate-distortion cost in this case as cost1.
In this way, the electronic device may re-determine the position of the last non-zero quantization value, i.e., bestLastNZPos = nzPos-1, among the respective optimal quantization values of the updated respective transform coefficients, in the case that the second rate-distortion Cost is less than the first rate-distortion Cost (Cost 1< Cost 0'), and calculate a third rate-distortion Cost as Cost0, and then re-perform the step of whether the current coefficient position is greater than or equal to 0.
In one example, the process by which the electronic device quantizes the target transform block may be as shown in fig. 9:
the electronic device calculates a rate-distortion optimization cost RDCOST in the case where quantization values of all transform coefficients of a target transform block (current TU block) are zero: the first rate-distortion Cost, cost0, such that the position of the optimal last non-zero coefficient in the current case is initialized, i.e. BestLastNZPos =0. At this time, the coefficient position is a position of a last non-zero quantized value among the respective optimal quantized values of the respective transform coefficients, i.e., nzPos = LastNZPos.
The electronic device may determine that, when the current coefficient position is greater than or equal to 0, the electronic device may set a last non-zero quantized value of each optimal quantized value of each transform coefficient of the current TU block to 0, obtain each updated optimal quantized value of each transform coefficient, and calculate a third rate-distortion cost in this case as cost1.
In this way, the electronic device may re-determine the position of the last non-zero quantized value, i.e., bestLastNZPos = nzPos-1, among the respective optimal quantized values of the updated respective transform coefficients in the case where Cost1< Cost0', and obtain the third rate-distortion Cost as Cost0 through calculation, and then re-perform the step of whether the current coefficient position is greater than or equal to 0.
It should be understood that although the various steps in the flowcharts of fig. 1-9 are shown in order as indicated by the arrows, the steps are not necessarily performed in order as indicated by the arrows. The steps are not limited to being performed in the exact order illustrated and, unless explicitly stated herein, may be performed in other orders. Moreover, at least some of the steps in fig. 1-9 may include multiple steps or multiple stages, which are not necessarily performed at the same time, but may be performed at different times, which are not necessarily performed in sequence, but may be performed in turn or alternately with other steps or at least some of the other steps or stages.
It is understood that the same/similar parts between the embodiments of the method described above in this specification can be referred to each other, and each embodiment focuses on the differences from the other embodiments, and it is sufficient that the relevant points are referred to the descriptions of the other method embodiments.
Fig. 10 is a block diagram illustrating an apparatus for video quantization according to an example embodiment. Referring to fig. 10, the apparatus includes a first determination unit 1001, an acquisition unit 1002, a first calculation unit 1003, and an adjustment unit 1004.
A first determining unit 1001 configured to perform, in a case where a preset optimization condition is satisfied, determining an optimal quantization value of each transform coefficient of a target transform block in video data according to a preset rate-distortion optimization policy, where the target transform block is any one of a plurality of transform blocks included in the video data;
an obtaining unit 1002 configured to perform obtaining a first rate-distortion cost corresponding to a target transform block, where the first rate-distortion cost is obtained when a quantization value of each transform coefficient is a target value;
a first calculation unit 1003 configured to perform, in a case where the component type corresponding to the target transform block is a chroma component, calculating a cost adjustment factor according to a target number of non-target values among the optimal quantization values and an area of the target transform block;
and an adjusting unit 1004 configured to perform adjusting the first rate-distortion cost based on the cost adjusting factor to obtain a second rate-distortion cost, and perform quantization processing on the target transform block based on the second rate-distortion cost.
In one embodiment, the obtaining unit 1002 includes:
a first calculation subunit configured to perform calculation of the number of distortion bits in accordance with a difference between the optimal quantization value of each transform coefficient and a target value;
a second calculation subunit configured to perform determining a target coding identifier of a corresponding target transform block in a case where quantization values of respective transform coefficients of the target transform block are all target values, and calculate a first coding prediction bit number for coding the target coding identifier through a preset coding bit number calculation model corresponding to a luminance component;
a third calculation subunit configured to perform a calculation of a first rate-distortion cost from the number of distorted bits and the number of first coded prediction bits.
In one embodiment, the obtaining unit 1002 includes:
a fourth calculation subunit configured to perform calculation of the number of distortion bits in accordance with a difference between the optimal quantization value of each transform coefficient and the target value;
a first determining subunit, configured to execute determining a target coding bit number calculation model corresponding to the target classification type according to the target component type corresponding to the target transform block, determine a target coding identifier of the corresponding target transform block when quantization values of each transform coefficient of the target transform block are all target values, and calculate a second coding prediction bit number for coding the target coding identifier through the target coding bit number calculation model;
and a fifth calculating subunit configured to calculate the first rate-distortion cost according to the distortion bit number and the second coding prediction bit number.
In one embodiment, the apparatus further comprises:
a second determining unit configured to determine an optimization strategy threshold corresponding to the target transformation block according to the area of the target transformation block, wherein the optimization strategy threshold is in forward correlation with the area of the target transformation block;
a counting unit configured to perform counting of a target number of optimal quantized values of non-target values among the optimal quantized values of the respective transform coefficients of the target transform block;
and the execution unit is configured to execute the step of determining that the preset optimization condition is met if the target number is less than or equal to the optimization strategy threshold.
In one embodiment, the apparatus further comprises:
a third determination unit configured to perform determining that a preset optimization condition is not satisfied if the target number is greater than the optimization policy threshold;
a second calculation unit configured to perform calculation of the number of distortion bits according to a difference between the optimal quantization value of each transform coefficient and a target value in a case where a preset optimization condition is not satisfied;
a third calculation unit configured to perform determining a target coding identifier of a corresponding target transform block in a case where quantization values of respective transform coefficients of the target transform block are all target values, and calculating a first coding prediction bit number for coding the target coding identifier through a coding bit number calculation model corresponding to a preset luminance component;
and a fourth calculation unit configured to calculate a first rate-distortion cost according to the distortion bit number and the first coding prediction bit number, and perform quantization processing on the target transform block based on the first rate-distortion cost.
In one embodiment, the first computing unit 1003 includes:
a sixth calculation subunit configured to perform calculation of a target ratio of the target number of non-target values to the area of the target transform block among the optimal quantization values;
and the second determining subunit is configured to determine a cost adjustment factor corresponding to the target ratio according to a preset corresponding relationship between the ratio and the adjustment factor.
In one embodiment, the adjusting unit 1004 includes:
an adjusting subunit configured to perform a multiplication of the cost adjustment factor and the first rate-distortion cost as a second rate-distortion cost.
With regard to the apparatus in the above embodiment, the specific manner in which each module performs the operation has been described in detail in the embodiment related to the method, and will not be described in detail here.
Fig. 11 is a block diagram illustrating an electronic device 1100 for a video quantization method according to an example embodiment. For example, the electronic device 1100 may be a mobile phone, a computer, a digital broadcast terminal, a messaging device, a gaming console, a tablet device, a medical device, a fitness device, a personal digital assistant, and so forth.
Referring to fig. 11, electronic device 1100 may include one or more of the following components: processing component 1102, memory 1104, power component 1106, multimedia component 1108, audio component 1110, input/output (I/O) interface 1112, sensor component 1114, and communications component 1116.
The processing component 1102 generally controls the overall operation of the electronic device 1100, such as operations associated with display, telephone calls, data communications, camera operations, and recording operations. The processing component 1102 may include one or more processors 1120 to execute instructions to perform all or a portion of the steps of the methods described above. Further, the processing component 1102 may include one or more modules that facilitate interaction between the processing component 1102 and other components. For example, the processing component 1102 may include a multimedia module to facilitate interaction between the multimedia component 1108 and the processing component 1102.
The memory 1104 is configured to store various types of data to support operations at the electronic device 1100. Examples of such data include instructions for any application or method operating on the electronic device 1100, contact data, phonebook data, messages, pictures, videos, and so forth. The memory 1104 may be implemented by any type or combination of volatile or non-volatile storage devices, such as Static Random Access Memory (SRAM), electrically erasable programmable read-only memory (EEPROM), erasable programmable read-only memory (EPROM), programmable read-only memory (PROM), read-only memory (ROM), magnetic memory, flash memory, magnetic disk, optical disk, or graphene memory.
The power supply component 1106 provides power to the various components of the electronic device 1100. The power components 1106 may include a power management system, one or more power supplies, and other components associated with generating, managing, and distributing power for the electronic device 1100.
The multimedia component 1108 includes a screen between the electronic device 1100 and a user that provides an output interface. In some embodiments, the screen may include a Liquid Crystal Display (LCD) and a Touch Panel (TP). If the screen includes a touch panel, the screen may be implemented as a touch screen to receive an input signal from a user. The touch panel includes one or more touch sensors to sense touch, slide, and gestures on the touch panel. The touch sensor may not only sense the boundary of a touch or slide action, but also detect the duration and pressure associated with the touch or slide operation. In some embodiments, the multimedia component 1108 includes a front facing camera and/or a rear facing camera. The front camera and/or the rear camera may receive external multimedia data when the electronic device 1100 is in an operation mode, such as a photographing mode or a video mode. Each front camera and rear camera may be a fixed optical lens system or have a focal length and optical zoom capability.
The audio component 1110 is configured to output and/or input audio signals. For example, the audio component 1110 includes a Microphone (MIC) configured to receive external audio signals when the electronic device 1100 is in an operational mode, such as a call mode, a recording mode, and a voice recognition mode. The received audio signals may further be stored in the memory 1104 or transmitted via the communication component 1116. In some embodiments, audio component 1110 further includes a speaker for outputting audio signals.
The I/O interface 1112 provides an interface between the processing component 1102 and peripheral interface modules, which can be keyboards, click wheels, buttons, etc. These buttons may include, but are not limited to: a home button, a volume button, a start button, and a lock button.
The sensor assembly 1114 includes one or more sensors for providing various aspects of state assessment for the electronic device 1100. For example, the sensor component 1114 can detect an open/closed state of the electronic device 1100, the relative positioning of components, such as a display and keypad of the electronic device 1100, the sensor component 1114 can also detect a change in position of the electronic device 1100 or components of the electronic device 1100, the presence or absence of user contact with the electronic device 1100, orientation or acceleration/deceleration of the device 1100, and a change in temperature of the electronic device 1100. The sensor assembly 1114 may include a proximity sensor configured to detect the presence of a nearby object without any physical contact. The sensor assembly 1114 may also include a light sensor, such as a CMOS or CCD image sensor, for use in imaging applications. In some embodiments, the sensor assembly 1114 may also include an acceleration sensor, a gyroscope sensor, a magnetic sensor, a pressure sensor, or a temperature sensor.
The communication component 1116 is configured to facilitate wired or wireless communication between the electronic device 1100 and other devices. The electronic device 1100 may access a wireless network based on a communication standard, such as WiFi, an operator network (such as 2G, 3G, 4G, or 5G), or a combination thereof. In an exemplary embodiment, the communication component 1116 receives broadcast signals or broadcast related information from an external broadcast management system via a broadcast channel. In an exemplary embodiment, the communication component 1116 also includes a Near Field Communication (NFC) module to facilitate short-range communications. For example, the NFC module may be implemented based on Radio Frequency Identification (RFID) technology, infrared data association (IrDA) technology, ultra Wideband (UWB) technology, bluetooth (BT) technology, and other technologies.
In an exemplary embodiment, the electronic device 1100 may be implemented by one or more Application Specific Integrated Circuits (ASICs), digital Signal Processors (DSPs), digital Signal Processing Devices (DSPDs), programmable Logic Devices (PLDs), field Programmable Gate Arrays (FPGAs), controllers, micro-controllers, microprocessors or other electronic components for performing the above-described methods.
In an exemplary embodiment, a computer-readable storage medium comprising instructions, such as the memory 1104 comprising instructions, executable by the processor 1120 of the electronic device 1100 to perform the method described above is also provided. For example, the computer readable storage medium may be a ROM, a Random Access Memory (RAM), a CD-ROM, a magnetic tape, a floppy disk, an optical data storage device, and the like.
In an exemplary embodiment, a computer program product is also provided, which includes instructions executable by the processor 1120 of the electronic device 1100 to perform the above-described method.
It should be noted that the descriptions of the above-mentioned apparatus, the electronic device, the computer-readable storage medium, the computer program product, and the like according to the method embodiments may also include other embodiments, and specific implementations may refer to the descriptions of the related method embodiments, which are not described in detail herein.
Other embodiments of the disclosure will be apparent to those skilled in the art from consideration of the specification and practice of the disclosure disclosed herein. This disclosure is intended to cover any variations, uses, or adaptations of the disclosure following, in general, the principles of the disclosure and including such departures from the present disclosure as come within known or customary practice within the art to which the disclosure pertains. It is intended that the specification and examples be considered as exemplary only, with a true scope and spirit of the disclosure being indicated by the following claims.
It will be understood that the present disclosure is not limited to the precise arrangements described above and shown in the drawings and that various modifications and changes may be made without departing from the scope thereof. The scope of the present disclosure is limited only by the appended claims.

Claims (11)

1. A method for video quantization, comprising:
under the condition of meeting a preset optimization condition, determining an optimal quantization value of each transformation coefficient of a target transformation block in video data according to a preset rate distortion optimization strategy, wherein the target transformation block is any one of a plurality of transformation blocks contained in the video data;
acquiring a first rate distortion cost corresponding to the target transformation block, wherein the first rate distortion cost is obtained under the condition that the quantization values of the transformation coefficients are all target values;
under the condition that the component type corresponding to the target transformation block is a chrominance component, calculating a cost adjustment factor according to the target number of non-target values in each optimal quantization value and the area of the target transformation block;
and adjusting the first rate distortion cost based on the cost adjustment factor to obtain a second rate distortion cost, and performing quantization processing on the target transformation block based on the second rate distortion cost.
2. The method of claim 1, wherein obtaining the first rate-distortion cost corresponding to the target transform block comprises:
calculating the number of distortion bits according to the difference between the optimal quantization value of each transformation coefficient and the target value;
determining a target coding identifier of the corresponding target transformation block under the condition that the quantization values of all transformation coefficients of the target transformation block are target values, and calculating a first coding prediction bit number for coding the target coding identifier through a preset coding bit number calculation model corresponding to a brightness component;
and calculating the first rate-distortion cost according to the distortion bit number and the first coding prediction bit number.
3. The method according to claim 1, wherein said obtaining the first rate-distortion cost corresponding to the target transform block comprises:
calculating the number of distortion bits according to the difference between the optimal quantization value of each transformation coefficient and the target value;
determining a target coding bit number calculation model corresponding to the target classification type according to the target component type corresponding to the target transformation block, determining a target coding identifier of the corresponding target transformation block under the condition that the quantization values of all transformation coefficients of the target transformation block are target values, and calculating a second coding prediction bit number for coding the target coding identifier through the target coding bit number calculation model;
and calculating the first rate-distortion cost according to the distortion bit number and the second coding prediction bit number.
4. The video quantization method of claim 1, wherein before the step of determining the optimal quantization value of each transform coefficient of the target transform block in the video data according to a preset rate-distortion optimization strategy if a preset optimization condition is satisfied, the method further comprises:
determining an optimization strategy threshold corresponding to the target transformation block according to the area of the target transformation block, wherein the optimization strategy threshold is in forward correlation with the area of the target transformation block;
counting the target number of the optimal quantization values of the non-target values in the optimal quantization values of the transform coefficients of the target transform block;
determining that the preset optimization condition is satisfied if the target number is less than or equal to the optimization policy threshold.
5. The video quantization method of claim 4, wherein the method further comprises:
if the target number is larger than the optimization strategy threshold value, determining that the preset optimization condition is not met;
under the condition that the preset optimization condition is not met, determining the optimal quantization value of each transformation coefficient of a target transformation block in the video data according to a preset rate distortion optimization strategy;
calculating the number of distortion bits according to the difference between the optimal quantization value and the target value of each transformation coefficient;
determining a target coding identifier of the corresponding target transformation block under the condition that the quantization values of all transformation coefficients of the target transformation block are target values, and calculating a first coding prediction bit number for coding the target coding identifier through a preset coding bit number calculation model corresponding to a brightness component;
and calculating the first rate-distortion cost according to the distortion bit number and the first coding prediction bit number, and quantizing the target transform block based on the first rate-distortion cost.
6. The method of claim 1, wherein calculating a cost adjustment factor according to the target number of non-target values in each of the optimal quantization values and the area of the target transform block comprises:
calculating a target ratio of the target number of non-target values in each optimal quantization value to the area of the target transformation block;
and determining a cost adjustment factor corresponding to the target ratio according to the corresponding relation between the preset ratio and the adjustment factor.
7. The method of claim 1, wherein the adjusting the first rate-distortion cost based on the cost adjustment factor to obtain a second rate-distortion cost comprises:
and taking the product of the cost adjustment factor and the first rate distortion cost as the second rate distortion cost.
8. An apparatus for quantizing a video, comprising:
a first determining unit, configured to perform, in a case where a preset optimization condition is satisfied, determining an optimal quantization value of each transform coefficient of a target transform block in video data according to a preset rate-distortion optimization policy, where the target transform block is any one of a plurality of transform blocks included in the video data;
an obtaining unit configured to perform obtaining a first rate distortion cost corresponding to the target transform block, where the first rate distortion cost is obtained when the quantization value of each transform coefficient is a target value;
a calculating unit configured to calculate a cost adjustment factor according to a target number of non-target values in each of the optimal quantized values and an area of the target transform block, in a case where a component type corresponding to the target transform block is a chrominance component;
and the adjusting unit is configured to perform adjustment on the first rate distortion cost based on the cost adjusting factor to obtain a second rate distortion cost, and perform quantization processing on the target transform block based on the second rate distortion cost.
9. An electronic device, comprising:
a processor;
a memory for storing the processor-executable instructions;
wherein the processor is configured to execute the instructions to implement the video quantization method of any of claims 1 to 7.
10. A computer-readable storage medium, wherein instructions in the computer-readable storage medium, when executed by a processor of an electronic device, enable the electronic device to perform the video quantization method of any of claims 1-7.
11. A computer program product comprising instructions therein, which when executed by a processor of an electronic device, enable the electronic device to perform the video quantization method of any one of claims 1-7.
CN202210945992.XA 2022-08-08 2022-08-08 Video quantization method and device, electronic equipment and storage medium Pending CN115278244A (en)

Priority Applications (1)

Application Number Priority Date Filing Date Title
CN202210945992.XA CN115278244A (en) 2022-08-08 2022-08-08 Video quantization method and device, electronic equipment and storage medium

Applications Claiming Priority (1)

Application Number Priority Date Filing Date Title
CN202210945992.XA CN115278244A (en) 2022-08-08 2022-08-08 Video quantization method and device, electronic equipment and storage medium

Publications (1)

Publication Number Publication Date
CN115278244A true CN115278244A (en) 2022-11-01

Family

ID=83748305

Family Applications (1)

Application Number Title Priority Date Filing Date
CN202210945992.XA Pending CN115278244A (en) 2022-08-08 2022-08-08 Video quantization method and device, electronic equipment and storage medium

Country Status (1)

Country Link
CN (1) CN115278244A (en)

Similar Documents

Publication Publication Date Title
CN109859144B (en) Image processing method and device, electronic equipment and storage medium
CN110536168B (en) Video uploading method and device, electronic equipment and storage medium
US20060245493A1 (en) Macroblock level bit allocation
CN110650370B (en) Video coding parameter determination method and device, electronic equipment and storage medium
KR20090117780A (en) Distortion estimation for quantized data
CN103650504A (en) Control of video encoding based on image capture parameters
KR20130039670A (en) Use of noise-optimized selection criteria to calculate scene white points
WO2017143776A1 (en) Method and device for recognizing picture type
CN107948510B (en) Focal length adjusting method and device and storage medium
CN111193927B (en) Encoded data processing method, apparatus, computer device and storage medium
WO2004056125A1 (en) Video encoding with skipping motion estimation for selected macroblocks
CN115052150A (en) Video encoding method, video encoding device, electronic equipment and storage medium
JP2006005650A (en) Device and method for image encoding
US7956898B2 (en) Digital image stabilization method
Li et al. Saliency based perceptual HEVC
Maugey et al. Using an exponential power model forwyner ziv video coding
Brandao et al. No-reference PSNR estimation algorithm for H. 264 encoded video sequences
CN115278244A (en) Video quantization method and device, electronic equipment and storage medium
CN115297333B (en) Inter-frame prediction method and device of video data, electronic equipment and storage medium
CN109068138B (en) Video image processing method and device, electronic equipment and storage medium
CN109660794B (en) Decision method, decision device and computer readable storage medium for intra prediction mode
CN110166797B (en) Video transcoding method and device, electronic equipment and storage medium
CN117956145A (en) Video encoding method, video encoding device, electronic equipment and storage medium
EP3970376A1 (en) Methods and apparatuses for decoder-side motion vector refinement in video coding
CN118200568A (en) Method and device for determining quantization parameter in video coding and electronic equipment

Legal Events

Date Code Title Description
PB01 Publication
PB01 Publication
SE01 Entry into force of request for substantive examination
SE01 Entry into force of request for substantive examination