A variable bit rate control method for real-time video encoding

CN116233446BActive Publication Date: 2026-10-20INGENIC SEMICON CO LTD
View PDF 1 Cites 0 Cited by

Patent Information

Application Number
CN202111478221.6
Authority / Receiving Office
CN · China
Patent Type
Patents(China)
Current Assignee / Owner
Filing Date
2021-12-06
Publication Date
2026-10-20
Estimated Expiration
2041-12-06

AI Technical Summary

Technical Problem

[0003]但是,现有VBR控制技术中仍采用精确的目标码率进行控制,当瞬时码率在目标码率上下波动时易引起QP的振荡,不利于维持图像质量的稳定

Benefits of technology

[0102]由此,本申请的优势在于:本方法通过码率波动容忍度,将瞬时估计码率与目标码率允许波动的上下限进行比较,而不是和目标码率作比较,来决定如何调整QP以减少QP的不必要波动。更好的维持图像质量的稳定,保证在码率可控的前提下质量的稳定,减少码流的浪费。本方法简单有效,很好的解决了现有技术中的问题。

✦ Generated by Eureka AI based on patent content.

Smart Images

  • Figure CN116233446B_ABST
    Figure CN116233446B_ABST
Patent Text Reader

Abstract

The application provides a variable bit rate control method for real-time video encoding, which is applied to the IPPP structure of real-time video encoding, adopts a hierarchical strategy, includes GOPs level, GOP level and frame level, and allocates target bit rates to different encoding units in sequence. The maximum encoding allowed bit rate is set at the GOPs level to ensure effective transmission and storage of data. The target bit rate is allocated according to the image complexity and motion intensity information obtained by an image feature analysis algorithm at the GOP level, and the encoding bit rate is allowed to fluctuate within the GOPs statistical time, thereby ensuring the stable image quality. At the frame level, if the instantaneous estimated bit rate fluctuation is within the user tolerance range, the QP is not adjusted; when the instantaneous estimated bit rate exceeds the tolerance range, a new upper and lower limit of the bit rate fluctuation is calculated according to the influence degree of scene change on the bit rate and the scene change position, and the QP adjustment is guided. The image quality is better maintained stable.
Need to check novelty before this filing date? Find Prior Art

Description

Technical Field

[0001] This invention relates to the field of video encoding technology, and in particular to a variable bitrate control method for real-time video encoding. Background Technology

[0002] Currently, VBR algorithms used in real-time video coding all employ a strategy of allocating a lower target bitrate for simple scenes and a higher target bitrate for complex scenes to maintain stable video image coding quality. Existing VBR optimization algorithms are based on image content and motion state, analyzing image complexity information over a period of time and using it as a factor in calculating the target bitrate to achieve different target bitrates for different levels of complexity.

[0003] However, existing VBR control technologies still use a precise target bitrate for control. When the instantaneous bitrate fluctuates around the target bitrate, it can easily cause QP oscillations, which is not conducive to maintaining stable image quality. Furthermore, there is no suitable allocation strategy for scenes with different complexities and motion intensities. When the scene changes in the video image, the actual bitrate is prone to being too high or too low.

[0004] In addition, the following are commonly used terms in the prior art:

[0005] Video encoding is a method of converting a raw video file into another video file format that is easier to transmit and store, using compression technology.

[0006] Bitrate is the number of bits of data transmitted per unit of time. The higher the number of bits transmitted per unit of time, the higher the precision, and the closer the processed file is to the original file.

[0007] Bitrate control is the process of effectively transmitting video data while meeting channel bandwidth and transmission delay limitations, thus ensuring the playback quality of video services. This requires bitrate control during the video encoding process.

[0008] VBR (Variable Bit Rate) control allows the encoding bitrate to fluctuate with changes in image complexity to ensure stable encoded image quality. The algorithm allocates a target bitrate based on the scene image content; a lower bitrate is allocated for simpler image content, and a higher bitrate is allocated for more complex image content, thus ensuring image quality while also considering bandwidth limitations.

[0009] A Group of Pictures (GOP) represents the number of frames between two adjacent coded I-frames, and is typically set as a multiple of the frame rate (fps).

[0010] GOPs represents multiples of GOP.

[0011] The IPPP coding structure means that each GOP has only one I-frame, and all others are P-frames. During real-time encoding, each P-frame only references the previously encoded image frame.

[0012] The quantization parameter (QP) is a crucial parameter in video coding, directly affecting the bitrate and image distortion. Bitrate control adjusts the QP to ensure the coding rate is as close as possible to the target bitrate. Summary of the Invention

[0013] To address the aforementioned issues, this method aims to set upper and lower limits for the allowable fluctuation of the target bitrate at the current GOP level based on the user's tolerance for bitrate fluctuations. This reduces QP oscillations caused by normal instantaneous bitrate fluctuations, thus better maintaining image quality stability. When the video scene changes, a reasonable new bitrate control upper and lower limits are obtained by weighted summation of the estimated instantaneous bitrate and the allocated target bitrate fluctuation limits. The weighting ratio is related to the current frame's position within the GOP; the closer to the I-frame, the stronger the control, and the farther away from the I-frame, the weaker the control, ensuring quality stability under controllable bitrate and reducing bitstream waste.

[0014] Specifically, the present invention provides a variable bitrate control method for real-time video encoding. The method is applied to the IPPP structure of real-time video encoding to achieve frame-level target bitrate control, including GOPs and GOP-level bitrate allocation, frame-level bitstream allocation, frame-level QP calculation, and encoding information statistics. The method adopts a hierarchical strategy, which is divided into: GOPs level, GOP level, and frame level, and target bitrates are allocated to different coding units in sequence.

[0015] Set the maximum allowed bitrate at the GOPs level to ensure effective data transmission and storage;

[0016] At the GOP level, the target bitrate is allocated based on the image complexity and motion intensity information obtained by the image feature analysis algorithm. This allows for bitrate fluctuations within the statistical time of GOPs, thereby ensuring stable encoded image quality.

[0017] If the instantaneous estimated bitrate fluctuation at the frame level is within the user's tolerance range, the quantization parameter QP is not adjusted; when the instantaneous estimated bitrate exceeds the tolerance range, a new upper and lower limit of bitrate fluctuation is calculated based on the degree of impact of scene changes on bitrate and the location of scene changes, and this guides the adjustment of QP.

[0018] The method further includes:

[0019] S1, Bitrate Allocation:

[0020] S1.1, GOPs-level target bitrate allocation: Maximum bitrate is set only for GOPs-level targets. This ensures that the average bitrate of the actual encoding within the statistical period does not exceed this maximum value, guaranteeing bitrate transmission and storage. ;

[0021] S1.2, GOP-level target bitrate allocation: GOP-level target bitrate Subject to GOPs of remaining maximum bitrate Limitations on video image complexity (cplx) and motion intensity (motionStrength); the allocation of GOP-level target bitrate increases with image complexity and motion intensity to ensure stable video quality after scene changes; the upper and lower limits of GOP-level bitrate fluctuation are determined based on the user's tolerance for bitrate fluctuation (fluctLvl).

[0022] S1.3, Frame-level bitstream allocation: The bitstream value of the last encoded frame is used as the bitstream estimate of the remaining uncoded frames in the GOP, thus obtaining the current instantaneous estimated bitrate. ;Will With maximum bitrate Minimum bit rate Compare and calculate the new maximum bitrate. and the new minimum bit rate ; Assign a target bitstream to the current frame ;

[0023] S2, Calculation of frame-level P-frame QP:

[0024] 1) For stable scenarios, and , Compare and determine the adjustment direction and offset of the current frame's QP. ;

[0025] 2) For unstable scenarios, according to and , Get the current sum ,Will and , Compare and determine the adjustment direction and offset of the current frame's QP. ;

[0026] Then the QP of the current P-frame to be encoded is the QP value of the previous encoded frame. and sum;

[0027] S3 updates relevant statistics after encoding a frame or a GOP to prepare for encoding the next frame or the next GOP.

[0028] In the method,

[0029] Set control parameters: Maximum bitrate Maximum static bitrate Minimum bit rate Bitrate fluctuation tolerance FluctLvl, maximum QP and minimum value GOPs statistics time ,in,

[0030] Maximum bitrate Used to ensure the normal transmission and storage of the encoded bitrate;

[0031] minimum bit rate Used to control the worst quality of the encoding;

[0032] Maximum still bitrate Used to control unnecessary waste of bitrate in static scenes;

[0033] FluctLvl, the bitrate fluctuation tolerance, is used to calculate the range of instantaneous bitrate fluctuations that a customer can tolerate around the target bitrate.

[0034] QP maximum value and minimum value Used to control the range of image quality;

[0035] GOPs statistics time The longer the bitrate, the greater the allowed instantaneous bitrate fluctuation; otherwise, the smaller the allowed instantaneous bitrate fluctuation.

[0036] Step S1.2 further includes:

[0037] S1.2.1, Allocate bitrate based on scenario complexity:

[0038] The complexity of the current frame is obtained based on image feature analysis; the range from the minimum bitrate to the maximum still bitrate is divided into N intervals, where... Positive integers, numbered in ascending order as follows: The complexity of video images is related to a threshold. Compare and determine the index cplxIdx of the interval it belongs to, and then look up the table. The bitrate offset ratio is obtained; the values ​​in this table are derived empirically. Therefore, the stationary target bitrate at the GOP level for this image complexity is... The calculation method is as follows:

[0039] ;

[0040] S1.2.2, allocate bitrate based on scene motion intensity:

[0041] The motion intensity of the current frame's video image is obtained based on image feature analysis; the range from the stationary bitrate to the maximum allowed bitrate under this complexity is divided into N intervals, where... Positive integers, numbered from 0 to N-1 in ascending order, are used to compare the motion intensity in the current scene with the threshold. Compare and determine the index motionIdx of the interval it belongs to, and then look up the table. The bitrate offset ratio is obtained, and the values ​​in this table are derived empirically. Therefore, the method for calculating the GOP-level target bitrate under the motion intensity of this scene is as follows:

[0042] ;

[0043] Limit the target bitrate at the GOP level to avoid uncontrollable average bitrate of actual encoding at the GOPs level:

[0044]

[0045] Among them, the remaining maximum bitrate To meet the requirement of real-time adjustment of the maximum average target bitrate of the remaining uncoded GOPs within a GOPs under the condition of controllable bitrate at the GOPs level;

[0046] S1.2.3, Based on the user's tolerance for bitrate fluctuations (fluctLvl), determine the upper and lower limits of GOP-level bitrate fluctuations:

[0047]

[0048] ,

[0049] Limit the upper and lower limits of the target bitrate:

[0050]

[0051] ,

[0052] This indicates the maximum bitrate that the current GOP is allowed to reach.

[0053] In step S1.2.1,

[0054] Assuming N=6, meaning the test results are divided into 6 intervals, numbered from 0 to 5 in ascending order, the video image complexity is compared with the threshold. Compare and determine the index cplxIdx of the interval it belongs to, and then look up the table. The bitrate offset ratio is obtained. and These represent the image complexity threshold and the calculated target bitrate relative to the minimum bitrate, respectively. To maximum static bitrate The offset ratio values ​​in the table are derived empirically.

[0055] set up

[0056] set up

[0057] So, the stationary target bitrate at the GOP level under this image complexity. The calculation method is as follows:

[0058] According to the formula

[0059] If minimum bit rate Set to 500Kbps, maximum still bitrate Allowing speeds up to 800Kbps, with a current complexity of 85, this can be achieved through table lookup. The corresponding index can be obtained. Then check the table. achievable The current image complexity results in a static target bitrate of 695Kbps.

[0060] In step S1.2.2,

[0061] Assumption Based on actual testing, six intervals were divided, numbered from 0 to 5 from smallest to largest, to represent the motion intensity and threshold in the current scene. Compare and determine the index motionIdx of the interval it belongs to, and then look up the table. The bit rate offset ratio is obtained, where, and These represent the motion intensity threshold and the ratio of the calculated target bitrate to the stationary bitrate offset relative to the scene complexity, respectively. The values ​​in this table are derived empirically.

[0062] set up

[0063] set up

[0064] The method for calculating the GOP-level target bitrate under the motion intensity in this scenario is as follows:

[0065] According to the formula

[0066] If the bitrate under the current image complexity 600Kbps, maximum bitrate At 1000Kbps and an exercise intensity of 40, the results can be obtained by referring to a table. The corresponding exercise intensity index can be obtained. Then check the table. achievable The target bitstream at the GOP level under the current scene motion intensity is 740Kbps;

[0067] Limit the target bitrate at the GOP level, if the calculated The bitrate is 700Kbps, but because the first few GOPs in the GOPs level consume too much bitrate, If the target bitrate is less than 700Kbps, say 650Kbps, then the target bitrate at the current GOP level is limited to 650Kbps.

[0068] In step S1.2.3,

[0069] set up

[0070] set up

[0071] When users expect more stable encoded image quality but tolerate some bitrate fluctuations, fluctLvl is used as... and The table index value is used to look up the upper and lower limit bitrates relative to the target bitrate. Assume the user's tolerance for bitrate fluctuations, fluctLvl, is 3.

[0072] The allowable upper and lower limits of bitrate fluctuation can be calculated simultaneously below:

[0073]

[0074]

[0075] If the target bitrate for a GOP is 1000 Kbps, then the upper limit of the target bitrate for a GOP can be calculated using the formula. The lower limit can be calculated using a formula. ;

[0076] Limit the upper and lower limits of the target bitrate according to the formula:

[0077]

[0078]

[0079] If the maximum bitrate The value is 1000Kbps, when the average bitrate of the encoded GOPs within a GOP exceeds [a certain value]. The maximum bitrate of the remaining uncoded GOPs. Less than Assuming it's 900Kbps, at this time... The average bitrate needs to be limited to 900Kbps to keep it within the maximum allowable range at the GOPs level.

[0080] Step S1.3 further includes:

[0081] The current instantaneous estimated bit rate is obtained. As follows, among which, This represents the bits that have been encoded in the current GOP. This represents the encoded bitstream value of the previous encoded frame. Indicates the number of frames encoded in a GOP. Indicates the number of uncoded frames in a GOP. This represents the total number of encoded frames in a GOP. Indicates the encoded frame rate:

[0082]

[0083] The and , Compare, calculate and as follows:

[0084]

[0085] ;

[0086] The target bitstream allocated to the current frame as follows:

[0087] .

[0088] Step S2 further includes:

[0089] set up

[0090] set up

[0091] To estimate bitrate The degree to which the target bitrate is exceeded is divided into 6 levels, and the QP is increased to different degrees according to the level. To estimate bitrate The level of bitrate below the target bitrate is divided into 6 levels, and the QP is reduced to different degrees according to the level.

[0092] 1) For stable scenarios, and , Compare and determine the adjustment direction and offset of the QP in the current frame:

[0093] when hour, , obtain exist The corresponding interval index number is upIdx;

[0094] when hour, , obtain exist The corresponding interval index number dwIdx;

[0095] ;

[0096] 2) For unstable scenarios, according to and , Get the current and :

[0097] when hour, , obtain exist The corresponding interval index number is upIdx;

[0098] when hour, , obtain exist The corresponding interval index number dwIdx;

[0099]

[0100] Then the QP of the current P-frame to be encoded is the QP value of the previous encoded frame. and The sum of .

[0101] The relevant statistical parameters in step S3 include: , and .

[0102] Therefore, the advantage of this application lies in the following: This method compares the instantaneously estimated bitrate with the upper and lower limits of the allowable fluctuation of the target bitrate, rather than comparing it with the target bitrate itself, to determine how to adjust the QP to reduce unnecessary QP fluctuations. This better maintains image quality stability, ensuring quality stability under controllable bitrate and reducing bitstream waste. This method is simple and effective, and effectively solves the problems in the prior art. Attached Figure Description

[0103] The accompanying drawings, which are provided to further illustrate the invention and form part of this application, are not intended to limit the scope of the invention.

[0104] Figure 1 This is a schematic diagram illustrating the trend of GOP-level allocation bitrate as a function of image information.

[0105] Figure 2 This is a diagram showing the comparison of various bitrate adjustment results during scene switching.

[0106] Figure 3 This is a flowchart illustrating the method described in this application. Detailed Implementation

[0107] To better understand the technical content and advantages of the present invention, the present invention will now be described in further detail with reference to the accompanying drawings.

[0108] First, the VBR method in this application is applied to the IPPP structure for real-time video coding, employing a hierarchical strategy (divided into GOPs level, GOP level, and frame level) to allocate target bitrates to different coding units sequentially. At the GOPs level, the maximum allowable bitrate is set to ensure effective data transmission and storage. At the GOP level, the target bitrate is allocated based on image complexity and motion intensity information obtained from image feature analysis algorithms, allowing bitrate fluctuations within the GOPs statistical timeframe, thereby ensuring stable encoded image quality. At the frame level, if the instantaneous estimated bitrate fluctuation is within the user's tolerance range, the QP is not adjusted; when the instantaneous estimated bitrate exceeds the tolerance range, a new upper and lower limit for bitrate fluctuation is calculated based on the impact of scene changes on the bitrate and the location of the scene change, guiding the adjustment of the QP.

[0109] The VBR algorithm in this invention provides users with a configurable maximum bitrate. Maximum static bitrate Minimum bit rate Bitrate fluctuation tolerance FluctLvl, maximum QP and minimum value GOPs statistics time Control parameters, etc. Among them,

[0110] Maximum bitrate Used to ensure the normal transmission and storage of the encoded bitrate;

[0111] minimum bit rate Used to control the worst quality of the encoding;

[0112] Maximum still bitrate Used to control unnecessary waste of bitrate in static scenes;

[0113] FluctLvl, the bitrate fluctuation tolerance, is used to calculate the range of instantaneous bitrate fluctuations that a customer can tolerate around the target bitrate.

[0114] QP maximum value and minimum value Used to control the range of image quality;

[0115] GOPs statistics time The longer the bitrate, the greater the allowed instantaneous bitrate fluctuation; otherwise, the smaller the allowed instantaneous bitrate fluctuation.

[0116] Frame-level target bitrate control mainly includes GOPs and GOP-level bitrate allocation, frame-level bitstream allocation, frame-level QP calculation, and encoding information statistics.

[0117] like Figure 3 As shown, the method further includes:

[0118] S1. Code Rate Allocation

[0119] S1.1) GOPs-level target bitrate allocation

[0120] For the VBR algorithm, the maximum bitrate is only set for the GOPs level. This ensures that the average bitrate of actual encoding within the statistical period does not exceed this maximum value, guaranteeing bitrate transmission and storage.

[0121]

[0122] S1.2) GOP-level target bitrate allocation

[0123] The target bitrate at the GOP level is subject to the remaining maximum bitrate at the GOPs level. The video image complexity (cplx) and motion strength (motionStrength) are limited. The allocation of target bitrate at the GOP level increases with image complexity and motion strength to ensure stable video quality after scene changes.

[0124] (1) Allocate bitrate based on scene complexity

[0125] The complexity of the current frame is obtained through image feature analysis. Based on the encoding characteristics of static scenes, the coding bitrate at the GOP level is mainly concentrated in I-frames; the greater the complexity of the I-frame image content, the higher the GOP-level bitrate. The range from the minimum bitrate to the maximum static bitrate is divided into multiple intervals. Based on actual testing, this invention divides the range into six intervals, numbered 0-5 from smallest to largest, and correlates video image complexity with a threshold. Compare and determine the index cplxIdx of the interval it belongs to, and then look up the table. The bitrate offset ratio is obtained; the values ​​in this table are derived empirically. Therefore, the bitrate for stationary targets at the GOP level for this image complexity is... The calculation method is as follows:

[0126] set up

[0127] set up

[0128]

[0129] For example: if the minimum bit rate Set to 500Kbps, maximum still bitrate Allowing speeds up to 800Kbps, with a current complexity of 85, this can be achieved through table lookup. The corresponding index can be obtained. Then check the table. achievable The current image complexity results in a static target bitrate of 695Kbps.

[0130] (2) Allocate bitrate based on scene motion intensity

[0131] The motion intensity of the current frame's video image is obtained through image feature analysis. Based on the coding characteristics of moving scenes, it is known that the proportion of P-frames in the GOP-level coding bitrate gradually increases with increasing motion intensity. Therefore, the range from the stationary bitrate to the maximum allowed bitrate under this complexity is divided into multiple intervals. This invention divides the range into 6 intervals based on actual testing, numbered 0-5 from smallest to largest, to represent the motion intensity of the current scene relative to a threshold. Compare and determine the index motionIdx of the interval it belongs to, and then look up the table. The bitrate offset ratio is obtained; the values ​​in this table are derived empirically. Therefore, the method for calculating the GOP-level target bitrate under the motion intensity of this scene is as follows:

[0132] set up

[0133] set up

[0134]

[0135] For example: If the bitrate is under the current image complexity 600Kbps, maximum bitrate At 1000Kbps and an exercise intensity of 40, the results can be obtained by referring to a table. The corresponding exercise intensity index can be obtained. Then check the table. achievable The target bitstream at the GOP level under the current scene motion intensity is 740Kbps.

[0136] Limit the target bitrate at the GOP level to avoid the average bitrate of actual encoding at the GOPs level becoming uncontrollable.

[0137]

[0138] Among them, the remaining maximum bitrate .

[0139] For example: if the calculated result is The bitrate is 700Kbps, but because the first few GOPs in the GOPs level consume too much bitrate, If the target bitrate is less than 700Kbps, say 650Kbps, then the target bitrate at the current GOP level is limited to 650Kbps.

[0140] like Figure 1 This shows the range and trend of the target bitrate as image complexity and scene motion intensity change. Increased image content complexity indicates that more bits are needed for encoding to achieve stable and clear image quality, which is reflected in… Figure 1 The lower right half gradually changes color from light to dark from left to right, requiring a progressively higher target bitrate. Increased motion intensity means more bits are needed to encode content that differs from the previous frame, which manifests in… Figure 1 The color of the upper left part gradually changes from light to dark from bottom to top, and the target bitrate to be allocated gradually increases.

[0141] (3) Determine the upper and lower limits of GOP-level bitrate fluctuation based on the user's tolerance for bitrate fluctuations, fluctLvl.

[0142] set up

[0143] set up

[0144]

[0145]

[0146] For example, when a user expects more stable encoded image quality but allows for some bitrate fluctuation, assuming the user's tolerance for bitrate fluctuation, fluctLvl, is 3, and the target bitrate for the GOP level is 1000Kbps, the upper limit of the target bitrate for the GOP level can be calculated using the formula. The lower limit can be calculated using a formula. .

[0147] Limit the upper and lower limits of the target bitrate:

[0148]

[0149] .

[0150] This indicates the maximum bitrate allowed by the current GOP, and the remaining maximum bitrate. It is the maximum average target bitrate of the remaining uncoded GOPs within a GOPs that is adjusted in real time under the condition that the bitrate at the GOPs level is controllable.

[0151] For example: if the maximum bitrate The value is 1000Kbps, when the average bitrate of the encoded GOPs within a GOP exceeds [a certain value]. The maximum bitrate of the remaining uncoded GOPs. Less than Assuming it's 900Kbps, at this time... The average bitrate needs to be limited to 900Kbps to keep it within the maximum allowable range at the GOPs level.

[0152] S1.3) Frame-level bitstream allocation

[0153] For real-time video coding using the IPPP architecture, the current frame has the strongest dependency on the previous frame, and the image similarity is also the highest. The bitstream value of the last encoded frame can be used as an estimate of the bitstream of the remaining uncoded frames in the Group of Pictures (GOP), thus obtaining the current instantaneous estimated bitrate. .in, This represents the bits that have been encoded in the current GOP. This represents the encoded bitstream value of the previous encoded frame. Indicates the number of frames encoded in a GOP. Indicates the number of uncoded frames in a GOP. This represents the total number of encoded frames in a GOP. This indicates the encoding frame rate.

[0154]

[0155] Will and , Compare, calculate and :

[0156]

[0157] .

[0158] Assign a target bitstream to the current frame :

[0159] .

[0160] like Figure 2 The upper-middle figure illustrates the smoothing effect of this invention on bitrate fluctuations and image quality when the video scene switches from static to dynamic. White represents the bitrate if the scene remains static, while dark gray represents the bitrate when the qp remains unchanged after the scene switches to motion. Light gray represents the bitrate after adjusting the qp according to this invention, achieving the advantages of reducing bitrate fluctuations and minimizing image quality loss. It also shows a comparison of various bitrate adjustments when a scene switch occurs at a certain P-frame within a GOP. The method of this invention adjusts the bitrate according to the different locations of the scene switch. By varying the intensity, the bitrate remains controllable, and image quality smoothly switches across multiple frames during adjustments. Compared to over-adjustment and under-adjustment, the optimization method of this invention achieves a reasonable trade-off between bitrate and image quality.

[0161] In GOP, when a scene change occurs at a certain P-frame, dark gray represents under-adjusted bitrate, white represents over-adjusted bitrate, and light gray represents the optimized bitrate.

[0162] S2. Calculation of frame-level P-frame and QP

[0163] set up

[0164] set up

[0165] To estimate bitrate The degree to which the bitrate exceeds the target bitrate is divided into several levels, and the QP is increased to different degrees according to the level. To estimate bitrate The level of bitrate below the target bitrate is divided into several levels, and the QP is reduced to different degrees according to the level.

[0166] 1) For stable scenarios, and , Compare and determine the adjustment direction and offset of the QP in the current frame.

[0167] when hour, , obtain exist The corresponding interval index number is upIdx;

[0168] when hour, , obtain exist The corresponding interval index number dwIdx;

[0169]

[0170] 2) For unstable scenarios, according to and , Get the current and

[0171] when hour, , obtain exist The corresponding interval index number is upIdx;

[0172] when hour, , obtain exist The corresponding interval index number dwIdx;

[0173]

[0174] Then the QP of the current P-frame to be encoded is the QP value of the previous encoded frame. and sum.

[0175] S3 is updated after encoding one frame or one GOP. , and This information, along with relevant statistics, is used to prepare for encoding the next frame or the next GOP.

[0176] The above description is merely a preferred embodiment of the present invention and is not intended to limit the present invention. For those skilled in the art, various modifications and variations can be made to the embodiments of the present invention. Any modifications, equivalent substitutions, improvements, etc., made within the spirit and principles of the present invention should be included within the protection scope of the present invention.

Claims

1. A variable bitrate control method for real-time video encoding, characterized in that, The method is applied to the IPPP structure for real-time video encoding to achieve frame-level target bitrate control, including GOPs and GOP-level bitrate allocation, frame-level bitstream allocation, frame-level QP calculation, and encoding information statistics. The method adopts a hierarchical strategy, divided into GOPs level, GOP level, and frame level, and allocates target bitrate to different coding units in sequence. Set the maximum allowed bitrate at the GOPs level to ensure effective data transmission and storage; At the GOP level, the target bitrate is allocated based on the image complexity and motion intensity information obtained by the image feature analysis algorithm. This allows for bitrate fluctuations within the statistical time of GOPs, thereby ensuring stable encoded image quality. If the instantaneous estimated bitrate fluctuation at the frame level is within the user's tolerance range, the quantization parameter QP is not adjusted; when the instantaneous estimated bitrate exceeds the tolerance range, a new upper and lower limit of bitrate fluctuation is calculated based on the degree of impact of scene changes on bitrate and the location of scene changes, and this guides the adjustment of QP. The method further includes: S1, bitrate allocation: S1.1, GOPs-level target bitrate allocation: Maximum bitrate is set only for GOPs-level targets. The average bitrate of actual coding within the GOPs statistical time period should not exceed To ensure the transmission and storage of the bitrate: ; S1.2, GOP-level target bitrate allocation: GOP-level target bitrate Subject to the remaining maximum bitrate in the GOPs level Limitations on video image complexity (cplx) and motion intensity (motionStrength); the allocation of GOP-level target bitrate increases with image complexity and motion intensity to ensure stable video quality after scene changes; the upper and lower limits of GOP-level bitrate fluctuation are determined based on the user's tolerance for bitrate fluctuation (fluctLvl). Step S1.2 further includes: S1.2.1, Allocate bitrate based on scenario complexity: The complexity of the current frame is obtained based on image feature analysis; the range from the minimum bitrate to the maximum still bitrate is divided into N intervals, where... Positive integers, numbered in ascending order as follows: The complexity of video images is related to a threshold. Compare and determine the index cplxIdx of the interval it belongs to, and then look up the table. The bitrate offset ratio is obtained, and the values ​​of the cplxThrd and cplxRatio tables are obtained empirically; then the bitrate of stationary targets at the GOP level under this image complexity is... The calculation method is as follows: ; In step S1.2.1, Let N=6, meaning that based on the actual test results, 6 intervals were divided, numbered from 0 to 5 in ascending order. The video image complexity was then compared with the threshold. Compare and determine the index cplxIdx of the interval it belongs to, and then look up the table. The bit rate offset ratio is obtained, where, and These represent the image complexity threshold and the calculated target bitrate relative to the minimum bitrate, respectively. To maximum static bitrate The offset ratio values, obtained empirically from the cplxThrd and cplxRatio table values: set up ; set up ; So, the stationary target bitrate at the GOP level under this image complexity. The calculation method is as follows: According to the formula: ; If minimum bit rate Set to 500Kbps, maximum still bitrate Allowing speeds up to 800Kbps, with a current complexity of 85, this can be achieved through table lookup. The corresponding index can be obtained. Then check the table. achievable The current image complexity results in a static target bitrate of 695Kbps. S1.3, Frame-level bitstream allocation: The bitstream value of the last encoded frame is used as the bitstream estimate of the remaining uncoded frames in the GOP, thus obtaining the current instantaneous estimated bitrate. ;Will With maximum bitrate Minimum bit rate Compare and calculate the new maximum bitrate. and the new minimum bit rate ; Assign a target bitstream to the current frame ; S2, Calculation of frame-level P-frame QP: 1) For stable scenarios, and , Compare and determine the adjustment direction and offset of the current frame's QP. ; 2) For unstable scenarios, according to and , Get the current and ,Will and , Compare and determine the adjustment direction and offset of the current frame's QP. ; Then the QP of the current P-frame to be encoded is the QP value of the previous encoded frame. and sum; S3 updates relevant statistics after encoding a frame or a GOP to prepare for encoding the next frame or the next GOP.

2. The variable bitrate control method for real-time video encoding according to claim 1, characterized in that, In the method, Set control parameters: Maximum bitrate Maximum static bitrate Minimum bit rate Bitrate fluctuation tolerance FluctLvl, maximum QP and minimum value GOPs statistics time ,in, Maximum bitrate Used to ensure the normal transmission and storage of the encoded bitrate; minimum bit rate Used to control the worst quality of the encoding; Maximum still bitrate Used to control unnecessary waste of bitrate in static scenes; FluctLvl, the bitrate fluctuation tolerance, is used to calculate the range of instantaneous bitrate fluctuations that a customer can tolerate around the target bitrate. QP maximum value and minimum value Used to control the range of image quality; GOPs statistics time The longer the bitrate, the greater the allowed instantaneous bitrate fluctuation; otherwise, the smaller the allowed instantaneous bitrate fluctuation.

3. The variable bitrate control method for real-time video encoding according to claim 1, characterized in that, Step S1.2 further includes: S1.2.2, allocate bitrate based on scene motion intensity: The motion intensity of the current frame's video image is obtained based on image feature analysis; the range from the stationary bitrate to the maximum allowed bitrate under this complexity is divided into N intervals, where... Positive integers, numbered from 0 to N-1 in ascending order, are used to compare the motion intensity in the current scene with the threshold. By comparing and determining the label of the interval, motionIdx, and looking up the table motionRatio[motionIdx], the bitrate offset ratio is obtained. The values ​​of motionThrd and motionRatio are obtained empirically. Therefore, the method for calculating the GOP-level target bitrate under the motion intensity of this scene is as follows: ; Limit the target bitrate at the GOP level to avoid uncontrollable average bitrate of actual encoding at the GOPs level: ; Among them, the remaining maximum bitrate To meet the requirement of real-time adjustment of the maximum average target bitrate of the remaining uncoded GOPs within a GOPs under the condition of controllable bitrate at the GOPs level; S1.2.3, Based on the user's tolerance for bitrate fluctuations (fluctLvl), determine the upper and lower limits of GOP-level bitrate fluctuations: , , Limit the upper and lower limits of the target bitrate: , , This indicates the maximum bitrate that the current GOP is allowed to reach.

4. The variable bitrate control method for real-time video encoding according to claim 1, characterized in that, In step S1.2.2, set up Based on actual testing, six intervals were divided, numbered from 0 to 5 from smallest to largest, to determine the relationship between the motion intensity and the threshold in the current scene. Compare and determine the label of the interval containing motionIdx, and then look up the table. The bit rate offset ratio is obtained, where, and These represent the motion intensity threshold and the ratio of the calculated target bitrate to the stationary bitrate offset under the scene complexity, respectively. The values ​​in the `motionThrd` and `motionRatio` tables are obtained empirically. set up ; set up ; The method for calculating the GOP-level target bitrate under the motion intensity in this scenario is as follows: According to the formula: ; If the bitrate under the current image complexity 600Kbps, maximum bitrate At 1000Kbps and an exercise intensity of 40, the results can be obtained by referring to a table. The corresponding exercise intensity index can be obtained. Then check the table. achievable The target bitstream at the GOP level under the current scene motion intensity is 740Kbps; Limit the target bitrate at the GOP level, if the calculated The bitrate is 700Kbps, but because the first few GOPs in the GOPs level consume too much bitrate, If the target bitrate is less than 700Kbps, say 650Kbps, then the target bitrate at the current GOP level is limited to 650Kbps.

5. The variable bitrate control method for real-time video encoding according to claim 1, characterized in that, In step S1.2.3, set up ; set up ; When users expect more stable encoded image quality but tolerate some bitrate fluctuations, fluctLvl is used as... and The table index value is used to look up the upper and lower limit bitrates relative to the target bitrate; assuming the user's tolerance for bitrate fluctuations, fluctLvl, is 3, The allowable upper and lower limits of bitrate fluctuation can be calculated simultaneously below: ; ; If the target bitrate for a GOP is 1000 Kbps, then the upper limit of the target bitrate for a GOP can be calculated using the formula. The lower limit can be calculated using a formula. ; Limit the upper and lower limits of the target bitrate according to the formula: ; ; If the maximum bitrate The value is 1000Kbps, when the average bitrate of the encoded GOPs within a GOP exceeds [a certain value]. The maximum bitrate of the remaining uncoded GOPs. Less than Assuming it's 900Kbps, at this time... The average bitrate needs to be limited to 900Kbps to keep it within the maximum allowable range at the GOPs level.

6. The variable bitrate control method for real-time video encoding according to claim 1, characterized in that, Step S1.3 further includes: The current instantaneous estimated bit rate is obtained. As follows, among which, This represents the bits that have been encoded in the current GOP. This represents the encoded bitstream value of the previous encoded frame. Indicates the number of frames encoded in a GOP. Indicates the number of uncoded frames in a GOP. This represents the total number of encoded frames in a GOP. Indicates the encoded frame rate: ; The and , Compare, calculate and as follows: ; ; The target bitstream allocated to the current frame as follows: 。 7. The variable bitrate control method for real-time video encoding according to claim 6, characterized in that, Step S2 further includes: set up ; set up ; To estimate the bit rate The degree to which the target bitrate is exceeded is divided into 6 levels, and the QP is increased to different degrees according to the level. To estimate the bit rate The level of bitrate below the target bitrate is divided into 6 levels, and the QP is reduced to different degrees according to the level. 1) For stable scenarios, and , Compare and determine the adjustment direction and offset of the QP in the current frame: when hour, , obtain exist The corresponding interval index number is upIdx; when hour, , obtain exist The corresponding interval index number dwIdx; ; 2) For unstable scenarios, according to and , Get the current and : when hour, , obtain exist The corresponding interval index number is upIdx; when hour , obtain exist The corresponding interval index number dwIdx; ; Then the QP of the current P-frame to be encoded is the QP value of the previous encoded frame. and The sum of .

8. The variable bitrate control method for real-time video encoding according to claim 1, characterized in that, The relevant statistical information in step S3 includes , and .

Citation Information

Patent Citations

  • VBR code rate control method for video real-time coding

    CN114598866A