A low-delay video encoding bit rate control method and device
By adopting a differentiated encoding code rate control method in a low-latency, low-cost hardware video encoder, the video frame is divided into I frames, BP frames and LP frames, and the target encoding bit count is calculated based on the specific bit count ratio, the problem of low video encoding efficiency in the prior art is solved and higher encoding efficiency is achieved.
Patent Information
- Application Number
- CN202210798696.1
- Authority / Receiving Office
- CN · China
- Patent Type
- Patents(China)
- Current Assignee / Owner
- Filing Date
- 2022-07-08
- Publication Date
- 2025-04-22
- Estimated Expiration
- 2042-07-08
AI Technical Summary
In low-latency, low-cost hardware video encoder scenarios, existing code rate control methods cannot effectively improve video encoding efficiency, especially in video surveillance and video conferencing scenarios.
A code rate control method is proposed, which realizes differentiated encoding by dividing the encoded video frames into I frames, BP frames and LP frames, and calculates the target encoding number of BP frames and LP frames in each P frame group based on the ‘BP frame period’ and ‘BP/LP frame size ratio’.
This method can effectively improve the encoding quality and judgment probability of SKIP blocks in video surveillance and video conferencing scenarios, thereby improving the encoding efficiency of the entire video. It is suitable for low-latency and low-cost hardware video encoders.
Smart Images

Figure CN115103187B_ABST
Abstract
Description
Technical Field
[0001] The present invention relates to a video coding technology, and in particular to a video coding bit rate control method. Background Art
[0002] Video coding is a technology that represents video information by compressing redundant components in video images and using as little data as possible. HEVC (High Efficiency Video Coding, also known as H.265) is a new generation of video coding standard. Compared with the previous generation of video coding standard AVC (Advanced Video Coding, also known as H.264), HEVC can reduce the encoding bit rate by about 50% while achieving the same video coding quality, and the video compression performance is about twice that of AVC.
[0003] In video encoding, intra-frame coding and inter-frame coding are used to remove information redundancy in the spatial and temporal domains of the input video. The encoded video frames can generally be divided into I frames, P frames, and B frames. I frames are encoded only using intra-frame coding technology, and other encoded video frames are not referenced during encoding. P frames and B frames use a mixture of inter-frame coding and intra-frame coding technology, and one or more other encoded video frames are referenced during encoding.
[0004] Since the computational complexity of video encoding algorithms is very large, in order to increase the speed of video encoding, the industry usually uses application-specific integrated circuits (ASICs) to perform hardware acceleration on the video encoding process. Such application-specific integrated circuits that perform hardware acceleration on the video encoding process are generally referred to as hardware video encoders.
[0005] In order to improve the video compression rate as much as possible, common video encoding algorithms often use lossy compression algorithms, which causes the difference between the encoded and reconstructed video and the original video, that is, the encoded and reconstructed video will be distorted. HEVC is a lossy compression algorithm. For lossy compression algorithms, their encoding performance needs to be measured by the encoding bit rate (Rate) and the distortion (Distortion) introduced by the encoding. In the process of video encoding, the encoding bit rate and encoding distortion are mutually restricted and contradictory. For example, reducing the encoding bit rate often increases the encoding distortion, while reducing the encoding distortion often leads to an increase in the encoding bit rate. The purpose of rate distortion optimization (RDO) is to reduce the encoding distortion as much as possible under a certain encoding bit rate, or to reduce the encoding bit rate as much as possible under a certain encoding distortion. In the current common video encoding algorithms, the rate distortion optimization method based on the Lagrange multiplier λ is adopted. This method can be expressed as min(J), where min() means taking the minimum value, J is the rate distortion cost (RDCost), and J=D+λ×R. When encoding a video, each encoding mode has its corresponding encoding distortion D and encoding bit rate R, so the encoding rate distortion cost J corresponding to each encoding mode can be calculated. When encoding, the encoding mode with the smallest rate distortion cost J is selected to obtain the best encoding performance.
[0006] In real life, the channel bandwidth capacity used to transmit compressed video is limited. If the encoding bit rate of the compressed video is too high and exceeds the capacity of the channel bandwidth, it will cause video transmission congestion or even packet loss; if the encoding bit rate of the compressed video is too low, the channel bandwidth will not be fully utilized and higher video quality cannot be obtained. Therefore, it is necessary to use rate control technology to control the output bit rate of the video encoder to match it with the channel bandwidth capacity.
[0007] The purpose of rate control technology is to adjust the encoding parameters of the video encoder so that the output bit rate of the video encoder is equal to the preset target bit rate, while minimizing the encoding distortion to improve the video encoding quality. Currently, the rate control algorithm used in the HEVC reference encoder HM (High Efficiency Video Coding Test Model) is based on the JCTVC-K0103 proposal. The JCTVC-K0103 proposal established a mathematical relationship model between the encoding bit rate R and the Lagrange multiplier λ (i.e., the R-λ model), and achieved the rate control task through two links: target bit allocation and target bit control. In the JCTVC-K0103 proposal, target bit allocation is carried out at three levels, namely, the GOP (Group Of Pictures, i.e., a set of time-continuous video frames) level, the video frame level, and the basic coding unit level. After the target bit allocation at the video frame level, the target number of coding bits for the current video frame to be encoded is determined. The next step is to calculate the value of the Lagrange multiplier λ of the current video frame to be encoded based on the R-λ model proposed in the JCTVC-K0103 proposal. λ can be used for rate-distortion optimization during the encoding process. Then calculate the quantization step size QP of the current video frame to be encoded for quantization operations during the encoding process.
[0008] In some video encoding scenarios (such as video surveillance and video conferencing), in order to improve the subjective experience of the human eye and enhance the real-time nature of interaction, the hardware video encoder is required to have the feature of low latency. Although the encoding efficiency of B frames is high, it will introduce a large encoding delay. Therefore, in this type of video encoding scenario, the encoding frame type is generally not set to B frames. For the sake of low latency and low cost, the video encoder used in this type of video encoding scenario usually does not support the encoding of B frames, but only supports the encoding of I frames and P frames; and when encoding P frames, they can only refer to one encoded video frame, and cannot refer to multiple encoded video frames at the same time. In addition, in order to minimize latency and cost, the video encoder used in this type of video encoding scenario generally does not increase the image preprocessing level to preprocess the content of the current video frame (such as performing histogram statistics or frame difference operations on the original resolution or downsampled resolution video frame), and cannot obtain prior information that can guide the video frame encoding process. These characteristics of low-latency and low-cost hardware video encoders are actually not conducive to improving the encoding efficiency of this type of video encoding scenario.
[0009] In video surveillance and video conferencing encoding scenarios, the encoded compressed video stream is generally transmitted through various channels. In this case, it is necessary to use rate control technology to control the output bit rate of the video encoder to match it with the channel bandwidth capacity. Figure 1 In low-latency, low-cost hardware video encoders, the rate control method generally sets the target number of coding bits of the P frames to be encoded to the same size, so that the number of coding frame bits of the P frames after actual encoding remains as the same as possible. The inventors have experimentally demonstrated that for video surveillance and video conferencing encoding scenarios, the rate control method of setting the target number of coding bits of the P frames to be encoded to the same size cannot achieve the optimal coding efficiency. Therefore, it is necessary to design a rate control method that effectively improves the video coding efficiency based on the characteristics of low-latency, low-cost hardware video encoders.
[0010] At present, there are some technologies used to improve the video coding efficiency of video surveillance and video conferencing coding scenarios, among which the most typical is the long-term reference frame technology. In the long-term reference frame technology, when the current video frame is inter-frame coded, in addition to referring to the video frame with a closer distance (i.e., the short-term reference frame, which is generally selected as the previous frame of the current video frame to be coded), it can also refer to the video frame with a farther distance (i.e., the long-term reference frame, which is generally selected as a high-quality background frame or scene change frame far away from the current video frame). Although the long-term reference frame technology can effectively improve the video coding efficiency of video surveillance and video conferencing coding scenarios, the hardware implementation cost is high because two reference frames need to be referenced during inter-frame coding. In addition, the selection of the long-term reference frame also needs to be set according to the prior information obtained after the image pre-processing stage pre-processes the video frame (for example, performing histogram statistics or frame difference operations on the original resolution or downsampled resolution video frame). However, adding an image pre-processing stage will not only increase the coding delay, but also increase the cost of hardware implementation. It can be seen that the long-term reference frame technology is not suitable for low-delay, low-cost hardware video encoders. Summary of the invention
[0011] The technical problem to be solved by the present invention is to propose a bit rate control method suitable for a low-cost, low-delay hardware video encoder.
[0012] To solve the above technical problems, the present invention discloses a low-delay video coding rate control method, comprising the following steps. Step S1: Determine the type and arrangement rule of the coded video frames, that is, the coded video frames are divided into multiple large groups; in each large group, an I frame is followed by multiple P frames, these P frames are divided into multiple P frame groups, and the P frames are further divided into BP frames and LP frames; in each P frame group, a BP frame is followed by multiple LP frames; the target coding bit number of the I frame> the target coding bit number of the BP frame> the target coding bit number of the LP frame; the I frame does not refer to other coded video frames when encoding; the P frame only refers to the previous video frame closest to the current video frame when performing inter-frame coding. Step S2: Determine whether the current coded P frame belongs to a BP frame or a LP frame according to the "BP frame period"; the number of P frames contained in each P frame group = BP frame period, where one BP frame is followed by "BP frame period - 1" LP frames; the "BP frame period" is an integer greater than 1. Step S3: According to the "BP frame period" and the "BP / LP frame size ratio", combined with the encoding target bit rate and the current encoding state, the target number of encoding bits of the BP frames and LP frames in each P frame group is calculated; the "BP / LP frame size ratio">1. The above method differentially encodes P frames that originally have the same target number of encoding bits through the "BP / LP frame size ratio" and the "BP frame period", and divides them into BP frames with larger target encoding bits and LP frames with smaller target encoding bits. This idea is one of the core innovations of the present invention. The encoded video frames of the present invention do not include B frames, but only I frames and P frames; and the P frames only refer to the previous video frame closest to the current video frame when performing inter-frame encoding, so they have the characteristics of small encoding delay and low implementation cost, and are suitable for low-delay, low-cost hardware video encoders.
[0013] Furthermore, after step S3, step S4 is further included. Step S4: Calculate the value of the Lagrange multiplier λ of the current video frame to be encoded according to the target encoding bit number of the BP frame and the LP frame, λ = α·bpp β ; where α and β are the parameters of the R-λ model, bpp represents the average target number of coding bits allocated to each pixel, which is the quotient of the target number of coding bits of the video frame to be encoded and the number of pixels in the video frame. λ can be used for rate-distortion optimization in the encoding process.
[0014] Furthermore, after step S4, step S5 is also included. Step S5: Calculate the quantization step size QP of the current video frame to be encoded according to the Lagrange multiplier λ of the current video frame to be encoded, QP = 4.2005 × ln (λ) + 13.7122; wherein ln is a natural logarithm operator. QP can be used for quantization operation in the encoding process.
[0015] Further, the value of "BP frame period" is set to be ≥2 and ≤10. Preferably, the value of "BP frame period" is set to 6.
[0016] Further, the value of the "BP / LP frame size ratio" is set to be greater than 1 and less than or equal to 3. Preferably, the "BP / LP frame size ratio" is set to be 1.85.
[0017] Furthermore, the step S2 specifically includes the following steps. Step S21: Read the current coding frame type. Step S22: If the current coding frame type is a P frame, the frame number counter is incremented by one, and the process goes to step S23; otherwise, the frame number counter is cleared, and the current coding frame is not marked as a BP frame or a LP frame. Step S23: Perform a modulo operation on the count value of the frame number counter with respect to the "BP frame period"; if the remainder is 1, the current coding P frame is marked as a BP frame, otherwise, the current coding P frame is marked as a LP frame. This is an exemplary implementation of step S2.
[0018] Furthermore, the step S3 specifically includes the following steps: Step S31: before encoding each P frame group, calculate the target frame average encoding bit number of the P frame group to be encoded according to the encoding target bit rate and the current encoding state.
[0019]
[0020] Among them, "coding target bit rate" refers to the coding target bit rate of the entire video; "coding target frame rate" refers to the coding target frame rate of the entire video; "coded frames" refers to the number of video frames that have been coded so far; "coded bits" refers to the total number of bits of video frames that have been coded so far; "sliding window size" is in units of frames. Step S32: Before encoding each P frame group, calculate the target coding bit numbers of the BP frames and LP frames in the P frame group to be encoded, so as to perform target bit allocation.
[0021]
[0022]
[0023] This is an exemplary implementation of step S3.
[0024] The present invention also discloses a code rate control device for low-delay video coding, comprising an arrangement unit, a decision unit and a calculation unit. The arrangement unit is used to determine the type and arrangement rule of the coded video frame, namely: the coded video frame is divided into multiple large groups; in each large group, a plurality of P frames are followed by an I frame, and these P frames are divided into multiple P frame groups, and the P frames are further divided into BP frames and LP frames; in each P frame group, a plurality of LP frames are followed by a BP frame; the target coding bit number of the I frame> the target coding bit number of the BP frame> the target coding bit number of the LP frame; the I frame does not refer to other coded video frames when coding; the P frame only refers to the previous video frame closest to the current video frame when performing inter-frame coding. The decision unit is used to determine whether the current coded P frame belongs to a BP frame or a LP frame according to the "BP frame period"; the number of P frames contained in each P frame group = BP frame period, wherein one BP frame is followed by "BP frame period - 1" LP frames; the "BP frame period" is an integer greater than 1. The calculation unit is used to calculate the target coding bit number of BP frames and LP frames in each P frame group according to the "BP frame period" and "BP / LP frame size ratio", combined with the coding target bit rate and the current coding state; the "BP / LP frame size ratio">1.
[0025] The technical effect achieved by the present invention is: there is no need to introduce an image preprocessing stage to preprocess the video frames, low-cost video encoding with low encoding delay can be achieved, low-latency, low-cost hardware video encoders can be adapted, and the encoding quality and decision probability of the SKIP block in video surveillance and video conferencing scenarios can be effectively improved, thereby improving the encoding efficiency of the entire video. BRIEF DESCRIPTION OF THE DRAWINGS
[0026] Figure 1 It is a schematic diagram of the rules for encoding video frames suitable for existing low-latency, low-cost hardware video encoders.
[0027] Figure 2 It is a flow chart of the bit rate control method for low-delay video encoding proposed by the present invention.
[0028] Figure 3 It is a schematic diagram of the arrangement rule of a large group of encoded video frames in the low-delay video encoding bit rate control method proposed by the present invention.
[0029] Figure 4 is a flowchart of an exemplary implementation of step S2.
[0030] Figure 5 is a flowchart of an exemplary implementation of step S3.
[0031] Figure 6It is a structural schematic diagram of a bit rate control device for low-delay video coding proposed by the present invention.
[0032] Explanation of the reference numerals in the figure: 1 is an arrangement unit, 2 is a decision unit, and 3 is a calculation unit. DETAILED DESCRIPTION
[0033] See also Figure 2 The low-delay video coding bit rate control method proposed by the present invention includes the following steps.
[0034] Step S1: Determine the type and arrangement rule of the encoded video frames, specifically: the encoded video frames are divided into multiple large groups. In each large group, an I frame is followed by multiple P frames, and these P frames are divided into multiple P frame groups, and the P frames are further divided into BP frames and LP frames. In each P frame group, a BP frame is followed by multiple LP frames. The target coding bit number of the I frame>the target coding bit number of the BP frame>the target coding bit number of the LP frame. The I frame does not refer to other encoded video frames when encoding. When the P frame is inter-frame encoded, it only refers to the previous video frame (only one) closest to the current video frame. The P frame is further divided into BP frames (large P frames) and LP frames (small P frames) according to the size of the target coding bit number. Therefore, the present invention limits the types of encoded video frames to only include I frames and P frames, and does not include B frames.
[0035] See also Figure 3 , which is a schematic diagram of the arrangement rule of a large group of coded video frames in the code rate control method of low-delay video coding proposed by the present invention. The number of video frames in different large groups can be the same or different. When the "BP frame period" does not change during the video coding process, each P frame group is the same. Step S2: Determine whether the currently coded P frame belongs to a BP frame or an LP frame according to the "BP frame period". The number of P frames contained in each P frame group = BP frame period, where 1 BP frame is followed by "BP frame period - 1" LP frames. "BP frame period" refers to the occurrence interval of BP frames, which is used to control the ratio of the number of BP frames to LP frames in each P frame group. The "BP frame period" is either a preset value or set and adjusted by the user. The "BP frame period" is an integer greater than 1. The larger the "BP frame period", the more stable the instantaneous code rate fluctuation; but if the "BP frame period" is too large, it will cause a decrease in coding efficiency. Therefore, it is more appropriate to set the value of "BP frame period" to ≥2 and ≤10. Preferably, the "BP frame period" is set to 6.
[0036] Step S3: Calculate the target coding bit numbers of the BP frames and LP frames in each P frame group according to the "BP frame period" and the "BP / LP frame size ratio", combined with the coding target bit rate and the current coding state.
[0037] "BP / LP frame size ratio" refers to the ratio of the target number of coding bits of the BP frame to the target number of coding bits of the LP frame. The "BP / LP frame size ratio" is either a preset value or is set and adjusted by the user. The "BP / LP frame size ratio" is greater than 1. The larger the "BP / LP frame size ratio", the greater the difference in coding size and coding quality between the BP frame and the LP frame, the more drastic the fluctuation of the instantaneous bit rate, and the easier it is to cause visual flicker. Therefore, it is more appropriate to set the "BP / LP frame size ratio" to a value greater than 1 and less than or equal to 3. Preferably, the "BP / LP frame size ratio" is set to 1.85.
[0038] Optionally, step S4 is further included after step S3. Step S4: According to the target number of coding bits of the BP frame and the LP frame, the value of the Lagrange multiplier λ of the current video frame to be encoded is calculated according to the R-λ model proposed in the JCTVC-K0103 proposal. λ can be used for rate distortion optimization operation in the encoding process. λ = α·bpp β . Among them, λ is the Lagrange multiplier of the current video frame to be encoded; α 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 proceeds; bpp is bit per pixel, which means the average target number of coding bits allocated to each pixel, and its value is the quotient of the target number of coding bits of the video frame to be encoded and the number of pixels in the video frame.
[0039] Optionally, step S5 is further included after step S4. Step S5: Calculate the quantization step size QP of the current video frame to be encoded according to the Lagrange multiplier λ of the current video frame to be encoded, which is used for quantization operation in the encoding process. QP = 4.2005 × ln (λ) + 13.7122. Wherein, "ln" is a natural logarithm operator.
[0040] See also Figure 4 In step S2, the type of the currently encoded P frame is determined according to the "BP frame period" to determine whether it belongs to a BP frame or a LP frame, for example, in the following manner.
[0041] Step S21: Read the current encoding frame type.
[0042] Step S22: If the current coded frame type is a P frame, the frame number counter is incremented by one, and the process proceeds to step S23. If the current coded frame type is not a P frame, it must be an I frame, the frame number counter is reset, and the current coded frame is not marked as a BP frame or a LP frame.
[0043] Step S23: The count value of the frame number counter is modulo the "BP frame period", that is, the count value % BP frame period, % is the modulo operator. If the remainder is 1, the current coded P frame is marked as a BP frame, otherwise the current coded P frame is marked as a LP frame.
[0044] See also Figure 5 In step S3, the target number of coding bits of the BP frame and the LP frame is calculated, for example, in the following manner.
[0045] Step S31: Before encoding each P frame group, the target frame average encoding bit number of the P frame group to be encoded is calculated based on the encoding target bit rate and the current encoding state. In the actual encoding process, there is an error between the target encoding bit number of the video frame calculated by the bit rate control algorithm and the actual number of bits of the encoded video frame, and it is difficult to make them completely the same. Therefore, after encoding a P frame group, the target frame average encoding bit number of the next P frame group is calculated based on the actual number of bits encoded.
[0046]
[0047] Among them, "coding target bit rate" refers to the encoding target bit rate of the entire video, and the unit is bps (bit per second); "coding target frame rate" refers to the encoding target frame rate of the entire video, and the unit is fps (frame per second); "encoded frames" refers to the number of video frames that have been encoded so far; "encoded bits" refers to the total number of bits of video frames that have been encoded so far. "Sliding window" is used to smooth the bit rate change, that is, it is hoped that the accumulated bit error generated by the encoded video frame can be compensated within the sliding window range. "Sliding window size" is in units of frames, and is generally greater than 40. The "current encoding state" refers to data such as "encoded frames" and "encoded bits" that change continuously as the encoding process proceeds.
[0048] Step S32: Before encoding each P frame group, the target number of coding bits of the BP frame and the LP frame in the P frame group to be encoded is calculated, so as to allocate the target bits. In different P frame groups, even if the "BP frame period" and the "BP / LP frame size ratio" are the same, the average target number of coding bits of the frames may be different, so the target number of coding bits of the BP frame and the LP frame may also be different. Within each P frame group, the ratio of the target number of coding bits of the BP frame and the LP frame satisfies the "BP / LP frame size ratio".
[0049]
[0050]
[0051] See also Figure 6 The low-delay video coding bit rate control device proposed in the present invention includes an arrangement unit 1, a decision unit 2 and a calculation unit 3. Figure 6 The device shown is Figure 2 The method shown corresponds to .
[0052] The arrangement unit 1 is used to determine the type and arrangement rule of the encoded video frames, specifically: the encoded video frames are divided into multiple large groups. In each large group, an I frame is followed by multiple P frames, and these P frames are divided into multiple P frame groups, and the P frames are further divided into BP frames and LP frames. In each P frame group, a BP frame is followed by multiple LP frames. The target coding bit number of the I frame is greater than the target coding bit number of the BP frame, and the target coding bit number of the LP frame. The I frame does not refer to other encoded video frames when encoding. The P frame only refers to the previous video frame closest to the current video frame when performing inter-frame encoding.
[0053] The decision unit 2 is used to determine whether the currently encoded P frame belongs to a BP frame or a LP frame according to the "BP frame period". The number of P frames contained in each P frame group = BP frame period, where one BP frame is followed by "BP frame period - 1" LP frames. The "BP frame period" is an integer greater than 1.
[0054] The calculation unit 3 is used to calculate the target coding bit number of the BP frame and the LP frame in each P frame group according to the "BP frame period" and the "BP / LP frame size ratio", combined with the coding target bit rate and the current coding state. The "BP / LP frame size ratio">1.
[0055] The inventors have found through research that the rate control method proposed in the present invention can effectively improve the coding quality and judgment probability of SKIP blocks in video surveillance and video conferencing coding scenarios. SKIP blocks are a type of residual-free coding block that uses inter-frame coding technology, and are characterized by having very few bits after coding. The judgment probability of a SKIP block refers to the probability that an image block is encoded as a SKIP block. The probability of SKIP blocks appearing in video surveillance and video conferencing coding scenarios is very high, especially in the static background area of the scene, where the possibility of an image block being encoded as a SKIP block is very high. Under the action of the rate control algorithm, when the average bit rate of video coding is fixed, if the coding quality and judgment probability of SKIP blocks in video coding can be improved, the coding efficiency of the entire video (including the coding efficiency of non-SKIP blocks) can also be effectively improved.
[0056] In order to verify the beneficial effects of the present invention, the present invention selects three YUV video streams Johnny, FourPeople and KristenAndSara in the HEVC standard test sequence ClassE for testing. These three video streams belong to typical video surveillance and video conferencing scenarios. Figure 1 The rate control method shown in the figure sets the target coding bit numbers of all P frames to the same size as a benchmark, and is compared with the rate control method proposed in the present invention.
[0057] During the experiment, four different target bit rates were set for each YUV video stream for encoding, and the average BD-rate of all target bit rates was measured. Delta bit rate is used to measure the encoding efficiency of the encoder. The smaller the BD-rate is, the fewer bits are used for encoding to achieve the same video quality, and the higher the encoding efficiency is. In the experiment, the number of encoded frames is set to 120 frames, the encoding GOP structure is IPPP structure, the first frame is encoded as I frame, and the remaining frames are encoded as P frames, and the P frame only refers to the previous frame. In the experiment, for the bit rate control method proposed in the present invention, the "BP / LP frame size ratio" is set to 1.85, and the "BP frame period" is set to 6. The experimental results are shown in the following table.
[0058]
[0059] It can be seen that the bit rate control method proposed by the present invention is better than Figure 1 As shown in the bit rate control method, the target encoding bit number of all P frames is set to the same size. The average BD-rate of the ClassE standard test sequence is reduced by 5.75%, and the encoding efficiency is significantly improved.
[0060] The above are only preferred embodiments of the present invention and are not intended to limit the present invention. For those skilled in the art, the present invention may have various modifications and variations. Any modification, equivalent replacement, improvement, etc. made within the spirit and principle of the present invention shall be included in the protection scope of the present invention.
Claims
1. A low-delay video coding bit rate control method, characterized in that: The method comprises the following steps: Step S1: determining the type and arrangement rule of the encoded video frames, that is, the encoded video frames are divided into a plurality of large groups; in each large group, an I frame is followed by a plurality of P frames, and these P frames are divided into a plurality of P frame groups, and the P frames are further divided into BP frames and LP frames; In each P frame group, there is a BP frame followed by multiple LP frames; The target number of coding bits for I frame>the target number of coding bits for BP frame>the target number of coding bits for LP frame; The I frame does not refer to other encoded video frames when encoding; the P frame only refers to the previous video frame closest to the current video frame when performing inter-frame encoding; Step S2: judging whether the current coded P frame belongs to a BP frame or a LP frame according to the "BP frame period"; The number of P frames contained in each P frame group = BP frame period, wherein one BP frame is followed by "BP frame period - 1" LP frames; the "BP frame period" is an integer greater than 1; Step S3: Calculate the target number of coding bits of the BP frame and LP frame in each P frame group according to the "BP frame period" and "BP / LP frame size ratio", combined with the coding target bit rate and the current coding state; the "BP / LP frame size ratio">1.
2. The bit rate control method for low-delay video coding according to claim 1, characterized in that Step S3 also includes step S4; Step S4: Calculate the value of the Lagrange multiplier λ of the current video frame to be encoded according to the target encoding bit number of the BP frame and the LP frame, λ = α·bpp β ; Among them, α and β are R-λ model parameters, bpp represents the average target number of coding bits allocated to each pixel, and its value is the quotient of the target number of coding bits of the video frame to be encoded and the number of pixels in the video frame.
3. The bit rate control method for low-delay video coding according to claim 2, characterized in that: After step S4, the method further includes step S5; Step S5: Calculate the quantization step size QP of the current video frame to be encoded according to the Lagrange multiplier λ of the current video frame to be encoded, QP=4.2005×ln(λ)+13.7122; wherein ln is a natural logarithm operator.
4. The low-delay video coding bit rate control method according to claim 1, characterized in that: The value of "BP frame period" is set to ≥2 and ≤10.
5. The bit rate control method for low-delay video coding according to claim 4, characterized in that: "BP Frame Period" is set to 6.
6. The low-delay video coding bit rate control method according to claim 1, characterized in that: The value of "BP / LP frame size ratio" is set to >1 and ≤3.
7. The bit rate control method for low-delay video coding according to claim 6, characterized in that: The "BP / LP frame size ratio" is set to 1.
85.
8. The low-delay video coding bit rate control method according to claim 1, characterized in that: The step S2 specifically includes the following steps: Step S21: Read the current encoding frame type; Step S22: If the current coded frame type is a P frame, the frame number counter is incremented by one, and the process proceeds to step S23; otherwise, the frame number counter is reset, and the current coded frame is not marked as a BP frame or a LP frame; Step S23: perform a modulo operation on the count value of the frame number counter with respect to the “BP frame period”; if the remainder is 1, the current coded P frame is marked as a BP frame, otherwise the current coded P frame is marked as a LP frame.
9. The low-delay video coding bit rate control method according to claim 1, characterized in that: The step S3 specifically includes the following steps: Step S31: before encoding each P frame group, the target average number of encoding bits of the P frame group to be encoded is calculated according to the encoding target bit rate and the current encoding state; Among them, "Encoding target bit rate" refers to the encoding target bit rate of the entire video; "Encoding target frame rate" refers to the encoding target frame rate of the entire video; "Encoded frames" refers to the number of video frames that have been encoded so far; "Encoded bits" refers to the total number of bits of video frames that have been encoded so far; "Sliding window size" is in frames; Step S32: before encoding each P frame group, calculating the target number of coding bits of the BP frame and the LP frame in the P frame group to be encoded, so as to perform target bit allocation; 10. A low-delay video coding bit rate control device, characterized in that: It includes an arrangement unit, a decision unit and a calculation unit; The arrangement unit is used to determine the type and arrangement rule of the encoded video frames, that is, the encoded video frames are divided into a plurality of large groups; in each large group, an I frame is followed by a plurality of P frames, these P frames are divided into a plurality of P frame groups, and the P frames are further divided into BP frames and LP frames; In each P frame group, there is a BP frame followed by multiple LP frames; The target number of coding bits for I frame>the target number of coding bits for BP frame>the target number of coding bits for LP frame; The I frame does not refer to other encoded video frames when encoding; the P frame only refers to the previous video frame closest to the current video frame when performing inter-frame encoding; The decision unit is used to determine whether the current coded P frame belongs to a BP frame or a LP frame according to the "BP frame period"; The number of P frames contained in each P frame group = BP frame period, where one BP frame is followed by "BP frame period - 1" LP frames; The "BP frame period" is an integer greater than 1; The calculation unit is used to calculate the target coding bit number of BP frames and LP frames in each P frame group according to the "BP frame period" and "BP / LP frame size ratio", combined with the coding target bit rate and the current coding state; the "BP / LP frame size ratio">1.
Citation Information
Patent Citations
Codec method for realizing AVS video standard time domain classification
CN101621688A
Multi-channel serial flow cloud game control method, device and equipment and storage medium
CN112866746A