A code rate control method, device, electronic device and storage medium
By building a code control module outside the hardware encoder, estimating the complexity and quality coefficient of the video frame, and predicting the quantization parameter offset of the coding block, the problem of low coding efficiency caused by the hardware encoder's inability to perform pre-analysis is solved, and more efficient video encoding is achieved.
Patent Information
- Application Number
- CN202510927576.0
- Authority / Receiving Office
- CN · China
- Patent Type
- Patents(China)
- Current Assignee / Owner
- Filing Date
- 2025-07-07
- Publication Date
- 2025-09-19
- Estimated Expiration
- 2045-07-07
AI Technical Summary
In surveillance video scenarios, since the hardware encoder cannot obtain pre-analyzed frame video information, video bit rate control can basically only use constant QP mode or constant bit rate mode, and the video compression efficiency is not high.
By combining software and hardware, a code control module independent of the hardware encoder is built. The frame-level complexity and constant quality coefficient of the video frame are estimated based on the encoding information, the block-level quantization parameter offset of each encoding block is predicted, and then passed to the hardware encoder for encoding.
It effectively improves the encoding efficiency of hardware encoding and overcomes the limitation that the hardware encoder cannot pre-analyze video frames.
Smart Images

Figure CN120434392B_ABST
Abstract
Description
Technical Field
[0001] The present invention relates to the field of video coding technology, and in particular to a rate control method, device, electronic device and storage medium. Background Art
[0002] With the rapid development of network communications and video processing technologies, video surveillance is increasingly being used in all aspects of our lives, such as banks, subways, roads, and community monitoring. Surveillance video encoding typically uses hardware encoders due to power consumption and speed constraints. However, in surveillance video scenarios, hardware design limitations preclude the acquisition of pre-analyzed frame information. Consequently, video bitrate control is limited to constant QP mode or constant bitrate mode, resulting in low video compression efficiency. Summary of the Invention
[0003] Since the existing methods have the above-mentioned problems, the embodiments of the present invention provide a rate control method, device, electronic device and storage medium.
[0004] Specifically, the embodiments of the present invention provide the following technical solutions:
[0005] In a first aspect, an embodiment of the present invention provides a rate control method, including:
[0006] Estimate the frame-level complexity cplx and constant quality coefficient factor of the current video frame based on the encoding information.
[0007] The frame-level quantization parameter QP of the current video frame is obtained according to the frame-level complexity cplx of the current video frame and the constant quality coefficient factor f .
[0008] Predict the block-level quantization parameter offset offset for each coding block in the current video frame.
[0009] The current video frame level quantization parameter QP f The block-level quantization parameter QP of each coding block in the current video frame is added to the block-level quantization parameter offset of each coding block in the current video frame to obtain the block-level quantization parameter QP of each coding block in the current video frame. mb .
[0010] The block-level quantization parameter QP mb Pass in the hardware encoder and use it to encode each encoding block of the current video frame.
[0011] In a second aspect, an embodiment of the present invention provides a rate control device, including:
[0012] The first calculation module is used to estimate the frame level complexity cplx and the constant quality coefficient factor of the current video frame according to the encoding information.
[0013] The second calculation module is used to obtain the frame-level quantization parameter QP of the current video frame according to the frame-level complexity cplx of the current video frame and the constant quality coefficient factor f .
[0014] The third calculation module is used to predict the block-level quantization parameter offset of each coding block in the current video frame.
[0015] The fourth calculation module is used to calculate the frame-level quantization parameter QP of the current video frame f The block-level quantization parameter QP of each coding block in the current video frame is added to the block-level quantization parameter offset of each coding block in the current video frame to obtain the block-level quantization parameter QP of each coding block in the current video frame. mb .
[0016] The encoding module is used to convert the block-level quantization parameter QP mb Pass in the hardware encoder and use it to encode each encoding block of the current video frame.
[0017] In a third aspect, an embodiment of the present invention further provides an electronic device comprising a memory, a processor, and a computer program stored in the memory and executable on the processor, wherein the processor implements the bit rate control method as described in the first aspect when executing the computer program.
[0018] In a fourth aspect, an embodiment of the present invention further provides a non-transitory computer-readable storage medium having a computer program stored thereon, which, when executed by a processor, implements the rate control method as described in the first aspect.
[0019] As can be seen from the above solution, the technical solution provided by the embodiment of the present invention has the following beneficial effects: by combining software and hardware, a code control module is built that is independent of the hardware encoder, overcoming the problem that the hardware encoder cannot pre-analyze video frames and can only set a constant bit rate mode. The technical solution provided by this application effectively improves the encoding efficiency of hardware encoding. BRIEF DESCRIPTION OF THE DRAWINGS
[0020] Figure 1 This is a flow chart of a rate control method provided by one embodiment of the present invention.
[0021] Figure 2 A schematic structural diagram of a rate control device provided by an embodiment of the present invention.
[0022] Figure 3 A schematic structural diagram of an electronic device provided by an embodiment of the present invention. DETAILED DESCRIPTION
[0023] The following embodiments of the present invention are further described in conjunction with the accompanying drawings. The following embodiments are only used to more clearly illustrate the technical solutions of the present invention and are not intended to limit the scope of protection of the present invention.
[0024] Figure 1 FIG. 1 shows a flow chart of a rate control method provided by an embodiment of the present invention. Figure 1 As shown, the bit rate control method provided by the embodiment of the present invention specifically includes the following contents:
[0025] Step 1: Estimate the frame-level complexity cplx and constant quality coefficient factor of the current video frame based on the encoding information.
[0026] It should be understood that any algorithm that can calculate frame-level complexity is within the scope of this disclosure, and the embodiments of the present invention do not specifically limit the type of frame-level complexity algorithm.
[0027] For example, the frame-level complexity of the current video frame can be estimated based on the coding information, and the calculation formula is as follows:
[0028] cplx = (width / size block )* (height / size block )*a.
[0029] Among them, width and height are the width and height of the current video frame respectively; size block Indicates the size of the current video frame coding block; a represents a constant coefficient.
[0030] It should be noted that the method of dividing the coding blocks is determined by the coding standard.
[0031] The constant mass coefficient is calculated as follows:
[0032] factor = pow (cplx, b ) / (c * pow (d, (QP init - e) / f)).
[0033] Among them, cplx is the frame-level complexity of the current video frame; QP init It is the initial frame-level quantization parameter preset by the user; b, c, d, e, and f represent constant coefficients; and pow() represents a power function.
[0034] Furthermore, in another embodiment, in order to more accurately calculate the frame-level complexity of the current video frame, the frame-level complexity of the current video frame may be corrected in combination with the actual encoding information of the previous video frame, specifically including:
[0035] Set the threshold T, the value range of T is [0.5, 1).
[0036] If the ratio I > T, then cplx = cplx * (g + ratio I ).
[0037] If the ratio skip > T, then cplx = cplx * (h - ratio skip ).
[0038] Otherwise: cplx = cplx * 1.0.
[0039] Among them, ratio I Indicates the ratio of the number of intra-frame prediction coding blocks to the number of all coding blocks in the previous video frame; ratio skip It represents the ratio of the number of skip coding blocks in the previous video frame to the number of all coding blocks; cplx is the frame-level complexity of the current video frame; g and h are constant coefficients.
[0040] It is understandable that the greater the number of intra-frame prediction coding blocks in the previous video frame, the higher the complexity of the previous video frame. Therefore, generally speaking, the complexity of the current video frame adjacent to the previous video frame is also higher. Similarly, the greater the number of skip coding blocks in the previous video frame, the lower the complexity of the previous video frame. Therefore, generally speaking, the complexity of the current video frame adjacent to the previous video frame is also lower. Therefore, by using the previous video frame as a reference to correct the frame-level complexity of the current video frame, a more accurate and reasonable complexity can be obtained.
[0041] Step 2: Obtain the frame-level quantization parameter QP of the current video frame according to the frame-level complexity cplx of the current video frame and the constant quality coefficient factor. f .
[0042] The frame-level quantization parameter QP of the current video frame is obtained according to the frame-level complexity cplx of the current video frame and the constant quality coefficient factor f , the calculation formula is as follows:
[0043] QP f = pow (cplx, w) / factor.
[0044] Among them, cplx represents the frame-level complexity of the current video frame; factor represents the constant quality coefficient; pow() represents the power function; and w represents the constant coefficient.
[0045] Furthermore, in another embodiment, in order to obtain the frame-level quantization parameter of the current video frame more accurately, the frame-level quantization parameter QP of the current video frame is calculated based on the number of bits used in the prediction of the current video frame and the buffer status. f Make corrections:
[0046] Preset thresholds T1 and T2, where 0 < T2 < T1 <1.
[0047] If the ratio buffer < T1, then QP f = QP f / (2 * ratio buffer ).
[0048] If the ratio buffer < T2, then QP f = QP f / (2.5 * ratio buffer ).
[0049] If the number of bits used in the prediction of the current video frame is greater than half of the currently available buffer size, the QP f = QP f / (buffer avl / (2*bits)).
[0050] If the predicted number of bits used by the current video frame is less than half of the target number of bits used by the video frame at the target bit rate, then QP f = QP f * (bits *2 / bits tag ).
[0051] Among them, ratio buffer Indicates the ratio of the current remaining buffer size to the total buffer size; bits indicates the number of bits used for the prediction of the current video frame; buffer avl Indicates the currently available buffer size; bits tag Indicates the target number of bits used by a video frame at the target bitrate.
[0052] It should be noted that the embodiment of the present invention does not impose any restrictions on the method of predicting the number of bits used for encoding the current video frame, and the prediction can be performed according to actual conditions.
[0053] For example, the number of bits used to encode the current video frame is calculated as follows: bits = (k * cplx + m) / (QP f * t).
[0054] Among them, k, m, t represent constant coefficients less than 1; cplx represents the frame-level complexity of the current video frame; QP f Indicates the frame-level quantization parameter of the current video frame.
[0055] Step 3: predict the block-level quantization parameter offset of each coding block in the current video frame.
[0056] Specifically, the block-level quantization parameter offset of each coding block in the current video frame may be predicted using the block-level content feature information of the current video frame and / or the ROI information.
[0057] The block-level content feature information of the current video frame is represented by one or more of the following methods: gradient, variance, SATD, etc.
[0058] The content feature information is fitted to obtain a quantization parameter offset function based on the content feature information.
[0059] It should be noted that the embodiment of the present invention does not limit the specific fitting method.
[0060] Preferably, the quantization parameter offset function algorithm formula based on content feature information is: offset var =strength * [log2(max(S, 1)) - j].
[0061] Among them, j represents an empirical constant, strength represents a constant coefficient with a value range of [0, 1]; max() represents a maximum value function; S represents the block-level content feature information of the current video frame.
[0062] It should be noted that to save CPU overhead, usually only the block-level content feature information of the Y component of the video content is calculated. If the chip itself has strong performance, it is recommended to calculate the block-level content feature information of the three YUV components of the video content.
[0063] Specifically, in order to better utilize the bitrate overhead and improve coding efficiency, the block-level quantization offset of each coding block in the current video frame can be predicted in combination with ROI information, including:
[0064] The types of ROI content features that need to be recognized in the preset video, such as faces, bodies, vehicles, license plates, etc.
[0065] Preset the corresponding importance according to different ROI content feature types.
[0066] It should be noted that the embodiment of the present invention does not limit the quantification method of the importance, and it can be set according to actual conditions.
[0067] Users can customize the importance of specific ROI content features. Examples are as follows:
[0068]
[0069] Identify the type of ROI content features in the current video frame, and fit the corresponding importance to obtain a quantization parameter offset function based on the ROI information.
[0070] It should be noted that the embodiment of the present invention does not limit the specific fitting method.
[0071] Preferably, the quantization parameter offset function algorithm formula based on ROI information is: offset roi = (1-priority) * weight.
[0072] Wherein, weight is an empirical constant, and its specific value is not limited in the embodiment of the present invention. It is recommended to be set in the range of [0, 3]; priority represents the quantitative value of the importance of the ROI content feature type.
[0073] According to preset weights, the quantization parameter offset based on the content feature information and the quantization parameter offset based on the ROI information are weighted averaged to obtain the block-level quantization parameter offset of each coding block. The calculation formula is as follows:
[0074] offset = offset roi * w1 + offset var * w2.
[0075] Among them, w1 and w2 represent the preset weights, w1+w2=1; offset var Indicates the quantization parameter offset based on content feature information; offset roi Indicates the quantization parameter offset based on ROI information.
[0076] Step 4: quantize the current video frame frame level QP f The block-level quantization parameter QP of each coding block in the current video frame is added to the block-level quantization parameter offset of each coding block in the current video frame to obtain the block-level quantization parameter QP of each coding block in the current video frame. mb .
[0077] Step 5: The block-level quantization parameter QP mb Pass in the hardware encoder and use it to encode each encoding block of the current video frame.
[0078] Figure 2 FIG. 1 shows a schematic structural diagram of a rate control device according to an embodiment of the present invention. Figure 2 As shown, the bit rate control device provided by the embodiment of the present invention specifically includes the following contents:
[0079] The first calculation module is used to estimate the frame level complexity cplx and the constant quality coefficient factor of the current video frame according to the encoding information.
[0080] It should be understood that any algorithm that can calculate frame-level complexity is within the scope of this disclosure, and the embodiments of the present invention do not specifically limit the type of frame-level complexity algorithm.
[0081] For example, the frame-level complexity of the current video frame can be estimated based on the coding information, and the calculation formula is as follows:
[0082] cplx = (width / size block )* (height / size block )*a.
[0083] Among them, width and height are the width and height of the current video frame respectively; size block Indicates the size of the current video frame coding block; a represents a constant coefficient.
[0084] It should be noted that the method of dividing the coding blocks is determined by the coding standard.
[0085] The constant mass coefficient is calculated as follows:
[0086] factor = pow (cplx, b ) / (c * pow (d, (QP init - e) / f)).
[0087] Among them, cplx is the frame-level complexity of the current video frame; QP init It is the initial frame-level quantization parameter preset by the user; b, c, d, e, and f represent constant coefficients; and pow() represents a power function.
[0088] Furthermore, in another embodiment, in order to more accurately calculate the frame-level complexity of the current video frame, a first correction module is further included after the first calculation module, for correcting the frame-level complexity of the current video frame based on actual encoding information of the previous video frame, specifically comprising:
[0089] Set the threshold T, the value range of T is [0.5, 1).
[0090] If the ratio I > T, then cplx = cplx * (g + ratio I ).
[0091] If the ratio skip > T, then cplx = cplx * (h - ratio skip ).
[0092] Otherwise: cplx = cplx * 1.0.
[0093] Among them, ratio I Indicates the ratio of the number of intra-frame prediction coding blocks to the number of all coding blocks in the previous video frame; ratio skip It represents the ratio of the number of skip coding blocks in the previous video frame to the number of all coding blocks; cplx is the frame-level complexity of the current video frame; g and h are constant coefficients.
[0094] It is understandable that the greater the number of intra-frame prediction coding blocks in the previous video frame, the higher the complexity of the previous video frame. Therefore, generally speaking, the complexity of the current video frame adjacent to the previous video frame is also higher. Similarly, the greater the number of skip coding blocks in the previous video frame, the lower the complexity of the previous video frame. Therefore, generally speaking, the complexity of the current video frame adjacent to the previous video frame is also lower. Therefore, by using the previous video frame as a reference to correct the frame-level complexity of the current video frame, a more accurate and reasonable complexity can be obtained.
[0095] The second calculation module is used to obtain the frame-level quantization parameter QP of the current video frame according to the frame-level complexity cplx of the current video frame and the constant quality coefficient factor f .
[0096] The frame-level quantization parameter QP of the current video frame is obtained according to the frame-level complexity cplx of the current video frame and the constant quality coefficient factor f , the calculation formula is as follows:
[0097] QP f = pow (cplx, w) / factor.
[0098] Among them, cplx represents the frame-level complexity of the current video frame; factor represents the constant quality coefficient; pow() represents the power function; and w represents the constant coefficient.
[0099] Furthermore, in another embodiment, in order to obtain the frame-level quantization parameter of the current video frame more accurately, a second correction module is further included after the second calculation module, for correcting the frame-level quantization parameter QP of the current video frame according to the predicted number of bits used in the current video frame and the buffer status. f Make corrections:
[0100] Preset thresholds T1 and T2, where 0 < T2 < T1 <1.
[0101] If the ratio buffer < T1, then QP f = QP f / (2 * ratio buffer ).
[0102] If the ratio buffer < T2, then QP f = QP f / (2.5 * ratio buffer ).
[0103] If the number of bits used in the prediction of the current video frame is greater than half of the currently available buffer size, the QP f = QP f / (buffer avl / (2*bits)).
[0104] If the predicted number of bits used by the current video frame is less than half of the target number of bits used by the video frame at the target bit rate, then QP f = QP f * (bits *2 / bits tag ).
[0105] Among them, ratio buffer Indicates the ratio of the current remaining buffer size to the total buffer size; bits indicates the number of bits used for the prediction of the current video frame; buffer avl Indicates the currently available buffer size; bits tag Indicates the target number of bits used by a video frame at the target bitrate.
[0106] It should be noted that the embodiment of the present invention does not impose any restrictions on the method of predicting the number of bits used for encoding the current video frame, and the prediction can be performed according to actual conditions.
[0107] For example, the number of bits used to encode the current video frame is predicted as follows: bits = (k * cplx +m) / (QP f * t).
[0108] Among them, k, m, t represent constant coefficients less than 1; cplx represents the frame-level complexity of the current video frame; QP f Indicates the frame-level quantization parameter of the current video frame.
[0109] The third calculation module is used to predict the block-level quantization parameter offset of each coding block in the current video frame.
[0110] Specifically, the block-level quantization parameter offset of each coding block in the current video frame may be predicted using the block-level content feature information of the current video frame and / or the ROI information.
[0111] The block-level content feature information of the current video frame may be represented by one or more of the following methods: gradient, variance, SATD, etc.
[0112] The content feature information is fitted to obtain a quantization parameter offset function based on the content feature information.
[0113] It should be noted that the embodiment of the present invention does not limit the specific fitting method.
[0114] Preferably, the quantization parameter offset function algorithm formula based on content feature information is: offset var =strength * [log2(max(S, 1)) - j].
[0115] Among them, j represents an empirical constant, strength represents a constant coefficient with a value range of [0, 1]; max() represents a maximum value function; S represents the block-level content feature information of the current video frame.
[0116] It should be noted that to save CPU overhead, usually only the block-level content feature information of the Y component of the video content is calculated. If the chip itself has strong performance, it is recommended to calculate the block-level content feature information of the three YUV components of the video content.
[0117] Specifically, in order to better utilize the bitrate overhead and improve coding efficiency, the block-level quantization offset of each coding block in the current video frame can be predicted in combination with ROI information, including:
[0118] The types of ROI content features that need to be recognized in the preset video, such as faces, bodies, vehicles, license plates, etc.
[0119] Preset the corresponding importance according to different ROI content feature types.
[0120] It should be noted that the embodiment of the present invention does not limit the quantification method of the importance, and it can be set according to actual conditions.
[0121] Users can customize the importance of specific ROI content features. Examples are as follows:
[0122]
[0123] Identify the type of ROI content features in the current video frame, and fit the corresponding importance to obtain a quantization parameter offset function based on the ROI information.
[0124] It should be noted that the embodiment of the present invention does not limit the specific fitting method.
[0125] Preferably, the quantization parameter offset function algorithm formula based on ROI information is: offset roi = (1-priority) * weight.
[0126] Wherein, weight is an empirical constant, and its specific value is not limited in the embodiment of the present invention. It is recommended to be set in the range of [0, 3]; priority represents the quantitative value of the importance of the ROI content feature type.
[0127] According to preset weights, the quantization parameter offset based on the content feature information and the quantization parameter offset based on the ROI information are weighted averaged to obtain the block-level quantization parameter offset of each coding block. The calculation formula is as follows:
[0128] offset = offset roi * w1 + offset var * w2.
[0129] Among them, w1 and w2 represent the preset weights, w1+w2=1; offset var Indicates the quantization parameter offset based on content feature information; offset roi Indicates the quantization parameter offset based on ROI information.
[0130] The fourth calculation module is used to calculate the frame-level quantization parameter QP of the current video frame f Adding the block-level quantization parameter offset of each coding block in the current video frame to obtain the block-level quantization parameter QP of each coding block in the current video frame mb .
[0131] The encoding module is used to convert the block-level quantization parameter QP mb Pass in the hardware encoder and use it to encode each encoding block of the current video frame.
[0132] Based on the same inventive concept, another embodiment of the present invention provides an electronic device, such as Figure 3 As shown, the electronic device specifically includes the following contents: a processor 301 , a memory 302 , a communication interface 303 and a communication bus 304 .
[0133] The processor 301 , the memory 302 , and the communication interface 303 communicate with each other via the communication bus 304 ; the communication interface 303 is used to implement information transmission between various devices.
[0134] The processor 301 is configured to call the computer program in the memory 302 , and the processor implements all steps of the above-mentioned rate control method when executing the computer program.
[0135] Based on the same inventive concept, another embodiment of the present invention provides a non-transitory computer-readable storage medium having a computer program stored thereon. When the computer program is executed by a processor, all steps of the above-mentioned rate control method are implemented.
[0136] In addition, in the embodiments of the present invention, relational terms such as "first" and "second" are merely used to distinguish one entity or operation from another entity or operation, and do not necessarily require or imply any such actual relationship or order between these entities or operations. In the description of this specification, descriptions such as "in one embodiment" and "in another embodiment" mean that the specific features, structures, materials or characteristics described in conjunction with the embodiment are included in at least one embodiment of the present invention. In this specification, the schematic representations of the above terms do not necessarily refer to the same embodiment. Moreover, the specific features, structures, materials or characteristics described can be combined in an appropriate manner in any one or more embodiments. In addition, those skilled in the art can combine and combine the different embodiments described in this specification and the features of the different embodiments, unless they are contradictory.
[0137] Finally, it should be noted that the above embodiments are only used to illustrate the technical solutions of the present invention, rather than to limit it. Although the present invention has been described in detail with reference to the aforementioned embodiments, those skilled in the art should understand that they can still modify the technical solutions described in the aforementioned embodiments, or make equivalent replacements for some of the technical features therein. However, these modifications or replacements do not deviate the essence of the corresponding technical solutions from the spirit and scope of the technical solutions of the various embodiments of the present invention.
Claims
1. A rate control method, characterized in that: include: Estimate the frame-level complexity cplx and constant quality factor of the current video frame based on the encoding information; The frame-level quantization parameter QP of the current video frame is obtained according to the frame-level complexity cplx of the current video frame and the constant quality coefficient factor f ; Predict the block-level quantization parameter offset of each coding block in the current video frame; Predicting the block-level quantization parameter offset of each coding block in the current video frame using the block-level content feature information of the current video frame and / or the ROI information, including: The block-level content feature information of the current video frame is represented by one or more of the following methods: gradient, variance, SATD; Fitting the content feature information to obtain a quantization parameter offset function based on the content feature information; Preset the types of ROI content features that need to be identified in the video and their corresponding importance; Identify the type of ROI content features in the current video frame and fit the corresponding importance to obtain a quantization parameter offset function based on the ROI information; According to preset weights, a weighted average is performed on the quantization parameter offset based on the content feature information and the quantization parameter offset based on the ROI information to obtain a block-level quantization parameter offset of each coding block in the current video frame; The current video frame level quantization parameter QP f Adding the block-level quantization parameter offset of each coding block in the current video frame to obtain the block-level quantization parameter QP of each coding block in the current video frame mb ; The block-level quantization parameter QP mb Pass in the hardware encoder and use it to encode each encoding block of the current video frame.
2. The rate control method according to claim 1, wherein: The constant mass coefficient is calculated as follows: factor = pow (cplx, b ) / (c * pow (d, (QP init - e) / f)); Among them, cplx is the frame-level complexity of the current video frame; QP init It is the initial frame-level quantization parameter preset by the user; b, c, d, e, and f represent constant coefficients; and pow() represents a power function.
3. The rate control method according to claim 1, wherein: After estimating the frame-level complexity of the current video frame according to the coding information, the frame-level complexity cplx of the current video frame is modified according to the actual coding information of the previous video frame: Set the threshold T, the value range of T is [0.5, 1); If the ratio I > T, then cplx = cplx * (g + ratio I ); If the ratio skip > T, then cplx = cplx * (h - ratio skip ); Otherwise: cplx = cplx * 1.0; Among them, ratio I Indicates the ratio of the number of intra-frame prediction coding blocks to the number of all coding blocks in the previous video frame; ratio skip It represents the ratio of the number of skip coding blocks in the previous video frame to the number of all coding blocks; cplx is the complexity of the current video frame; g and h are constant coefficients.
4. The rate control method according to claim 1, wherein: The frame-level quantization parameter QP of the current video frame is obtained according to the frame-level complexity cplx of the current video frame and the constant quality coefficient factor f , the calculation formula is as follows: QP f = pow (cplx, w) / factor; Among them, cplx represents the frame-level complexity of the current video frame; factor represents the constant quality coefficient; pow() represents the power function; and w represents the constant coefficient.
5. The rate control method according to claim 1, wherein: In the above method, the frame-level quantization parameter QP of the current video frame is obtained. f After that, it also includes the frame-level quantization parameter QP of the current video frame according to the predicted number of bits used in the current video frame and the buffer state. f Make corrections, including: Preset thresholds T1 and T2, where 0 < T2 < T1 < 1; If the ratio buffer < T1, then QP f = QP f / (2 * ratio buffer ); If the ratio buffer < T2, then QP f = QP f / (2.5 * ratio buffer ); If the number of bits used in the prediction of the current video frame is greater than half of the currently available buffer size, the QP f =QP f / (buffer avl / (2*bits)); If the predicted number of bits used by the current video frame is less than half of the target number of bits used by the video frame at the target bit rate, the QP f = QP f * (bits *2 / bits tag ); Among them, ratio buffer Indicates the ratio of the current remaining buffer size to the total buffer size; bits indicates the number of bits used for the prediction of the current video frame; buffer avl Indicates the currently available buffer size; bits tag Indicates the target number of bits used by a video frame at the target bitrate.
6. A rate control device, characterized in that: include: The first calculation module is used to estimate the frame level complexity cplx and the constant quality coefficient factor of the current video frame according to the encoding information; The second calculation module is used to obtain the frame-level quantization parameter QP of the current video frame according to the frame-level complexity cplx of the current video frame and the constant quality coefficient factor f ; The third calculation module is used to predict the block-level quantization parameter offset of each coding block in the current video frame; Predicting the block-level quantization parameter offset of each coding block in the current video frame using the block-level content feature information of the current video frame and / or the ROI information, including: The block-level content feature information of the current video frame is represented by one or more of the following methods: gradient, variance, SATD; Fitting the content feature information to obtain a quantization parameter offset function based on the content feature information; Preset the types of ROI content features that need to be identified in the video and their corresponding importance; Identify the type of ROI content features in the current video frame and fit the corresponding importance to obtain a quantization parameter offset function based on the ROI information; According to preset weights, a weighted average is performed on the quantization parameter offset based on the content feature information and the quantization parameter offset based on the ROI information to obtain a block-level quantization parameter offset of each coding block in the current video frame; The fourth calculation module is used to calculate the frame-level quantization parameter QP of the current video frame f The block-level quantization parameter QP of each coding block in the current video frame is added to the block-level quantization parameter offset of each coding block in the current video frame to obtain the block-level quantization parameter QP of each coding block in the current video frame. mb ; The encoding module is used to convert the block-level quantization parameter QP mb Pass in the hardware encoder and use it to encode each encoding block of the current video frame.
7. The bit rate control device according to claim 6, wherein: The constant mass coefficient is calculated as follows: factor = pow (cplx, b ) / (c * pow (d, (QP init - e) / f)); Among them, cplx is the frame-level complexity of the current video frame; QP init It is the initial frame-level quantization parameter preset by the user; b, c, d, e, and f represent constant coefficients; and pow() represents a power function.
8. The bit rate control device according to claim 6, wherein: A first correction module is further included after the first calculation module, for correcting the frame-level complexity cplx of the current video frame according to actual coding information of the previous video frame, including: Set the threshold T, the value range of T is [0.5, 1); If the ratio I > T, then cplx = cplx * (g + ratio I ); If the ratio skip > T, then cplx = cplx * (h - ratio skip ); Otherwise: cplx = cplx * 1.0; Among them, ratio I Indicates the ratio of the number of intra-frame prediction coding blocks to the number of all coding blocks in the previous video frame; ratio skip It represents the ratio of the number of skip coding blocks in the previous video frame to the number of all coding blocks; cplx is the complexity of the current video frame; g and h are constant coefficients.
9. The bit rate control device according to claim 6, wherein: The frame-level quantization parameter QP of the current video frame is obtained according to the frame-level complexity cplx of the current video frame and the constant quality coefficient factor f , the calculation formula is as follows: QP f = pow (cplx, w) / factor; Where cplx represents the frame-level complexity of the current video frame; factor represents the constant quality coefficient; pow() represents the power function; and w represents the constant coefficient.
10. The bit rate control device according to claim 6, wherein: A second correction module is also included after the second calculation module, for adjusting the frame-level quantization parameter QP of the current video frame according to the predicted number of bits used in the current video frame and the buffer state. f Make corrections: Preset thresholds T1 and T2, where 0 < T2 < T1 < 1; If the ratio buffer < T1, then QP f = QP f / (2 * ratio buffer ); If the ratio buffer < T2, then QP f = QP f / (2.5 * ratio buffer ); If the number of bits used in the prediction of the current video frame is greater than half of the currently available buffer size, the QP f =QP f / (buffer avl / (2*bits)); If the predicted number of bits used by the current video frame is less than half of the target number of bits used by the video frame at the target bit rate, the QP f = QP f * (bits *2 / bits tag ); Among them, ratio buffer Indicates the ratio of the current remaining buffer size to the total buffer size; bits indicates the number of bits used for the prediction of the current video frame; buffer avl Indicates the currently available buffer size; bits tag Indicates the target number of bits used by a video frame at the target bitrate.
11. An electronic device comprising a memory, a processor, and a computer program stored in the memory and executable on the processor, wherein: When the processor executes the computer program, the rate control method according to any one of claims 1 to 5 is implemented.
12. A non-transitory computer-readable storage medium having a computer program stored thereon, characterized in that: When the computer program is executed by a processor, the rate control method according to any one of claims 1 to 5 is implemented.
Citation Information
Patent Citations
Constant quality video coding
CN106170979A
Code rate control and video coding method and device, live broadcast system, equipment and medium
CN119854498A