Video quantization method, device, electronic device and storage medium

By determining the optimal quantization value of the target transform block in video encoding and calculating the cost adjustment factor, the problem of poor coding performance of the RDOQ algorithm in chroma component is solved, and higher coding accuracy and performance are achieved.

CN115278244BActive Publication Date: 2025-08-26BEIJING DAJIA INTERNET INFORMATION TECH CO LTD
View PDF 2 Cites 0 Cited by

Patent Information

Application Number
CN202210945992.X
Authority / Receiving Office
CN · China
Patent Type
Patents(China)
Current Assignee / Owner
Filing Date
2022-08-08
Publication Date
2025-08-26
Estimated Expiration
2042-08-08

AI Technical Summary

Technical Problem

The existing rate distortion optimization quantization algorithm (RDOQ) has poor encoding performance in chroma component, mainly due to the large error in the calculation of the number of encoding prediction bits, which leads to inaccurate cost of rate distortion.

Method used

When the preset optimization conditions are met, the optimal quantization value of each transformation coefficient of the target transformation block in the video data is determined according to the preset rate distortion optimization strategy, and the cost adjustment factor is calculated in the case of chroma component, and the first rate distortion cost is adjusted to obtain a more accurate second rate distortion cost, thereby performing quantization processing.

Benefits of technology

Improves the video encoding performance of chroma component, and improves the encoding effect through higher accuracy rate distortion cost adjustment.

✦ Generated by Eureka AI based on patent content.

Smart Images

  • Figure CN115278244B_ABST
    Figure CN115278244B_ABST
Patent Text Reader

Abstract

The present disclosure relates to a video quantization method, device, electronic device and storage medium. The method includes: when a preset optimization condition is met, according to a preset rate-distortion optimization strategy, determining the optimal quantization value of each transform coefficient of the target transform block in the video data, and determining the first rate-distortion cost corresponding to the target transform block, and when the component type corresponding to the target transform block is a chroma component, 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. Based on the cost adjustment factor, the first rate-distortion cost is adjusted to obtain a second rate-distortion cost, and the target transform block is quantized 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 performing video encoding on the chroma component.
Need to check novelty before this filing date? Find Prior Art

Description

Technical Field

[0001] The present disclosure relates to the field of video coding technology, and in particular to a video quantization method, device, electronic device, and storage medium. Background Art

[0002] With the development of video coding technology, a video coding algorithm has emerged. In this video coding algorithm, quantization is the core process to achieve good compression effect. Quantization refers to mapping the continuous signal corresponding to video data into multiple discrete values.

[0003] In related technologies, the Rate Distortion Optimization Quantization (RDOQ) algorithm is often used for quantization processing to improve video coding performance. During the calculation process of this algorithm, for each transform block of video data, the corresponding coding prediction number of bits is calculated. This coding prediction number represents the number of bits required to encode the all-zero flag of the transform block. Then, the rate-distortion cost is calculated based on the coding prediction number of bits, and the transform block is quantized and encoded based on this rate-distortion cost.

[0004] However, when determining the number of coding prediction bits for the transform block on the chrominance component, a rate estimation function is usually used for calculation, which has a large error, resulting in an inaccurate calculated rate-distortion cost, leading to poor coding performance of RDOQ on the coding of chrominance components. Summary of the Invention

[0005] The present disclosure provides a video quantization method, apparatus, electronic device, and storage medium to at least address the problem of poor encoding performance of the RDOQ algorithm for chrominance components in related technologies. The technical solutions of the present disclosure are as follows:

[0006] According to a first aspect of an embodiment of the present disclosure, a video quantization method is provided, including:

[0007] determining, in accordance with a preset rate-distortion optimization strategy, an optimal quantization value of each transform coefficient of a target transform block in the video data when a preset optimization condition is satisfied, the target transform block being any one of a plurality of transform blocks included in the video data;

[0008] Obtaining a first rate-distortion cost corresponding to the target transform block, where the first rate-distortion cost is obtained when the quantized values ​​of the transform coefficients are all target values;

[0009] When 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;

[0010] 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.

[0011] In one embodiment, obtaining a first rate-distortion cost corresponding to the target transform block includes:

[0012] Calculating the number of distorted bits according to the difference between the optimal quantization value of each transform coefficient and the target value;

[0013] determining a target coding identifier of the target transform block corresponding to a case where the quantized values ​​of the transform coefficients of the target transform block are all target values, and calculating a first coding prediction bit number for encoding the target coding identifier using a preset coding bit number calculation model corresponding to a luminance component;

[0014] The first rate-distortion cost is calculated according to the number of distorted bits and the first coding prediction number of bits.

[0015] In one embodiment, obtaining a first rate-distortion cost corresponding to the target transform block includes:

[0016] Calculating the number of distorted bits according to the difference between the optimal quantization value of each transform coefficient and the target value;

[0017] Determining a target coding bit number calculation model corresponding to the target component type according to the target component type corresponding to the target transform block;

[0018] determining a target coding identifier of the target transform block corresponding to a case where the quantized values ​​of the transform coefficients of the target transform block are all target values, and calculating a second coding prediction bit number for encoding the target coding identifier using the target coding bit number calculation model;

[0019] The first rate-distortion cost is calculated according to the number of distorted bits and the second coding prediction number of bits.

[0020] 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 when the preset optimization condition is satisfied, the method further comprises:

[0021] 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 positively correlated with the area of ​​the target transformation block;

[0022] counting a target number of optimal quantization values ​​other than target values ​​among the optimal quantization values ​​of each transform coefficient of the target transform block;

[0023] If the target number is less than or equal to the optimization strategy threshold, it is determined that the preset optimization condition is met.

[0024] In one embodiment, the method further comprises:

[0025] If the target number is greater than the optimization strategy threshold, determining that the preset optimization condition is not met;

[0026] In the case where the preset optimization condition is not met, 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;

[0027] Calculating the number of distorted bits according to the difference between the optimal quantization value of each transform coefficient and the target value;

[0028] determining a target coding identifier of the target transform block corresponding to a case where the quantized values ​​of the transform coefficients of the target transform block are all target values, and calculating a first coding prediction bit number for encoding the target coding identifier using a preset coding bit number calculation model corresponding to a luminance component;

[0029] The first rate-distortion cost is calculated according to the number of distorted bits and the first number of coding prediction bits, and quantization processing is performed on the target transform block based on the first rate-distortion cost.

[0030] In one embodiment, calculating the 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 includes:

[0031] Calculating a target ratio of a target number of non-target values ​​in each of the optimal quantization values ​​to an area of ​​the target transform block;

[0032] According to the corresponding relationship between the preset ratio and the adjustment factor, the cost adjustment factor corresponding to the target ratio is determined.

[0033] In one embodiment, adjusting the first rate-distortion cost based on the cost adjustment factor to obtain a second rate-distortion cost includes:

[0034] The product of the cost adjustment factor and the first rate-distortion cost is used as the second rate-distortion cost.

[0035] According to a second aspect of an embodiment of the present disclosure, a video quantization apparatus is provided, including:

[0036] a first determining unit configured to determine, when a preset optimization condition is satisfied and according to a preset rate-distortion optimization strategy, an optimal quantization value of each transform coefficient of a target transform block in the video data, the target transform block being any one of the plurality of transform blocks included in the video data;

[0037] an acquiring unit configured to acquire a first rate-distortion cost corresponding to the target transform block, where the first rate-distortion cost is obtained when the quantized values ​​of the transform coefficients are all target values;

[0038] a first calculation unit configured to calculate 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 when the component type corresponding to the target transform block is a chroma component;

[0039] The adjustment unit is configured to adjust the first rate-distortion cost based on the cost adjustment factor to obtain a second rate-distortion cost, and perform quantization processing on the target transform block based on the second rate-distortion cost.

[0040] In one embodiment, the acquisition unit includes:

[0041] A first calculation subunit is configured to calculate the number of distorted bits according to the difference between the optimal quantization value of each transform coefficient and the target value;

[0042] a second calculation subunit configured to determine a target coding identifier of the target transform block corresponding to a case where the quantized values ​​of the transform coefficients of the target transform block are all target values, and calculate a first coding prediction bit number for encoding the target coding identifier using a preset coding bit number calculation model corresponding to a luminance component;

[0043] The third calculation subunit is configured to calculate the first rate-distortion cost according to the number of distorted bits and the first coding prediction number of bits.

[0044] In one embodiment, the acquisition unit includes:

[0045] a fourth calculation subunit, configured to calculate the number of distorted bits according to a difference between the optimal quantization value of each transform coefficient and the target value;

[0046] a first determining subunit configured to execute, according to a target component type corresponding to the target transform block, a target coding bit number calculation model corresponding to the target component type, determine a target coding identifier of the target transform block corresponding to a case where the quantized values ​​of each transform coefficient of the target transform block are all target values, and calculate a second coding prediction bit number for encoding the target coding identifier using the target coding bit number calculation model;

[0047] The fifth calculation subunit is configured to calculate the first rate-distortion cost according to the number of distorted bits and the second coding prediction number of bits.

[0048] In one embodiment, the apparatus further comprises:

[0049] A second determining unit is 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 positively correlated with the area of ​​the target transform block;

[0050] a counting unit configured to count a target number of optimal quantization values ​​other than target values ​​among the optimal quantization values ​​of each transform coefficient of the target transform block;

[0051] The execution unit is configured to determine that the preset optimization condition is met if the target number is less than or equal to the optimization strategy threshold.

[0052] In one embodiment, the apparatus further comprises:

[0053] a third determining unit, configured to determine that the preset optimization condition is not satisfied if the target number is greater than the optimization strategy threshold;

[0054] a second calculating unit configured to calculate the number of distorted bits according to the difference between the optimal quantization value of each transform coefficient and the target value when the preset optimization condition is not satisfied;

[0055] a third calculation unit configured to determine a target coding identifier of the target transform block corresponding to a case where the quantized values ​​of the transform coefficients of the target transform block are all target values, and calculate a first coding prediction bit number for encoding the target coding identifier using a preset coding bit number calculation model corresponding to a luminance component;

[0056] The fourth calculation unit is configured to calculate the first rate-distortion cost according to the number of distorted bits and the first coding prediction bit number, and perform quantization processing on the target transform block based on the first rate-distortion cost.

[0057] In one embodiment, the first computing unit includes:

[0058] a sixth calculation subunit, configured to calculate a target ratio of a target number of non-target values ​​in each of the optimal quantization values ​​to an area of ​​the target transform block;

[0059] The second determining subunit is configured to determine the cost adjustment factor corresponding to the target ratio according to a preset correspondence between the ratio and the adjustment factor.

[0060] In one embodiment, the adjustment unit includes:

[0061] The adjustment subunit is configured to perform multiplication of the cost adjustment factor and the first rate-distortion cost as the second rate-distortion cost.

[0062] According to a third aspect of an embodiment of the present disclosure, there is provided an electronic device, including:

[0063] processor;

[0064] a memory for storing instructions executable by the processor;

[0065] The processor is configured to execute the instructions to implement the video quantization method as described in any one of the first aspects.

[0066] According to a fourth aspect of an embodiment of the present disclosure, a computer-readable storage medium is provided. When instructions in the computer-readable storage medium are executed by a processor of an electronic device, the electronic device is enabled to perform the video quantization method as described in any one of the first aspects.

[0067] According to a fifth aspect of an embodiment of the present disclosure, a computer program product is provided, wherein the computer program product includes instructions, and when the instructions are executed by a processor of an electronic device, the electronic device is capable of performing the video quantization method as described in any one of the first aspects.

[0068] The technical solutions provided by the embodiments of the present disclosure bring at least the following beneficial effects:

[0069] When preset optimization conditions are met, a cost adjustment factor is calculated based on the area of ​​the target transform block and the target non-target value of the optimal quantized value of each transform coefficient of the target transform block. When the component type corresponding to the current target transform block is a chroma component, the first rate-distortion cost corresponding to quantizing each transform coefficient to the target value is adjusted based on the cost adjustment factor to obtain an adjusted first rate-distortion cost, i.e., a second rate-distortion cost. The target transform block is then quantized based on the second rate-distortion cost. In this way, by adjusting the first rate-distortion cost, the accuracy of determining the rate-distortion cost can be improved, thereby improving the encoding performance when encoding the chroma component video.

[0070] It is to be understood that the foregoing general description and the following detailed description are exemplary and explanatory only and are not restrictive of the disclosure. BRIEF DESCRIPTION OF THE DRAWINGS

[0071] The accompanying drawings herein are incorporated into and constitute a part of the specification, illustrate embodiments consistent with the present disclosure, and together with the description are used to explain the principles of the present disclosure, and do not constitute an improper limitation of the present disclosure.

[0072] Figure 1 The figure is a flowchart of a video quantization method according to an exemplary embodiment.

[0073] Figure 2 The figure is a flowchart showing a step of calculating a first rate-distortion cost according to an exemplary embodiment.

[0074] Figure 3 The figure is a flowchart showing a step of calculating a first rate-distortion cost according to an exemplary embodiment.

[0075] Figure 4 The present invention is a flowchart showing a step of determining an optimal quantization value for each transform coefficient according to an exemplary embodiment.

[0076] Figure 5 The figure is a flowchart showing steps of performing a quantization process according to an exemplary embodiment.

[0077] Figure 6 The figure is a flowchart showing a step of calculating a first rate-distortion cost according to an exemplary embodiment.

[0078] Figure 7 The figure is a flowchart showing a step of determining an optimal quantization value according to an exemplary embodiment.

[0079] Figure 8 is a schematic diagram according to an exemplary embodiment.

[0080] Figure 9is a schematic diagram according to an exemplary embodiment.

[0081] Figure 10 The figure is a block diagram showing a video quantization device according to an exemplary embodiment.

[0082] Figure 11 It is a block diagram of an electronic device according to an exemplary embodiment. DETAILED DESCRIPTION

[0083] In order to enable ordinary persons in the art to better understand the technical solutions of the present disclosure, the technical solutions in the embodiments of the present disclosure will be clearly and completely described below with reference to the accompanying drawings.

[0084] It should be noted that the terms "first," "second," and the like in the specification and claims of the present disclosure and the above-mentioned drawings are used to distinguish similar objects and are not necessarily used to describe a specific order or precedence. It should be understood that the numbers used in this manner are interchangeable where appropriate so that the embodiments of the present disclosure described herein can be implemented in an order other than those illustrated or described herein. The embodiments described in the following exemplary embodiments do not represent all embodiments consistent with the present disclosure. Instead, they are merely examples of apparatus and methods consistent with certain aspects of the present disclosure as detailed in the appended claims.

[0085] 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 used for display, data for analysis, etc.) involved in this disclosure are all information and data authorized by the user or fully authorized by all parties.

[0086] Video coding technologies include intra-frame and inter-frame prediction, transforms, quantization, and entropy coding. Quantization is a core process in video encoding and decoding that achieves effective compression of video data. Video data is typically transmitted as a continuous signal. Quantization maps the corresponding signal to multiple discrete amplitudes, achieving a many-to-one mapping of the signal, reducing the signal's dynamic range and thus achieving video data compression. This is also a major cause of distortion.

[0087] Because quantization affects video distortion and bitrate, it's important to select a high-performance quantization algorithm at the encoder end to improve video coding performance. The rate-distortion optimized quantization algorithm is currently adopted by numerous coding standards, including High Efficiency Video Coding (HEVC), Versatile Video Coding (VVC), and Enhanced Compression Model (ECM). The RDOQ algorithm uses rate-distortion optimization (RDO) to select the optimal quantization value for each coefficient in a transform block, significantly improving coding performance. However, since the HEVC encoder, RDOQ has consistently shown significantly higher coding performance for luma components than for chroma components, a characteristic that persists in VVC and ECM encoders. This is primarily due to RDOQ calculating the number of coding prediction bits for each transform block of the video data. It then calculates a rate-distortion cost based on the number of coding prediction bits, and quantizes and encodes the transform block based on this rate-distortion cost. However, when predicting the number of bits for encoding chroma components in a transform block, a rate estimation function is typically used for calculation, which results in large errors. This leads to poor RDOQ encoding performance for chroma components. Therefore, this disclosure proposes a video quantization method that can improve the encoding performance of chroma components.

[0088] Figure 1 FIG. 1 is a flow chart showing a video quantization method according to an exemplary embodiment. Figure 1 As shown, the video quantization method is used in an electronic device and includes the following steps.

[0089] In step S110 , when a preset optimization condition is met, an optimal quantization value of each transform coefficient of a target transform block in the video data is determined according to a preset rate-distortion optimization strategy.

[0090] Among them, the target transform block is any one of the multiple transform blocks contained in the video data. The target transform block is a TU (Transform Unit) block, which is the unit of quantization. That is, each TU block can be quantized separately during the video quantization process, thereby realizing quantization processing of all video data. A target transform block corresponds to multiple transform coefficients, and a target transform block can include information about the luminance component and information about the chrominance component. The preset rate-distortion optimization strategy can be predetermined by the electronic device.

[0091] In implementation, an electronic device may obtain video data to be quantized. For the video data to be quantized, the electronic device may obtain multiple transform blocks corresponding to the video data to be quantized, and randomly determine a target transform block from the multiple transform blocks. When the electronic device satisfies a preset optimization condition, the electronic device may determine at least one optional quantization value corresponding to each of the multiple transform coefficients included in the target transform block, and calculate the rate-distortion cost corresponding to each optional quantization value, respectively, and use the optional quantization value corresponding to the minimum rate-distortion cost as the optimal quantization value for the transform coefficient. In this way, the electronic device may determine the optimal quantization value for each transform coefficient included in the target transform block.

[0092] Optionally, the electronic device may also determine a transform block from a plurality of transform blocks corresponding to the video data to be quantized as a target transform block according to an actual application scenario.

[0093] In step S120 , a first rate-distortion cost corresponding to the target transform block is obtained.

[0094] The first rate-distortion cost is obtained when the quantized value of each transform coefficient is a target value. For example, the target value may be zero.

[0095] In implementation, the electronic device may set the quantization values ​​of each transform coefficient of the target transform block to the target value. In this way, in the HEVC video coding standard, when the electronic device determines that the quantization values ​​of each transform coefficient 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 the number of bits required to encode the all-zero flag and the number of distorted bits corresponding to the target transform block. In this way, the electronic device may calculate the first rate-distortion cost cost0 of the target transform block based on the number of bits required for encoding and the number of distorted bits. The all-zero flag is used to characterize that the quantization values ​​of each transform coefficient are all target values.

[0096] In step S130 , when 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.

[0097] In implementation, the target transform block includes a luminance component (luma component) and a chrominance component (Cbcomponent, Cr component), and the process of quantizing the luminance component by the electronic device and the process of quantizing the chrominance component are performed independently of each other. In this way, the electronic device can judge the type of component currently being quantized. When it is determined that the type of component currently being quantized is the chrominance component, the electronic device can screen the optimal quantization values ​​of each transform coefficient of the obtained target transform block, determine the number of non-target values ​​(hereinafter referred to as the target number), and obtain the size information of the target transform block, and calculate the area of ​​the target transform block based on the size information. In this way, the electronic device can calculate the cost adjustment factor based on the target number and the area of ​​the target transform block, wherein the cost adjustment factor is a value greater than 1. The execution order of step 120 and step 130 is not specifically limited in this disclosure.

[0098] 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.

[0099] During implementation, the electronic device can adjust the first rate-distortion cost based on the calculated cost adjustment factor. Because the image data of the video signal contains texture, the electronic device may be unable to accurately obtain the number of coding prediction bits for the chrominance component corresponding to the target transform block. For example, this may cause the calculated number of coding prediction bits to be too small, resulting in a too small rate-distortion cost derived from the number of coding prediction bits. Thus, the electronic device can amplify and adjust the first rate-distortion cost based on the cost adjustment factor to obtain a more accurate rate-distortion cost, allowing the electronic device to quantize the target transform block based on the second rate-distortion cost.

[0100] In one embodiment, the process of adjusting the first rate-distortion cost by the electronic device may be as follows:

[0101] Cost0'=Cost0*scale_factor

[0102] Here, Cost0' represents the second rate-distortion cost, Cost0 represents the first rate-distortion cost, and scale_factor represents the cost adjustment factor.

[0103] In one embodiment, the specific process of the electronic device performing quantization processing on the target transform block based on the second rate-distortion cost Cost0′ may include:

[0104] The electronic device calculates the second rate-distortion cost as Cost0' using the method provided in the above embodiment. The electronic device can determine the position of the last non-target optimal quantization value among the optimal quantization values ​​of the transform coefficients corresponding to the target transform block, and set the optimal quantization value to the target value (i.e., set it to zero), obtain the updated optimal quantization value of each transform coefficient, and calculate the third rate-distortion cost in this case as Cost1. If Cost1>Cost0', it means that the encoding effect corresponding to the target transform block being quantized as an all-zero block is better than the encoding effect when the target transform block is quantized as a non-all-zero block. In this way, the electronic device can determine that the quantization values ​​of each transform coefficient of the target transform block are all target values, and perform quantization processing on the target transform block based on the quantization values ​​of each transform coefficient of the target transform block.

[0105] If Cost1≤Cost0', it means that the coding effect of the target transform block quantized as an all-zero block is worse than the coding effect of the target transform block quantized as a non-all-zero block. In this way, the electronic device can use the third rate-distortion cost as Cost0'. In this way, the electronic device can re-determine the position of the optimal quantization value of the last non-target value in the updated optimal quantization values ​​of each transform coefficient, set the optimal quantization value as the target value, recalculate the rate-distortion cost in this case as Cost1, and compare Cost1 with Cost0' until Cost1>Cost0'. In this case, the rate-distortion cost calculated by the electronic device at this time is the optimal rate-distortion cost. In this way, the electronic device can perform quantization processing on the target transform block based on the optimal quantization values ​​of each transform coefficient corresponding to the current Cost1.

[0106] If Cost1≤Cost0', it means that the coding effect of quantizing the target transform block into an all-zero block is worse than the coding effect of quantizing the target transform block into a non-all-zero block. In this way, the electronic device can use the third rate-distortion cost as Cost0'. In this way, the electronic device can re-determine the position of the optimal quantization value of the last non-target value among the optimal quantization values ​​of each updated transform coefficient, set the optimal quantization value as the target value, recalculate the rate-distortion cost in this case as Cost1, and compare Cost1 with Cost0' until the optimal quantization value of the first non-target value of the transform coefficient among the updated optimal quantization values ​​of each transform coefficient is set as the target value. In this way, the electronic device can perform quantization processing on the target transform block based on the optimal quantization value corresponding to each transform coefficient in the current situation.

[0107] In the above-mentioned video quantization method, when preset optimization conditions are met, optimal quantization values ​​for each transform coefficient of a target transform block in the video data are determined according to a preset rate-distortion optimization strategy. A first rate-distortion cost corresponding to the target transform block is determined, the first rate-distortion cost being obtained when the quantization values ​​of each transform coefficient are all target values. If the component type corresponding to the target transform block is a chrominance component, a cost adjustment factor is calculated based on a target number of non-target values ​​in each optimal quantization value and the area of ​​the target transform block. 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. The cost adjustment factor is calculated based on the area of ​​the target transform block and the target number of non-target values ​​in the optimal quantization values ​​of each transform coefficient of the target transform block. If the component type corresponding to the current target transform block is a chrominance component, the first rate-distortion cost corresponding to quantizing each transform coefficient to the target value is adjusted based on the cost adjustment factor to obtain an adjusted first rate-distortion cost, i.e., a second rate-distortion cost, and the target transform block is quantized based on the second rate-distortion cost. In this way, by adjusting the first rate-distortion cost, the accuracy of determining the rate-distortion cost can be improved, thereby improving the encoding performance when performing video encoding on the chrominance component.

[0108] In an exemplary embodiment, Figure 2 As shown, in step 120, obtaining the first rate-distortion cost corresponding to the target transform block can be specifically achieved by the following steps:

[0109] In step 1211, the number of distorted bits is calculated based on the difference between the optimal quantization value of each transform coefficient and the target value.

[0110] The target value can be zero.

[0111] In practice, the number of distorted bits represents the number of bits distorted in the target transform block when all transform coefficients in the target transform block are quantized to target values. For each transform coefficient, the electronic device can calculate the 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 for the transform coefficient. In this way, the electronic device can add up the distorted sub-bits corresponding to each transform coefficient and use the resulting sum as the total number of distorted bits, i.e., the number of distorted bits for the target transform block.

[0112] In step 1212, the target coding identifier of the target transform block corresponding to the target transform block when the quantization values ​​of each transform coefficient of the target transform block are all target values ​​is determined, and the first coding prediction bit number for encoding the target coding identifier is calculated through the preset coding bit number calculation model corresponding to the luminance component.

[0113] Among them, the preset coding bit number calculation model corresponding to the luminance component can be the entropy coding context model (lumaCbfContext) of the luminance component, or it can be other models for calculating the coding bit number corresponding to the luminance component. The present disclosure does not limit this. The target coding identifier indicates that the quantization values ​​of each transform coefficient of the target transform block are all target values.

[0114] In implementation, when the quantization values ​​of each transform coefficient of the transform block are all target values, the coding identifier of the transform block is an all-zero identifier. In this case, when the electronic device performs entropy encoding on the transform block, it only needs to encode the coding identifier of the transform block (i.e., the all-zero identifier); when the quantization value marks of each transform coefficient of the transform block are not all target values, the coding identifier of the transform block is a non-all-zero identifier. In this case, the electronic device needs to encode the non-all-zero identifier and the amplitude of each transform coefficient.

[0115] The electronic device can determine the quantization value of each transform coefficient of the target transform block as the target value, and then the electronic device can determine that when all the transform coefficients of the target transform block are target values, the coding identifier of the target transform block is the target coding identifier (such as an all-zero identifier). When the corresponding component type of the target transform block is a chrominance component, the electronic device can calculate the first coding prediction bit number R(cbf(0)) based on the preset coding bit number calculation model corresponding to the luminance component. Among them, R(cbf(0)) represents the number of bits required for encoding the target coding identifier predicted by the electronic device, cbf is the coding identifier, cbfValue is the value of cbf, cbf=0 means that the quantization values ​​of the transform coefficients of the target transform block are all zero, that is, cbf=0 is an all-zero identifier; cbf=1 means that there is a non-zero quantization value in the quantization value of the transform coefficient of the target transform block.

[0116] In step 1213, a first rate-distortion cost is calculated according to the number of distorted bits and the first coding prediction bit number.

[0117] In implementation, the electronic device may perform superposition processing on the number of distorted bits and the number of coded prediction bits, and use the obtained sum as the first rate-distortion cost cost0. The specific calculation process may be shown in the following formula:

[0118]

[0119] Wherein, N represents the number of transform coefficients in the target transform block; D(Ci,0) represents the distortion corresponding to quantizing the transform coefficient Ci to 0, that is, the number of distortion sub-bits corresponding to the i-th transform coefficient; when all transform coefficients of the current target transform block are quantized to zero, in the field of video coding and decoding, the coefficients of the target transform block do not need to be encoded, and only the coding identifier (Coded Block Flag, CBF) of the current target transform block needs to be written equal to 0, that is, cbf = 0. In other words, if the coding identifier cbf = 0 of the target transform block, it means that the quantized values ​​of all transform coefficients of the target transform block are zero. In this way, the electronic device can determine that the coding identifier of the transform block is the target coding identifier, that is, cbf = 0, and the electronic device only needs to encode cbf = 0. In this way, the number of coding prediction bits R(cbf(0)) represents the number of bits consumed by the electronic device to encode the target coding identifier.

[0120] In this embodiment, the electronic device can use the entropy coding context model (lumaCbfContext) corresponding to the luminance luma component when the component type corresponding to the target transform block is the chroma Cb component and the chroma Cr component, avoiding the use of the context model (ChromaCbContext / ChromaCrContext) carried by the encoder itself. This can effectively reduce the error generated by the electronic device when estimating the number of coding prediction bits corresponding to the chroma component, and improve the accuracy of the first rate-distortion cost calculation corresponding to the chroma component.

[0121] In an exemplary embodiment, Figure 3 As shown, in step 120, obtaining the first rate-distortion cost corresponding to the target transform block can be specifically achieved by the following steps:

[0122] In step 1221, the number of distorted bits is calculated based on the difference between the optimal quantization value of each transform coefficient and the target value.

[0123] In practice, the number of distortion bits represents the number of bits corresponding to the distortion produced by the target transform block when each transform coefficient of the target transform block is quantized to a target value. For each transform coefficient, the electronic device can calculate the 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 distortion sub-bits for the transform coefficient. In this way, the electronic device can add up the distortion sub-bits corresponding to each transform coefficient and use the resulting sum as the total number of distortion bits, i.e., the number of distortion bits for the target transform block.

[0124] In step 1222, based on the target component type corresponding to the target transform block, a target coding bit number calculation model corresponding to the target component type is determined, and the target coding identifier of the target transform block corresponding to the target transform block when the quantization values ​​of each transform coefficient of the target transform block are all target values ​​is determined. The second coding prediction bit number for encoding the target coding identifier is calculated through the target coding bit number calculation model.

[0125] In an implementation, the component types corresponding to the transform block may include a chroma component type and a luminance component type, and the chroma component types may include a chroma Cb component type and a chroma Cr component type. The electronic device may determine the target component type corresponding to the current target transform block, and based on the correspondence between the component type and the coding bit number calculation model, determine the target coding bit number calculation model corresponding to the target component type. In this way, the electronic device may determine the target coding identifier of the corresponding target transform block when the quantized values ​​of each transform coefficient of the target transform block are all target values. In this way, the electronic device may calculate the second coding prediction bit number for encoding the target coding identifier using the target coding bit number calculation model.

[0126] In an example, the correspondence between component type and coding bit calculation model may include: the coding bit calculation model corresponding to the luminance component may be lumaCbfContext, the coding bit calculation model corresponding to the chrominance Cb component may be ChromaCbContext, and the coding bit calculation model corresponding to the chrominance Cr component may be ChromaCrContext.

[0127] Thus, the number of coding prediction bits R(cbf(0)) can be determined by the following process:

[0128] R(cbf(0))=estimateCbfBits(cbfContext,cbfValue)

[0129] Among them, estimateCbfBits is the bit rate estimation function for estimating R(cbf(0)), and cbfContext is the coding bit calculation model.

[0130] In this way, the rate estimation function calculates the number of bits required by simulating the way an actual entropy coding engine encodes the bitstream. Similar to the actual entropy coding method, the input parameters of estimateCbfBits include different context models (cbfContext) corresponding to different types of components and the cbf value (cbfValue), for example, 0 or 1.

[0131] In step 1223, a first rate-distortion cost is calculated according to the number of distorted bits and the second coding prediction number of bits.

[0132] In implementation, the electronic device may perform superposition processing on the number of distorted bits and the number of coded predicted bits, and use the obtained sum as the first rate-distortion cost cost0. The specific calculation process may be the same as formula (1) provided in the above embodiment, and will not be repeated here.

[0133] 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, thereby improving the efficiency of calculating the coding prediction bit number.

[0134] In an exemplary embodiment, the electronic device can determine whether the target transformation block satisfies a preset optimization condition based on the actual situation of the target transformation block, and select different optimization strategies to optimize the target transformation block when the preset optimization condition is met or when the preset optimization condition is not met.

[0135] like Figure 4 As shown, under the condition that the preset optimization conditions are met, before the step of determining the optimal quantization value of each transform coefficient of the target transform block in the video data according to the preset rate-distortion optimization strategy, the video quantization method further includes:

[0136] In step 410, an optimization strategy threshold corresponding to the target transform block is determined according to the area of ​​the target transform block.

[0137] Among them, the optimization strategy threshold is positively correlated with the area of ​​the target transformation block.

[0138] In implementation, the electronic device can determine different optimization strategies based on the comparison result between the target number and the optimization strategy threshold. In the case where the component type corresponding to the target transform block is a chroma component, the electronic device can obtain the size information of the target transform block, which includes the height and width. The electronic device performs a product process based on the height and width of the target transform block to obtain the area of ​​the target transform block. In the field of video coding and decoding, the numerical value of the area of ​​the target transform block is the same as the number of transform coefficients contained in the target transform block. In this way, the electronic device can determine the number of transform coefficients contained in the target transform block based on the area of ​​the target transform block.

[0139] The electronic device may be pre-configured with a scaling factor (i.e., a preset scaling factor). Thus, the electronic device can calculate the optimization strategy threshold based on the preset scaling factor and the area of ​​the target transform block. For example, the electronic device can multiply the preset scaling factor by the area of ​​the target transform block and use the resulting product as the optimization strategy threshold. In other words, if the component type corresponding to the target transform block is a chroma component, the electronic device can calculate the optimization strategy threshold corresponding to the target transform block based on the area of ​​the target transform block and determine different optimization strategies based on a comparison between the optimization strategy threshold and the target number of target transform blocks.

[0140] In one embodiment, the preset proportional coefficient may be one-half. Those skilled in the art may determine the specific value of the preset proportional coefficient based on actual application scenarios, and this disclosure does not limit this.

[0141] In step 420 , a target number of optimal quantization values ​​other than the target value is counted among the optimal quantization values ​​of each transform coefficient of the target transform block.

[0142] The target value may be pre-configured by a technician. In one example, the target value may be zero.

[0143] In implementation, the electronic device may screen the optimal quantized values ​​of each transform coefficient of the target transform block and determine a target number of non-target values ​​contained therein. The electronic device may then compare the target number with an optimization strategy threshold and select a different optimization strategy based on the comparison result.

[0144] In step 430 , if the target number is less than or equal to the optimization strategy threshold, it is determined that the preset optimization condition is met.

[0145] In implementation, if the target number is less than or equal to the optimization strategy threshold, the electronic device can determine that the actual situation of the target transform block meets the preset optimization condition, that is, the preset optimization condition can be that the target number of the target transform block is less than or equal to the optimization strategy threshold. In this way, when the preset optimization condition is met, the electronic device can obtain multiple target transform blocks corresponding to the video data to be quantized, and the target transform blocks correspond to multiple transform coefficients. For each transform coefficient, the electronic device can determine at least one optional quantization value corresponding to the transform coefficient, and calculate the rate-distortion cost corresponding to each optional quantization value based on the preset rate-distortion optimization strategy, 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 quantization value of each transform coefficient contained in the target transform block.

[0146] In this embodiment, the electronic device may determine different optimization strategies according to the comparison result between the number of targets and the optimization strategy threshold, thereby increasing the adaptability of different optimization strategies to the target transformation block.

[0147] In an exemplary embodiment, Figure 5 As shown, the method further includes:

[0148] In step 510, if the target number is greater than the optimization strategy threshold, it is determined that the preset optimization condition is not met; if the preset optimization condition is not met, the optimal quantization value of each transform coefficient of the target transform block in the video data is determined according to the preset rate-distortion optimization strategy.

[0149] In an embodiment, if the target number is greater than the optimization strategy threshold, the electronic device may determine that the target transform block does not meet the preset optimization conditions. Thus, if the preset optimization conditions are not met, 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 the rate-distortion cost corresponding to each optional quantization value. The optional quantization value corresponding to the minimum rate-distortion cost is used as the optimal quantization value for the transform coefficient. In this way, the electronic device can determine the optimal quantization value for each transform coefficient included in the target transform block.

[0150] In step 520, the number of distorted bits is calculated based on the difference between the optimal quantization value of each transform coefficient and the target value.

[0151] The target value can be zero.

[0152] In practice, the number of distorted bits represents the number of bits distorted in the target transform block when all transform coefficients in the target transform block are quantized to target values. For each transform coefficient, the electronic device can calculate the 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 for the transform coefficient. In this way, the electronic device can add up the distorted sub-bits corresponding to each transform coefficient and use the resulting sum as the total number of distorted bits, i.e., the number of distorted bits for the target transform block.

[0153] In step 530, a first coding prediction bit number for encoding the target coding identifier is calculated using a preset coding bit number calculation model corresponding to the luminance component.

[0154] Among them, the preset coding bit calculation model corresponding to the luminance component can be the entropy coding context model (lumaCbfContext) of the luminance component, or it can be other. The present disclosure does not limit this. The target coding identifier is used to indicate that the quantization values ​​of each transform coefficient of the target transform block are all target values.

[0155] In implementation, when the quantization values ​​of each transform coefficient of the transform block are all target values, the coding identifier of the transform block is an all-zero identifier. In this case, when the electronic device performs entropy encoding on the transform block, it only needs to encode the coding identifier of the transform block (i.e., the all-zero identifier); when the quantization value marks of each transform coefficient of the transform block are not all target values, the coding identifier of the transform block is a non-all-zero identifier. In this case, the electronic device needs to encode the non-all-zero identifier and the amplitude of each transform coefficient.

[0156] In step 540 , a first rate-distortion cost is calculated according to the number of distorted bits and the first coding prediction bit number, and quantization processing is performed on the target transform block based on the first rate-distortion cost.

[0157] In implementation, the electronic device can superimpose the number of distorted bits and the number of encoded prediction bits, and use the obtained sum as the first rate-distortion cost. The process of the electronic device quantizing the target transform block based on the first rate-distortion cost is similar to the process of quantizing the target transform block based on the second rate-distortion cost in the above embodiment, and will not be repeated in this disclosure.

[0158] In this embodiment, the electronic device can determine the optimization strategy threshold based on the size information of the target transform block, and determine different optimization strategies based on the comparison result of the optimization strategy threshold and the target number of non-target values ​​in the optimal quantization value of each transform coefficient of the target transform block, which can improve the encoding performance of the RDOQ algorithm in different application scenarios and increase the flexibility of the application scenarios of the RDOQ algorithm.

[0159] In one possible implementation, the target number is compared with the optimization strategy threshold to obtain a comparison result. Selecting a different optimization strategy based on the comparison result can be specifically implemented by the following steps:

[0160] When the target number is less than or equal to the optimization strategy threshold, the electronic device can determine the optimal quantization value of each transform coefficient of the target transform block in the video data according to the preset rate-distortion optimization strategy; obtain a first rate-distortion cost corresponding to the target transform block, and the first rate-distortion cost is obtained when the quantization value of each transform coefficient is the target value; when the component type corresponding to the target transform block is the chrominance component, calculate 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; based on the cost adjustment factor, adjust the first rate-distortion cost to obtain a second rate-distortion cost, and quantize the target transform block based on the second rate-distortion cost.

[0161] Alternatively, when the target number is less than or equal to the optimization strategy threshold, the electronic device can also determine 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; calculate the number of distortion bits according to the difference between the optimal quantization value of each transform coefficient and the target value; calculate the first coding prediction bit number for encoding the target coding identifier through a preset coding bit number calculation model corresponding to the brightness component, the target coding identifier is used to indicate that the quantization values ​​of each transform coefficient of the target transform block are all target values; calculate the first rate-distortion cost according to the distortion bit number and the first coding prediction bit number, and quantize the target transform block based on the first rate-distortion cost.

[0162] When the target number is greater than the optimization strategy threshold, the electronic device can determine the optimal quantization value of each transform coefficient of the target transform block in the video data according to the preset rate-distortion optimization strategy; obtain a first rate-distortion cost corresponding to the target transform block, the first rate-distortion cost is obtained when the quantization value of each transform coefficient is the target value; calculate the number of distortion bits according to the difference between the optimal quantization value of each transform coefficient and the target value; calculate the first coding prediction bit number for encoding the target coding identifier through a preset coding bit number calculation model corresponding to the luminance component, the target coding identifier is used to indicate that the quantization value of each transform coefficient of the target transform block is the target value; calculate the first rate-distortion cost according to the number of distortion bits and the first coding prediction bit number; adjust the first rate-distortion cost based on the cost adjustment factor to obtain a second rate-distortion cost, and quantize the target transform block based on the second rate-distortion cost.

[0163] In an exemplary embodiment, Figure 6 As shown, in step 130, according to the target number of non-target values ​​in each optimal quantization value and the area of ​​the target transform block, the cost adjustment factor can be calculated by the following steps:

[0164] In step 131 , a target ratio of the target number of non-target values ​​in each optimal quantization value to the area of ​​the target transform block is calculated.

[0165] During implementation, the electronic device determines the optimal quantization value for each transform coefficient of the target transform block in the video data based on a preset distortion optimization strategy. This allows the electronic device to determine the number of non-target values, i.e., the target number, among the optimal quantization values ​​of each transform coefficient. The electronic device can also obtain size information of the target transform block and calculate the area of ​​the target transform block based on this size information. This allows the electronic device to calculate a target ratio based on the target number and the area of ​​the target transform block. The numerical value of the area of ​​the target transform block is the same as the number of transform coefficients corresponding to the target transform block. Thus, the electronic device can determine the number of transform coefficients corresponding to the target ratio based on the numerical value of the area of ​​the target transform block.

[0166] In one example, the target value may be zero, so that the electronic device may calculate the number numSig of non-zero quantization values ​​in the optimal quantization value of the target transform block. The electronic device may calculate the ratio chromaRatio of the non-zero quantization values, and the ratio chromaRatio may be calculated by the following formula:

[0167] chromaRatio=numSig / TUArea,

[0168] Wherein, TUArea represents the area of ​​the target transform block, and the area TUArea of ​​the target transform block can be calculated by the following formula:

[0169] TUArea=TUHeight*TUWidth,

[0170] Among them, TUHeight represents the height of the target transform block, and TUWidth represents the width of the target transform block.

[0171] In step 132 , a cost adjustment factor corresponding to the target ratio is determined according to a preset correspondence between the ratio and the adjustment factor.

[0172] In implementation, the electronic device can determine the correspondence between the preset ratio and the adjustment factor based on the actual application scenario. For example, scale_factor can be = chromaRatio*2+1, where scale_factor represents the cost adjustment factor and chromaRatio represents the target ratio. Based on the correspondence between the preset ratio and the adjustment factor, the electronic device can determine the range of the cost adjustment factor to be 1.0≤scale_factor≤3.0.

[0173] In this embodiment, the cost adjustment factor can 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 is more adapted to the target transform block, thereby ensuring the accuracy of the cost adjustment factor.

[0174] In an exemplary embodiment, in step 140, adjusting the first rate-distortion cost based on the cost adjustment factor to obtain the second rate-distortion cost can be specifically achieved by the following steps:

[0175] The product of the cost adjustment factor and the first rate-distortion cost is used as the second rate-distortion cost.

[0176] In an implementation, the electronic device may adjust the first rate-distortion cost cost0 based on the cost adjustment factor by performing a multiplication operation on the first rate-distortion cost cost0 and the cost adjustment factor, and use the product as the second rate-distortion cost cost0′.

[0177] In this embodiment, the first rate-distortion cost can be adjusted promptly based on the cost adjustment factor, so that the calculated first rate-distortion cost can be more accurate.

[0178] 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 can be specifically implemented by the following steps:

[0179] The area of ​​the target transformation block and the preset proportional coefficient are multiplied to determine the optimization strategy threshold corresponding to the target transformation block.

[0180] 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. Those skilled in the art may determine the specific value of the preset scaling factor according to actual application scenarios, and this disclosure does not limit this.

[0181] In implementation, the electronic device may perform a product process on the area of ​​the target transformation block and a preset proportional coefficient, and use the obtained product as the optimization strategy threshold corresponding to the target transformation block.

[0182] In this embodiment, the optimization strategy threshold may be calculated based on the actual situation of the target transformation block, so that the obtained optimization strategy threshold may be more accurate.

[0183] In an exemplary embodiment, Figure 7 As shown, in step 110, according to the preset rate-distortion optimization strategy, determining the optimal quantization value of each transform coefficient of the target transform block in the video data can be specifically achieved by the following steps:

[0184] In step 710 , for each transform coefficient of the target transform block, at least one optional quantization value of the transform coefficient is obtained.

[0185] In implementation, the target transform block TU includes multiple transform coefficients. For each transform coefficient, the terminal can calculate the optional quantization value of the transform coefficient according to the value of the transform coefficient. Specifically, the optional quantization value of the i-th transform coefficient can be calculated by the following formula:

[0186] |l i |=round(|C i | / Q step ),

[0187] Among them, C i is the value of the i-th transform coefficient of the target transform block TU, l i Indicates C i Pre-quantization obtains the quantized value. round(*) means rounding * to the nearest integer. |*| means taking the absolute value of *. Qstep Indicates the quantization step size.

[0188] Optionally, the quantization step size Q step You can use Q step =(2^(QP-4)) / 6, where QP represents a quantization parameter. The specific value of the quantization parameter can be determined by those skilled in the art based on actual application scenarios and is not limited in this disclosure. For example, the value of the quantization parameter is an integer in the range [0, 51].

[0189] In this way, the electronic device can i The size of | determines the optional quantization value, specifically according to |l i The corresponding relationship between the optional quantization values ​​determined by the size of | can be as shown in the following Table 1:

[0190] Table 1

[0191] <![CDATA[|l i |]]> 0 1 2 3 … N Optional quantization value 0 0,1 0,1,2 2,3 … N-1,N

[0192] For example, the second transform coefficient corresponds to |l i |=2, thus, the electronic device can determine that the optional quantization values ​​of the second transform coefficient may include 0, 1, and 2.

[0193] In step 720, the rate-distortion cost corresponding to each optional quantization value is calculated respectively, and the optional quantization value corresponding to the minimum rate-distortion cost is used as the optimal quantization value of the transform coefficient.

[0194] In implementation, the electronic device determines one or more optional quantization values ​​corresponding to each transform coefficient. Thus, for each transform coefficient, the electronic device needs to separately calculate the rate-distortion cost when the transform coefficient is quantized to each optional quantization value, and select the optional quantization value corresponding to the minimum rate-distortion cost among the multiple rate-distortion costs corresponding to the various optional quantization values ​​as the optimal quantization value for the transform coefficient.

[0195] In one example, the preset rate-distortion optimization strategy may be an RDO criterion. The electronic device may calculate the optimal quantization value corresponding to each transform coefficient using the following formula:

[0196] J(l i,k )=D(c i ,l i,k )+λ*R(l i,k )

[0197] Among them, D(c i ,l i,k ) means c i Quantized to l i,k When the total number of distorted bits of the target transform block is i,k) means c i Quantized to l i,k When the total number of coded bits of the target transform block is i,k ) means c i Quantized to l i,k The rate-distortion cost of the target transform block when .

[0198] For example, the optional quantization values ​​for the second transform coefficient may include 0, 1, and 2. The electronic device may calculate the rate-distortion cost a1 of the corresponding target transform block when the second transform coefficient is quantized to 0, the rate-distortion cost a2 of the corresponding target transform block when the second transform coefficient is quantized to 1, and the rate-distortion cost a3 of the corresponding target transform block when the second transform coefficient is quantized to 2. In this way, the electronic device may compare the rate-distortion cost a1, the rate-distortion cost a2, and the rate-distortion cost a3 to determine the minimum rate-distortion cost, and use the optional quantization value corresponding to the minimum rate-distortion cost as the optimal quantization value for the second transform coefficient. For example, the comparison result may be a1 < a2, and a1 < a3. In this way, the electronic device may determine that the optimal quantization value for the second transform coefficient may be 0. The process of determining the optimal quantization value for the target transform block is similar to the process of determining the optimal quantization value for the second transform coefficient and will not be repeated here.

[0199] In this embodiment, the rate-distortion optimization strategy can accurately and efficiently determine the optimal quantization value of each transform coefficient of the target transform block.

[0200] In one example, the process of quantizing the target transform block by the electronic device may be as follows: Figure 8 As shown:

[0201] The electronic device calculates a rate-distortion optimization cost (which can be denoted as RDCOST) when the quantization values ​​of all transform coefficients in the target transform block (current TU block) are zero: a first rate-distortion cost (which can be denoted as Cost0), and initializes the position of the optimal last non-zero coefficient in the current case (which can be denoted as BestLastNZPos), i.e., BestLastNZPos = 0. The electronic device determines whether the component type of the currently processed target transform block is a chroma component. If it is determined that the component type of the currently processed target transform block is a chroma component, the electronic device calculates a second rate-distortion cost (which can be denoted as Cost0') based on the cost adjustment factor scale_factor and the first rate-distortion cost Cost0, i.e., Cost0' = Cost0 * scale_factor. At this time, the current coefficient position (which can be denoted as nzPos) is the position of the last non-zero quantization value among the optimal quantization values ​​of each transform coefficient, i.e., nzPos = LastNZPos.

[0202] When the electronic device determines that the current coefficient position is greater than or equal to 0, the electronic device can set the last non-zero quantization value among the respective optimal quantization values of the respective transform coefficients of the current TU block to 0, obtain the respective optimal quantization values of the respective updated transform coefficients, and calculate the third rate-distortion cost in this case as cost1.

[0203] In this way, when the second rate-distortion cost is less than the first rate-distortion cost (cost1 < Cost0’), the electronic device can re-determine the position of the last non-zero quantization value among the respective optimal quantization values of the respective updated transform coefficients, that is, BestLastNZPos = nzPos - 1, and take the calculated third rate-distortion cost as cost0, and then re-execute the step of whether the current coefficient position is greater than or equal to 0.

[0204] In an example, the process by which the electronic device quantizes the target transform block can be as Figure 9 shown:

[0205] The electronic device calculates the rate-distortion optimization cost RDCOST when the quantization values of all transform coefficients of the target transform block (current TU block) are zero: the first rate-distortion cost Cost0. In this way, the position of the optimal last non-zero coefficient in the current case is initialized, that is, BestLastNZPos = 0. At this time, the coefficient position is the position of the last non-zero quantization value among the respective optimal quantization values of the respective transform coefficients, that is, nzPos = LastNZPos.

[0206] When the electronic device determines that the current coefficient position is greater than or equal to 0, the electronic device can set the last non-zero quantization value among the respective optimal quantization values of the respective transform coefficients of the current TU block to 0, obtain the respective optimal quantization values of the respective updated transform coefficients, and calculate the third rate-distortion cost in this case as cost1.

[0207] In this way, when cost1 < Cost0’, the electronic device can re-determine the position of the last non-zero quantization value among the respective optimal quantization values of the respective updated transform coefficients, that is, BestLastNZPos = nzPos - 1, and take the calculated third rate-distortion cost as cost0, and then re-execute the step of whether the current coefficient position is greater than or equal to 0.

[0208] It should be understood that although Figures 1-9The steps in the flowchart are shown in sequence as indicated by the arrows, but these steps are not necessarily executed in the order indicated by the arrows. Unless otherwise specified in this document, there is no strict order restriction for the execution of these steps, and these steps can be executed in other orders. In addition, Figures 1-9 At least part of the steps may include multiple steps or multiple stages. These steps or stages are not necessarily performed at the same time, but can be performed at different times. The order of execution of these steps or stages is not necessarily one by one, but can be performed in turn or alternately with other steps or at least part of the steps or stages in other steps.

[0209] It can be understood that the same / similar parts between the various embodiments of the above method in this specification can be referred to each other, and each embodiment focuses on the differences from other embodiments. For related parts, please refer to the description of other method embodiments.

[0210] Figure 10 FIG. 1 is a block diagram of a device for video quantization according to an exemplary embodiment. Figure 10 The device includes a first determining unit 1001, an acquiring unit 1002, a first calculating unit 1003 and an adjusting unit 1004.

[0211] The first determining unit 1001 is configured to determine, when a preset optimization condition is satisfied, an optimal quantization value of each transform coefficient of a target transform block in the video data according to a preset rate-distortion optimization strategy, where the target transform block is any one of the multiple transform blocks included in the video data;

[0212] An acquiring unit 1002 is configured to acquire a first rate-distortion cost corresponding to a target transform block, where the first rate-distortion cost is obtained when the quantized values ​​of each transform coefficient are all target values;

[0213] The first calculation unit 1003 is configured to calculate a cost adjustment factor according to a target number of non-target values ​​in each optimal quantization value and an area of ​​the target transform block when the component type corresponding to the target transform block is a chroma component;

[0214] The adjusting unit 1004 is configured to adjust the first rate-distortion cost based on the cost adjustment factor to obtain a second rate-distortion cost, and perform quantization processing on the target transform block based on the second rate-distortion cost.

[0215] In one embodiment, the acquiring unit 1002 includes:

[0216] A first calculation subunit is configured to calculate the number of distorted bits according to the difference between the optimal quantization value of each transform coefficient and the target value;

[0217] The second calculation subunit is configured to determine a target coding identifier of the target transform block corresponding to the target transform block when the quantized values ​​of the transform coefficients of the target transform block are all target values, and calculate a first coding prediction bit number for encoding the target coding identifier using a preset coding bit number calculation model corresponding to the luminance component;

[0218] The third calculation subunit is configured to calculate a first rate-distortion cost according to the number of distorted bits and the first coding prediction number of bits.

[0219] In one embodiment, the acquiring unit 1002 includes:

[0220] a fourth calculation subunit, configured to calculate the number of distorted bits according to the difference between the optimal quantization value of each transform coefficient and the target value;

[0221] The first determining subunit is configured to execute a target coding bit number calculation model corresponding to a target classification type according to a target component type corresponding to the target transform block, determine a target coding identifier of the target transform block corresponding to the target transform block when the quantized values ​​of each transform coefficient of the target transform block are all target values, and calculate a second coding prediction bit number for encoding the target coding identifier using the target coding bit number calculation model;

[0222] The fifth calculation subunit is configured to calculate a first rate-distortion cost according to the number of distorted bits and the second coding prediction number of bits.

[0223] In one embodiment, the apparatus further comprises:

[0224] A second determining unit is configured to determine an optimization strategy threshold corresponding to the target transform block according to the area of ​​the target transform block, where the optimization strategy threshold is positively correlated with the area of ​​the target transform block;

[0225] a counting unit configured to count a target number of optimal quantization values ​​other than target values ​​among the optimal quantization values ​​of each transform coefficient of the target transform block;

[0226] The execution unit is configured to determine that a preset optimization condition is met if the target number is less than or equal to an optimization strategy threshold.

[0227] In one embodiment, the apparatus further comprises:

[0228] A third determining unit is configured to determine that a preset optimization condition is not satisfied if the target number is greater than the optimization strategy threshold;

[0229] A second calculation unit is configured to calculate the number of distorted bits according to the difference between the optimal quantization value of each transform coefficient and the target value when the preset optimization condition is not met;

[0230] a third calculation unit configured to determine a target coding identifier of a target transform block corresponding to a case where the quantized values ​​of the transform coefficients of the target transform block are all target values, and calculate a first coding prediction bit number for encoding the target coding identifier using a preset coding bit number calculation model corresponding to a luminance component;

[0231] The fourth calculation unit is configured to calculate a first rate-distortion cost according to the number of distorted bits and the first coding prediction bit number, and perform quantization processing on the target transform block based on the first rate-distortion cost.

[0232] In one embodiment, the first computing unit 1003 includes:

[0233] a sixth calculation subunit, configured to calculate a target ratio of a target number of non-target values ​​in each optimal quantization value to an area of ​​a target transform block;

[0234] The second determining subunit is configured to determine the cost adjustment factor corresponding to the target ratio according to a preset correspondence between the ratio and the adjustment factor.

[0235] In one embodiment, the adjusting unit 1004 includes:

[0236] The adjustment subunit is configured to multiply the cost adjustment factor by the first rate-distortion cost to obtain the second rate-distortion cost.

[0237] Regarding the apparatus in the above embodiment, the specific manner in which each module performs operations has been described in detail in the embodiment of the method, and will not be elaborated here.

[0238] Figure 11 FIG1 is a block diagram of an electronic device 1100 for a video quantization method according to an exemplary embodiment. For example, the electronic device 1100 may be a mobile phone, a computer, a digital broadcast terminal, a messaging device, a game console, a tablet device, a medical device, a fitness device, a personal digital assistant, etc.

[0239] Reference Figure 11 , the electronic device 1100 may include one or more of the following components: a processing component 1102 , a memory 1104 , a power component 1106 , a multimedia component 1108 , an audio component 1110 , an input / output (I / O) interface 1112 , a sensor component 1114 , and a communication component 1116 .

[0240] The processing component 1102 generally controls the overall operation of the electronic device 1100, such as operations associated with display, phone calls, data communications, camera operation, and recording operations. The processing component 1102 may include one or more processors 1120 to execute instructions to perform all or part of the steps of the above-described method. In addition, the processing component 1102 may include one or more modules to 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.

[0241] The memory 1104 is configured to store various types of data to support operations on the electronic device 1100. Examples of such data include instructions for any application or method operating on the electronic device 1100, contact data, phone book data, messages, pictures, videos, etc. The memory 1104 can be implemented by any type of volatile or non-volatile storage device, or a combination thereof, 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.

[0242] The power supply component 1106 provides power to the various components of the electronic device 1100. The power supply component 1106 may include a power management system, one or more power supplies, and other components associated with generating, managing, and distributing power to the electronic device 1100.

[0243] The multimedia component 1108 includes a screen that provides an output interface between the electronic device 1100 and the user. 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 input signals from the user. The touch panel includes one or more touch sensors to sense touches, slides, and gestures on the touch panel. The touch sensor can not only sense the boundaries 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 camera and / or a rear camera. When the electronic device 1100 is in an operating mode, such as a shooting mode or a video mode, the front camera and / or the rear camera can receive external multimedia data. Each front camera and rear camera can be a fixed optical lens system or have a focal length and optical zoom capability.

[0244] The audio component 1110 is configured to output and / or input audio signals. For example, the audio component 1110 includes a microphone (MIC), which is configured to receive external audio signals when the electronic device 1100 is in an operating mode, such as a call mode, a recording mode, and a voice recognition mode. The received audio signal can be further stored in the memory 1104 or transmitted via the communication component 1116. In some embodiments, the audio component 1110 also includes a speaker for outputting audio signals.

[0245] I / O interface 1112 provides an interface between processing component 1102 and peripheral interface modules, such as a keyboard, click wheel, buttons, etc. These buttons may include but are not limited to: a home button, volume buttons, a start button, and a lock button.

[0246] The sensor assembly 1114 includes one or more sensors for providing various aspects of the status assessment of the electronic device 1100. For example, the sensor assembly 1114 can detect the open / closed state of the electronic device 1100, the relative positioning of components, such as the display and keypad of the electronic device 1100. The sensor assembly 1114 can also detect changes in the 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, the orientation or acceleration / deceleration of the device 1100, and temperature changes of the electronic device 1100. The sensor assembly 1114 can include a proximity sensor configured to detect the presence of nearby objects without any physical contact. The sensor assembly 1114 can also include an optical sensor, such as a CMOS or CCD image sensor, for use in imaging applications. In some embodiments, the sensor assembly 1114 can also include an accelerometer, a gyroscope, a magnetic sensor, a pressure sensor, or a temperature sensor.

[0247] The communication component 1116 is configured to facilitate wired or wireless communication between the electronic device 1100 and other devices. The electronic device 1100 can 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 a broadcast signal 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 communication. For example, the NFC module can be implemented based on radio frequency identification (RFID) technology, infrared data association (IrDA) technology, ultra-wideband (UWB) technology, Bluetooth (BT) technology and other technologies.

[0248] 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, microcontrollers, microprocessors, or other electronic components to perform the above-described methods.

[0249] In an exemplary embodiment, a computer-readable storage medium including instructions is also provided, such as a memory 1104 including instructions, and the instructions can be executed by the processor 1120 of the electronic device 1100 to perform the above method. For example, the computer-readable storage medium can be a ROM, a random access memory (RAM), a CD-ROM, a magnetic tape, a floppy disk, an optical data storage device, etc.

[0250] In an exemplary embodiment, a computer program product is further provided. The computer program product includes instructions, and the instructions can be executed by the processor 1120 of the electronic device 1100 to implement the above method.

[0251] It should be noted that the above-mentioned devices, electronic devices, computer-readable storage media, computer program products, etc. can also include other implementation methods according to the description of the method embodiments. The specific implementation methods can refer to the description of the relevant method embodiments and will not be described one by one here.

[0252] Other embodiments of the present disclosure will readily occur to those skilled in the art after considering the specification and practicing the invention disclosed herein. This disclosure is intended to cover any variations, uses, or adaptations of the present disclosure that follow the general principles of the present disclosure and include common knowledge or customary techniques in the art not disclosed herein. The description and examples are to be considered as exemplary only, with the true scope and spirit of the present disclosure being indicated by the claims.

[0253] It should be understood that the present disclosure is not limited to the exact structures that have been described above and shown in the drawings, and that various modifications and changes can be made without departing from the scope thereof. The scope of the present disclosure is limited only by the appended claims.

Claims

1. A video quantization method, characterized in that: include: determining, in accordance with a preset rate-distortion optimization strategy, an optimal quantization value of each transform coefficient of a target transform block in the video data when a preset optimization condition is satisfied, the target transform block being any one of a plurality of transform blocks included in the video data; Obtaining a first rate-distortion cost corresponding to the target transform block, where the first rate-distortion cost is obtained when the quantized values ​​of the transform coefficients are all target values; When 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, the cost adjustment factor being a value greater than 1; 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; Calculating the cost adjustment factor according to the target number of non-target values ​​in each of the optimal quantized values ​​and the area of ​​the target transform block includes: calculating a target ratio of the target number of non-target values ​​in each of the optimal quantized values ​​to the area of ​​the target transform block; According to the corresponding relationship between the preset ratio and the adjustment factor, the cost adjustment factor corresponding to the target ratio is determined.

2. The video quantization method according to claim 1, wherein: The obtaining a first rate-distortion cost corresponding to the target transform block includes: Calculating the number of distorted bits according to the difference between the optimal quantization value of each transform coefficient and the target value; determining a target coding identifier of the target transform block corresponding to a case where the quantized values ​​of the transform coefficients of the target transform block are all target values, and calculating a first coding prediction bit number for encoding the target coding identifier using a preset coding bit number calculation model corresponding to a luminance component; The first rate-distortion cost is calculated according to the number of distorted bits and the first coding prediction number of bits.

3. The video quantization method according to claim 1, wherein: The obtaining a first rate-distortion cost corresponding to the target transform block includes: Calculating the number of distorted bits according to the difference between the optimal quantization value of each transform coefficient and the target value; determining, according to a target component type corresponding to the target transform block, a target coding bit number calculation model corresponding to the target component type, determining a target coding identifier of the target transform block corresponding to a case where quantized values ​​of transform coefficients of the target transform block are all target values, and calculating a second coding prediction bit number for encoding the target coding identifier using the target coding bit number calculation model; The first rate-distortion cost is calculated according to the number of distorted bits and the second coding prediction number of bits.

4. The video quantization method according to 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 when the 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 positively correlated with the area of ​​the target transformation block; counting a target number of optimal quantization values ​​other than target values ​​among the optimal quantization values ​​of each transform coefficient of the target transform block; If the target number is less than or equal to the optimization strategy threshold, it is determined that the preset optimization condition is met.

5. The video quantization method according to claim 4, characterized in that: The method further comprises: If the target number is greater than the optimization strategy threshold, determining that the preset optimization condition is not met; In the case where the preset optimization condition is not met, 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; Calculating the number of distorted bits according to the difference between the optimal quantization value of each transform coefficient and the target value; determining a target coding identifier of the target transform block corresponding to a case where the quantized values ​​of the transform coefficients of the target transform block are all target values, and calculating a first coding prediction bit number for encoding the target coding identifier using a preset coding bit number calculation model corresponding to a luminance component; The first rate-distortion cost is calculated according to the number of distorted bits and the first number of coding prediction bits, and quantization processing is performed on the target transform block based on the first rate-distortion cost.

6. The video quantization method according to claim 1, wherein: The adjusting the first rate-distortion cost based on the cost adjustment factor to obtain a second rate-distortion cost includes: The product of the cost adjustment factor and the first rate-distortion cost is used as the second rate-distortion cost.

7. A video quantization device, characterized in that: include: a first determining unit configured to determine, when a preset optimization condition is satisfied and according to a preset rate-distortion optimization strategy, an optimal quantization value of each transform coefficient of a target transform block in the video data, the target transform block being any one of the plurality of transform blocks included in the video data; an acquiring unit configured to acquire a first rate-distortion cost corresponding to the target transform block, where the first rate-distortion cost is obtained when the quantized values ​​of the transform coefficients are all target values; a calculation unit configured to calculate 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 when the component type corresponding to the target transform block is a chroma component, wherein the cost adjustment factor is a value greater than 1; an adjusting unit configured to adjust the first rate-distortion cost based on the cost adjustment factor to obtain a second rate-distortion cost, and perform quantization processing on the target transform block based on the second rate-distortion cost; The calculation unit is specifically configured to calculate the target ratio of the target number of non-target values ​​in each of the optimal quantization values ​​to the area of ​​the target transformation block; and determine the cost adjustment factor corresponding to the target ratio based on the corresponding relationship between the preset ratio and the adjustment factor.

8. An electronic device, characterized in that: include: processor; a memory for storing instructions executable by the processor; The processor is configured to execute the instructions to implement the video quantization method according to any one of claims 1 to 6.

9. A computer-readable storage medium, characterized in that When the instructions in the computer-readable storage medium are executed by a processor of an electronic device, the electronic device is enabled to perform the video quantization method according to any one of claims 1 to 6.

10. A computer program product comprising instructions, characterized in that: When the instruction is executed by a processor of an electronic device, the electronic device is enabled to execute the video quantization method according to any one of claims 1 to 6.

Citation Information

Patent Citations

  • Coefficient optimization method of RDOQ, acceleration method and device of RDOQ

    CN108322749A

  • Image encoding method, image decoding method and related device

    CN113747176A