Rate-Distortion Model-Based Bitrate Control Coding Method, System, Device, and Medium
By employing higher-order rate-distortion models with frame-level switching in video coding, the method addresses limitations in existing rate control schemes, achieving improved coding performance and accuracy.
Patent Information
- Application Number
- CN202410056285.4
- Authority / Receiving Office
- CN · China
- Patent Type
- Patents(China)
- Current Assignee / Owner
- Filing Date
- 2024-01-15
- Publication Date
- 2025-07-15
- Estimated Expiration
- 2044-01-15
AI Technical Summary
The existing λ domain code rate control scheme based on hyperbolic distortion model has room for improvement in encoding performance and code rate control error, especially in the high-efficiency video encoding standards, which fail to achieve ideal accuracy and effect.
The N-rate distortion model is constructed, combined with the frame-level rate distortion model switching scheme, adjust the rate distortion model parameters frame by frame, and control the bitrate rate by fitting a higher-precision rate distortion model, including the quadratic or quadratic rate distortion model, and select the encoding configuration with the lowest rate distortion cost during the encoding process.
It improves the encoding performance and the accuracy of bit rate control, reduces the encoding error, and improves the encoding efficiency of the encoder and the accuracy of bit rate control.
Smart Images

Figure CN117692645B_ABST
Abstract
Description
Technical Field
[0001] The present invention relates to the technical field of video coding, and in particular to a bitrate control coding method, system, device and storage medium based on a rate-distortion model. Background Art
[0002] In a bitrate control coding scheme, for a video frame to be encoded, bitrate control is performed through a rate-distortion model, and then the encoding work is completed.
[0003] Currently, the bitrate control schemes based on the rate-distortion model are mainly divided into the following two categories:
[0004] The first category is: the bitrate control scheme based on the Q domain / ρ domain.
[0005] The Q-domain bitrate control scheme models the relationship between the quantization parameter Q and the bitrate. Specifically, the Q-domain bitrate control scheme updates the model parameters according to the intermediate results of the encoding process. After that, according to the updated model parameters, the relationship between the quantization parameter Q and the bitrate can be obtained, and then the value of the quantization parameter that needs to be set to achieve the target bitrate can be calculated. The Q-domain bitrate control scheme assumes that the quantization parameter is the key factor in bitrate control. However, with the development of the encoder, this assumption no longer holds. Therefore, the latest encoders rarely use the Q-domain bitrate control scheme.
[0006] The technical solution of the ρ-domain bitrate control attempts to model the relationship between the proportion ρ of zeros in the quantized transform coefficients and the bitrate. Since there is a direct relationship between the quantization parameter and the proportion of zeros in the quantized transform coefficients, its essence is no different from the Q-domain bitrate control scheme. And because the ρ-domain bitrate control scheme is not easily applied to the advanced video coding scheme that supports variable block size quantization, the latest encoders rarely use the ρ-domain bitrate control scheme.
[0007] The second category is: the λ-domain bitrate control scheme based on the double curvature distortion model.
[0008] λ is the Lagrange parameter in the rate-distortion optimization objective J of video coding. It determines the trade-off between the bitrate and the distortion in the rate-distortion optimization objective, and thus affects all aspects of the encoding process. The optimization objective J is expressed as:
[0009] J = D + λR
[0010] where R is the bitrate and D is the distortion.
[0011] At the same time, λ is also the slope of the rate-distortion curve, which can be expressed as the following formula:
[0012]
[0013] where is the partial derivative symbol.
[0014] The λ-domain bitrate control scheme attempts to model the relationship between the Lagrangian parameter λ and the bitrate. Since λ is the slope of the rate-distortion curve, in order to establish the relationship between λ and the bitrate, it is necessary to first model the relationship between the bitrate and the distortion.
[0015] A typical rate-distortion model is the double-curvature distortion model, as shown in the following formula:
[0016] D(R) = CR -K
[0017] where D(R) represents the functional relationship between the distortion D and the bitrate R, and both C and K are model parameters related to the characteristics of the encoded video.
[0018] The double-curvature distortion model performs well within the bitrate range of practical applications. Therefore, the λ-domain bitrate control scheme uses it as the rate-distortion relationship model. Substituting it into the relationship between the Lagrangian parameter λ and the bitrate and the distortion, the relationship between the Lagrangian parameter λ and the bitrate can be obtained, as shown in the following formula:
[0019]
[0020] where is the "defined as" symbol, that is indicates that α is defined as b, and α and β are model parameters related to the characteristics of the encoded video.
[0021] Therefore, based on the model of the λ-domain bitrate control scheme, for the units (sequence, group of pictures, frame, block) in the video coding process, as long as the parameters α and β of the double-curvature distortion model can be obtained as accurately as possible according to the characteristics of the encoded content, the value of the Lagrangian parameter λ can be obtained to approach the target bitrate. Currently, the λ-domain bitrate control scheme based on the double-curvature distortion model is applied to the HEVC (High Efficiency Video Coding) reference software HM (software for encoding and decoding that conforms to the HEVC standard), and continues to be used in the VVC (Versatile Video Coding) reference software VTM (software for encoding and decoding that conforms to the VVC standard). However, there is still room for improvement in the coding performance and bitrate control error of the λ-domain bitrate control scheme based on the double-curvature distortion model.
[0022] In view of this, the present invention is specifically proposed. Summary of the Invention
[0023] The purpose of the present invention is to provide a bitrate control encoding method, system, device, and storage medium based on a rate-distortion model, which realizes a bitrate control scheme with higher accuracy and better coding performance by fitting a rate-distortion model with higher accuracy and adaptively adjusting the rate-distortion model frame by frame according to the content.
[0024] The object of the present invention is achieved by the following technical solutions:
[0025] A rate control encoding method based on a rate-distortion model, comprising:
[0026] Step 1, constructing an N-th order rate-distortion model based on a double-curvature distortion model, where N is an integer greater than or equal to 2;
[0027] Step 2, calculating the target bitrate of the current group of video frames in the video sequence, and calculating the bitrates allocated to each video frame in the current group of video frames according to whether a frame-level rate-distortion model switching scheme is enabled; wherein, if the frame-level rate-distortion model switching scheme is enabled, the rate-distortion model includes the N-th order rate-distortion model and the double-curvature distortion model, and if the frame-level rate-distortion model switching scheme is not enabled, the rate-distortion model is the N-th order rate-distortion model;
[0028] Step 3, if the frame-level rate-distortion model switching scheme is enabled, for the current video frame to be encoded in the current group of video frames, calculating the parameters of each rate-distortion model respectively, and determining the rate-distortion model used for the current video frame to be encoded according to a preset frame-level rate-distortion model switching criterion; if the frame-level rate-distortion model switching scheme is not enabled, the rate-distortion model used for the current video frame to be encoded is the N-th order rate-distortion model, and calculating the corresponding model parameters;
[0029] Step 4, according to the rate-distortion model used for the current video frame to be encoded, calling the parameters of the corresponding rate-distortion model, and estimating the Lagrangian parameter applied to the current video frame to be encoded in combination with the bitrate allocated to the current video frame to be encoded;
[0030] Step 5, performing rate-distortion optimization according to the estimated Lagrangian parameter applied to the current video frame to be encoded, and selecting the encoding configuration with the minimum rate-distortion cost to encode the current video frame to be encoded, to obtain a bitstream.
[0031] A rate control encoding system based on a rate-distortion model, comprising:
[0032] An N-th order rate-distortion model construction unit, constructing an N-th order rate-distortion model based on a double-curvature distortion model, where N is an integer greater than or equal to 2;
[0033] A bitrate allocation unit, configured to calculate the target bitrate of the current group of video frames in the video sequence, and calculate the bitrates allocated to each video frame in the current group of video frames according to whether a frame-level rate-distortion model switching scheme is enabled; wherein, if the frame-level rate-distortion model switching scheme is enabled, the rate-distortion model includes the N-th order rate-distortion model and the double-curvature distortion model, and if the frame-level rate-distortion model switching scheme is not enabled, the rate-distortion model is the N-th order rate-distortion model;
[0034] A rate-distortion model parameter calculation unit, which is configured to, if the frame-level rate-distortion model switching scheme is enabled, calculate the parameters of each rate-distortion model for the current video frame to be encoded in the current video frame group, and determine the rate-distortion model used for the current video frame to be encoded according to a preset frame-level rate-distortion model switching criterion; if the frame-level rate-distortion model switching scheme is not enabled, the rate-distortion model used for the current video frame to be encoded is the N-th order rate-distortion model, and the corresponding model parameters are calculated;
[0035] A Lagrange parameter estimation unit, which is configured to call the parameters of the corresponding rate-distortion model according to the rate-distortion model used for the current video frame to be encoded, and estimate the Lagrange parameter applied to the current video frame to be encoded in combination with the bitrate allocated to the current video frame to be encoded;
[0036] A bitrate control encoding unit, which is configured to perform rate-distortion optimization according to the estimated Lagrange parameter applied to the current video frame to be encoded, and the encoder selects the encoding configuration with the minimum rate-distortion cost to encode the current video frame to be encoded, and obtains a bitstream.
[0037] A processing device includes: one or more processors; a memory for storing one or more programs;
[0038] Wherein, when the one or more programs are executed by the one or more processors, the one or more processors implement the foregoing method.
[0039] A readable storage medium stores a computer program, and when the computer program is executed by a processor, the foregoing method is implemented.
[0040] It can be seen from the technical solutions provided by the present invention that a rate-distortion model with higher fitting accuracy (i.e., the N-th order rate-distortion model) is designed on the basis of the dual-curvature distortion model, and the parameters of the rate-distortion model can be calculated frame by frame, thereby improving the encoding performance and bitrate control error. BRIEF DESCRIPTION OF THE DRAWINGS
[0041] In order to more clearly illustrate the technical solutions of the embodiments of the present invention, the following will briefly introduce the drawings required for the description of the embodiments. Obviously, the following drawings are only some embodiments of the present invention. For those of ordinary skill in the art, other drawings can be obtained according to these drawings without creative efforts.
[0042] Figure 1 It is a flowchart of a bitrate control encoding method based on a rate-distortion model provided by an embodiment of the present invention;
[0043] Figure 2 It is a schematic diagram of a bitrate control encoding system based on a rate-distortion model provided by an embodiment of the present invention;
[0044] Figure 3 Schematic diagram of a processing device provided by an embodiment of the present invention. Specific implementation manners
[0045] The following combines the accompanying drawings in the embodiments of the present invention to clearly and completely describe the technical solutions in the embodiments of the present invention. Obviously, the described embodiments are only a part of the embodiments of the present invention, rather than all the embodiments. Based on the embodiments of the present invention, all other embodiments obtained by those of ordinary skill in the art without creative efforts shall fall within the protection scope of the present invention.
[0046] First, the following explanations are given for the terms that may be used in this article:
[0047] Descriptions with semantic meanings such as "including", "comprising", "containing", "having" or other similar ones shall be interpreted as non-exclusive inclusion. For example: including a certain technical feature element (such as raw materials, components, ingredients, carriers, dosage forms, materials, dimensions, parts, components, mechanisms, devices, steps, processes, methods, reaction conditions, processing conditions, parameters, algorithms, signals, data, products or articles, etc.) shall be interpreted as not only including the clearly listed certain technical feature element, but also including other well-known technical feature elements in the art that are not clearly listed.
[0048] The following gives a detailed description of a rate control coding method, system, device and medium based on a rate-distortion model provided by the present invention. The content not described in detail in the embodiments of the present invention belongs to the prior art well-known to those of ordinary skill in the art. For those conditions not specified in the embodiments of the present invention, they are carried out according to the conventional conditions in the art or the conditions recommended by the manufacturer.
[0049] Embodiment 1
[0050] The embodiment of the present invention provides a rate control coding method based on a rate-distortion model, as Figure 1 shown, mainly including the following steps:
[0051] Step 1: Construct an N - th order rate-distortion model based on a double-curvature distortion model.
[0052] Currently, the λ - domain rate control scheme widely used in video encoders is generally based on a double-curvature distortion model. The double-curvature distortion model can be expressed in the following form after taking the natural logarithm on both sides of the equation:
[0053] lnD = - KlnR + lnC = αlnR + β
[0054] Among them, C, K, α, and β are all model parameters, and ln is the natural logarithm. It can be seen from the above formula that the double-curvature distortion model means that the logarithm of the distortion D and the logarithm of the bit rate R are linearly related. To improve the fitting accuracy of the rate-distortion model, based on the double-curvature distortion model, the orders of the logarithm of the distortion and the logarithm of the bit rate are increased to N, and an N-th order rate-distortion model is obtained, which is a rate-distortion model with higher fitting accuracy.
[0055] In the embodiments of the present invention, N is an integer greater than or equal to 2, and the specific value can be set according to the situation or experience. Here, N = 2 and N = 3 are taken as examples for introduction.
[0056] (1) When N = 2, the N-th order rate-distortion model is a quadratic rate-distortion model, which is expressed as:
[0057]
[0058] Among them, and are the parameters of the quadratic rate-distortion model, D represents the distortion, R represents the bit rate, and ln is the natural logarithm.
[0059] Substituting the quadratic rate-distortion model into the relationship between the Lagrangian parameter λ and the rate-distortion, the relationship between the Lagrangian parameter λ and the bit rate can be obtained as shown in the following formula:
[0060]
[0061] (2) When N = 3, the N-th order rate-distortion model is a cubic rate-distortion model, which is expressed as:
[0062]
[0063] Among them, and are the parameters of the cubic rate-distortion model.
[0064] Substituting the cubic rate-distortion model into the relationship between the Lagrangian parameter λ and the rate-distortion, the relationship between the Lagrangian parameter λ and the bit rate can be obtained as shown in the following formula:
[0065]
[0066] Step 2: Calculate the target bit rate of the current group of video frames in the video sequence, and calculate the bit rates allocated to each video frame in the current group of video frames according to whether the frame-level rate-distortion model switching scheme is enabled.
[0067] In an embodiment of the present invention, a video sequence is divided into multiple (Group of Pictures, GOPs) according to a set size, and then, the GOP-level target bitrate is calculated based on the sequence-level target bitrate (i.e., the target bitrate of a given video sequence). Specifically, the sequence-level target bitrate can be further allocated to the GOP level through a GOP-level bitrate control algorithm, and the specific process can be implemented with reference to conventional techniques; for ease of understanding, a brief description is given below. The GOP-level bitrate control calculates the GOP-level target bitrate based on a sliding window. The sliding window size SW is first calculated according to the following formula:
[0068]
[0069] where SW alpha and SW beta are parameters when calculating the sliding window size. Exemplarily, they are respectively set to 20 and 60; GOPSize is the GOP size (i.e., the set size mentioned above), IntraPeriod is the interval of intra-coded frames, FramesLeft is the number of remaining frames in the video sequence; the function min(.) represents outputting the minimum value, and the function max(.) represents outputting the maximum value.
[0070] Those skilled in the art can understand that the intra-coded frame is a technical term in the art. In a video sequence, intra-coded frames are inserted at fixed intervals. Intra-coded frames are not encoded using inter-frame information but are encoded as independent frames.
[0071] After calculating the sliding window size, the average target bitrate of the video sequence target bitrate averaged to each video frame is calculated. It is set that each video frame outside the sliding window is allocated according to the calculated average target bitrate, and the remaining bitrate after allocation is evenly distributed to the video frames within the sliding window, that is, the GOP-level target bitrate R G can be calculated by the following formula:
[0072]
[0073] where BitsLeft is the remaining bitrate, AvgTargetBits is the average target bitrate of the video sequence target bitrate averaged to each video frame, and PixelNum is the total number of pixels within the GOP.
[0074] In an embodiment of the present invention, the total bit rate of a video frame group being equal to the target bit rate of the video frame group can be used as a condition, and the estimated Lagrangian parameter of each video frame in the video frame group is set to the product of a fixed weight and a basic Lagrangian parameter. The estimated Lagrangian parameter is defined as the Lagrangian parameter used to calculate the bit rate allocated to a video frame. After solving for the basic Lagrangian parameter of each video frame by the bisection method and multiplying it by the fixed weight, the estimated Lagrangian parameter of each video frame is obtained. Then, according to the relationship between the Lagrangian parameter and the bit rate corresponding to the corresponding rate-distortion model, and in combination with the estimated Lagrangian parameter, the bit rate allocated to each video frame in the video frame group is calculated.
[0075] Preferably, considering that higher-order rate-distortion models often increase the number of model parameters while introducing better rate-distortion fitting capabilities, thereby increasing the difficulty of model parameter estimation. Therefore, the present invention designs a frame-level rate-distortion model switching scheme. The frame-level rate-distortion model switching scheme refers to using different rate-distortion models for bit rate control of video frames, that is, the rate-distortion model includes an N-th order rate-distortion model and a double-curvature distortion model. Whether to enable the frame-level rate-distortion model switching scheme or not, the rate-distortion model is the N-th order rate-distortion model. When the frame-level rate-distortion model switching scheme is enabled, for video frames where the parameters of the high-order rate-distortion model (i.e., the N-th order rate-distortion model) are difficult to estimate accurately, the low-order rate-distortion model (i.e., the double-curvature distortion model) is used for all links of bit rate control, while for video frames where the parameters of the high-order rate-distortion model are estimated accurately, the high-order rate-distortion model is used for bit rate control.
[0076] When the frame-level rate-distortion model switching scheme is enabled, the relationships between the bit rate and the Lagrangian parameter corresponding to the N-th order rate-distortion model and the double-curvature distortion model are different, so the allocated bit rates are also different. For each video frame in the current video frame group, when calculating the allocated bit rate, the rate-distortion model and the corresponding parameters selected for each video frame in the previous video frame group are directly used; that is, if the m-th video frame in the previous video frame group selects the N-th order rate-distortion model, then the m-th video frame in the current video frame will use the N-th order rate-distortion model and the parameters of the N-th order rate-distortion model of the m-th video frame in the previous video frame group to calculate the allocated bit rate. Specifically, the estimated Lagrangian parameter of the video frame calculated by the method introduced above and the parameters of the N-th order rate-distortion model of the m-th video frame in the previous video frame group are substituted into the relationship formula between the Lagrangian parameter and the bit rate corresponding to the corresponding rate-distortion model to calculate the allocated bit rate. If the frame-level rate-distortion model switching scheme is not enabled, the N-th order rate-distortion model is directly used to calculate the bit rate allocated to each video frame.
[0077] In an embodiment of the present invention, it is possible to set the first video frame group to fixedly use the double-curvature distortion model.
[0078] In the embodiments of the present invention, the user can set whether to enable the frame-level rate distortion model switching scheme according to the actual situation or experience.
[0079] Step 3: If the frame-level rate distortion model switching scheme is enabled, for the current video frame to be encoded in the current video frame group, calculate the parameters of each rate distortion model respectively, and determine the rate distortion model used for the current video frame to be encoded according to the pre-set frame-level rate distortion model switching criterion; if the frame-level rate distortion model switching scheme is not enabled, the rate distortion model used for the current video frame to be encoded is the N-th order rate distortion model, and calculate the corresponding model parameters.
[0080] In the embodiments of the present invention, when the frame-level rate distortion model switching scheme is enabled, for the current video frame to be encoded, calculate the parameters of the N-th order rate distortion model and the dual-curvature distortion model respectively. Specifically: for the N-th order rate distortion model, combine the rate distortion relationship of the video frame corresponding to the N-th order rate distortion model, as well as the Lagrangian parameter and the bitrate relationship, and use the relevant information of the encoded video frames to calculate the parameters of the N-th order rate distortion model of the current video frame to be encoded; for the dual-curvature distortion model, combine the rate distortion relationship of the video frame corresponding to the dual-curvature distortion model, as well as the Lagrangian parameter and the bitrate relationship, and use the relevant information of the encoded video frames to calculate the parameters of the dual-curvature distortion model of the current video frame to be encoded.
[0081] If the frame-level rate distortion model switching scheme is not enabled, the N-th order rate distortion model is used for bitrate control, and combine the rate distortion relationship of the video frame corresponding to the N-th order rate distortion model, as well as the Lagrangian parameter and the bitrate relationship, and use the relevant information of the encoded video frames to calculate the parameters of the N-th order rate distortion model of the current video frame to be encoded.
[0082] For the N-th order rate distortion model, the calculation process of its model parameters is related to the value of N. Similarly, take N = 2 and N = 3 as examples for introduction.
[0083] (1) When N = 2, the N-th order rate distortion model is the second-order rate distortion model, and calculating the parameters of the second-order rate distortion model includes:
[0084] According to the bitrate and distortion relationship of the video frame, as well as the Lagrangian parameter and the bitrate relationship, obtain the following three equations:
[0085]
[0086] Among them, is the distortion of the encoded video frame P i of, and is the encoded video frame P i and the video frame P i-1 is the true bitrate of, and is the encoded video frame P i and the video frame P i-1 of the true Lagrangian parameter, i is the number of the video frame, e is the natural constant, ln is the natural logarithm, and is the current video frame P to be encoded i+1 parameters of the quadratic rate - distortion model.
[0087] The distortion, true bitrate and true Lagrangian parameter in the above formulas are all known numbers. By jointly solving the above three formulas, the parameters of the quadratic rate - distortion model of the current video frame P i+1 are obtained and
[0088] (2) When N = 3, the N - th rate - distortion model is the cubic rate - distortion model. Calculating the parameters of the cubic rate - distortion model includes:
[0089] According to the relationship between the bitrate and distortion of the video frame, and the relationship between the Lagrangian parameter and bitrate, the following four formulas are obtained:
[0090]
[0091] Among them, and are the distortions of the encoded video frame P i and the video frame P i-1 ; and are the true bitrates of the encoded video frame P i and the video frame P i-1 ; and are the true Lagrangian parameters of the encoded video frame P i and the video frame P i-1 , i is the number of the video frame, e is the natural constant, ln is the natural logarithm; and are the parameters of the cubic rate - distortion model of the current video frame P i+1 .
[0092] The distortion, true bitrate and true Lagrangian parameter in the above formulas are all known numbers. By jointly solving the above four formulas, the parameters of the cubic rate - distortion model of the current video frame P i+1 are obtained and
[0093] The true bitrate and true Lagrangian parameter of the encoded video frames involved in the above calculations refer to the true information after encoding. Specifically, the true bitrate is the actual bitrate after encoding, and the true Lagrangian parameter is the actual Lagrangian parameter used during encoding. In the present invention, rate control encoding is performed frame by frame. Therefore, the true bitrate and true Lagrangian parameter here can be understood with reference to subsequent step 5, where a comparison is also described.
[0094] Considering that the specific process of calculating the parameters of the double-curvature distortion model can be implemented with reference to conventional techniques. For example, it can be calculated with reference to the relevant expressions of the double-curvature distortion model provided above, and details are not described here.
[0095] Particularly: If the current video frame to be encoded is the first frame, then the initialized parameters are used. The specific configuration method of the initialized parameters can be referred to conventional techniques, and details are not described here.
[0096] In the embodiments of the present invention, when the frame-level rate-distortion model switching scheme is enabled, it is also necessary to determine the rate-distortion model used for the current video frame to be encoded according to the preset frame-level rate-distortion model switching criterion, including: for the current video frame to be encoded, determining whether the parameters of its N-th rate-distortion model meet the set conditions; if so, it means that the current video frame to be encoded is a video frame with accurate model parameter estimation, and the N-th rate-distortion model can be used for rate control; if not, it indicates that the current video frame to be encoded is a video frame with difficult-to-estimate accurate model parameters, and at this time, the double-curvature distortion model is used for rate control.
[0097] Exemplarily: Assume that the current video frame to be encoded is the (i + 1)-th video frame P i+1 , then the parameters of the N-th rate-distortion model of video frame P i can be calculated in combination with the relevant information of its previous two encoded video frames P i-1 and video frame P i+1 . Then, it is determined whether the parameters of the N-th rate-distortion model of video frame P i+1 are reasonable. The determination method can be: calculate the derivative of the distortion with respect to the allocated bitrate of the current video frame to be encoded according to the parameters of the N-th rate-distortion model of video frame P i+1 , and calculate the derivative of the Lagrangian parameter with respect to the allocated bitrate of the current video frame to be encoded. If both calculated derivatives are less than 0, it means that the set conditions are met, indicating that the parameters of the N-th rate-distortion model of video frame P i+1 are reasonable, and the current video frame to be encoded is a video frame with accurate model parameter estimation, and the N-th rate-distortion model can be used for rate control; otherwise, the double-curvature distortion model is used. The above two derivative calculations only need to substitute the allocated bitrate of the current video frame to be encoded, and the allocated bitrate of the current video frame to be encoded is obtained through the aforementioned step 2.
[0098] Step 4: According to the rate-distortion model used for the current video frame to be encoded, call the parameters of the corresponding rate-distortion model, and combine the bitrate allocated to the current video frame to be encoded to estimate the Lagrangian parameter applied to the current video frame to be encoded.
[0099] In the embodiments of the present invention, the relationships between the bitrates and the Lagrangian parameters corresponding to the Nth rate-distortion model and the double-curvature distortion model are different. Call the parameters of the corresponding rate-distortion model according to the rate-distortion model determined in Step 3, and substitute them together with the bitrate allocated to the current video frame to be encoded into the relational expression between the corresponding Lagrangian parameter λ and the bitrate, and then the Lagrangian parameter of the current video frame to be encoded can be solved.
[0100] Step 5: Perform rate-distortion optimization according to the estimated Lagrangian parameter applied to the current video frame to be encoded. The encoder selects the encoding configuration with the minimum rate-distortion cost to encode the current video frame to be encoded, and obtains the bitstream.
[0101] Specifically: According to the estimated Lagrangian parameter applied to the current video frame to be encoded, set the rate-distortion optimization target for the current video frame to be encoded, and perform rate-distortion optimization. The encoder searches for possible encoding configurations of the current video frame to be encoded according to the rate-distortion optimization target, and finally selects the encoding configuration with the minimum rate-distortion cost at the encoding end to encode the current video frame to be encoded, and obtains the bitstream.
[0102] In the embodiments of the present invention, the encoding configuration with the minimum rate-distortion cost includes the actual Lagrangian parameter when encoding the current video frame to be encoded. After encoding, the actual bitrate of the current video frame to be encoded can be obtained, and then the parameters of the Nth rate-distortion model of the next video frame to be encoded can be calculated through Step 3; of course, if the next video frame to be encoded belongs to the next group of video frames, the target bitrate of the group of video frames also needs to be calculated through Step 2.
[0103] In order to more clearly show the technical solutions provided by the present invention and the technical effects produced, the following uses specific examples to describe in detail the method provided by the embodiments of the present invention.
[0104] Example 1: Bitrate control based on the quadratic rate-distortion model and model switching.
[0105] After obtaining the GOP-level target bitrate through the GOP-level bitrate control algorithm, perform frame-level bitrate control. During the frame-level bitrate control process, while using the quadratic rate-distortion model, set the frame-level rate-distortion model switching criterion (specifically the introduction method in the foregoing Step 3), and select the rate-distortion model used for each video frame according to the frame-level rate-distortion model switching criterion when allocating bitrates and implementing bitrates for each frame.
[0106] (1) GOP-level bitrate control.
[0107] Calculate the target bitrate R at the GOP level according to the solution provided in the foregoing step 2 G 。
[0108] (2) Update the parameters of the frame-level rate-distortion model.
[0109] The parameters of the quadratic rate-distortion model can be calculated through the solution provided in the foregoing step 3. Considering that while the fitting accuracy of the quadratic rate-distortion model improves, the difficulty of parameter estimation also increases, the parameters of the double-curvature distortion model are also updated synchronously during parameter update in this example. When actually using the model, different rate-distortion models are selected for different coding units according to the discrimination criterion. That is to say, the parameters of the two types of rate-distortion models are updated synchronously here. However, the specific rate-distortion model used will be judged later, and then the parameters of the corresponding rate-distortion model will be called for subsequent calculations. At the same time, the parameters of the model obtained here are for each video frame. Therefore, they are called the frame-level rate-distortion model parameters.
[0110] (3) Frame-level bitrate allocation.
[0111] During the bitrate allocation process, the total bitrate of the current GOP is equal to the GOP-level target bitrate R G As a condition, the estimated Lagrangian parameter of each video frame is set as the product of a fixed weight and the basic Lagrangian parameter. The basic Lagrangian parameter is solved by the bisection method, and then the estimated Lagrangian parameter of each video frame is determined, and the allocated bitrate of each frame is calculated as shown in the following formula:
[0112]
[0113] Among them, the left side of the equal sign is the total bitrate of the current GOP, {PicH} represents the set of video frames using the double-curvature distortion model within the currently initially allocated GOP, and {PicQ} represents the set of video frames using the quadratic rate-distortion model within the currently initially allocated GOP; represents the bitrate allocated for video frame P l allocated bitrate, represents the bitrate allocated for video frame P j allocated bitrate.
[0114] The initial allocation of the rate-distortion model here is mainly to calculate the bitrate allocated for each video frame. During subsequent encoding, the corresponding rate-distortion model needs to be determined according to the discrimination method introduced in the foregoing step 3.
[0115] (4) Frame-level bitrate implementation.
[0116] The rate-distortion model used for the currently to-be-encoded video frame, the parameters of the rate-distortion model, and the allocated bitrate have been determined through the foregoing method.
[0117] If the current video frame to be encoded is video frame P using the double-curvature distortion model i , the corresponding Lagrange parameter is estimated according to the relationship between λ and the code rate corresponding to the double-curvature distortion model shown in the following formula
[0118]
[0119] where and are the double-curvature distortion model parameters of video frame P updated with parameters l , and is the code rate allocated for video frame P l .
[0120] If the current video frame to be encoded is video frame P using the quadratic rate-distortion model j , the corresponding Lagrange parameter is estimated according to the relationship between λ and the code rate corresponding to the quadratic rate-distortion model shown in the following formula
[0121]
[0122] where and are the quadratic rate-distortion model parameters of video frame P updated with parameters j , and is the code rate allocated for video frame P j .
[0123] Example 2: Rate control based on the quadratic rate-distortion model
[0124] The main difference between Example 2 and Example 1 is that Example 2 does not use the frame-level rate-distortion model switching scheme. That is to say, Example 2 only uses the quadratic rate-distortion model for rate control
[0125] (1) GOP-level rate control
[0126] Refer to the scheme provided in step 2 above to calculate the target code rate R at the GOP level G .
[0127] (2) Frame-level rate-distortion model parameter update
[0128] The parameters of the quadratic rate-distortion model can be calculated through the scheme provided in step 3 above
[0129] (3) Frame-level code rate allocation
[0130] The code rate allocation method can refer to step 4 above and is expressed as
[0131]
[0132] Among them, M is the number of video frames, and the left side of the equal sign is the total bitrate of the current GOP. Indicates the bitrate allocated to video frame P j Allocated bitrate.
[0133] (4) Frame-level bitrate implementation.
[0134] After obtaining the target bitrates of each frame in bitrate allocation, the corresponding Lagrange parameter can be estimated for each frame according to the relationship between the Lagrange parameter λ and the bitrate corresponding to the quadratic rate-distortion model shown in the following formula:
[0135]
[0136] Among them, and Are the parameters of the quadratic rate-distortion model obtained by parameter update for video frame P j Corresponding to the quadratic rate-distortion model parameters, Is the bitrate allocated to the current frame P j Allocated bitrate.
[0137] Example 3: Bitrate control based on the cubic rate-distortion model and model switching.
[0138] The main difference between Example 3 and Example 1 is that instead of using the quadratic rate-distortion model, a cubic rate-distortion model is proposed to further improve the model fitting ability on the basis of the quadratic rate-distortion model, and a frame-level rate-distortion model switching mechanism is combined for bitrate control.
[0139] (1) GOP-level bitrate control.
[0140] Referring to the solution provided in step 2 above, calculate the target bitrate R of the GOP level G .
[0141] (2) Frame-level rate-distortion model parameter update.
[0142] Through the solution provided in step 3 above, the parameters of the cubic rate-distortion model can be calculated. In this example, the parameters of the double-curvature distortion model are also updated synchronously during parameter update. When actually using the model, different rate-distortion models are selected for different coding units according to the discrimination criterion.
[0143] (3) Frame-level bitrate allocation.
[0144] During bitrate allocation, taking the total bitrate of the current GOP equal to the GOP-level target bitrate R G As a condition, the Lagrange parameter of each frame is set to the product of a fixed weight and the basic Lagrange parameter, and then the basic Lagrange parameter can be solved by the bisection method, and further the allocated bitrate of each frame can be calculated, as shown in the following formula:
[0145]
[0146] Among them, the left side of the equal sign is the total bitrate of the current GOP. {PicH} represents the set of video frames using the bi-curvature distortion model within the current GOP in the preliminary allocation, and {PicC} represents the set of video frames using the tri-curvature distortion model within the current GOP in the preliminary allocation; Denoted as the bitrate allocated for video frame P l The allocated bitrate, Denoted as the bitrate allocated for video frame P k The allocated bitrate.
[0147] Similarly, the preliminary allocation here is mainly for calculating the bitrates allocated for each video frame.
[0148] (4) Frame-level bitrate implementation.
[0149] The rate-distortion model used for the current video frame to be encoded, the parameters of the rate-distortion model, and the allocated bitrate have been determined through the aforementioned method.
[0150] If the current video frame to be encoded is video frame P using the bi-curvature distortion model l , then the corresponding Lagrange parameter is calculated according to the relationship between λ and the bitrate corresponding to the bi-curvature distortion model shown in the following formula
[0151]
[0152] Among them, and are the parameters of the bi-curvature distortion model corresponding to video frame P updated from the parameters, l and is the bitrate allocated for video frame P l The allocated bitrate.
[0153] If the current video frame to be encoded is video frame P using the tri-curvature distortion model k then the corresponding Lagrange parameter can be calculated according to the relationship between λ and the bitrate corresponding to the tri-curvature distortion model shown in the following formula
[0154]
[0155] Among them, and are the parameters of the tri-curvature distortion model corresponding to video frame P updated from the parameters, k and is the bitrate allocated for video frame P k The allocated bitrate.
[0156] To illustrate the performance of the above-mentioned solution of the present invention, the following is an example of the solution of Example 1 (simply referred to as the solution of the present invention) for comparison experiments with the λ-domain bitrate control solution based on the double-curvature distortion model in the prior art (simply referred to as the comparative solution); in the comparative experiment, the performance comparison was carried out under the encoding configurations RA (Random Access) and LB (Low-delay B) of the VVC reference software VTM-19.2 (19.2 is the software version number). The Y-channel BD-rate (Y-BDBR) was used. Y-BDBR refers to the average difference between the rate-distortion curves of the Y components of the solution of the present invention and the comparative solution, which is used to measure the coding gain. A negative value indicates the percentage increase in coding performance, and a positive value indicates the percentage decrease in coding performance. In addition, the growth value of the sequence-level bitrate error (ΔBitErr) and the average frame-level bitrate error growth value (ΔAFBE) were used as metrics for bitrate control accuracy. A negative value of these two error growth values indicates a decrease in bitrate control error, and a positive value indicates an increase in bitrate control error. The results of the comparative experiment are shown in Table 1.
[0157] Table 1: Performance Comparison Results between the Solution of the Present Invention and the Comparative Solution
[0158]
[0159] In Table 1, Class represents the category of video sequences divided according to resolution, Sequence represents the name of the video sequence defined in the standard test conditions for testing, and these video sequences are all from existing datasets. Overall represents the comprehensive comparison result, and T Enc and T Dec respectively represent the encoding time and decoding time ratios of the solution of the present invention compared to the comparative solution. From the results shown in Table 1, it can be seen that the solution of the present invention can reduce the bitrate control error and improve the coding performance.
[0160] Through the description of the above embodiments, those skilled in the art can clearly understand that the above embodiments can be implemented by software or by means of software plus a necessary general hardware platform. Based on such an understanding, the technical solutions of the above embodiments can be embodied in the form of a software product, which can be stored in a non-volatile storage medium (which can be a CD-ROM, USB flash drive, mobile hard disk, etc.), including several instructions for causing a computer device (which can be a personal computer, server, or network device, etc.) to execute the methods described in various embodiments of the present invention.
[0161] Example 2
[0162] The present invention also provides a bitrate control encoding system based on a rate-distortion model, which is mainly used to implement the method provided in the foregoing embodiments, such as Figure 2As shown, the system mainly includes:
[0163] An N - th rate - distortion model construction unit that constructs an N - th rate - distortion model based on a double - curvature distortion model, where N is an integer greater than or equal to 2;
[0164] A bit - rate allocation unit for calculating the target bit - rate of the current group of video frames in a video sequence and, according to whether a frame - level rate - distortion model switching scheme is enabled, calculating the bit - rate allocated to each video frame in the current group of video frames; wherein, if the frame - level rate - distortion model switching scheme is enabled, the rate - distortion model includes an N - th rate - distortion model and a double - curvature distortion model, and if the frame - level rate - distortion model switching scheme is not enabled, the rate - distortion model is an N - th rate - distortion model;
[0165] A rate - distortion model parameter calculation unit for, if the frame - level rate - distortion model switching scheme is enabled, calculating the parameters of each rate - distortion model for the current video frame to be encoded in the current group of video frames and, according to a pre - set frame - level rate - distortion model switching criterion, determining the rate - distortion model used for the current video frame to be encoded; if the frame - level rate - distortion model switching scheme is not enabled, the rate - distortion model used for the current video frame to be encoded is an N - th rate - distortion model, and calculating the corresponding model parameters;
[0166] A Lagrangian parameter estimation unit for, according to the rate - distortion model used for the current video frame to be encoded, invoking the parameters of the corresponding rate - distortion model and, in combination with the bit - rate allocated to the current video frame to be encoded, estimating the Lagrangian parameter applied to the current video frame to be encoded;
[0167] A rate - control encoding unit for performing rate - distortion optimization according to the estimated Lagrangian parameter applied to the current video frame to be encoded, and having the encoder select the encoding configuration with the minimum rate - distortion cost to encode the current video frame to be encoded, obtaining a bitstream.
[0168] The specific technical details involved in each unit of the above - mentioned system have been introduced in detail in the previous Embodiment 1, so they will not be elaborated here.
[0169] Those skilled in the art can clearly understand that, for the sake of convenience and brevity of description, only the above - mentioned division of each functional module is used as an example. In practical applications, the above functions can be allocated to different functional modules as needed, that is, the internal structure of the system is divided into different functional modules to complete all or part of the functions described above.
[0170] Embodiment 3
[0171] The present invention also provides a processing device, such as Figure 3As shown, it mainly includes: one or more processors; a memory for storing one or more programs; wherein, when the one or more programs are executed by the one or more processors, the one or more processors implement the methods provided in the foregoing embodiments.
[0172] Further, the processing device further includes at least one input device and at least one output device; in the processing device, the processor, the memory, the input device, and the output device are connected through a bus.
[0173] In the embodiments of the present invention, the specific types of the memory, the input device, and the output device are not limited; for example:
[0174] The input device can be a touch screen, an image acquisition device, a physical button, or a mouse, etc.;
[0175] The output device can be a display terminal;
[0176] The memory can be a Random Access Memory (RAM), or a non-volatile memory, such as a disk memory.
[0177] Embodiment 4
[0178] The present invention also provides a readable storage medium storing a computer program, which implements the methods provided in the foregoing embodiments when the computer program is executed by a processor.
[0179] In the embodiments of the present invention, the readable storage medium as a computer-readable storage medium can be disposed in the foregoing processing device, for example, as the memory in the processing device. In addition, the readable storage medium can also be various media that can store program codes, such as a USB flash drive, a mobile hard disk, a Read-Only Memory (ROM), a magnetic disk, or an optical disc.
[0180] The above are only the preferred specific embodiments of the present invention, but the protection scope of the present invention is not limited thereto. Any changes or substitutions that can be easily thought of by those skilled in the art within the technical scope disclosed by the present invention should be covered by the protection scope of the present invention. Therefore, the protection scope of the present invention should be subject to the protection scope of the claims.
Claims
1. A rate control coding method based on a rate-distortion model, characterized in that, Including: Step 1: Construct an N - th rate - distortion model based on the bi - curvature distortion model, where N is an integer greater than or equal to 2. Specifically, on the basis of the bi - curvature distortion model, the orders of the distortion logarithm and the rate logarithm are increased to N to obtain the N - th rate - distortion model. Step 2: Calculate the target bitrate of the current group of video frames in the video sequence, and calculate the bitrates allocated to each video frame in the current group of video frames according to whether the frame - level rate - distortion model switching scheme is enabled. If the frame - level rate - distortion model switching scheme is enabled, the rate - distortion model includes the N - th rate - distortion model and the bi - curvature distortion model; if the frame - level rate - distortion model switching scheme is not enabled, the rate - distortion model is the N - th rate - distortion model. Step 3: If the frame - level rate - distortion model switching scheme is enabled, for the current video frame to be encoded in the current group of video frames, calculate the parameters of each rate - distortion model respectively, and determine the rate - distortion model used for the current video frame to be encoded according to the pre - set frame - level rate - distortion model switching criterion. If the frame - level rate - distortion model switching scheme is not enabled, the rate - distortion model used for the current video frame to be encoded is the N - th rate - distortion model, and calculate the corresponding model parameters. Step 4: According to the rate - distortion model used for the current video frame to be encoded, call the parameters of the corresponding rate - distortion model, and combine the bitrate allocated to the current video frame to be encoded to estimate the Lagrangian parameter applied to the current video frame to be encoded. Step 5: Perform rate - distortion optimization according to the estimated Lagrangian parameter applied to the current video frame to be encoded, select the encoding configuration with the minimum rate - distortion cost to encode the current video frame to be encoded, and obtain the bitstream.
2. The rate control coding method based on the rate-distortion model according to claim 1, wherein The construction of the N - th rate - distortion model based on the bi - curvature distortion model includes: When N = 2, the N - th rate - distortion model is the quadratic rate - distortion model, expressed as: Among them, and are parameters of the quadratic rate-distortion model, D represents distortion, R represents bit rate, and ln is the natural logarithm; When N = 3, the N - th rate - distortion model is the cubic rate - distortion model, expressed as: Among them, and are parameters of the third-order rate distortion model.
3. A rate control coding method based on a rate distortion model according to claim 1, characterized in that, The calculation of the bitrates allocated to each video frame in the current group of video frames according to whether the frame - level rate - distortion model switching scheme is enabled includes: When the frame - level rate - distortion model switching scheme is enabled, for the current group of video frames, use the rate - distortion models selected for each video frame in the previous group of video frames as the rate - distortion models for the corresponding - position video frames in the current group of video frames to calculate the allocated bitrates. If the frame - level rate - distortion model switching scheme is not enabled, directly use the N - th rate - distortion model to calculate the bitrates allocated to each video frame.
4. A rate control encoding method based on a rate-distortion model according to claim 3, characterized in that, The method for calculating the bitrates allocated to each video frame in the current group of video frames includes: Taking the total bitrate of the group of video frames equal to the target bitrate of the group of video frames as a condition, set the estimated Lagrangian parameters of each video frame in the group of video frames as the product of a fixed weight and the base Lagrangian parameter. The estimated Lagrangian parameter is defined as the Lagrangian parameter used to calculate the bitrate allocated to the video frame. After solving the base Lagrangian parameter of each video frame by the bisection method and multiplying it by the fixed weight to obtain the estimated Lagrangian parameter of each video frame, then, according to the relationship between the Lagrangian parameter and the bitrate corresponding to the corresponding rate - distortion model, and combining the estimated Lagrangian parameter, calculate the bitrates allocated to each video frame in the group of video frames.
5. A rate control coding method based on a rate-distortion model according to claim 1, characterized in that If the frame-level rate-distortion model switching scheme is enabled, for the current video frame to be encoded in the current video frame group, calculate the parameters of each rate-distortion model respectively, and determine the rate-distortion model used for the current video frame to be encoded according to the pre-set frame-level rate-distortion model switching criterion, including: When the frame-level rate-distortion model switching scheme is enabled, for the current video frame to be encoded, calculate the parameters of the N-th order rate-distortion model and the double-curvature rate-distortion model respectively N times; for the N-th order rate-distortion model, combine the rate-distortion relationship of the video frame corresponding to the N-th order rate-distortion model, and the Lagrangian parameter and bitrate relationship, and use the relevant information of the encoded video frame to calculate the parameters of the N-th order rate-distortion model of the current video frame to be encoded; for the double-curvature rate-distortion model, combine the rate-distortion relationship of the video frame corresponding to the double-curvature rate-distortion model, and the Lagrangian parameter and bitrate relationship, and use the relevant information of the encoded video frame to calculate the parameters of the double-curvature rate-distortion model of the current video frame to be encoded; For the current video frame to be encoded, determine whether the parameters of the N-th order rate-distortion model of its two previous encoded video frames meet the set conditions; if so, use the N-th order rate-distortion model for bitrate control; if not, use the double-curvature rate-distortion model for bitrate control.
6. A rate control coding method based on a rate-distortion model according to claim 5, characterized in that, Calculating the parameters of the rate-distortion model of the current video frame to be encoded in the current video frame group includes: If the N-th order rate-distortion model is used; when N = 2, the N-th order rate-distortion model is the second-order rate-distortion model, and the calculation method of the parameters of the second-order rate-distortion model is: Among them, is the distortion of the encoded video frame P i ; and is the true bitrate of the encoded video frame P i and the video frame P i-1 ; and is the true Lagrange parameter of the encoded video frame P i and the video frame P i-1 ; i is the number of the video frame, e is the natural constant, and ln is the natural logarithm, and are the parameters of the quadratic rate-distortion model of the currently to-be-encoded video frame P i+1 ; Jointly solve the above three equations to obtain the current video frame P to be encoded i+1 parameters of the quadratic rate-distortion model and 7. A rate control encoding method based on a rate-distortion model according to claim 5, characterized in that, Calculating the parameters of the rate-distortion model of the current video frame to be encoded in the current video frame group includes: When N = 3, the N-th order rate-distortion model is the third-order rate-distortion model, and the calculation method of the parameters of the third-order rate-distortion model is: Among them, and is the encoded video frame P i and the video frame P i-1 of the distortion, and is the encoded video frame P i and the video frame P i-1 of the true bitrate, and is the encoded video frame P i and the video frame P i-1 of the true Lagrangian parameter, i is the number of the video frame, e is the natural constant, and ln is the natural logarithm; and are the parameters of the cubic rate-distortion model of the current video frame P to be encoded i+1 ; Jointly solve the above four equations to obtain the current video frame P to be encoded i+1 parameters of the cubic rate-distortion model and 8. A rate control coding system based on a rate-distortion model, characterized in that, Including: An N-th order rate-distortion model construction unit constructs an N-th order rate-distortion model based on the double-curvature rate-distortion model, where N is an integer greater than or equal to 2; among them, on the basis of the double-curvature rate-distortion model, the order of the distortion logarithm and the bitrate logarithm is increased to N to obtain the N-th order rate-distortion model; A bitrate allocation unit is used to calculate the target bitrate of the current video frame group in the video sequence, and calculate the bitrates allocated to each video frame in the current video frame group according to whether the frame-level rate-distortion model switching scheme is enabled; among them, if the frame-level rate-distortion model switching scheme is enabled, the rate-distortion model includes the N-th order rate-distortion model and the double-curvature rate-distortion model, and if the frame-level rate-distortion model switching scheme is not enabled, the rate-distortion model is the N-th order rate-distortion model; A rate-distortion model parameter calculation unit is used to, if the frame-level rate-distortion model switching scheme is enabled, for the current video frame to be encoded in the current video frame group, calculate the parameters of each rate-distortion model respectively, and determine the rate-distortion model used for the current video frame to be encoded according to the pre-set frame-level rate-distortion model switching criterion; if the frame-level rate-distortion model switching scheme is not enabled, the rate-distortion model used for the current video frame to be encoded is the N-th order rate-distortion model, and calculate the corresponding model parameters; A Lagrangian parameter estimation unit, configured to call parameters of a corresponding rate-distortion model according to the rate-distortion model used for a current video frame to be encoded, and estimate a Lagrangian parameter applied to the current video frame to be encoded in combination with the bitrate allocated to the current video frame to be encoded; A bitrate control encoding unit, configured to perform rate-distortion optimization according to the estimated Lagrangian parameter applied to the current video frame to be encoded, and cause an encoder to encode the current video frame to be encoded with an encoding configuration having the minimum rate-distortion cost, thereby obtaining a bitstream.
9. A processing device, characterized in that, Comprising: One or more processors; A memory, configured to store one or more programs; Wherein, when the one or more programs are executed by the one or more processors, the one or more processors are caused to implement the method according to any one of claims 1 to 7.
10. A readable storage medium stores a computer program, characterized in that, When a computer program is executed by a processor, the method according to any one of claims 1 to 7 is implemented.