A method and apparatus for I-frame video frame level rate control

By performing intra-frame coding mode prediction and quantization parameter calculation on I-frames in a hardware video encoder, and utilizing information from already encoded frames, the accuracy and cost issues of I-frame bitrate control are resolved, achieving more efficient bitrate control.

CN116886921BActive Publication Date: 2026-07-28ASR MICROELECTRONICS CO LTD
View PDF 2 Cites 0 Cited by

Patent Information

Authority / Receiving Office
CN · China
Patent Type
Patents(China)
Current Assignee / Owner
ASR MICROELECTRONICS CO LTD
Filing Date
2023-06-28
Publication Date
2026-07-28

AI Technical Summary

Technical Problem

In hardware video encoders, the bitrate control method for I-frames suffers from problems such as large calculation errors, high costs, and increased latency. In particular, it is difficult to accurately calculate the encoding parameters of I-frames without adding a preprocessing stage.

Method used

By performing intra-frame coding mode prediction on the image block to be encoded, retaining the mode candidate with the lowest prediction cost, and combining the information of the already encoded I-frames to calculate the video frame-level quantization parameters, the intra-frame coding complexity of the already encoded frames is used to replace the complexity of the frame to be encoded, reducing multiplication and division operations, and using addition and subtraction operations to calculate the quantization parameters.

Benefits of technology

It improves the accuracy of I-frame bitrate control, reduces hardware implementation costs and latency, and is suitable for the actual needs of hardware video encoders.

✦ Generated by Eureka AI based on patent content.

Smart Images

  • Figure CN116886921B_ABST
    Figure CN116886921B_ABST
Patent Text Reader

Abstract

The application discloses a kind of I frame video frame level code rate control method.To be encoded image block is carried out intraframe coding mode prediction.The smallest intraframe coding mode prediction cost is selected to represent the intraframe coding complexity of the to-be-encoded image block, the sum of the intraframe coding complexity of all image blocks in the video frame is used as the intraframe coding complexity of the video frame.According to the actual encoding bit number of the previous coded I frame, the video frame level quantization parameter and the intraframe coding complexity, combined with the target encoding bit number and the intraframe coding complexity of the to-be-encoded I frame, the video frame level quantization parameter of the to-be-encoded I frame is calculated;Wherein, the intraframe coding complexity of the to-be-encoded I frame is obtained by replacing the intraframe coding complexity of the previous coded video frame of the to-be-encoded I frame.The application uses the video frame level quantization parameter as the operation core of the code rate control algorithm, mainly addition and subtraction operation, which is more suitable for hardware implementation.
Need to check novelty before this filing date? Find Prior Art

Description

Technical Field

[0001] This invention relates to a digital video coding technology, and more particularly to a video frame-level bitrate control method suitable for hardware implementation of I-frames. Background Technology

[0002] Video coding is a technique that compresses redundant components in video images and represents video information using as little data as possible. Common video coding standards include HEVC (High Efficiency Video Coding, also known as H.265) and AVC (Advanced Video Coding, also known as H.264).

[0003] Video coding technology uses image blocks as the most basic coding unit. For example, in HEVC, the basic unit of video coding is the CU (Coding Unit). A CU can be an image block of 64 pixels × 64 pixels, 32 pixels × 32 pixels, 16 pixels × 16 pixels, or 8 pixels × 8 pixels. The 64-pixel × 64-pixel image block is also called the LCU (Largest Coding Unit).

[0004] To maximize video compression, common video coding algorithms often employ lossy compression, resulting in differences between the reconstructed video and the original (distortion). HEVC and AVC are both lossy compression algorithms. The coding performance of lossy compression algorithms needs to be measured by both the coding bit rate (Rate) and the distortion introduced by the coding. In video coding, the coding bit rate R and coding distortion D are mutually restrictive and contradictory; reducing the coding bit rate R often increases coding distortion D, and reducing coding distortion D often increases coding bit rate R. Rate-Distortion Optimization (RDO) aims to minimize coding distortion D at a given coding bit rate R, or minimize coding bit rate R at a given coding distortion D. Common video coding algorithms employ rate-distortion optimization methods based on Lagrange multipliers λ, which aim to achieve the minimum coding rate-distortion cost (RD Cost) J, where J = D + λ × R.

[0005] In video encoding, each encoding mode has a coding distortion D and a coding bit rate R, and the coding rate-distortion cost J of each encoding mode can be calculated. During video encoding, selecting the encoding mode with the lowest coding rate-distortion cost J yields optimal encoding performance. The process by which the encoder selects the optimal coding mode for each image block to be encoded using rate-distortion optimization methods is called mode decision for the image block to be encoded.

[0006] To remove information redundancy in the spatial and temporal domains, video coding techniques encode input video frames using intra-frame coding and inter-frame coding techniques. I-frames are encoded using only intra-frame coding. P-frames and B-frames are encoded using a combination of intra-frame and inter-frame coding techniques. The type of frame to be encoded is determined by the user-defined Group of Pictures (GOP) parameter. Figure 1 This demonstrates a common image group structure of I-frames, P-frames, and B-frames. When encoding an I-frame, only the information of the current video frame is used; it does not reference information from other encoded video frames. All image blocks within an I-frame are encoded as intra-frame coded blocks. When encoding P-frames and B-frames, in addition to using the information of the current video frame, information from one or more other encoded video frames is also referenced. Image blocks within P-frames and B-frames can be encoded as intra-frame coded blocks or inter-frame coded blocks, depending on which has a lower rate-distortion cost.

[0007] In real-world scenarios, the bandwidth capacity of a video transmission channel is limited. If the video encoding bitrate is too high, exceeding the channel bandwidth capacity, it will cause video transmission congestion or even packet loss. Conversely, if the video encoding bitrate is too low, the channel bandwidth will not be fully utilized, and higher video quality cannot be achieved. Therefore, it is necessary to use bitrate control technology to control the output bitrate of the video encoder to match it with the channel bandwidth capacity.

[0008] Rate control aims to adjust the encoding parameters of a video encoder to make its output bitrate equal to a pre-set target bitrate, while minimizing encoding distortion (D) to improve video encoding quality. Currently, the rate control algorithm used in the HEVC (High Efficiency Video Coding Test Model, HM) reference encoder is based on the JCTVC-K0103 proposal. The JCTVC-K0103 proposal establishes a mathematical relationship model between the encoding bitrate R and the Lagrange multiplier λ (i.e., the R-λ model), achieving rate control through two stages: target bit allocation and target bit control.

[0009] In the JCTVC-K0103 proposal, the target bit allocation process is conducted at three levels: GOP (Group of Pictures, a set of time-sequential video frames) level, video frame level, and image block level. At the GOP level, target bit allocation is based on the target bitrate of the video to determine the target coded bits for the GOP. At the video frame level, target bit allocation is based on the target coded bits for the GOP to determine the target coded bits for each video frame within that GOP. At the image block level, target bit allocation is based on the target coded bits for each video frame and the bit allocation weights for each image block within that video frame to determine the target coded bits for each image block within that video frame.

[0010] Target bit control typically occurs at the video frame level and the image block level. At the video frame level, the Lagrange multiplier λ and the quantization parameter QP are calculated based on the target number of coded bits in the video frame. Specifically, the value of the Lagrange multiplier λ for the current video frame to be encoded is calculated using the R-λ model proposed in JCTVC-K0103, where λ = α·bpp. β Here, α and β are R-λ model parameters, whose values ​​are determined by the video content and encoder configuration parameters, and are continuously updated as the encoding process progresses; bpp, or bits per pixel, represents the average target coding bits allocated to each pixel, and its value is the quotient of the target coding bits of the video frame to be encoded and the number of pixels in the video frame. After calculating the Lagrange multiplier λ of the current video frame to be encoded, λ can be used for rate-distortion optimization during the encoding process. Simultaneously, the quantization parameter QP of the current video frame to be encoded can also be calculated according to the following formula: QP = 4.2005 × ln(λ) + 13.7122. Here, ln is the natural logarithm operator. At the image block level, the image block-level Lagrange multiplier λ and quantization parameter QP of a given image block are calculated based on the target coding bits of that image block, the video frame-level Lagrange multiplier λ and quantization parameter QP of the video frame to which the image block belongs, and the image block-level Lagrange multiplier λ and quantization parameter QP of the previously encoded image block, and are used in the video encoding process of that image block.

[0011] Both the Lagrange multiplier λ and the quantization parameter QP are used at the video frame level and the image block level. The video frame-level Lagrange multiplier λ and quantization parameter QP are used in the target bit allocation and control stages (i.e., video frame-level bitrate control), while the image block-level Lagrange multiplier λ and quantization parameter QP are used in the target bit allocation and control stages (i.e., image block-level bitrate control). The video frame-level Lagrange multiplier is sometimes simply referred to as the video frame-level Lagrange multiplier, frame-level Lagrange multiplier, or video frame Lagrange multiplier. The image block-level Lagrange multiplier is sometimes simply referred to as the image block-level Lagrange multiplier, block-level Lagrange multiplier, or image block Lagrange multiplier. The abbreviations for the quantization parameter follow the same pattern.

[0012] Because video encoding algorithms are computationally intensive, the industry typically uses application-specific integrated circuits (ASICs) to accelerate the video encoding process in hardware to improve encoding speed and achieve real-time encoding and transmission. ASICs used for hardware acceleration of the video encoding process are generally referred to as hardware video encoders.

[0013] In hardware video encoders, bitrate control of I-frames has always been a challenge. The main reasons are as follows.

[0014] First, in the JCTVC-K0103 proposal, the bitrate control parameters (α and β) for I-frames are empirical values, which are not directly related to the content complexity of the I-frame. This leads to a large error in the calculated I-frame encoding parameters (such as video frame-level Lagrange multipliers or quantization parameters), ultimately resulting in a large discrepancy between the actual encoded bit count and the target encoded bit count, causing severe instantaneous bitrate fluctuations. To calculate the I-frame encoding parameters (such as video frame-level Lagrange multipliers or quantization parameters) more accurately, a dedicated preprocessing stage is needed to evaluate the content complexity of the I-frame before encoding. However, in hardware video encoders, adding a dedicated preprocessing stage is not only costly but also increases video encoding latency.

[0015] Second, in rate control algorithms represented by the JCTVC-K0103 proposal, operations centered on Lagrange multipliers introduce a large number of multiplication and division operations. Furthermore, due to the wide range of values ​​for Lagrange multipliers, high precision requirements, and large bit width, the computational, storage, and bandwidth costs in hardware implementation are all relatively high.

[0016] Therefore, it is necessary to design a bitrate control method for I-frames suitable for hardware video encoders, which can accurately calculate the encoding parameters required for I-frame encoding without adding a dedicated preprocessing stage, so that the actual number of encoded bits of the I-frame is closer to the target number of encoded bits, and the bitrate control process is more precise. Summary of the Invention

[0017] The technical problem to be solved by this invention is: how to make the bitrate control method of I-frame more suitable for hardware implementation.

[0018] To address the aforementioned technical problems, this invention proposes a video frame-level bitrate control method for I-frames, comprising the following steps: Step S1: Perform intra-frame coding mode prediction on the image block to be encoded, i.e., calculate the prediction cost corresponding to each intra-frame coding mode for the image block to be encoded, retain only one or more intra-frame coding modes with the lowest prediction cost as intra-frame coding mode candidates, and retain the intra-frame coding mode prediction cost corresponding to each intra-frame coding mode candidate. Step S2: Among the intra-frame coding mode prediction costs corresponding to all intra-frame coding mode candidates of the image block to be encoded, select the minimum intra-frame coding mode prediction cost to characterize the intra-frame coding complexity of the image block to be encoded, and then use the sum of the intra-frame coding complexities of all image blocks within the video frame as the intra-frame coding complexity of the video frame. Step S3: Based on the actual number of encoded bits, video frame-level quantization parameters, and intra-frame coding complexity of the previous encoded I-frame, and combined with the target number of encoded bits and intra-frame coding complexity of the I-frame to be encoded, calculate the video frame-level quantization parameters of the I-frame to be encoded; wherein, the intra-frame coding complexity of the I-frame to be encoded is obtained by replacing the intra-frame coding complexity of the previous encoded video frame of the I-frame to be encoded.

[0019] Preferably, in step S2, only the intra-frame coding complexity of each I-frame and the video frame preceding each I-frame is calculated.

[0020] Furthermore, in step S3, the video frame-level quantization parameter QP of the I-frame to be encoded... new From Formula 5: Find f; where f -1 It is the inverse function of the first function f; I(n) new Indicates the target number of coded bits for the I-frame to be encoded; I(m) old This represents the actual number of encoded bits in the previous encoded I-frame; g is the second function; ω n-1 The value represents the intra-frame coding complexity of the preceding encoded video frame, used to replace the intra-frame coding complexity ω of the I-frame to be encoded. n ;ω m QP represents the intra-frame coding complexity of the previous encoded I-frame. old This represents the video frame-level quantization parameters of the previous encoded I-frame.

[0021] Furthermore, the first function f is given by Formula 1: The first function f represents the relationship between the ratio of the different actual encoded bits obtained by the same video frame when using different video frame-level quantization parameters during I-frame encoding and the difference between the different video frame-level quantization parameters used in the video frame.

[0022] Furthermore, the second function g is derived from Formula 2: The second function g represents the relationship between the ratio of the actual number of encoded bits obtained by different video frames when using the same video frame-level quantization parameters during I-frame encoding and the ratio of their respective intra-frame coding complexity.

[0023] Furthermore, I-frame encoding experiments were conducted on a large number of different video streams in advance, and the expressions for the first function f and the second function g were obtained by function fitting and stored in the video encoder.

[0024] Furthermore, based on Formula 1 and Formula 2, Formula 3 is derived: Further derivation yields Formula 4: ω n The intra-frame coding complexity of frame n is represented by the intra-frame coding complexity ω of the (n-1)th frame that is adjacent to frame n. n-1 By making substitutions, we obtain Formula 5.

[0025] Optionally, step S4 is included after step S3; Step S4: Based on the conversion relationship between quantization parameters and Lagrange multipliers, the video frame-level Lagrange multipliers of the I-frame to be encoded are obtained from the video frame-level quantization parameters of the I-frame to be encoded.

[0026] This invention also proposes a video frame-level bitrate control device for I-frames, including an intra-frame coding mode prediction module, an intra-frame coding complexity calculation module, and an I-frame quantization parameter calculation module. The intra-frame coding mode prediction module is used to predict the intra-frame coding mode of the image block to be encoded, obtaining one or more intra-frame coding mode candidates and their corresponding intra-frame coding mode prediction costs. The intra-frame coding complexity calculation module is used to select the minimum intra-frame coding mode prediction cost to characterize the intra-frame coding complexity of the image block to be encoded, and the sum of the intra-frame coding complexities of all image blocks within the video frame is taken as the intra-frame coding complexity of the video frame. The I-frame quantization parameter calculation module is used to calculate the video frame-level quantization parameters of the I-frame to be encoded based on the actual number of encoded bits, video frame-level quantization parameters, and intra-frame coding complexity of the previous encoded I-frame, combined with the target number of encoded bits and intra-frame coding complexity of the I-frame to be encoded; wherein the intra-frame coding complexity of the I-frame to be encoded is obtained by substituting the intra-frame coding complexity of the previous encoded video frame.

[0027] Optionally, a conversion module is further included after the I-frame quantization parameter calculation module; the conversion module is used to obtain the video frame-level Lagrange multipliers of the I-frame to be encoded from the video frame-level quantization parameters of the I-frame to be encoded according to the conversion relationship between the quantization parameters and the Lagrange multipliers.

[0028] The technical effects achieved by this invention are: (1) Using video frame-level quantization parameters as the core of the bitrate control algorithm, the operation on the quantization parameters is mainly addition and subtraction, which is more suitable for hardware implementation. (2) No image preprocessing stage is required, resulting in low hardware overhead and low implementation cost. (3) The frame-level quantization parameters of the I-frame to be encoded are calculated using information from the encoded video frames, resulting in high calculation accuracy and effectively improving the accuracy of I-frame bitrate control. Attached Figure Description

[0029] Figure 1 This is a schematic diagram of a common image group structure consisting of I-frames, P-frames, and B-frames.

[0030] Figure 2 This is a flowchart illustrating the I-frame-level bitrate control method for video frames proposed in this invention.

[0031] Figure 3 This is a schematic diagram of the I-frame video frame-level bitrate control device proposed in this invention.

[0032] The following are the labels in the figure: 1 is the intra-frame coding mode prediction module, 2 is the intra-frame coding complexity calculation module, 3 is the I-frame quantization parameter calculation module, and 4 is the conversion module. Detailed Implementation

[0033] Please see Figure 2 The video frame-level bitrate control method for I-frames proposed in this invention includes the following steps.

[0034] Step S1: Perform intra-frame coding mode prediction on the image block to be encoded. This involves calculating the prediction cost for each intra-frame coding mode for the image block, retaining only one or more intra-frame coding modes with the lowest prediction cost as intra-frame coding mode candidates, and retaining the intra-frame coding mode prediction cost corresponding to each candidate. This step is a common step in existing video coding processes, where intra-frame coding mode prediction is performed on all image blocks in I-frames, P-frames, and B-frames.

[0035] In hardware video encoders, to reduce cost and power consumption, when using rate-distortion optimization methods to select modes for the image blocks to be encoded, the mode selection process is generally divided into a coding mode prediction stage and a coding mode rate-distortion optimization stage. The coding mode prediction stage is completed by the intra-frame or inter-frame coding mode prediction module, while the coding mode rate-distortion optimization stage is completed by the intra-frame or inter-frame coding mode rate-distortion optimization module.

[0036] Essentially, both the coding mode prediction stage and the coding mode rate-distortion optimization stage use rate-distortion optimization methods to select coding modes for the image blocks to be coded. The main difference between these two stages lies in the precision of the calculation method for the coding rate-distortion cost J. In the coding mode prediction stage, a less computationally intensive and less precise method for calculating the coding rate-distortion cost J is generally used; the coding distortion D is generally calculated using the SAD (Sum of Absolute Difference) algorithm or the SATD (Sum of Absolute Transformed Difference) algorithm; the coding bit rate R is generally calculated using a simplified bit rate estimation algorithm, such as the exponential Golomb algorithm; and the coding mode prediction stage generally does not introduce transformation and quantization operations. In the rate-distortion (RDD) optimization stage of the coding mode, a computationally intensive and highly accurate method for calculating the RDD cost J is generally used. The coding distortion D is typically calculated using the SSD (Sum of Squared Differences) algorithm; the coding bit rate R is typically calculated using either the CABAC (Context Adaptive Binary Arithmatic Coding) algorithm or the CAVLC (Context Adaptive Variable Length Coding) algorithm. Furthermore, the RDD optimization stage generally introduces transform and quantization operations. Conventionally, the low-computational-intensive, low-precision RDD cost J calculated in the coding mode prediction stage is referred to as the prediction cost of the coding mode.

[0037] When encoding an image block, the coding mode prediction stage performs an initial screening of numerous coding modes by calculating the prediction cost for each mode, selecting one or more candidate coding modes with lower prediction costs. The subsequent coding mode rate-distortion optimization stage then precisely calculates the prediction costs for these candidate coding modes to obtain their accurate coding rate-distortion costs J. Finally, the mode selection module selects the coding mode with the lowest coding rate-distortion cost J as the optimal coding mode for the image block to be encoded.

[0038] Step S2: Among the intra-coding mode prediction costs corresponding to all intra-coding mode candidates for the image block to be encoded, select the intra-coding mode prediction cost with the smallest value to characterize the intra-coding complexity of the image block to be encoded. Then, the sum of the intra-coding complexities of all image blocks within the video frame is taken as the intra-coding complexity of the video frame. Preferably, this step only calculates the intra-coding complexity of each I-frame and the video frame preceding each I-frame, and does not calculate the intra-coding complexity of other video frames.

[0039] Step S3: Based on the actual number of encoded bits, video frame-level quantization parameters, and intra-frame coding complexity of the previous encoded I-frame, and combined with the target number of encoded bits and intra-frame coding complexity of the I-frame to be encoded, calculate the video frame-level quantization parameters of the I-frame to be encoded. The intra-frame coding complexity of the I-frame to be encoded is obtained by substituting the intra-frame coding complexity of the previous encoded video frame.

[0040] The video frame-level quantization parameter QP of the I-frame to be encoded new From Formula 5: Find, here is an example. Where, f -1 It is the inverse function of the first function f. The first function f represents the relationship between the ratio of the different actual encoded bit counts obtained by the same video frame using different video frame-level quantization parameters during I-frame encoding, and the difference between the different video frame-level quantization parameters used in that video frame. I(n) new This represents the target number of coded bits for the I-frame to be encoded. I(m) old ω represents the actual number of encoded bits in the previous encoded I-frame. g is the second function, representing the relationship between the ratio of the actual number of encoded bits obtained by different video frames using the same frame-level quantization parameters during I-frame encoding, and the ratio of their respective intra-frame coding complexities. n-1 The value represents the intra-frame coding complexity of the preceding encoded video frame, used to replace the intra-frame coding complexity ω of the I-frame to be encoded. n ω m This represents the intra-frame coding complexity of the previous encoded I-frame. QP old This represents the video frame-level quantization parameters of the previous encoded I-frame. In this step, the video frame-level quantization parameters QP of the I-frame to be encoded are derived using information from the previously encoded I-frame. new The process, and the replacement operation that utilizes the temporal correlation of consecutive video frames to perform intra-frame coding complexity replacement on the I-frame to be coded, are innovations of this invention.

[0041] Please see Figure 1 Frame m and frame n are two consecutive I-frames, and there may be zero or more P-frames or B-frames between them. Let I(m) be the frame number. old This indicates that the m-th frame uses QP.old The actual number of encoded bits after encoding is denoted by I(m). new This indicates that the m-th frame uses QP. new The actual number of encoded bits after encoding is denoted by I(n). old This indicates that the nth frame uses QP. old The actual number of encoded bits after encoding is denoted by I(n). new This indicates that the nth frame uses QP. new The actual number of encoded bits after encoding, where QP old and QP new This represents two different video frame-level quantization parameters. ω is used to represent these parameters. m Let ω represent the intra-frame coding complexity of the m-th frame. n This represents the intra-frame coding complexity of the nth frame.

[0042] The first function f is given by formula one: The physical meaning of Formula 1 is that when the same video frame is I-frame encoded using different video frame-level quantization parameters, the ratio of the actual number of encoded bits obtained is related to the difference in the video frame-level quantization parameters. This relationship can be represented by the first function f. The specific expression of the first function f can be obtained by calculating the actual parameters of the encoded I-frame and fitting Formula 1, which will not be elaborated here.

[0043] The second function g is derived from formula two: The physical meaning of Formula 2 is that, when using the same video frame-level quantization parameters to perform I-frame encoding on different video frames, the ratio of the actual number of encoded bits obtained after encoding is related to the ratio of the intra-frame encoding complexity of the video frames. This relationship can be represented by the second function g. The specific expression of the second function g can be obtained by calculating the actual parameters of the encoded I-frame and fitting Formula 2, which will not be elaborated here.

[0044] This invention pre-conducts I-frame encoding experiments on a large number of different video streams, and obtains the expressions for the first function f and the second function g using function fitting, which are then stored in the video encoder. Therefore, the first function f and the second function g in Formula 1 and Formula 2 above belong to known functional relationships. Since they are obtained after I-frame encoding of a large number of video streams, the expressions for the first function f and the second function g have strong adaptability and good versatility.

[0045] Based on the derivation of Formula 1 and Formula 2, Formula 3 can be obtained: Further derivation yields Formula 4: Wherein, function f -1It is the inverse function of the first function f. Since the first function f is known, then the function f -1 This is also known. In Formula 4, the m-th frame is an encoded I-frame, whose encoding process has been completed, so its corresponding actual number of encoded bits is I(m). old The video frame-level quantization parameter QP used during encoding old Intra-frame coding complexity ω m All of these are known quantities. If the nth frame is an I-frame to be encoded, then I(n) new ω represents the desired target number of encoded bits, which is a known quantity; n This represents the intra-frame coding complexity of the nth frame, which is an unknown quantity since the nth frame has not yet been encoded; QP new This indicates that when the actual number of encoded bits in the nth frame is equal to the desired target number of encoded bits, I(n) new At this time, the required video frame-level quantization parameters are unknown quantities, and also quantities that need to be calculated. To calculate the video frame-level quantization parameters QP of the I-frame to be encoded using Formula 4... new This invention utilizes the temporal correlation of consecutive video frames (consecutive video frames are similar in content) and uses the intra-frame coding complexity ω of the (n-1)th frame that is already encoded and adjacent to the nth frame. n-1 To replace the intra-frame coding complexity ω of the nth frame to be encoded n Since the sampling times of frame n-1 and frame n are very close, the content of the two video frames is very similar. The error in the replacement operation of the intra-frame coding complexity is very small, and it will not affect the video frame-level quantization parameter QP of the uncoded I-frame. new This has a significant impact on the calculation. Thus, since the encoding of the (n-1)th frame has already been completed, its intra-frame coding complexity ω... n-1 It is a known quantity. In Formula 4, let ω n-1 Replace ω n This leads to Formula 5.

[0046] Optionally, step S4 is included after step S3, indicated by dashed arrows and dashed boxes. Step S4: Based on the conversion relationship between quantization parameters and Lagrange multipliers, the video frame-level Lagrange multipliers of the I-frame to be encoded are obtained from the video frame-level quantization parameters. These multipliers can then be used to encode the I-frame, yielding its actual number of encoded bits and intra-frame coding complexity.

[0047] Please see Figure 3 The video frame-level bitrate control device proposed in this invention includes an intra-frame coding mode prediction module 1, an intra-frame coding complexity calculation module 2, and an I-frame quantization parameter calculation module 3. Figure 3 The device shown corresponds to Figure 2 The method shown.

[0048] The intra-coding mode prediction module 1 is used to perform intra-coding mode prediction on the image block to be coded, and obtain one or more intra-coding mode candidates and the corresponding intra-coding mode prediction cost.

[0049] The intra-frame coding complexity calculation module 2 is used to select the minimum intra-frame coding mode prediction cost to characterize the intra-frame coding complexity of the image block to be encoded, and the sum of the intra-frame coding complexities of all image blocks in the video frame is used as the intra-frame coding complexity of the video frame.

[0050] The I-frame quantization parameter calculation module 3 is used to calculate the video frame-level quantization parameters of the I-frame to be encoded based on the actual number of encoded bits, video frame-level quantization parameters, and intra-frame coding complexity of the previous encoded I-frame, combined with the target number of encoded bits and intra-frame coding complexity of the I-frame to be encoded. The intra-frame coding complexity of the I-frame to be encoded is obtained by substituting the intra-frame coding complexity of the previous encoded video frame.

[0051] Optionally, a conversion module 4, indicated by dashed arrows and dashed boxes, is included after the I-frame quantization parameter calculation module 3. The conversion module 4 is used to obtain the video frame-level Lagrange multipliers of the I-frame to be encoded from the video frame-level quantization parameters of the I-frame to be encoded, based on the conversion relationship between the quantization parameters and the Lagrange multipliers.

[0052] This invention proposes a video frame-level bitrate control method suitable for hardware video encoders of I-frames. This method utilizes the intra-frame coding mode prediction cost generated during video frame encoding to characterize the intra-frame coding complexity of the video frame. It eliminates the need for an additional image preprocessing stage, resulting in low hardware overhead and low implementation cost. Simultaneously, it uses information from already encoded video frames to calculate the frame-level quantization parameters of the I-frame to be encoded, achieving high calculation accuracy and effectively improving the accuracy of I-frame bitrate control.

[0053] This invention shares similar technical objectives with Chinese invention patent application CN115550656A, published on December 30, 2022, entitled "A Method and Apparatus for I-Frame Rate Control Suitable for Hardware Implementation," both aiming at I-frame-level bitrate control for video frames. However, the technical solutions employed by the two are significantly different. In CN115550656A, the core of all formula derivations and calculations is based on video frame-level Lagrange multipliers. In this invention, the core of all formula derivations and calculations is based on video frame-level quantization parameters. Using video frame-level Lagrange multipliers as the core of calculations introduces numerous multiplication and division operations. Furthermore, due to the wide range of values, high precision requirements, and large bit width of Lagrange multipliers, hardware implementation results in large bit widths for multipliers and dividers, leading to higher storage space and bandwidth costs for storing and accessing Lagrange multipliers. This invention, by using video frame-level quantization parameters as the core of its computation, primarily performs addition and subtraction operations on the quantization parameters, avoiding numerous multiplication and division operations. Furthermore, due to the small value range and low bit width of the quantization parameters, the storage space and bandwidth costs associated with storing and accessing these parameters during hardware implementation are also lower. Therefore, compared to CN115550656A, this invention has lower computational, storage, and bandwidth costs, making it more suitable for hardware implementation.

[0054] The above are merely preferred embodiments of the present invention and are not intended to limit the invention. Various modifications and variations can be made to the present invention by those skilled in the art. Any modifications, equivalent substitutions, improvements, etc., made within the spirit and principles of the present invention should be included within the scope of protection of the present invention.

Claims

1. A method for rate control at the frame level of I frames of a video, characterized in that, Includes the following steps; Step S1: Perform intra-frame coding mode prediction on the image block to be coded, that is, calculate the prediction cost corresponding to each intra-frame coding mode for the image block to be coded, and retain only one or more intra-frame coding modes with the lowest prediction cost as intra-frame coding mode candidates, while retaining the intra-frame coding mode prediction cost corresponding to each intra-frame coding mode candidate. Step S2: Among the intra-coding mode prediction costs corresponding to all intra-coding mode candidates of the image block to be encoded, select the intra-coding mode prediction cost with the smallest value to characterize the intra-coding complexity of the image block to be encoded, and then take the sum of the intra-coding complexities of all image blocks in the video frame as the intra-coding complexity of the video frame. Step S3: Based on the actual number of encoded bits, video frame-level quantization parameters, and intra-frame coding complexity of the previous encoded I-frame, and combined with the target number of encoded bits and intra-frame coding complexity of the I-frame to be encoded, calculate the video frame-level quantization parameters of the I-frame to be encoded; wherein, the intra-frame coding complexity of the I-frame to be encoded is obtained by replacing the intra-frame coding complexity of the previous encoded video frame of the I-frame to be encoded. The video frame-level quantization parameters of the I-frame to be encoded From Formula 5: Find; where, It is the inverse function of the first function f; Indicates that the I-frame to be encoded uses The target number of encoded bits after encoding; Indicates that the previous encoded I-frame used The actual number of encoded bits after encoding; g is the second function; This represents the intra-frame coding complexity of the preceding encoded video frame, used to replace the intra-frame coding complexity of the I-frame to be encoded. ; This represents the intra-frame coding complexity of the previous encoded I-frame; This represents the video frame-level quantization parameters of the previous encoded I-frame; The first function f is given by formula one: The first function f represents the relationship between the ratio of the different actual encoded bits obtained by the same video frame using different video frame-level quantization parameters during I-frame encoding and the difference between the different video frame-level quantization parameters used in the video frame. Indicates that the previous encoded I-frame used The actual number of encoded bits after encoding; The second function g is derived from formula two: The second function g represents the relationship between the ratio of the actual number of encoded bits obtained by different video frames when using the same video frame-level quantization parameters during I-frame encoding and the ratio of their respective intra-frame coding complexity.

2. The video frame-level bitrate control method according to claim 1, characterized in that, In step S2, the intra-frame coding complexity is calculated only for each I-frame and the video frame preceding each I-frame.

3. The video frame-level bitrate control method according to claim 1, characterized in that, Beforehand, I-frame encoding experiments were performed on the video stream. The expressions for the first function f and the second function g were obtained by function fitting and stored in the video encoder.

4. The video frame-level bitrate control method according to claim 1, characterized in that, Based on the derivation of Formula 1 and Formula 2, Formula 3 is obtained: Further derivation yields Formula 4: ; The intra-frame coding complexity of frame n is represented by the intra-frame coding complexity of the (n-1)th frame that is adjacent to frame n. By making substitutions, we obtain Formula 5.

5. The video frame-level bitrate control method for I-frames according to claim 1, characterized in that, Step S3 is followed by step S4; Step S4: Based on the conversion relationship between quantization parameters and Lagrange multipliers, the video frame-level Lagrange multipliers of the I-frame to be encoded are obtained from the video frame-level quantization parameters of the I-frame to be encoded.

6. A bitrate control device at the I-frame level for video, characterized in that, It includes an intra-frame coding mode prediction module, an intra-frame coding complexity calculation module, and an I-frame quantization parameter calculation module; The intra-coding mode prediction module is used to perform intra-coding mode prediction on the image block to be coded, and obtain one or more intra-coding mode candidates and the corresponding intra-coding mode prediction cost. The intra-frame coding complexity calculation module is used to select the minimum intra-frame coding mode prediction cost to characterize the intra-frame coding complexity of the image block to be encoded, and the sum of the intra-frame coding complexities of all image blocks in the video frame is taken as the intra-frame coding complexity of the video frame. The I-frame quantization parameter calculation module is used to calculate the video frame-level quantization parameters of the I-frame to be encoded based on the actual number of encoded bits, video frame-level quantization parameters, and intra-frame coding complexity of the previous encoded I-frame, combined with the target number of encoded bits and intra-frame coding complexity of the I-frame to be encoded; wherein, the intra-frame coding complexity of the I-frame to be encoded is obtained by substituting the intra-frame coding complexity of the previous encoded video frame of the I-frame to be encoded. The video frame-level quantization parameters of the I-frame to be encoded From Formula 5: Find; where, It is the inverse function of the first function f; Indicates that the I-frame to be encoded uses The target number of encoded bits after encoding; Indicates that the previous encoded I-frame used The actual number of encoded bits after encoding; g is the second function; This represents the intra-frame coding complexity of the preceding encoded video frame, used to replace the intra-frame coding complexity of the I-frame to be encoded. ; This represents the intra-frame coding complexity of the previous encoded I-frame; This represents the video frame-level quantization parameters of the previous encoded I-frame; The first function f is given by formula one: The first function f represents the relationship between the ratio of the different actual encoded bits obtained by the same video frame using different video frame-level quantization parameters during I-frame encoding and the difference between the different video frame-level quantization parameters used in the video frame. Indicates that the previous encoded I-frame used The actual number of encoded bits after encoding; The second function g is derived from formula two: The second function g represents the relationship between the ratio of the actual number of encoded bits obtained by different video frames when using the same video frame-level quantization parameters during I-frame encoding and the ratio of their respective intra-frame coding complexity.

7. The video frame-level bitrate control method for I-frames according to claim 6, characterized in that, The I-frame quantization parameter calculation module is followed by a conversion module; the conversion module is used to obtain the video frame-level Lagrange multipliers of the I-frame to be encoded from the video frame-level quantization parameters of the I-frame to be encoded based on the conversion relationship between the quantization parameters and the Lagrange multipliers.