Video encoding method and apparatus, electronic device, and medium

By using predictive coding distortion and rate-distortion tradeoff coefficients to calculate the quantization value in video coding, the problem of inaccurate quantization parameter calculation in existing technologies is solved, achieving an efficient balance and stability between bit rate and quality.

CN122120440APending Publication Date: 2026-05-29BEIJING TSINGMICRO INTELLIGENT TECH CO LTD

Patent Information

Authority / Receiving Office
CN · China
Patent Type
Applications(China)
Current Assignee / Owner
BEIJING TSINGMICRO INTELLIGENT TECH CO LTD
Filing Date
2026-01-28
Publication Date
2026-05-29

AI Technical Summary

Technical Problem

In existing technologies, bit rate control schemes based on bit number prediction are susceptible to interference from entropy coding and coding modes, leading to inaccurate calculation of quantization parameters and affecting the balance between bit rate and quality.

Method used

The predicted coding distortion of the unit to be coded is determined by using pixel data based on the reference coding unit. The coding quantization value is calculated by utilizing the rate-distortion tradeoff coefficient and the preset distortion mapping relationship, thus avoiding the influence of entropy coding and coding mode and achieving stability and adaptability.

Benefits of technology

It improves the stability and adaptability of encoding results, ensures an efficient balance between bitrate and video quality, and enhances the stability and consistency of encoding quality.

✦ Generated by Eureka AI based on patent content.

Smart Images

  • Figure CN122120440A_ABST
    Figure CN122120440A_ABST
Patent Text Reader

Abstract

The application provides a video encoding method and device, electronic equipment and medium, and relates to the technical field of video encoding. The method comprises the following steps: determining a prediction encoding distortion degree of a to-be-encoded unit based on pixel data of a reference encoding unit in a to-be-encoded video, the reference encoding unit being an already-encoded encoding unit in the to-be-encoded video, and the encoding unit being any one of an encoding block, an encoding frame and an encoding frame group in the to-be-encoded video; determining a rate-distortion trade-off coefficient of the to-be-encoded unit based on the prediction encoding distortion degree and a reference rate-distortion parameter; determining an encoding quantization value of the to-be-encoded unit based on the rate-distortion trade-off coefficient and a preset distortion degree mapping relationship, so as to encode the to-be-encoded unit according to the encoding quantization value and obtain a target encoding video. The method realizes reasonable allocation of encoding quantization values to video frame images by taking the encoding distortion degree as a prediction basis, and effectively improves the stability and adaptability of the video encoding effect.
Need to check novelty before this filing date? Find Prior Art

Description

Technical Field

[0001] This application relates to the field of video coding technology, and in particular to a video coding method, apparatus, electronic device and medium. Background Technology

[0002] Bitrate control is a key technology in video coding, designed to adjust the size of the output bitstream to fit bandwidth or storage limitations. Its core is to assign appropriate quantization parameters (QP) to video frame images to achieve the best balance between bitrate, quality, and complexity.

[0003] Currently, relevant bitrate control schemes are mainly based on a preset bitrate target. They first allocate the target number of bits to the video frame image to be encoded through multiple pre-coding and dynamic sliding window methods, and then reverse the process to calculate the unified QP of the entire frame to complete the encoding. Typical algorithms include constant QP, constant bitrate, dynamic bitrate, and constant bitrate factor.

[0004] However, the control path based on bit number prediction has obvious technical limitations. Bit number pre-allocation is affected by factors such as entropy coding and coding mode. The prediction error is large at low bit rates or under special coding modes, which can easily lead to inaccurate QP calculation and poor balance between bit rate and quality. Summary of the Invention

[0005] This application provides a video encoding method, apparatus, electronic device, and medium to solve the problems of low encoding quantization value allocation accuracy and poor video quality stability caused by inaccurate bit number prediction in related technologies.

[0006] A first aspect of this application proposes a video coding method, comprising: determining a predicted coding distortion of a reference coding unit in a video to be encoded based on pixel data of a reference coding unit in the video to be encoded, wherein the reference coding unit is an already encoded coding unit in the video to be encoded, and the coding unit is any one of a coding block, a coding frame, and a group of coding frames in the video to be encoded; determining a rate-distortion tradeoff coefficient of the coding unit based on the predicted coding distortion and a reference rate-distortion parameter, wherein the reference rate-distortion parameter is a rate-distortion model parameter associated with the reference coding unit; and determining a coding quantization value of the coding unit based on the rate-distortion tradeoff coefficient and a preset distortion mapping relationship, so as to encode the coding unit according to the coding quantization value to obtain a target coded video.

[0007] In some embodiments, before determining the predicted coding distortion of the unit to be encoded based on the pixel data of the reference coding unit in the video to be encoded, the method includes: when the coding unit is a coding block, performing a matching degree estimation on at least one coded block in the reference frame image based on a preset estimation algorithm, determining the coded block that best matches the unit to be encoded as the reference coding unit, wherein the reference frame image is a frame image adjacent to the frame image where the unit to be encoded is located.

[0008] In some embodiments, determining the predicted coding distortion of a coding unit based on the pixel data of a reference coding unit in the video to be encoded includes: acquiring the original pixel data and reconstructed pixel data of the reference coding unit, wherein the reconstructed pixel data is the pixel data after encoding by the reference coding unit; performing differential processing on the original pixel data and the reconstructed pixel data to obtain the reference coding distortion of the reference coding unit, and determining the reference coding distortion as the predicted coding distortion.

[0009] In some embodiments, determining the rate-distortion tradeoff coefficient of the cell to be encoded based on the predicted coding distortion and the reference rate-distortion parameter includes: obtaining the reference rate-distortion parameter after the reference coding cell performs coding; and determining the rate-distortion tradeoff coefficient based on the reference rate-distortion parameter and the preset mapping relationship between the predicted coding distortion and the rate-distortion tradeoff coefficient.

[0010] In some embodiments, determining the encoded quantization value of the unit to be encoded based on the rate-distortion tradeoff coefficient and a preset distortion mapping relationship includes: constraining the rate-distortion tradeoff coefficient to obtain a constrained rate-distortion tradeoff coefficient; and determining the encoded quantization value based on the constrained rate-distortion tradeoff coefficient and the preset distortion mapping relationship, wherein the preset distortion mapping relationship is used to characterize the logarithmic fitting relationship between the rate-distortion tradeoff coefficient and the encoded quantization value.

[0011] In some embodiments, the constraints include at least one of the following: block-level constraints, used to constrain the rate-distortion tradeoff coefficient within a first preset range of block-level rate-distortion tradeoff coefficients corresponding to adjacent frames, and / or to constrain the rate-distortion tradeoff coefficient within a second preset range of adjacent block-level rate-distortion tradeoff coefficients within a frame; frame-level constraints, used to constrain the rate-distortion tradeoff coefficient within a third preset range of frame-level rate-distortion tradeoff coefficients corresponding to the video to be encoded; and frame group-level constraints, used to constrain the rate-distortion tradeoff coefficient within a fourth preset range of frame group-level rate-distortion tradeoff coefficients corresponding to the video to be encoded.

[0012] In some embodiments, after encoding the unit to be encoded according to the coded quantization value, the method includes: obtaining the true coding distortion and the true number of coded bits after encoding the unit to be encoded; updating the reference rate-distortion parameter based on the true coding distortion, the true number of coded bits and the predicted coding distortion, to obtain the updated rate-distortion parameter associated with the unit to be encoded.

[0013] A second aspect of this application provides a video encoding apparatus, the apparatus comprising:

[0014] The first determining unit is used to determine the predicted coding distortion of the unit to be encoded based on the pixel data of the reference coding unit in the video to be encoded. The reference coding unit is the coded unit that has been encoded in the video to be encoded, and the coding unit is any one of the coding block, coding frame and coding frame group in the video to be encoded. The second determining unit is used to determine the rate-distortion tradeoff coefficient of the unit to be encoded based on the predicted coding distortion and the reference rate-distortion parameter, wherein the reference rate-distortion parameter is the rate-distortion model parameter associated with the reference coding unit; The coding unit is used to determine the coding quantization value of the unit to be coded based on the rate-distortion tradeoff coefficient and a preset distortion mapping relationship, so as to encode the unit to be coded according to the coding quantization value to obtain the target coded video.

[0015] A third aspect of this application provides an electronic device comprising: at least one processor; and a memory communicatively connected to the at least one processor; wherein the memory stores instructions executable by the at least one processor, the instructions being executed by the at least one processor to enable the at least one processor to perform the methods described in the first aspect of this application.

[0016] A fourth aspect of this application provides a non-transitory computer-readable storage medium storing computer instructions, wherein the computer instructions are used to cause a computer to perform the methods described in the first aspect of this application.

[0017] In summary, the video coding method proposed in this application determines the predicted coding distortion of the unit to be encoded based on the pixel data of a reference coding unit in the video to be encoded. The reference coding unit is any one of the coded blocks, coded frames, and coded frame groups in the video to be encoded. Based on the predicted coding distortion and the reference rate-distortion parameter, the rate-distortion tradeoff coefficient of the unit to be encoded is determined. The reference rate-distortion parameter is the rate-distortion model parameter associated with the reference coding unit. Based on the rate-distortion tradeoff coefficient and combined with a preset distortion mapping relationship, the coded quantization value of the unit to be encoded is determined. The unit to be encoded is then encoded according to the coded quantization value to obtain the target encoded video. This method uses coding distortion instead of the number of coded bits as the prediction basis to infer the coded quantization value, which is not affected by multiple coding factors such as entropy coding and coding mode. This further achieves an efficient balance between bitrate and video quality, effectively improving the stability and adaptability of the coding effect.

[0018] It should be understood that the above general description and the following detailed description are exemplary and explanatory only, and do not limit this application. Attached Figure Description

[0019] The accompanying drawings, which are incorporated in and form part of this specification, illustrate embodiments consistent with this application and, together with the description, serve to explain the principles of this application, and do not constitute an undue limitation of this application.

[0020] Figure 1 A flowchart illustrating a video encoding method provided in this application embodiment; Figure 2 A schematic diagram illustrating a video frame image coding block position index provided in an embodiment of this application; Figure 3 A flowchart illustrating the second video encoding method provided in this application embodiment; Figure 4 A flowchart illustrating the third video encoding method provided in this application embodiment; Figure 5 A flowchart illustrating the fourth video encoding method provided in this application embodiment; Figure 6 A flowchart illustrating the fifth video encoding method provided in this application embodiment; Figure 7 This is a schematic diagram of the structure of a video encoding device provided in an embodiment of this application; Figure 8 This is a schematic diagram of the structure of an electronic device provided in an embodiment of this application; Figure 9 This is a schematic diagram of the structure of a chip provided in an embodiment of this application. Detailed Implementation

[0021] The embodiments of this application are described in detail below. Examples of the embodiments are shown in the accompanying drawings, wherein the same or similar reference numerals denote the same or similar elements or elements having the same or similar functions throughout. The embodiments described below with reference to the accompanying drawings are exemplary and intended to explain this application, and should not be construed as limiting this application.

[0022] Bitrate control is a key technology in video coding, aiming to adjust the output bitstream size to adapt to bandwidth or storage limitations. Its core is assigning an appropriate quantization value (QP) to each video frame to achieve the optimal balance between bitrate, quality, and complexity. A higher QP results in a higher compression ratio and a lower output bitrate, but it also introduces more distortion, leading to a decrease in subjective video quality, manifested as blurriness, loss of detail, or pixelation. Conversely, a lower QP results in a lower compression ratio and higher video quality, but it increases the bitrate. Therefore, appropriately adjusting the QP is the most direct and primary means of controlling bitrate and video quality.

[0023] Currently, the relevant bitrate control schemes mainly achieve bitrate control through bit pre-allocation and QP calculation. That is, the target number of bits is first allocated to the video frame image to be encoded through multiple pre-coding and dynamic sliding window, and then the QP of the whole frame is calculated to complete the encoding. Typical algorithms include constant QP, constant bitrate, dynamic bitrate, constant bitrate factor, etc.

[0024] However, the control path based on bit number prediction has obvious technical limitations. Bit number pre-allocation is affected by factors such as entropy coding and coding mode. The prediction error is large at low bit rates or under special coding modes, which can easily lead to inaccurate QP calculation and poor balance between bit rate and quality.

[0025] To address the aforementioned issues, this application proposes a video coding method that uses coding distortion instead of coding bit count as the basis for predicting QP, thus avoiding the influence of multiple coding factors such as entropy coding, coding segmentation, and coding mode. Furthermore, coding distortion has the advantages of high stability and good continuity, further ensuring the accuracy of QP allocation and the stability of video quality.

[0026] The video encoding method provided in this application will be described in detail below with reference to the accompanying drawings.

[0027] Figure 1 This is a flowchart illustrating a video encoding method provided in an embodiment of this application. Figure 1 As shown, the video encoding method includes steps 101-103.

[0028] Step 101: Based on the pixel data of the reference coding unit in the video to be encoded, determine the predictive coding distortion of the coding unit. The reference coding unit is the coding unit that has been encoded in the video to be encoded, and the coding unit is any one of the coding block, coding frame, and coding frame group in the video to be encoded.

[0029] In the embodiments of this application, the reference coding unit is a coding unit in the video to be encoded that has completed the entire coding process. Valid coding information such as pixel data, distortion, and rate-distortion parameters can be extracted from this unit, which is the main reference for predicting the distortion of the unit to be encoded. The granularity of the reference coding unit matches the unit to be encoded and can be a coding block, a coding frame, or a group of coding frames. This is not limited in the embodiments of this application.

[0030] A unit to be encoded is an independent processing unit in the video to be encoded, awaiting compression encoding. It can be flexibly selected as an encoding block, encoding frame, or encoding frame group, depending on the video encoding accuracy requirements, scene adaptability, and encoding efficiency requirements. An encoding block refers to the smallest pixel block obtained by dividing a video frame image into fixed sizes (such as 16×16 pixel blocks, 32×32 pixel blocks, etc.); an encoding frame refers to a single complete video image, suitable for scenes with high requirements for overall quality consistency within the frame; and an encoding frame group is a video unit composed of multiple consecutive encoded frames according to encoding standards, suitable for batch encoding, storage management, and macro-level bitrate control scenarios.

[0031] It should be noted that this application can flexibly adapt to different granularity coding quantization value allocation strategies according to actual coding needs: that is, it can allocate coding quantization values ​​individually to each coding block of the entire video frame to achieve intra-frame differential compression to optimize the balance between local image quality and bitrate; it can also uniformly allocate coding quantization values ​​to each video frame to ensure the uniformity of the overall frame quality while improving coding efficiency; or it can allocate uniform coding quantization values ​​to each coding frame group to achieve coarse-grained bitrate control to adapt to large-scale video batch processing scenarios. All of the above coding quantization value allocation methods are within the protection scope of this application and are not limited in the embodiments of this application.

[0032] Pixel data includes basic pixel-level data such as the original pixel data of the reference coding unit and the encoded reconstructed pixel data. The distortion of the reference coding unit is determined based on the pixel data of the reference coding unit before and after encoding.

[0033] Predictive coding distortion is an estimated value of the distortion of the unit to be encoded, derived from the actual coding distortion of a reference coding unit and the relevance of the video content. It is used to replace traditional bitrate prediction metrics (such as the number of encoded bits) to infer the coding quantization value. Coding distortion represents the expected loss of image quality if the current unit to be encoded is encoded with a certain quantization intensity (QP).

[0034] Since video sequence frames are highly correlated in time and the content differences between adjacent video frames are small, the distortion of the encoded video frames can be used to predict the distortion of the unit to be encoded.

[0035] Step 102: Based on the predicted coding distortion and the reference rate distortion parameter, determine the rate distortion tradeoff coefficient of the cell to be coded. The reference rate distortion parameter is the rate distortion model parameter associated with the reference coding cell.

[0036] In the embodiments of this application, a mapping relationship between coding distortion and rate-distortion tradeoff coefficients is established based on the Lagrangian Rate-Distortion Optimization (RDO) model and the Laplacian Rate-Distortion model. The RDO model is the core algorithm model for achieving the optimal balance between bitrate and distortion in video coding. The goal of the RDO model is to find a set of coding parameters (such as coding mode and coding quantization value) under given constraints that minimizes the overall cost of the coding unit, thereby achieving the optimal balance between bitrate and distortion. The Laplacian Rate-Distortion model is a statistical model that describes the mathematical relationship between coding distortion and coding bitrate.

[0037] The reference rate-distortion parameter refers to the Laplace distribution coefficient of the rate-distortion model associated with the reference coding unit. It is a dynamically updated core parameter that establishes the mapping relationship between coding distortion and rate-distortion tradeoff coefficients.

[0038] Rate-distortion tradeoffs, also known as Lagrange multipliers, are weighting parameters that balance coding distortion and coding rate. The magnitude of the rate-distortion tradeoffs precisely quantifies how much weight the encoder should assign to "saving bit rate" and "ensuring quality" in the current coding unit. For example, a larger rate-distortion tradeoff is more inclined to reduce the bit rate, while a smaller rate-distortion tradeoff is more inclined to ensure quality.

[0039] This application utilizes the coding distortion of the cell to be coded, predicted based on the already coded reference coding cell, and the reference rate-distortion parameter of the reference coding cell. Based on the pre-established mapping relationship between coding distortion and rate-distortion tradeoff coefficient, the rate-distortion tradeoff coefficient of the cell to be coded can be obtained.

[0040] Step 103: Based on the rate-distortion tradeoff coefficient and combined with the preset distortion mapping relationship, determine the coding quantization value of the unit to be encoded, and encode the unit to be encoded according to the coding quantization value to obtain the target coded video.

[0041] In the embodiments of this application, the preset distortion mapping relationship is a functional model representing the correspondence between the rate-distortion tradeoff coefficient and the encoded quantization value, which is a mathematical function established through experimental determination. The encoded quantization value, i.e., the quantization parameter QP, is a core parameter that directly determines the compression strength of the unit to be encoded and affects the final video quality and bitrate.

[0042] Specifically, based on the preset distortion mapping relationship, the coded quantization value of the unit to be encoded can be calculated using the rate-distortion tradeoff coefficient. Then, using this coded quantization value, standard encoding processes such as intra-frame or inter-frame prediction, transform, quantization, and entropy coding are performed on the unit to be encoded to complete the encoding of the unit, ultimately completing the video encoding.

[0043] In summary, the video coding method proposed in this application determines the predicted coding distortion of the unit to be encoded based on the pixel data of a reference coding unit in the video to be encoded. The reference coding unit is any one of the coded blocks, coded frames, and coded frame groups in the video to be encoded. Based on the predicted coding distortion and the reference rate-distortion parameter, the rate-distortion tradeoff coefficient of the unit to be encoded is determined. The reference rate-distortion parameter is the rate-distortion model parameter associated with the reference coding unit. Based on the rate-distortion tradeoff coefficient and a preset distortion mapping relationship, the coded quantization value of the unit to be encoded is determined. The unit to be encoded is then encoded according to the coded quantization value to obtain the target encoded video. This method uses coding distortion instead of the number of coded bits as the prediction basis to infer the coded quantization value, which is unaffected by multiple coding factors such as entropy coding and coding mode, further achieving an efficient balance between bitrate and video quality, and effectively improving the stability and adaptability of the coding effect.

[0044] As one possible implementation, this application requires, before determining the predicted coding distortion of the coding unit based on the pixel data of the reference coding unit in the video to be encoded, to accurately determine the reference coding unit according to the different granularities of the coding unit (coding block / coding frame / coding frame group) using a differentiated strategy.

[0045] Specifically, when the granularity of the coding unit is a coding block (a fine-grained operation unit for video coding, such as a 16×16 pixel block or a 32×32 pixel block), pixel-level content matching can be completed through a preset estimation algorithm to determine the most matching coded block as the reference coding unit. Specifically, firstly, the current frame image to which the block to be coded belongs is determined, and the temporally adjacent coded frames of this frame image are designated as reference frame images (preferably the previous frame). Next, all coded pixel blocks in the reference frame images are used as candidate reference coding blocks for the block to be coded. Then, using a preset estimation algorithm (e.g., motion estimation (ME) algorithm), the content matching degree between the block to be coded and all candidate reference coding blocks is calculated one by one based on the pixel features of the block to be coded. The matching criteria may include the sum of absolute differences (SAD), the sum of squared differences (SSD), etc., which are not limited in the embodiments of this application. Finally, the candidate reference coding block with the highest content matching degree is selected and determined as the reference coding unit corresponding to the block to be coded.

[0046] Furthermore, to help with a better understanding, please refer to... Figure 2 , Figure 2This is a schematic diagram illustrating a video frame image coding block position index provided in an embodiment of this application. In one example, the unit to be encoded (the block to be encoded) in this application is taken as the block to be encoded (x, y). Using the ME algorithm, within a preset search area of ​​the reference frame image, the block to be encoded is compared with each candidate position (e.g., ...). Figure 2 The coded blocks are compared with those in the coordinate grid shown, and a matching degree (such as the SAD value) is calculated. The candidate reference coded block with the highest matching degree (i.e., the smallest SAD value) is determined as the reference coded unit. For example, Figure 2 The coded block at position (x-2, y-2) is determined as the best matching reference block for the current unit to be coded (x, y).

[0047] Optionally, when the granularity of the coding unit is a coded frame, a coded frame that is temporally adjacent to the frame to be coded is selected as the reference coding unit.

[0048] Optionally, when the granularity of the coding unit is a coding frame group, adjacent coded frame groups can be selected, or non-adjacent but highly related coded frame groups can be selected based on the frame group characteristics. In the specific embodiments of this application, no restrictions are imposed.

[0049] As one possible implementation method, Figure 3 A flowchart of a second video coding method provided in an embodiment of this application is shown. Based on the above embodiments, the predictive coding distortion of the coding unit to be encoded is determined based on the pixel data of the reference coding unit in the video to be encoded, including the following steps: Step 201: Obtain the original pixel data and reconstructed pixel data of the reference coding unit. The reconstructed pixel data is the pixel data after the reference coding unit has performed encoding.

[0050] In the embodiments of this application, the original pixel data is the initial pixel data of the reference coding unit before any encoding processing. The reconstructed pixel data is the pixel data obtained after the reference coding unit has undergone complete encoding, decoding, and other operations. Due to lossy steps such as quantization, the reconstructed value suffers from information loss compared to the original value.

[0051] Specifically, the two sets of pixel data for the reference coding unit can be read directly from memory. The original pixel data comes from the encoder's original input buffer, and the reconstructed pixel data comes from the reference frame image buffer.

[0052] Step 202: Perform differential processing on the original pixel data and the reconstructed pixel data to obtain the reference coding distortion of the reference coding unit, and determine the reference coding distortion as the prediction coding distortion.

[0053] In the embodiments of this application, the difference between the reconstructed pixel data and the original pixel data can intuitively reflect the degree of encoding distortion. The difference between the reconstructed pixel data and the original pixel data can be calculated using SSD, SAD, Mean Squared Error (MSE), etc., and is not limited in the embodiments of this application. This application uses SSD as an example, and the formula for calculating encoding distortion based on SSD is as follows: Formula 1 in, To predict coding distortion; The original pixel data for the reference coding unit; Reconstructed pixel data for the reference coding unit.

[0054] In summary, this application employs a refined process of accurately matching reference coding units through a preset estimation algorithm, extracting original and reconstructed pixel data, and performing differential processing to obtain the reference distortion. This ensures the accuracy and reliability of the predicted coding distortion, solves the technical pain point of bit number prediction being affected by multiple factors, and provides high-quality input data for the subsequent calculation of rate-distortion tradeoff coefficients.

[0055] As one possible implementation method, Figure 4 A flowchart of a third video coding method provided in this application is shown. Based on the above embodiments, the rate-distortion tradeoff coefficient of the unit to be coded is determined based on the predicted coding distortion and reference rate-distortion parameters, including the following steps: Step 301: Obtain the reference rate distortion parameters after the reference coding unit performs encoding.

[0056] In the embodiments of this application, after the reference coding unit completes encoding within its own encoding cycle, the encoder uses its actual encoding results (including actual encoding distortion and actual encoding bit count) to calculate or update a model parameter (i.e., reference rate-distortion parameter) that matches the content characteristics of the reference coding unit through an online learning mechanism (refer to the explanation of step 502, which will not be repeated here). This parameter is stored as metadata in the reference frame buffer along with the reconstructed pixel data of the reference coding unit.

[0057] In the current encoding cycle, after determining the reference coding unit, the encoder can read the reference rate-distortion parameter associated with the reference coding unit from the buffer. This parameter can then be used as prior knowledge or empirical value to predict the rate-distortion characteristics of the current coding unit.

[0058] Step 302: Determine the rate-distortion tradeoff coefficient based on the reference rate-distortion parameters and the preset mapping relationship between the predicted coding distortion and the rate-distortion tradeoff coefficient.

[0059] In the embodiments of this application, a preset mapping relationship between predictive coding distortion and rate-distortion tradeoff coefficients is established based on the Lagrangian RDO model and the Laplace rate-distortion model. The specific derivation process is as follows: Based on the cost function of the RDO model, the video to be encoded is divided into K units to be encoded. ), encoding unit The specific cost function is as follows: Formula 2 in, For Lagrangian parameters (rate-distortion tradeoff coefficients); For encoding distortion, This represents the bitrate (number of encoded bits) of the encoded bitstream. Taking the partial derivative, we get: Formula 3 To solve the above coding distortion Rate-distortion tradeoff coefficient Relationships need to be established D and R Based on the specific functional relationship between them, and combined with the statistical law that the coding residuals follow a Laplace distribution, the rate-distortion function model is constructed as follows: Formula 4 in, and It is a constant parameter; For rate distortion parameters. Formula 4 for... R Taking the partial derivative, we get: Formula 5 Combining formulas 3, 4, and 5, we obtain the coding distortion. D Rate-distortion tradeoff coefficient The pre-defined mapping relationships between them are as follows: Formula 6 Predicting coding distortion and reference rate distortion parameters Substituting into Formula 6, we can obtain the rate-distortion tradeoff coefficient for the unit to be encoded: .

[0060] In summary, this application clarifies the transformation link from predicted coding distortion to weight coefficients by accurately retrieving the reference rate-distortion parameters of the reference coding unit and calculating the rate-distortion trade-off coefficients in combination with the preset mapping relationship. This ensures the calculation accuracy of the rate-distortion trade-off coefficients, lays the foundation for the accurate allocation of subsequent coding quantization values, and improves the standardization and repeatability of the rate control scheme.

[0061] As one possible implementation method, Figure 5 A flowchart of the fourth video coding method provided in this application is shown. Based on the above embodiments, the coding quantization value of the unit to be encoded is determined based on the rate-distortion tradeoff coefficient and a preset distortion mapping relationship, including the following steps: Step 401: Constrain the rate-distortion tradeoff coefficients to obtain the constrained rate-distortion tradeoff coefficients.

[0062] In the embodiments of this application, the constraints include at least one of block-level constraints, frame-level constraints, and frame group-level constraints. One or more of these constraints can be selected and combined according to the granularity of the coding unit and actual control requirements. The specific implementation methods of each constraint are as follows: (1) Block-level constraints: including temporal constraints and spatial constraints. Among them, the temporal constraints are used to constrain the rate-distortion tradeoff coefficient of the current unit to be encoded (coded block) within a first preset range of the block-level rate-distortion tradeoff coefficients corresponding to adjacent frames; The block-level rate-distortion tradeoff coefficient corresponding to adjacent frames refers to the rate-distortion tradeoff coefficient corresponding to the coded block in the reference frame that matches the current block to be coded in the temporal domain, and is used to reflect the content correlation and quality continuity constraints between video frames. The first preset range is a numerical interval defined based on the rate-distortion tradeoff coefficient of the reference coded block, used to limit the deviation of the rate-distortion tradeoff coefficient of the current block to be coded relative to the reference coded block.

[0063] In one example, to ensure the rate-distortion tradeoff coefficient of the block to be encoded Reference rate-distortion tradeoff relative to the reference coded block There will be no significant fluctuations, ensuring the temporal stability of the video frame images to be encoded, and the rate-distortion tradeoff coefficient will be adjusted accordingly. Constraints Within the range.

[0064] Spatial constraints are used to constrain the rate-distortion tradeoff coefficients of the current block to be encoded within a second preset range of the rate-distortion tradeoff coefficients of adjacent blocks within the frame.

[0065] The rate-distortion tradeoff coefficient at the intra-frame adjacent block level refers to the rate-distortion tradeoff coefficient corresponding to the spatially adjacent encoded block within the same frame as the current block to be encoded. It is used to ensure a smooth transition of image quality within a single frame. The second preset range is a numerical interval defined based on the rate-distortion tradeoff coefficients of intra-frame adjacent blocks, used to limit the deviation of the rate-distortion tradeoff coefficient of the current block to be encoded relative to adjacent encoded blocks.

[0066] In one example, to ensure the rate-distortion tradeoff coefficient of the block to be encoded The adjacent rate-distortion tradeoff coefficient relative to the preceding and following coded blocks within the current video frame to be encoded. There will be no significant fluctuations, ensuring the stability of the local (spatial domain) quality of the video frame image to be encoded, and the rate-distortion tradeoff coefficient will be adjusted accordingly. Constraints Within the range.

[0067] (2) Frame-level constraint, used to constrain the rate-distortion tradeoff coefficient within the third preset range of the frame-level rate-distortion tradeoff coefficient corresponding to the video to be encoded; Among them, the frame-level rate-distortion tradeoff coefficient corresponding to the video to be encoded refers to the rate-distortion tradeoff coefficient corresponding to the reference encoded frame. The rate-distortion tradeoff coefficient of the reference encoded frame can be the statistical value (e.g., the mean) of the rate-distortion tradeoff coefficients of each reference encoded block in the reference encoded frame, which is used to control the overall encoding quality and bit rate level of the entire frame image. The third preset range is a numerical range defined based on the frame-level rate-distortion tradeoff coefficient.

[0068] In one example, to ensure the rate-distortion tradeoff coefficient of the unit to be encoded relative to frame rate distortion trade-off There will be no significant fluctuations, ensuring the stability of the overall quality of the video frames to be encoded, and adjusting the rate-distortion tradeoff factor. Constraints Within the range.

[0069] (3) Frame group level constraint, used to constrain the rate-distortion tradeoff coefficient within the fourth preset range of the frame group level rate-distortion tradeoff coefficient corresponding to the video to be encoded.

[0070] Among them, the frame group-level rate-distortion tradeoff coefficient corresponding to the video to be encoded refers to the rate-distortion tradeoff coefficient corresponding to the reference encoded frame group. The rate-distortion tradeoff coefficient of the reference encoded frame group can be the statistical value (e.g., the mean) of the rate-distortion tradeoff coefficients of each reference encoded frame in the reference encoded frame group, which is used to achieve unified bitrate control and image quality planning at the frame group level. The fourth preset range is a numerical interval defined based on the frame group-level rate-distortion tradeoff coefficient.

[0071] It should be noted that if the unit to be encoded is a coding block, its rate-distortion tradeoff coefficient needs to be constrained at both the block level and the frame level (that is, the rate-distortion tradeoff coefficient of the block to be encoded needs to be constrained within the third preset range of the frame-level rate-distortion tradeoff coefficient of the frame in which the reference coding block is located); if the unit to be encoded is a coding frame, only the rate-distortion tradeoff coefficient needs to be constrained at the frame level; similarly, if the unit to be encoded is a group of coding frames, only the rate-distortion tradeoff coefficient needs to be constrained at the group level.

[0072] Understandably, the quantization value QP is usually an integer, with a coarse adjustment granularity. Even a small integer change can cause drastic fluctuations in coding quality or bitrate. Compared to related technologies that constrain the quantization value QP, this application uses a rate-distortion tradeoff coefficient... Imposing constraints not only achieves the same quality stabilization effect, but also improves the rate-distortion tradeoff coefficient. It is a floating-point value, which provides higher adjustment precision.

[0073] Step 402: Based on the constrained rate-distortion tradeoff coefficient and the preset distortion mapping relationship, determine the encoded quantization value. The preset distortion mapping relationship is used to characterize the logarithmic fitting relationship between the rate-distortion tradeoff coefficient and the encoded quantization value.

[0074] In the embodiments of this application, the preset distortion mapping relationship refers to the rate-distortion tradeoff coefficients obtained through experimental determination and fitting. This is a mathematical function that maps to discrete encoded quantization values ​​QP. In one example, The specific form is a logarithmic linear relationship, specifically The relationship is as follows: Formula 7 Based on the constrained rate-distortion tradeoff coefficients, the encoded quantization value of the current cell to be encoded can be calculated using Formula 7. Using this encoded quantization value, the encoder can drive the RDO decision to complete the encoding operation of the cell.

[0075] In summary, this application effectively limits the fluctuation range of the rate-distortion tradeoff coefficient by applying corresponding constraints to the rate-distortion tradeoff coefficient, thus avoiding abrupt changes in the coding quality of the coding unit. At the same time, by combining the mapping relationship of logarithmic fitting, it realizes the accurate calculation of the coding quantization value corresponding to the coding unit, thereby reasonably allocating coding quantization values ​​to different coding units in the video to be coded, further improving the stability and consistency of video coding quality.

[0076] As one possible implementation method, Figure 6 A flowchart of the fifth video encoding method provided in this application embodiment is shown. Based on the above embodiments, after encoding the unit to be encoded according to the quantization value, the method includes the following steps: Step 501: Obtain the actual coding distortion and the actual number of coding bits after encoding the unit to be encoded.

[0077] In the embodiments of this application, true encoding distortion refers to the degree of difference between the original pixel data and the reconstructed pixel data of the unit to be encoded after the unit to be encoded is completed; true encoding bit count refers to the actual bit stream size generated after the unit to be encoded is completed. Specifically, after completing all operations such as RDO, quantization, and entropy coding of the unit to be encoded, the encoder obtains the reconstructed unit (i.e., the encoded unit) of the unit to be encoded through local decoding. The actual coding distortion of the unit to be encoded can be calculated based on the pixel data before and after encoding. At the same time, the actual coding bit count is obtained by counting the number of bits output by entropy coding.

[0078] Step 502: Based on the actual coding distortion, the actual number of coding bits, and the predicted coding distortion, update the reference rate-distortion parameter to obtain the updated rate-distortion parameter associated with the unit to be coded.

[0079] In the embodiments of this application, updating the rate distortion parameter refers to correcting the reference rate distortion parameter inherited from the reference coding unit based on the difference between the predicted result and the actual result of the current encoding, obtaining a new and more accurate rate distortion parameter value, and storing it in association with the current coding unit (i.e., the coding unit that has been encoded).

[0080] Rate distortion parameters The update formula is as follows: Formula 8 in, This is the update rate distortion parameter; This is the reference rate distortion parameter; This is a preset step size constant; For true encoding distortion; To predict coding distortion; This represents the actual number of encoded bits.

[0081] Updated rate distortion parameters The parameter cache module of the encoder stores the parameter as a reference rate-distortion parameter for subsequent units to be encoded, for use in subsequent encoding.

[0082] In summary, this application obtains real encoded data after encoding is completed and dynamically updates the rate-distortion model parameters based on the real data, enabling the rate-distortion model to adapt to different encoded content and scenarios, continuously optimize the parameter calculation accuracy of subsequent encoded blocks, ensure the universality and stability of the bitrate control scheme in long-term, complex video sequence encoding, and further improve the continuous optimization capability of the encoding effect.

[0083] Figure 7 This is a schematic diagram of the structure of a video encoding device 700 provided in an embodiment of this application. Figure 7 As shown, the video encoding device includes: The first determining unit 710 is used to determine the predicted coding distortion of the unit to be encoded based on the pixel data of the reference coding unit in the video to be encoded. The reference coding unit is a coding unit that has been encoded in the video to be encoded, and the coding unit is any one of the coding block, coding frame and coding frame group in the video to be encoded. The second determining unit 720 is used to determine the rate-distortion tradeoff coefficient of the cell to be encoded based on the predicted coding distortion and the reference rate-distortion parameter, wherein the reference rate-distortion parameter is the rate-distortion model parameter associated with the reference coding cell; The coding unit 730 is used to determine the coding quantization value of the unit to be coded based on the rate-distortion tradeoff coefficient and in combination with the preset distortion mapping relationship, so as to encode the unit to be coded according to the coding quantization value to obtain the target coded video.

[0084] In some embodiments of this application, the first determining unit 710 is configured to: before determining the predicted coding distortion of the unit to be encoded based on the pixel data of the reference coding unit in the video to be encoded, and when the coding unit is a coding block, perform matching degree estimation on at least one coded block in the reference frame image based on a preset estimation algorithm, and determine the coded block that best matches the unit to be encoded as the reference coding unit, wherein the reference frame image is a frame image adjacent to the frame image where the unit to be encoded is located.

[0085] In some embodiments of this application, the first determining unit 710 is configured to: acquire the original pixel data and reconstructed pixel data of the reference coding unit, wherein the reconstructed pixel data is the pixel data after the reference coding unit performs encoding; perform differential processing on the original pixel data and the reconstructed pixel data to obtain the reference coding distortion of the reference coding unit, and determine the reference coding distortion as the predicted coding distortion.

[0086] In some embodiments of this application, the second determining unit 720 is configured to: obtain reference rate-distortion parameters after the reference coding unit performs coding; and determine the rate-distortion tradeoff coefficient based on the reference rate-distortion parameters and a preset mapping relationship between the predicted coding distortion and the rate-distortion tradeoff coefficient.

[0087] In some embodiments of this application, the encoding unit 730 is configured to: constrain the rate-distortion tradeoff coefficients to obtain constrained rate-distortion tradeoff coefficients; and determine the encoded quantization value based on the constrained rate-distortion tradeoff coefficients and a preset distortion mapping relationship, wherein the preset distortion mapping relationship is used to characterize the logarithmic fitting relationship between the rate-distortion tradeoff coefficients and the encoded quantization value.

[0088] In some embodiments of this application, the constraints include at least one of the following: block-level constraints, used to constrain the rate-distortion tradeoff coefficient within a first preset range of block-level rate-distortion tradeoff coefficients corresponding to adjacent frames, and / or to constrain the rate-distortion tradeoff coefficient within a second preset range of adjacent block-level rate-distortion tradeoff coefficients within a frame; frame-level constraints, used to constrain the rate-distortion tradeoff coefficient within a third preset range of frame-level rate-distortion tradeoff coefficients corresponding to the video to be encoded; and frame group-level constraints, used to constrain the rate-distortion tradeoff coefficient within a fourth preset range of frame group-level rate-distortion tradeoff coefficients corresponding to the video to be encoded.

[0089] In some embodiments of this application, the apparatus includes: an update unit, configured to obtain the actual coding distortion and the actual number of coding bits after encoding of the unit to be encoded; and update the reference rate-distortion parameter based on the actual coding distortion, the actual number of coding bits, and the predicted coding distortion, to obtain the updated rate-distortion parameter associated with the unit to be encoded.

[0090] Since the apparatus provided in this application corresponds to the methods provided in the above-mentioned embodiments, the implementation of the methods is also applicable to the apparatus provided in this embodiment, and will not be described in detail in this embodiment.

[0091] The methods and apparatus provided in the embodiments of this application have been described above. To implement the functions of the methods provided in the embodiments of this application, the electronic device may include a hardware structure and software modules, and may implement the above functions in the form of a hardware structure, software modules, or a hardware structure plus software modules. One of the above functions may be executed in the form of a hardware structure, software modules, or a hardware structure plus software modules.

[0092] Figure 8 This is a block diagram illustrating an electronic device for implementing the above-described video encoding method, according to an exemplary embodiment. For example, the electronic device may be an Artificial Intelligence (AI) server, a training and promotion integrated machine, etc.

[0093] Reference Figure 8 The electronic device may include one or more of the following components: an AI-accelerated computing module, a central processing unit (CPU) module, a power supply module, a hard drive module, and a fan module. Each module works in conjunction with the bus system through a standardized hardware interface, as detailed in the following architecture: The AI-accelerated computing module comprises multiple AI accelerator cards deployed in parallel. Each AI accelerator card integrates at least one AI acceleration chip (such as a Resistive Processing Unit (RPU) chip, a GPU chip, or a Coarse-Grained Reconfigurable Array (CGRA) chip). The AI ​​accelerator cards communicate with each other via a high-speed card-to-card (C2C) interconnect structure, supporting low-latency, high-bandwidth horizontal scaling. The AI ​​acceleration chip is dedicated to performing AI computing tasks such as high-density matrix operations, neural network model training, and / or inference, providing the main computing power support.

[0094] The CPU module includes at least one CPU board, on which a CPU chip and matching CPU memory (such as fourth / fifth generation double data rate (DDR4 / DDR5) or random access memory (RAM) are mounted. The CPU chip, as the system control center, is responsible for task scheduling, resource allocation, input / output (I / O) management, and coordinating the parallel operation of the AI ​​acceleration computing module, while also handling non-accelerated general-purpose computing tasks.

[0095] The power module is equipped with redundant power supply units to provide stable power distribution and management for the AI ​​acceleration computing module, CPU module and other modules.

[0096] The hard drive module integrates a high-speed solid-state drive (SSD) and / or a large-capacity hard disk drive (HDD), connected to the system bus via a backplane. The hard drive stores the operating system, AI training datasets, model parameters, and computation results, providing high-throughput data read / write channels and supporting data preprocessing and persistence.

[0097] The fan module uses a multi-zone independent speed-controlled fan array, which is configured in key heat source areas (such as AI accelerator cards and CPU heat dissipation areas) to achieve system heat dissipation through forced air cooling and ensure the stable operation of high-efficiency computing components.

[0098] The CPU module is connected to the AI ​​acceleration computing module via the PCIe bus to enable task distribution, result collection, and memory coordination.

[0099] The CPU module manages the data access of the hard drive module through SATA / SAS / NVMe interfaces.

[0100] The power module provides tiered power to all functional modules through the power distribution backplane.

[0101] The fan module adjusts the fan speed based on temperature monitoring signals from the CPU board and AI accelerator card.

[0102] In an exemplary embodiment, the electronic device may be implemented by one or more application-specific integrated circuits (ASICs), digital signal processors (DSPs), programmable logic devices (PLDs), complex programmable logic devices (CPLDs), field-programmable gate arrays (FPGAs), general-purpose processors, controllers, micro controller units (MCUs), microprocessors, or other electronic components to perform the aforementioned method.

[0103] Embodiments of this application also propose a non-transitory computer-readable storage medium storing computer instructions, wherein the computer instructions are used to cause a computer to execute the video coding method described in the above embodiments of this application.

[0104] Embodiments of this application also propose a computer program product, including a computer program that is executed by a processor using the video encoding method described in the above embodiments of this application.

[0105] Embodiments of this application also propose a chip, such as Figure 9 As shown, the chip includes one or more interface circuits 901 and one or more processors 902; the interface circuits are used to receive signals from the memory of the electronic device and send signals to the processors, the signals including computer instructions stored in the memory, and when the processor executes the computer instructions, it causes the electronic device to perform the video encoding method described in the above embodiments of this application.

[0106] It should be noted that the terms "first," "second," etc., used in the specification, claims, and accompanying drawings of this application are used to distinguish similar objects and are not necessarily used to describe a specific order or sequence. It should be understood that such data can be interchanged where appropriate so that the embodiments of this application described herein can be implemented in orders other than those illustrated or described herein. The embodiments described in the following exemplary embodiments do not represent all embodiments consistent with this application. Rather, they are merely examples of apparatuses and methods consistent with some aspects of this application as detailed in the appended claims.

[0107] In the description of this specification, the references to terms such as "one embodiment," "some embodiments," "illustrative embodiment," "example," "specific example," or "some examples," etc., indicate that a specific feature, structure, material, or characteristic described in connection with an embodiment or example is included in at least one embodiment or example of the present invention. In this specification, the illustrative expressions of the above terms do not necessarily refer to the same embodiment or example. Furthermore, the specific features, structures, materials, or characteristics described may be combined in any suitable manner in one or more embodiments or examples.

[0108] Any process or method description in the flowchart or otherwise herein can be understood as representing a module, segment, or portion of code comprising one or more executable instructions for implementing a particular logical function or process, and the scope of the preferred embodiments of the invention includes additional implementations in which functions may be performed not in the order shown or discussed, including substantially simultaneously or in reverse order depending on the functions involved, as will be understood by those skilled in the art to which embodiments of the invention pertain.

[0109] The logic and / or steps represented in the flowchart or otherwise described herein, for example, can be considered as a sequenced list of executable instructions for implementing logical functions, and can be embodied in any computer-readable medium for use by, or in conjunction with, an instruction execution system, apparatus, or device (such as a computer-based system, a system including a processing module, or other system that can fetch and execute instructions from, an instruction execution system, apparatus, or device). For the purposes of this specification, "computer-readable medium" can be any means that can contain, store, communicate, propagate, or transmit programs for use by, or in conjunction with, an instruction execution system, apparatus, or device. More specific examples (a non-exhaustive list) of computer-readable media include: an electrical connection having one or more wires (control method), a portable computer disk drive (magnetic device), random access memory (RAM), read-only memory (ROM), erasable and editable read-only memory (EPROM or flash memory), fiber optic device, and portable optical disc read-only memory (CDROM). Furthermore, computer-readable media can even be paper or other suitable media on which programs can be printed, because programs can be obtained electronically, for example, by optically scanning the paper or other media, followed by editing, interpreting, or otherwise processing as necessary, and then stored in computer memory.

[0110] It should be understood that various parts of the embodiments of the present invention can be implemented in hardware, software, firmware, or a combination thereof. In the above embodiments, multiple steps or methods can be implemented in software or firmware stored in memory and executed by a suitable instruction execution system. For example, if implemented in hardware, as in another embodiment, it can be implemented using any one or a combination of the following techniques known in the art: discrete logic circuits having logic gates for implementing logical functions on data signals, application-specific integrated circuits (ASICs) having suitable combinational logic gates, programmable gate arrays (PGAs), field-programmable gate arrays (FPGAs), etc.

[0111] Those skilled in the art will understand that all or part of the steps of the methods in the above embodiments can be implemented by a program instructing related hardware. The program can be stored in a computer-readable storage medium, and when executed, the program includes one or a combination of the steps of the method embodiments.

[0112] Furthermore, the functional units in the various embodiments of the present invention can be integrated into a processing module, or each unit can exist physically separately, or two or more units can be integrated into a module. The integrated module can be implemented in hardware or as a software functional module. If the integrated module is implemented as a software functional module and sold or used as an independent product, it can also be stored in a computer-readable storage medium. The storage medium mentioned above can be a read-only memory, a disk, or an optical disk, etc.

[0113] Although embodiments of the present invention have been shown and described above, it is understood that the above embodiments are exemplary and should not be construed as limiting the present invention. Those skilled in the art can make changes, modifications, substitutions and variations to the above embodiments within the scope of the present invention.

Claims

1. A video encoding method, characterized in that, The method includes: Based on the pixel data of the reference coding unit in the video to be encoded, the predicted coding distortion of the coding unit is determined. The reference coding unit is a coding unit that has been encoded in the video to be encoded. The coding unit is any one of the coding block, coding frame and coding frame group in the video to be encoded. Based on the predicted coding distortion and the reference rate distortion parameter, the rate distortion tradeoff coefficient of the unit to be encoded is determined, wherein the reference rate distortion parameter is the rate distortion model parameter associated with the reference coding unit; Based on the rate-distortion tradeoff coefficient and a preset distortion mapping relationship, the coding quantization value of the unit to be encoded is determined, and the unit to be encoded is encoded according to the coding quantization value to obtain the target coded video.

2. The method according to claim 1, characterized in that, Before determining the predictive coding distortion of the coding unit based on the pixel data of the reference coding unit in the video to be encoded, the method includes: When the coding unit is the coding block, based on a preset estimation algorithm, at least one coded block in the reference frame image is estimated to determine the matching degree, and the coded block that best matches the unit to be coded is determined to be the reference coding unit. The reference frame image is a frame image adjacent to the frame image where the unit to be coded is located.

3. The method according to claim 1, characterized in that, The determination of the predictive coding distortion of the cell to be encoded based on the pixel data of the reference coding cell in the video to be encoded includes: Obtain the original pixel data and reconstructed pixel data of the reference coding unit, wherein the reconstructed pixel data is the pixel data after the reference coding unit performs encoding; The original pixel data and the reconstructed pixel data are differentially processed to obtain the reference coding distortion of the reference coding unit, and the reference coding distortion is determined as the predicted coding distortion.

4. The method according to claim 1, characterized in that, The determination of the rate-distortion tradeoff coefficient for the cell to be encoded based on the predicted coding distortion and the reference rate-distortion parameter includes: Obtain the reference rate distortion parameters after the reference coding unit performs the encoding; The rate-distortion tradeoff coefficient is determined based on the reference rate-distortion parameter and the preset mapping relationship between the predicted coding distortion and the rate-distortion tradeoff coefficient.

5. The method according to claim 1, characterized in that, The determination of the encoded quantization value of the unit to be encoded based on the rate-distortion tradeoff coefficient and in conjunction with the preset distortion mapping relationship includes: The rate-distortion tradeoff coefficients are constrained to obtain constrained rate-distortion tradeoff coefficients; Based on the constrained rate-distortion tradeoff coefficient and the preset distortion mapping relationship, the encoded quantization value is determined. The preset distortion mapping relationship is used to characterize the logarithmic fitting relationship between the rate-distortion tradeoff coefficient and the encoded quantization value.

6. The method according to claim 5, characterized in that, The constraints include at least one of the following: Block-level constraints are used to constrain the rate-distortion tradeoff coefficient within a first preset range of the block-level rate-distortion tradeoff coefficients corresponding to adjacent frames, and / or to constrain the rate-distortion tradeoff coefficient within a second preset range of the adjacent block-level rate-distortion tradeoff coefficients within a frame. Frame-level constraints are used to constrain the rate-distortion tradeoff coefficients within a third preset range corresponding to the frame-level rate-distortion tradeoff coefficients of the video to be encoded. Frame group level constraints are used to constrain the rate-distortion tradeoff coefficients within a fourth preset range corresponding to the frame group level rate-distortion tradeoff coefficients of the video to be encoded.

7. The method according to claim 1, characterized in that, After encoding the unit to be encoded according to the coded quantization value, the method includes: Obtain the actual encoding distortion and the actual number of encoding bits of the unit to be encoded; Based on the actual coding distortion, the actual number of coding bits, and the predicted coding distortion, the reference rate-distortion parameter is updated to obtain the updated rate-distortion parameter associated with the unit to be encoded.

8. A video encoding device, characterized in that, The device includes: The first determining unit is used to determine the predicted coding distortion of the unit to be encoded based on the pixel data of the reference coding unit in the video to be encoded. The reference coding unit is a coding unit that has been encoded in the video to be encoded, and the coding unit is any one of the coding block, coding frame and coding frame group in the video to be encoded. The second determining unit is used to determine the rate-distortion tradeoff coefficient of the unit to be encoded based on the predicted coding distortion and the reference rate-distortion parameter, wherein the reference rate-distortion parameter is the rate-distortion model parameter associated with the reference coding unit; The encoding unit is used to determine the encoding quantization value of the unit to be encoded based on the rate-distortion tradeoff coefficient and in combination with a preset distortion mapping relationship, so as to encode the unit to be encoded according to the encoding quantization value to obtain the target encoded video.

9. An electronic device, characterized in that, include: At least one processor; as well as A memory communicatively connected to the at least one processor; wherein, The memory stores instructions that can be executed by the at least one processor to enable the at least one processor to perform the method of any one of claims 1-7.

10. A non-transitory computer-readable storage medium storing computer instructions, characterized in that, The computer instructions are used to cause the computer to perform the method according to any one of claims 1-7.