A bit rate control method for real-time monitoring scenarios

Through the method of bit rate estimation and dynamic bit rate threshold, the quantization parameter QP is adjusted, and the problem of strong dependence on the accuracy of the quadratic model in the prior art is solved, and the adaptability and image quality stability of bit rate control are improved.

CN115550655BActive Publication Date: 2025-04-25INGENIC SEMICON CO LTD
View PDF 2 Cites 0 Cited by

Patent Information

Application Number
CN202110734926.3
Authority / Receiving Office
CN · China
Patent Type
Patents(China)
Current Assignee / Owner
Filing Date
2021-06-30
Publication Date
2025-04-25
Estimated Expiration
2041-06-30

AI Technical Summary

Technical Problem

The code rate control method in the prior art has a strong dependence on the accuracy of the quadratic model, resulting in poor tolerance for instantaneous code rate fluctuations, which easily causes frequent fluctuations in quantization parameters, affecting image quality and adaptability.

Method used

The method of judging the change trend and intensity of the bit rate through the bit rate estimation is used to adjust the quantization parameter QP to achieve bit rate control. The specific methods include setting a code rate fluctuation tolerance limit at the GOP level, and using a dynamic code rate threshold to judge the instantaneous code rate offset at the frame level, thereby reducing the erroneous adjustment of QP.

Benefits of technology

It improves the adaptability of bit rate control, reduces the fluctuation frequency of quantization parameters, and achieves the optimal compromise between image quality and bit rate.

✦ Generated by Eureka AI based on patent content.

Smart Images

  • Figure CN115550655B_ABST
    Figure CN115550655B_ABST
Patent Text Reader

Abstract

The present invention provides a rate control method for real-time monitoring scenes, including: S1. judging the trend and intensity of rate change by rate estimation, and setting rate fluctuation tolerance limits for different scenes at the GOP level; S2. realizing rate control by adjusting QP based on the QP of the previous encoded frame, that is, calculating the QP of the P frame, using a dynamic rate threshold at the frame level to judge the degree of deviation of the instantaneous rate relative to the target rate, estimating the current instantaneous rate estbr according to the code stream of the previous encoded frame, comparing it with the dynamic rate threshold, obtaining the QP offset dqp, and summing the quantization parameter prevQp of the previous frame and the offset dqp to obtain the QP of the current frame. In order to improve the adaptability of the method, setting rate fluctuation tolerance limits for different scenes at the GOP level, and using a dynamic rate threshold at the frame level to judge the degree of deviation of the instantaneous rate relative to the target rate, so as to reduce the misadjustment of QP, so as to achieve the optimal compromise between the overall image quality and the rate.
Need to check novelty before this filing date? Find Prior Art

Description

Technical Field

[0001] The present invention relates to the technical field of video encoding, and in particular to a bit rate control method for real-time monitoring scenarios. Background Art

[0002] Rate control in video coding is an important coding technology that aims to ensure the smooth transmission of the code stream under the premise of limited communication channel bandwidth. The goal of rate control is to control the number of bits of each frame of image encoding output and minimize the image distortion under the constraint of a certain total number of bits. And ensure that the buffer area at the codec end does not overflow. Academically, the rate control process is a rate-distortion RDO optimization process, that is, selecting appropriate quantization parameters to minimize distortion at a given target bit rate. The quadratic model obtained by rate-distortion optimization is fitted to the encoded code stream and QP data to obtain the quadratic model curve, and the QP corresponding to the target code stream is obtained by solving the quadratic equation.

[0003] However, academic rate control methods are highly dependent on the accuracy of the quadratic model, focusing on rate control and optimizing the quality of the current frame image. They have poor tolerance for instantaneous rate fluctuations, which can easily cause frequent fluctuations in QP, adversely affecting the subjective perception of the image. They have poor adaptability to complex multi-scene video sequences and suffer from significant image quality fluctuations.

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

[0005] Video encoding is a way of converting the original video format file into another video format file that is easy to transmit and store through compression technology. Usually this kind of compression belongs to lossy data compression. The bit rate is the number of data bits transmitted per unit time during data transmission. The larger the number of bits transmitted per unit time, the higher the accuracy, and the closer the processed file is to the original file.

[0006] Bit rate control is to effectively transmit video data under the conditions of meeting the channel bandwidth and transmission delay constraints to ensure the playback quality of video services. Bit rate control is required for the video encoding process. Group of Pictures (GOP) indicates the number of frames between two adjacent encoded I frames, which is generally set to a multiple of the frame rate fps. The GOP level is based on the group of pictures GOP, while the frame level is based on the picture.

[0007] The instantaneous estimated bit rate is obtained by taking the frame as the sampling point, estimating the bit stream of the uncoded frame, and summing it with the coded bit stream to obtain the estimated bit rate of the current GOP.

[0008] The quantization parameter QP (QuantizerParameter) is a very important parameter in video encoding, which directly affects the video encoding compression rate and image distortion. If the QP is large, the corresponding encoding stream length is small, and the loss of image detail information is large; if the QP is small, the corresponding encoding stream length is also large, but the loss of image detail information is small. Bit rate control controls the quantization parameter QP to make the encoding rate as close to the target bit rate as possible.

[0009] The IPPP structure means that the coded frame type only includes I frames and P frames. During real-time coding, each P frame only refers to the image that has been coded in the previous frame. This structure is suitable for low-latency application scenarios.

[0010] A coding scene is a video sequence divided according to the amount of information change between two or more frames.

[0011] JVT-G012 rate control algorithm adopts a multi-level rate control method, which consists of three closely related levels: GOP level, frame level and macroblock group level. Among them, the GOP level determines the target number of bits of the current GOP and the QP of the starting I frame; the frame level determines the target number of bits and QP of the frame level through the number of remaining uncoded bits in the GOP and the quadratic RQ model; the macroblock group level determines the target number of bits and QP of the macroblock group according to the image content characteristics, the number of remaining uncoded bits in the frame and the quadratic RQ model. JVT-G012 adopts this structure to gradually refine the rate control from the GOP level to the macroblock group level, thereby improving the accuracy of rate control. Summary of the invention

[0012] In order to solve the above-mentioned problems in the prior art, the purpose of this application is: this application abandons the method of calculating QP according to the model, adopts the method of judging the trend and intensity of the bit rate change through the method of bit rate estimation, and adjusts the QP based on the QP of the previous encoded frame to achieve the purpose of bit rate control. In order to improve the adaptability of the method, this method sets the bit rate fluctuation tolerance limit for different scenes at the GOP level, and uses the dynamic bit rate threshold at the frame level to judge the degree of deviation of the instantaneous bit rate relative to the target bit rate, so as to reduce the misadjustment of QP, so as to achieve the optimal compromise between the overall image quality and bit rate.

[0013] Specifically, the present invention provides a bit rate control method for real-time monitoring scenarios, the method comprising:

[0014] S1, determines the trend and intensity of bit rate change by bit rate estimation, and sets bit rate fluctuation tolerance limits for different scenarios at the GOP level;

[0015] S2, the bit rate is controlled by adjusting the QP based on the QP of the previous encoded frame, that is, the QP of the P frame is calculated, and the dynamic bit rate threshold is used at the frame level to determine the degree of deviation of the instantaneous bit rate relative to the target bit rate. The current instantaneous bit rate estbr is estimated according to the bit stream of the previous encoded frame, and it is compared with the dynamic bit rate threshold to obtain the QP offset dqp. The quantization parameter prevQp of the previous frame and the offset dqp are summed to obtain the QP of the current frame.

[0016] The different scenes are surveillance video scenes, which are divided into 7 groups of scenes, namely, still scene, general scene, still to moving scene, moving scene, moving to still scene, violent moving scene, and scene switching.

[0017] The step S1 further includes: given a GOP-level target bit rate tgtbr, dividing the surveillance video scenes into 7 groups of scenes according to the bit rate fluctuation characteristics, and setting a group of bit rate fluctuation ranges minbr to maxbr that can be tolerated by users according to the characteristics of different scenes.

[0018] The fluctuation range can be obtained by setting the upper and lower limits of the bit rate fluctuation:

[0019] Set the upper limit of the code rate fluctuation

[0020] maxbrRatio[7]={105,107,110,115,110,120,125};

[0021] Set the lower limit ratio of bit rate fluctuation

[0022] minbrRatio[7]={95, 93, 90, 90, 90, 95, 95};

[0023] The calculation method for the allowed fluctuation range of the bit rate in the current scenario SCE is as follows:

[0024] maxbr=tgtbr·maxbrRatio[sce] / 100

[0025] minbr=tgtbr·minbrRatio[sce] / 100.

[0026] The step S2 further comprises:

[0027] S2.1, Calculation of instantaneous estimated bit rate

[0028] Encoded bit rate: encbr = encbs / gopTime

[0029] Instantaneous estimated bit rate: estbr = (encbs + predbs (gopsize - frmcnt) / gopTime

[0030] Current frame prediction stream:

[0031] Where encbs is the sum of the bitstreams of the encoded frames in the current GOP, predbs is the weighted sum of the bitstreams of the three frames closest to the current frame to be encoded, frmbs[3], and wi is the frame bitstream weight; gopsize represents the total number of frames in the current GOP, frmcnt represents the number of frames that have been encoded; gopTime represents the time required to encode a GOP;

[0032] S2.2, Calculation of dynamic bitrate threshold

[0033] A dynamic bitrate threshold is set between the bitrate fluctuation range minbr and maxbr to divide the bitrate interval; when estbr is between tgtbr and maxbr and estbr tends to decrease relative to estbr of the previous frame, when estbr is between minbr and tgtbr and estbr tends to increase relative to estbr of the previous frame or estbr is near tgtbr, the current frame QP should be consistent with prevQp to maintain stable image quality;

[0034] It is assumed that at most three dynamic threshold curves are divided between the target bit rate tgtbr and the maximum bit rate fluctuation range maxbr, and at most three dynamic threshold curves are divided between the minimum bit rate fluctuation range minbr and the target bit rate tgtbr;

[0035] The starting value of the dynamic bitrate threshold is determined by the slope of the dynamic maximum bitrate threshold and the slope of the dynamic minimum bitrate threshold:

[0036] Set the slope of the maximum bitrate threshold

[0037] DmaxbrSlope[4][7]={{30, 30, 40, 40, 50, 60, 60}, {50, 50, 60, 60, 70, 75, 75}, {80, 80, 80, 80, 90, 95, 95}, {100, 100, 100, 100, 100, 100, 100}}

[0038] Set the slope of the minimum bitrate threshold

[0039] DminbrSlope[4][7]={{80, 80, 80, 80, 90, 95, 95}, {50, 50, 60, 60, 70, 75, 75}, {30, 30, 40, 40, 50, 60, 60}, {0, 0, 0, 0, 0, 0, 0}}

[0040] The initial value of the dynamic bit rate threshold can be calculated by the following formula:

[0041] DmaxbrInit[i]=tgtbr+(maxbr-tgtbr)*DmaxbrSlope[i][sce] / 100, i=1, 2, 3, 4

[0042] DminbrInit[i]=minbr+(tgtbr-minbr)*DminbrSlope[i][sce] / 100, i=1, 2, 3, 4

[0043] The bitrate offset for increasing and decreasing the dynamic bitrate threshold is:

[0044] upDltbr=DmaxbrSlope[0][sce]·(maxbr-tgtbr) / gopsize

[0045] dwDltbr=DminbrSlope[2][sce]·(tgtbr-minbr) / gopsize

[0046] After each frame of image is encoded, 8 new dynamic bitrate thresholds can be calculated according to the following formula:

[0047] Dmaxbr[i]=DmaxbrInit[i]-frmcnt·upDltbr, i=1, 2, 3

[0048] Dminbr[i]=DminbrInit[i]+frmcnt·dwDltbr, i=1, 2, 3

[0049] Constrain the dynamic bit rate threshold according to the encoded bit rate encbr; calculate the minimum achievable encoding bit rate Dmin_est_br = encbr + min_rem_br, where the dynamic minimum residual bit rate min_rem_br can be obtained by a given value and the number of remaining frames;

[0050] S2.3, QP adjustment method

[0051] The current instantaneous estimated bit rate level cur_brlvl represents the degree of deviation between the current instantaneous estimated bit rate and the target bit rate: the larger the positive value of cur_brlvl, the more it exceeds the target bit rate, and the larger the negative value, the more it is below the target bit rate; and the comparison between the current instantaneous estimated bit rate level cur_brlvl and the instantaneous estimated bit rate level prev_brlvl of the previous frame can explain the trend of the bit rate when maintaining the current QP, and determine the offset dqp of the QP of the current frame based on prevQp; the maximum value of the instantaneous estimated bit rate level prev_brlvl of the previous frame and the current encoded bit rate level enc_brlvl is taken as cmp_brlvl, which is used to compare with the current instantaneous estimated bit rate level cur_brlvl to obtain the QP offset dqp; and the size of prevQp and the frame number frmcnt will also affect the amplitude of Qp fluctuation, so it is necessary to use dqp1 related to prevQp and dqp2 related to frmcnt to correct the dqp obtained above:

[0052] Correction offset:

[0053] Correction offset:

[0054] Corrected QP offset: adjDqp = dqp + dqp1 + dqp2

[0055] At this time, the QP of the current frame can be calculated as prevQp+adjDqp, and then the QP is limited to a given limit parameter between MinQp and MaxQp to obtain the encoding QP of the current frame.

[0056] In step S2.1, it can be seen from the calculation formula of the instantaneous estimated bit rate that the smaller the frmcnt is, the larger the error of estbr is. The bit rate threshold is dynamically adjusted to avoid incorrect adjustment of some QPs.

[0057] In step S2.2, if the tolerance for the previous bit rate fluctuation is greater, the dynamic threshold curve is steeper and the fewer levels are divided; conversely, the flatter it is, the more levels are divided; the greater the deviation between the upper and lower limits of the bit rate fluctuation is, the more dynamic threshold curves there are.

[0058] In the step S2.2, constraining the dynamic bit rate threshold according to the encoded bit rate encbr further includes:

[0059] When Dmaxbr[4]<estbr, Dmax_br[4] takes the maximum value of Dmax_br[4] and Dmin_est_br;

[0060] When Dmaxbr[3] < estbr < Dmaxbr[4], Dmax_br[3] takes the maximum value of Dmax_br[3] and Dmin_est_br;

[0061] When Dmaxbr[2] < estbr < Dmaxbr[3], Dmax_br[2] takes the maximum value of Dmax_br[2] and Dmin_est_br;

[0062] When Dmaxbr[1] < estbr < Dmaxbr[2], Dmax_br[1] takes the maximum value of Dmax_br[1] and Dmin_est_br;

[0063] When Dminbr[1] < estbr < Dmaxbr[1], Dmin_br[1] takes the maximum value of Dmin_br[1] and Dmin_est_br;

[0064] When Dminbr[2] < estbr < Dminbr[1], Dmin_br[2] takes the maximum value of Dmin_br[2] and Dmin_est_br;

[0065] When Dminbr[3] < estbr < Dminbr[2], Dmin_br[3] takes the maximum value of Dmin_br[2] and Dmin_est_br;

[0066] When Dminbr[4] < estbr < Dminbr[3], Dmin_br[4] takes the maximum value of Dmin_br[4] and Dmin_est_br;

[0067] When estbr < Dminbr[4], Dmin_br[4] takes the maximum value of Dmin_br[4] and Dmin_est_br.

[0068] In the step S2.3, it is compared with the current instantaneous estimated bitrate level cur_brlvl to obtain the QP offset dqp, as shown in the following table:

[0069]

[0070]

[0071] Therefore, the advantages of the present application are: the rate control method involves the compromise between image quality and bit rate, and the weight of image quality stability is assigned to different scenes according to their characteristics, in order to achieve the overall optimality of video encoding. The stability of image quality in the short term can be measured by the frequency and intensity of QP changes, and reducing the frequency of QP fluctuations is conducive to the stability of the encoded image quality. The method of using dynamic bit rate thresholds improves the adaptability of bit rate control, reduces the misadjustment of QP, and achieves the optimal compromise between image quality and bit rate. BRIEF DESCRIPTION OF THE DRAWINGS

[0072] The drawings described herein are used to provide a further understanding of the present invention, constitute a part of this application, and do not constitute a limitation of the present invention.

[0073] Figure 1 It is a flow chart of the method of the present invention.

[0074] Figure 2 It is a schematic diagram of a dynamic threshold curve in a specific embodiment of the present invention. DETAILED DESCRIPTION

[0075] In order to more clearly understand the technical content and advantages of the present invention, the present invention is now further described in detail in conjunction with the accompanying drawings.

[0076] The bit rate control method used in the field of video codec monitoring is not only to adapt to network transmission, but also to provide clear and stable video images. In the real-time monitoring codec process, the bit rate must be controllable to ensure normal network transmission and a good viewing experience for users. The bit rate control method involves the compromise between image quality and bit rate, and the weight of image quality stability is assigned according to the characteristics of different scenes. The stability of image quality in the short term can be measured by the frequency and intensity of QP changes. Reducing the frequency of QP fluctuations is conducive to the stability of the encoded image quality.

[0077] like Figure 1 As shown, the present invention relates to a bit rate control method for real-time monitoring scenarios, the method comprising:

[0078] S1, determines the trend and intensity of bit rate change by bit rate estimation, and sets bit rate fluctuation tolerance limits for different scenarios at the GOP level;

[0079] S2, the bit rate is controlled by adjusting the QP based on the QP of the previous encoded frame, that is, the QP of the P frame is calculated, and the dynamic bit rate threshold is used at the frame level to determine the degree of deviation of the instantaneous bit rate relative to the target bit rate. The current instantaneous bit rate estbr is estimated according to the bit stream of the previous encoded frame, and it is compared with the dynamic bit rate threshold to obtain the QP offset dqp. The quantization parameter prevQp of the previous frame and the offset dqp are summed to obtain the QP of the current frame.

[0080] The following is a specific embodiment. The present invention only involves the GOP level bit rate limiting method and the P frame QP calculation method. The I frame QP is still obtained using the JVT-G012 proposal method, which will not be described in detail here.

[0081] 1. GOP level bitrate limit

[0082] Given a GOP-level target bitrate tgtbr, the surveillance video scenes are divided into seven groups according to the bitrate fluctuation characteristics, namely, static scenes, general scenes, static to motion scenes, motion scenes, motion to static scenes, violent motion scenes, and scene switching. A set of bitrate fluctuation ranges minbr to maxbr that users can tolerate is set according to the characteristics of different scenes. The larger the bitrate fluctuation range, the more stable the image quality. This range can be obtained by setting the upper and lower limits of the bitrate fluctuation allowed.

[0083] Set the upper limit of the code rate fluctuation

[0084] maxbrRatio[7]={105, 107, 110, 115, 110, 120, 125};

[0085] Set the lower limit ratio of bit rate fluctuation

[0086] minbrRatio[7]={95, 93, 90, 90, 90, 95, 95};

[0087] The calculation method for the allowed fluctuation range of the bit rate in the current scenario SCE is as follows:

[0088] maxbr=tgtbr·maxbrRatio[sce] / 100

[0089] minbr=tgtbr·minbrRatio[sce] / 100

[0090] 2. Calculation of P-frame QP

[0091] Since the monitoring scene is highly continuous and the correlation between the previous and next frames is also strong, the current instantaneous bit rate estbr can be estimated based on the bit stream of the previously encoded frame, and compared with the dynamic bit rate threshold to obtain the QP offset dqp. The quantization parameters prevQp and dqp of the previous frame are summed to obtain the QP of the current frame.

[0092] 1) Calculation of instantaneous estimated bit rate

[0093] Encoded bit rate: encbr = encbs / gopTime

[0094] Instantaneous estimated bit rate: estbr = (encbs + predbs (gopsize - frmcnt) / gopTime

[0095] Current frame prediction stream:

[0096] Where encbs is the sum of the bitstreams of the encoded frames in the current GOP, predbs is the weighted sum of the bitstreams of the three frames closest to the current frame to be encoded, frmbs[3], and w i is the frame code stream weight; gopsize indicates the total number of frames in the current GOP, frmcnt indicates the number of frames that have been encoded; gopTime indicates the time required to encode a GOP.

[0097] From the calculation formula of the instantaneous estimated bit rate, it can be seen that the smaller the frmcnt is, the larger the error of estbr is. The bit rate threshold can be dynamically adjusted to avoid some incorrect adjustments of QP.

[0098] 2) Calculation of dynamic bit rate threshold

[0099] The present invention sets a dynamic bit rate threshold between minbr and maxbr and divides the bit rate interval, the purpose of which is to measure the state of the instantaneous bit rate, and to adjust the QP in time when the instantaneous bit rate tends to be too large or too small. The earlier the QP is adjusted, the better the bit rate controllability. When estbr is between tgtbr and maxbr and estbr tends to decrease relative to the estbr of the previous frame, when estbr is between minbr and tgtbr and estbr tends to increase relative to the estbr of the previous frame or estbr is near tgtbr, the current frame QP should be consistent with prevQp to maintain the stability of image quality.

[0100] It is assumed that there are at most 3 dynamic threshold curves between tgtbr and maxbr, and at most 3 dynamic threshold curves between minbr and tgtbr. If the tolerance for the previous bit rate fluctuation is greater, the dynamic threshold curve is steeper and the fewer the levels are; conversely, the flatter the dynamic threshold curve is, the more the levels are. The greater the deviation between the upper and lower limits of the bit rate fluctuation, the more dynamic threshold curves there are. The starting value of the dynamic bit rate threshold is determined by the slope of the dynamic maximum bit rate threshold and the slope of the dynamic minimum bit rate threshold.

[0101] Set the slope of the maximum bitrate threshold

[0102] DmaxbrSlope[4][7]={{30, 30, 40, 40, 50, 60, 60}, {50, 50, 60, 60, 70, 75, 75}, {80, 80, 80, 80, 90, 95, 95}, {100, 100, 100, 100, 100, 100, 100}}

[0103] Set the slope of the minimum bitrate threshold

[0104] DminbrSlope[4][7]={{80, 80, 80, 80, 90, 95, 95}, {50, 50, 60, 60, 70, 75, 75}, {30, 30, 40, 40, 50, 60, 60}, {0, 0, 0, 0, 0, 0, 0}}

[0105] The initial value of the dynamic bit rate threshold can be calculated by the following formula:

[0106] DmaxbrInit[i]=tgtbr+(maxbr-tgtbr)*DmaxbrSlope[i][sce] / 100, i=1, 2, 3, 4

[0107] DminbrInit[i]=minbr+(tgtbr-minbr)*DminbrSlope[i][sce] / 100, i=1, 2, 3, 4

[0108] The bitrate offset for increasing and decreasing the dynamic bitrate threshold is:

[0109] upDltbr=DmaxbrSlope[0][sce]·(maxbr-tgtbr) / gopsize

[0110] dwDltbr=DminbrSlope[2][sce]·(tgtbr-minbr) / gopsize

[0111] After each frame of image is encoded, eight new dynamic bit rate thresholds can be calculated according to the following formula.

[0112] Dmaxbr[i]=DmaxbrInit[i]-frmcnt·upDltbr, i=1, 2, 3

[0113] Dminbr[i]=DminbrInit[i]+frmcnt·dwDltbr, i=1, 2, 3

[0114] Constrain the dynamic bitrate threshold according to the encoded bitrate encbr. Calculate the minimum achievable encoding bitrate Dmin_est_br = encbr + min_rem_br, where the dynamic minimum remaining bitrate min_rem_br can be obtained from the given value and the remaining number of frames.

[0115] When Dmaxbr[4] < estbr, Dmax_br[4] takes the maximum value of Dmax_br[4] and Dmin_est_br;

[0116] When Dmaxbr[3] < estbr < Dmaxbr[4], Dmax_br[3] takes the maximum value of Dmax_br[3] and Dmin_est_br;

[0117] When Dmaxbr[2] < estbr < Dmaxbr[3], Dmax_br[2] takes the maximum value of Dmax_br[2] and Dmin_est_br;

[0118] When Dmaxbr[1] < estbr < Dmaxbr[2], Dmax_br[1] takes the maximum value of Dmax_br[1] and Dmin_est_br;

[0119] When Dminbr[1] < estbr < Dmaxbr[1], Dmin_br[1] takes the maximum value of Dmin_br[1] and Dmin_est_br;

[0120] When Dminbr[2] < estbr < Dminbr[1], Dmin_br[2] takes the maximum value of Dmin_br[2] and Dmin_est_br;

[0121] When Dminbr[3] < estbr < Dminbr[2], Dmin_br[3] takes the maximum value of Dmin_br[2] and Dmin_est_br;

[0122] When Dminbr[4] < estbr < Dminbr[3], Dmin_br[4] takes the maximum value of Dmin_br[4] and Dmin_est_br;

[0123] When estbr < Dminbr[4], Dmin_br[4] takes the maximum value of Dmin_br[4] and Dmin_est_br;

[0124] The schematic of the dynamic threshold curve is as Figure 2As shown, the dotted line refers to the result when encbr does not exceed the calculated dynamic bit rate threshold. Once encbr exceeds the calculated dynamic threshold, the dynamic bit rate threshold needs to be limited by Dmin_est_br.

[0125] according to Figure 2 The 8 dynamic bitrate thresholds in can obtain 9 bitrate ranges, which are expressed as bitrate levels, such as Figure 2 As shown, from top to bottom, they are 4, 3, 2, 1, 0, -1, -2, -3, -4. The instantaneous estimated bit rate estbr and the encoded bit rate encbr are compared with the dynamic bit rate threshold to obtain the current instantaneous estimated bit rate level cur_brlvl and the current encoded bit rate level enc_brlvl. The instantaneous estimated bit rate level prev_brlvl of the previous frame is retained.

[0126] 3) QP adjustment method

[0127] The current instantaneous estimated bit rate level cur_brlvl represents the degree of deviation between the current instantaneous estimated bit rate and the target bit rate. The larger the positive value of cur_brlvl, the more it exceeds the target bit rate, and the larger the negative value, the more it falls below the target bit rate. The comparison between the current instantaneous estimated bit rate level cur_brlvl and the instantaneous estimated bit rate level prev_brlvl of the previous frame can explain the trend of the bit rate when maintaining the current QP, and determine the offset dqp of the QP of the current frame based on prevQp. The maximum value of the instantaneous estimated bit rate level prev_brlvl of the previous frame and the current encoded bit rate level enc_brlvl is taken as cmp_brlvl, which is used for comparison with the current instantaneous estimated bit rate level cur_brlvl. As shown in the following table.

[0128]

[0129] At this time, the QP offset dqp is obtained. The size of prevQp and the frame number frmcnt will also affect the amplitude of Qp fluctuation. Therefore, it is necessary to use dqp1 related to prevQp and dqp2 related to frmcnt to correct the dqp obtained above.

[0130] Correction offset:

[0131] Correction offset:

[0132] Corrected QP offset: adjDqp = dqp + dqp1 + dqp2

[0133] At this time, the QP of the current frame can be calculated as preVQp+adjDqp, and then the encoding QP of the current frame can be obtained by constraining MaxQp and MinQp.

[0134] The above description is only a preferred embodiment of the present invention and is not intended to limit the present invention. For those skilled in the art, the embodiments of 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 bit rate control method for real-time monitoring scenarios, characterized in that: The method comprises: S1, setting a bit rate fluctuation tolerance limit for different scenarios at the coded picture group GOP level, and obtaining a minimum value minbr and a maximum value maxbr of the GOP level bit rate fluctuation range under different scenarios according to the GOP level target bit rate tgtbr and the bit rate fluctuation tolerance limit; S2, for P frame, adjust QP based on the quantization parameter value QP of the previous encoded frame, estimate the current instantaneous bit rate estbr according to the bit stream of the previous encoded frame at the frame level, compare it with the dynamic bit rate threshold, determine the QP offset dqp, and sum the quantization parameter prevQp of the previous frame and the offset dqp to obtain the QP of the current frame; The calculation of the dynamic bit rate threshold comprises: setting a plurality of dynamic bit rate threshold initial values ​​within the bit rate fluctuation range, and setting a bit rate offset for increasing and decreasing the dynamic bit rate threshold; after encoding each frame of an image, for a dynamic bit rate threshold greater than a target bit rate tgtbr, subtracting the reduced bit rate offset from the current value, and for a dynamic bit rate threshold less than the target bit rate tgtbr, adding the increased bit rate offset to the current value; The process of determining the QP offset dqp includes: comparing the instantaneous estimated bit rate estbr and the encoded bit rate encbr with the dynamic bit rate threshold respectively to obtain the current instantaneous estimated bit rate level cur_brlvl and the current encoded bit rate level enc_brlvl, retaining the instantaneous estimated bit rate level prev_brlvl of the previous frame, the instantaneous estimated bit rate level characterizing the degree of deviation between the instantaneous estimated bit rate and the target bit rate: the larger the positive value, the more it exceeds the target bit rate, and the larger the negative value, the more it falls below the target bit rate; taking the maximum value of the instantaneous estimated bit rate level prev_brlvl of the previous frame and the current encoded bit rate level enc_brlvl as cmp _brlvl is used to compare with the current instantaneous estimated bit rate level cur_brlvl, and the comparison result represents the trend of bit rate change; when the current instantaneous estimated bit rate level cur_brlvl is positive and the bit rate has an increasing trend, the QP offset dqp is determined to be a positive number, and the larger the current instantaneous estimated bit rate level cur_brlvl is or the stronger the bit rate increasing trend is, the larger the QP offset dqp value is; when the current instantaneous estimated bit rate level cur_brlvl is negative and the bit rate has a decreasing trend, the QP offset is determined to be a negative number, and the larger the current instantaneous estimated bit rate level cur_brlvl is or the stronger the bit rate decreasing trend is, the smaller the QP offset dqp value is.

2. A bit rate control method for real-time monitoring scenarios according to claim 1, characterized in that: The different scenes are surveillance video scenes, which are divided into 7 groups of scenes, namely, still scene, general scene, still to moving scene, moving scene, moving to still scene, violent moving scene, and scene switching.

3. A bit rate control method for real-time monitoring scenarios according to claim 2, characterized in that: The step S1 further includes: given a GOP-level target bit rate tgtbr, dividing the surveillance video scenes into 7 groups of scenes according to the bit rate fluctuation characteristics, and setting a group of bit rate fluctuation ranges minbr to maxbr that can be tolerated by users according to the characteristics of different scenes.

4. The bit rate control method for real-time monitoring scenarios according to claim 3 is characterized in that: The fluctuation range can be obtained by setting the upper and lower limits of the bit rate fluctuation: maxbrRatio[7]={105,107,110,115,110,120,125}; Set the lower limit ratio of bit rate fluctuation minbrRatio[7]={95,93,90,90,90,95,95}; The calculation method for the allowed bitrate fluctuation range when the scene type mark index value of the current frame is sce is as follows: maxbr=tgtbr·maxbrRatio[sce] / 100 minbr=tgtbr·minbrRatio[sce] / 100.

5. The bit rate control method for real-time monitoring scenarios according to claim 1, characterized in that: The step S2 further comprises: S2.1, Calculation of instantaneous estimated bit rate Encoded bit rate: encbr = encbs / gopTime Instantaneous estimated bit rate: estbr=(encbs+predbs·(gopsize-frmcnt)) / gopTime Current frame prediction stream: ; Where encbs is the sum of the bitstreams of the encoded frames in the current GOP, predbs is the weighted sum of the bitstreams of the three frames closest to the current frame to be encoded, frmbs[3], and w i is the frame code stream weight; gopsize indicates the total number of frames in the current GOP, frmcnt indicates the number of frames that have been encoded; gopTime indicates the time required to encode a GOP; S2.2, Calculation of dynamic bitrate threshold It is assumed that at most three dynamic bit rate threshold curves are divided between the target bit rate tgtbr and the maximum bit rate fluctuation range maxbr, and at most three dynamic bit rate threshold curves are divided between the minimum bit rate fluctuation range minbr and the target bit rate tgtbr; The starting value of the dynamic bitrate threshold is determined by the slope of the dynamic maximum bitrate threshold and the slope of the dynamic minimum bitrate threshold: Set the slope of the dynamic maximum bitrate threshold DmaxbrSlope[4][7]={{30,30,40,40,50,60,60}, {50,50,60,60,70,75,75}, {80,80,80,80,90,95,95}, {100,100,100,100,100,100,100}} Set the slope of the dynamic minimum bitrate threshold DminbrSlope[4][7]={{80,80,80,80,90,95,95}, {50,50,60,60,70,75,75}, {30,30,40,40,50,60,60}, {0,0,0,0,0,0,0}} The initial value of the dynamic bit rate threshold can be calculated by the following formula: DmaxbrInit[i]=tgtbr+(maxbr-tgtbr)*DmaxbrSlope[i][sce] / 100,i=0,1,2,3 Dmin brInit[i]=min br+(tgtbr-minbr)*DminbrSlope[i][sce] / 100,i=0,1,2,3 The bitrate offset for increasing and decreasing the dynamic bitrate threshold is: upDltbr=DmaxbrSlope[0][sce]·(maxbr-tgtbr) / gopsize dwDltbr=DminbrSlope[2][sce]·(tgtbr-minbr) / gopsize After each frame of image is encoded, 8 new dynamic bitrate thresholds can be calculated according to the following formula: Dmaxbr[i]=DmaxbrInit[i]-frmcnt·upDltbr,i=0,1,2,3 Dminbr[i]=DminbrInit[i]+frmcnt·upDltbr,i=0,1,2,3 Calculate the minimum achievable coding bitrate Dmin_est_br = encbr + min_rem_br, where the dynamic minimum remaining bitrate min_rem_br can be obtained from the given value and the remaining number of frames; constrain the dynamic bitrate threshold according to the encoded bitrate encbr and the minimum achievable coding bitrate Dmin_est_br; S2.3, QP adjustment method Use dqp1 related to prevQp and dqp2 related to frmcnt to correct the obtained dqp above: Correction offset: ; Correction offset: ; The corrected QP offset: adjDqp = dqp + dqp1 + dqp2 At this time, the QP of the current frame can be calculated as prevQp + adjDqp, and then the QP is restricted between the given limit parameters MinQp and MaxQp to obtain the encoding QP of the current frame.

6. A bit rate control method for real-time monitoring scenarios according to claim 5, characterized in that: In the step S2.2, if the tolerance for the previous bitrate fluctuation is greater, the dynamic threshold curve is steeper and the number of divided levels is less; on the contrary, it is flatter and the number of divided levels is more; the greater the ratio deviation of the allowable fluctuation upper and lower limits of the bitrate, the more the number of dynamic threshold curves.

7. The bit rate control method for real-time monitoring scenarios according to claim 5, characterized in that: In the step S2.2, the constraint of the dynamic bitrate threshold according to the encoded bitrate encbr and the minimum achievable coding bitrate Dmin_est_br further includes: When Dmaxbr[3] < estbr, Dmaxbr[3] takes the maximum value of Dmaxbr[3] and Dmin_est_br; When Dmaxbr[2] < estbr < Dmaxbr[3], Dmaxbr[2] takes the maximum value of Dmaxbr[2] and Dmin_est_br; When Dmaxbr[1] < estbr < Dmaxbr[2], Dmaxbr[1] takes the maximum value of Dmaxbr[1] and Dmin_est_br; When Dmaxbr[0] < estbr < Dmaxbr[1], Dmaxbr[0] takes the maximum value of Dmaxbr[0] and Dmin_est_br; When Dminbr[0] < estbr < Dmaxbr[0], Dminbr[0] takes the maximum value of Dminbr[0] and Dmin_est_br; When Dminbr[1] < estbr < Dminbr[0], Dminbr[1] takes the maximum value of Dminbr[1] and Dmin_est_br; When Dminbr[2] < estbr < Dminbr[1], Dminbr[2] takes the maximum value of Dminbr[2] and Dmin_est_br; When estbr < Dminbr[2], Dminbr[3] takes the maximum value of Dminbr[3] and Dmin_est_br.

8. The bit rate control method for real-time monitoring scenarios according to claim 5, characterized in that: In the step S2.3, determine the QP offset dqp according to the current instantaneous estimated bitrate level cur_brlvl and cmp_brlvl, as shown in the following table: 。

Citation Information

Patent Citations

  • Scene self-adaptive screen encoding rate control method and system

    CN102625106A

  • Video encoding method and video encoder

    CN107846590A