Rate control method, device, electronic device, storage medium and program product
By dividing the video sequence into image groups and using a linear model to predict the bit rate, the delay and resource consumption problems caused by dynamic bit rate allocation are solved, and flexible bit rate control is achieved without increasing hardware costs.
Patent Information
- Application Number
- CN202411462486.0
- Authority / Receiving Office
- CN · China
- Patent Type
- Patents(China)
- Current Assignee / Owner
- Filing Date
- 2024-10-18
- Publication Date
- 2025-10-03
- Estimated Expiration
- 2044-10-18
AI Technical Summary
In existing video coding technologies, dynamic bit rate allocation methods increase end-to-end latency and hardware resource consumption, leading to increased hardware costs.
The video sequence is divided into multiple image groups, each of which includes multiple consecutive frames. A linear model is used to predict the predicted bit rate of each image group. The bit rate is controlled by updating the parameters within the image group, avoiding the use of a pre-processing module.
Variable bit rate control is achieved, avoiding extra resource consumption and delay without increasing hardware costs.
Smart Images

Figure CN119402655B_ABST
Abstract
Description
Technical Field
[0001] The present disclosure relates to the field of video coding technology, and in particular to a rate control method, device, electronic device, storage medium, and program product. Background Art
[0002] Video coding is mainly about compressing video data to reduce the required storage space and transmission bandwidth. In the video coding process, bit rate control is a key point, which can affect the image quality and compression efficiency of the compressed video.
[0003] In the related art, dynamic bit rate allocation is used for bit rate control. This method requires a pre-processing module to analyze the differences between the previous and next frames of the image, thereby allocating different bit rates to the image frames according to the changes in the image picture. However, when the pre-processing module performs image analysis on the image frames, the end-to-end delay will be increased. Moreover, under the same hardware performance, adding a pre-processing module will introduce additional resource consumption or increase additional hardware costs. Summary of the Invention
[0004] To overcome the problems existing in the related art, the present disclosure provides a rate control method, device, electronic device, storage medium and program product to achieve variable bit rate rate control without significantly increasing resource consumption and delay.
[0005] According to a first aspect of an embodiment of the present disclosure, a rate control method is provided, comprising: dividing a video sequence into a plurality of image groups, each image group comprising a plurality of temporally continuous image frames; determining a predicted bitrate corresponding to each image group and a first parameter of each image group, the first parameter being a slope of a linear model, the linear model being used to predict a predicted bitrate of an i-th predicted frame in each image group, where i is an integer greater than 1; determining a predicted bitrate of a first predicted frame in each image group based on the predicted bitrate corresponding to each image group and the number of frames of the plurality of images included in each image group; and performing the following steps for the i-th predicted frame in each image group: updating a second parameter of the i-th predicted frame based on a second parameter of an i-1-th predicted frame in each image group, the predicted bitrates of all predicted frames in the preceding i-1 predicted frames, actual bitrates of all predicted frames, and the number of frames of the plurality of images included in each image group, the second parameter being an intercept of the linear model; and determining a predicted bitrate corresponding to the i-th predicted frame of each image group based on the first parameter of each image group, the predicted bitrate of the i-1-th predicted frame of each image group, and the second parameter of the i-th predicted frame of each image group.
[0006] In some embodiments, the predicted bit rate corresponding to the i-th predicted frame of each image group is determined based on the first parameter of each image group, the predicted bit rate of the i-1th predicted frame of each image group, and the second parameter of the i-th predicted frame of each image group, including: obtaining a first product between the first parameter of each image group and the predicted bit rate of the i-1th predicted frame of each image group; summing the first product and the second parameter of the i-th predicted frame of each image group to obtain the predicted bit rate corresponding to the i-th predicted frame of each image group.
[0007] In some embodiments, determining the first parameter of each image group includes: for the first image group, determining a first preset value as the first parameter of the first image group; for the non-first image group, determining the first parameter of the non-first image group based on the first parameter of the previous image group of the non-first image group, the actual bit rate of the previous image group, and the predicted bit rate of the previous image group.
[0008] In some embodiments, determining the first parameter of the non-first image group based on the first parameter of the previous image group of the non-first image group, the actual bit rate of the previous image group, and the predicted bit rate of the previous image group includes: obtaining a second product of the first parameter of the previous image group of the non-first image group and the actual bit rate of the previous image group; dividing the second product by the predicted bit rate of the previous image group to obtain the first parameter of the non-first image group.
[0009] In some embodiments, based on the second parameter of the i-1th predicted frame in each image group, the predicted bit rates of all predicted frames in the first i-1 predicted frames, the actual bit rates of all predicted frames, and the number of frames of the multi-frame images included in each image group, the second parameter of the i-th predicted frame is updated, including: determining the bit rate difference of all predicted frames based on the predicted bit rates of all predicted frames in the first i-1 predicted frames and the actual bit rates of all predicted frames; dividing the bit rate difference by the number of frames of the multi-frame images included in each image group to obtain the average bit rate difference of all predicted frames; obtaining the sum of the second parameter of the i-1th predicted frame in each image group and the average bit rate difference to obtain the second parameter of the i-1th predicted frame; wherein the second parameter of the first predicted frame is a second preset value.
[0010] In some embodiments, determining the predicted bit rate corresponding to each image group includes: for the first image group, determining the predicted bit rate corresponding to the first image group based on a first preset bit rate, the number of frames of multiple frames included in the first image group, and the frame rate; for the non-first image group, determining the predicted bit rate corresponding to the non-first image group based on the average intra-frame macroblock coding ratio of the previous image group of the non-first image group, a second preset bit rate, and a third preset bit rate, the second preset bit rate is greater than the first preset bit rate, and the first preset bit rate is greater than the third preset bit rate.
[0011] In some embodiments, the predicted bit rate corresponding to the non-first image group is determined based on the average intra-frame macroblock coding ratio of the previous image group of the non-first image group, the second preset bit rate and the third preset bit rate, including: obtaining the difference between the second preset bit rate and the third preset bit rate; obtaining a third product of the average intra-frame macroblock coding ratio and the difference; summing the third product and the third preset bit rate to obtain the predicted bit rate corresponding to the non-first image group.
[0012] In some embodiments, the above method also includes: obtaining the ratio value of the intra-frame coded macroblocks of each predicted frame in the previous picture group that is not the first picture group in all coded macroblocks; determining the average intra-frame macroblock coding ratio of the previous picture group that is not the first picture group based on the ratio value and the number of frames of the multi-frame images included in the previous picture group.
[0013] According to a second aspect of an embodiment of the present disclosure, a bit rate control device is provided, comprising: a division module configured to divide a video sequence into a plurality of image groups, each image group including a plurality of frames of images that are continuous in time; a first determination module configured to determine a predicted bit rate corresponding to each image group and a first parameter of each image group, the first parameter being a slope of a linear model, the linear model being used to predict a predicted bit rate of an i-th predicted frame in each image group, where i is an integer greater than 1; a second determination module configured to determine, based on the predicted bit rate corresponding to each image group and the number of frames of the plurality of frames included in each image group, the predicted bit rate of the first predicted frame in each image group. A predicted bit rate of a predicted frame; a third determination module is configured to perform the following steps for the i-th predicted frame in each image group: updating the second parameter of the i-th predicted frame based on the second parameter of the i-1-th predicted frame in each image group, the predicted bit rates of all predicted frames in the first i-1 predicted frames, the actual bit rates of all predicted frames, and the number of frames of the multi-frame image, where the second parameter is the intercept of the linear model; and determining the predicted bit rate corresponding to the i-th predicted frame of each image group according to the first parameter of each image group, the predicted bit rate of the i-1-th predicted frame of each image group, and the second parameter of the i-th predicted frame of each image group.
[0014] In some embodiments, the third determination module is configured to: obtain a first product between the first parameter of each image group and the predicted bit rate of the i-1th predicted frame of each image group; sum the first product and the second parameter of the i-th predicted frame of each image group to obtain the predicted bit rate corresponding to the i-th predicted frame of each image group.
[0015] In some embodiments, the first determination module includes a first determination submodule and a second determination submodule; the first determination submodule is configured to: for the first image group, determine the first preset value as the first parameter of the first image group; the second determination submodule is configured to: for the non-first image group, determine the first parameter of the non-first image group based on the first parameter of the previous image group of the non-first image group, the actual bit rate of the previous image group, and the predicted bit rate of the previous image group.
[0016] In some embodiments, the second determination submodule is configured to: obtain the second product of the first parameter of the previous image group that is not the first image group and the actual bit rate of the previous image group; divide the second product by the predicted bit rate of the previous image group to obtain the first parameter of the non-first image group.
[0017] In some embodiments, the third determination module is configured to: determine the rate difference of all predicted frames based on the predicted rate of all predicted frames in the first i-1 predicted frames and the actual rate of all predicted frames; divide the rate difference by the number of frames of the multi-frame images included in each image group to obtain the average rate difference of all predicted frames; obtain the sum of the second parameter of the i-1th predicted frame in each image group and the average rate difference to obtain the second parameter of the i-1th predicted frame; wherein the second parameter of the first predicted frame is a second preset value.
[0018] In some embodiments, the first determination module also includes a third determination submodule and a fourth determination submodule; the third determination submodule is configured to: for the first image group, determine the predicted bit rate corresponding to the first image group based on the first preset bit rate, the number of frames of multiple frames included in the first image group, and the frame rate; the fourth determination submodule is configured to: for the non-first image group, determine the predicted bit rate corresponding to the non-first image group based on the average intra-frame macroblock coding ratio of the previous image group of the non-first image group, the second preset bit rate, and the third preset bit rate, the second preset bit rate is greater than the first preset bit rate, and the first preset bit rate is greater than the third preset bit rate.
[0019] In some embodiments, the fourth determination submodule is configured to: obtain the difference between the second preset bit rate and the third preset bit rate; obtain the third product of the average intra-frame macroblock coding ratio and the difference; sum the third product and the third preset bit rate to obtain the predicted bit rate corresponding to the non-first image group.
[0020] In some embodiments, the above-mentioned device also includes: an acquisition module, configured to: obtain the ratio value of the intra-frame coded macroblock of each predicted frame in the previous image group that is not the first image group in all coded macroblocks; a fourth determination module, configured to: determine the average intra-frame macroblock coding ratio of the previous image group that is not the first image group based on the ratio value and the number of frames of multiple frames included in the previous image group.
[0021] According to a third aspect of an embodiment of the present disclosure, an electronic device is provided, comprising: a processor; and a memory for storing computer programs or instructions; wherein the processor executes the computer program or instructions to implement the steps in any one of the bit rate control methods in the first aspect above.
[0022] According to a fourth aspect of an embodiment of the present disclosure, a non-temporary computer-readable storage medium is provided, which stores a computer program or instructions. When the computer program or instructions in the storage medium are executed by a processor, the steps of any one of the bit rate control methods in the first aspect are implemented.
[0023] According to a fifth aspect of an embodiment of the present disclosure, a computer program product is provided, comprising a computer program or instructions, which, when executed by a processor, implements the steps of any one of the rate control methods in the first aspect.
[0024] The technical solutions provided by the embodiments of the present disclosure may have the following beneficial effects:
[0025] The method divides a video sequence into a plurality of image groups, each image group including a plurality of temporally continuous image frames; determines a predicted bit rate corresponding to each image group and a first parameter of each image group, where the first parameter is a slope of a linear model, and the linear model is used to predict the predicted bit rate of the i-th predicted frame in each image group, where i is an integer greater than 1; determines a predicted bit rate of the first predicted frame in each image group based on the predicted bit rate corresponding to each image group and the number of frames of the plurality of images included in each image group; and performs the following steps for the i-th predicted frame in each image group: updates a second parameter of the i-th predicted frame based on a second parameter of the i-1-th predicted frame in each image group, the predicted bit rates of all predicted frames in the first i-1 predicted frames, the actual bit rates of all predicted frames, and the number of frames of the plurality of images included in each image group, where the second parameter is an intercept of the linear model; and determines a predicted bit rate corresponding to the i-th predicted frame of each image group based on the first parameter of each image group, the predicted bit rate of the i-1-th predicted frame of each image group, and the second parameter of the i-th predicted frame of each image group. In this way, the predicted bit rate of the next predicted frame is determined based on the predicted bit rate of the previous predicted frame, the first parameter and the second parameter of the linear model, which can realize the variable bit rate control of the predicted frame. At the same time, since this solution does not involve a pre-processing module, it will not introduce additional resource consumption and delay, nor will it increase hardware costs.
[0026] It is to be understood that the foregoing general description and the following detailed description are exemplary and explanatory only and are not restrictive of the disclosure. BRIEF DESCRIPTION OF THE DRAWINGS
[0027] The accompanying drawings, which are incorporated in and constitute a part of this specification, illustrate embodiments consistent with the present disclosure and, together with the description, serve to explain the principles of the present disclosure.
[0028] Figure 1 is a flow chart showing a rate control method according to an exemplary embodiment;
[0029] Figure 2 is a schematic diagram showing an image group according to an exemplary embodiment;
[0030] Figure 3 is a flow chart showing a rate control method according to an exemplary embodiment;
[0031] Figure 4 is a block diagram of a rate control device according to an exemplary embodiment;
[0032] Figure 5 is a structural block diagram of an electronic device 500 according to an exemplary embodiment;
[0033] Figure 6 is a block diagram of a server 600 according to an exemplary embodiment. DETAILED DESCRIPTION
[0034] Exemplary embodiments will be described in detail herein, examples of which are illustrated in the accompanying drawings. In the following description, when referring to the drawings, identical numerals in different figures represent identical or similar elements unless otherwise indicated. The embodiments described in the following exemplary embodiments are not intended to represent all embodiments consistent with the present disclosure. Rather, they are merely examples of devices consistent with certain aspects of the present disclosure, as detailed in the appended claims.
[0035] In the field of video coding technology, there are two main rate control strategies: constant bitrate (CBR) and variable bitrate (VBR), depending on whether the bitrate is consistent within a unit of time.
[0036] Bitrate control mainly consists of two parts: bit allocation and quantization parameter (QP) adjustment. In the bitrate allocation process, there are two main methods: average bitrate allocation and dynamic bitrate allocation.
[0037] Among them, average bit rate allocation is to divide the preset bit rate (the bit rate is pre-set and the present disclosure does not limit its value) by the frame rate to obtain the bit rate of each frame image. Since the bit rate of each frame image is fixed, this will result in a poor quality of the encoded image when the scene switches. Therefore, this method is simple but lacks flexibility; dynamic bit rate allocation requires a pre-processing module to analyze the difference between the previous and next frames of the image, so as to allocate different bit rates to each frame image according to the changes in the image picture, thereby achieving more flexible bit rate control, that is: dynamic bit rate allocation is to determine whether the image is static or dynamic through the pre-processing module, so as to allocate different bit rates to different images. However, introducing a pre-processing module in the encoding process has the following two major disadvantages:
[0038] 1. Introducing delay: The pre-processing module needs to perform image analysis on each input frame, which increases the end-to-end delay.
[0039] 2. Increased cost: Under the same hardware performance, adding a pre-processing module will introduce additional resource consumption. If pre-processing is done through software, it will increase the burden on the central processing unit (CPU). If pre-processing is done through hardware, it will increase additional hardware costs.
[0040] Figure 1 FIG. 1 is a flow chart showing a method for bit rate control according to an exemplary embodiment. Figure 1 As shown, the rate control method can be applied to electronic devices, and the method mainly includes the following steps:
[0041] In step 101 , a video sequence is divided into a plurality of image groups, each of which includes a plurality of temporally continuous image frames.
[0042] In step 102, a prediction bit rate corresponding to each group of pictures and a first parameter of each group of pictures are determined.
[0043] In step 103, the predicted bit rate of the first predicted frame in each image group is determined according to the predicted bit rate corresponding to each image group and the number of frames of the multi-frame images included in each image group.
[0044] In step 104, the second parameter of the i-th prediction frame is updated based on the second parameter of the i-1-th prediction frame in each image group, the predicted bit rates of all prediction frames in the first i-1 prediction frames, the actual bit rates of all prediction frames, and the number of frames of the multi-frame images included in each image group.
[0045] In step 105, the predicted bit rate corresponding to the i-th predicted frame of each image group is determined according to the first parameter of each image group, the predicted bit rate of the i-1th predicted frame of each image group, and the second parameter of the i-th predicted frame of each image group.
[0046] Here, the video sequence can be any coded video sequence. The number of frames of the multiple frames included in each group of pictures (GOP, also called picture group) can be the same, such as the number of frames corresponding to the frame rate (frames per second, fps), or they can be different, and the present disclosure does not limit this. The number of frames of the multiple frames included in each image group can also be called the length of each image group. The first parameter is the slope of the linear model, which is used to predict the predicted bit rate of the i-th predicted frame in each image group, where i is an integer greater than 1. The second parameter is the intercept of the linear model.
[0047] In some embodiments, for step 101, the electronic device may divide the video sequence into multiple image groups according to the number of frames per second (fps), or may evenly divide all images included in the video sequence into multiple image groups according to a preset number of image groups. The division may also be performed in other ways, which are not limited by the present disclosure. In this way, each resulting image group includes multiple temporally consecutive frames of images.
[0048] Figure 2 FIG. 1 is a schematic diagram showing an image group according to an exemplary embodiment. Figure 2 As shown in FIG, two GOPs are used as an example to illustrate the GOPs. The first GOP includes an intra-coded picture (I-frame), the first predicted frame (P-frame), the second P-frame, ..., the m-th P-frame (m is an integer greater than 2); the second GOP includes an I-frame, the first P-frame, the second P-frame, ..., the n-th P-frame (n is an integer greater than 2).
[0049] It should be noted that the starting frame in each image group is the I frame. Figure 2 The types of image frames included in the illustrated image groups are merely examples. Adjacent P frames may also include bidirectionally predicted pictures (B frames) or other types of frames, which are not limited in this disclosure. m and n may be the same or different, which is not limited in this disclosure.
[0050] In some embodiments, for step 102 , in order to predict the bit rate of each predicted frame included in each group of pictures, it is necessary to first determine the predicted bit rate corresponding to each group of pictures.
[0051] In some embodiments, for step 103 , the predicted bit rate of the first predicted frame in each image group can be obtained by using the predicted bit rate corresponding to each image group and the number of frames of the multi-frame images included in each image group.
[0052] In one embodiment, the predicted bit rate of the first predicted frame is obtained by dividing the predicted bit rate corresponding to each image group by the number of frames of the multi-frame image included in each image group, as shown in the following formula (1):
[0053]
[0054] Wherein, j represents the j-th image group, and j is a positive integer; frameBitrate(1,j) represents the predicted bitrate of the first predicted frame of the j-th image group; GopBitrate(j) represents the predicted bitrate corresponding to the j-th image group; GopLen(j) represents the number of frames of the multi-frame images included in the j-th image group.
[0055] In some embodiments, for non-first predicted frames (e.g., the i-th predicted frame) in each GOP, a predicted bitrate of the i-th predicted frame in each GOP can be predicted using a linear model. In this case, first and second parameters of the linear model need to be determined, i.e., the first parameter in step 102 and the second parameter in step 104 need to be determined.
[0056] In some embodiments, for step 104, when updating the second parameter of the i-th prediction frame, it is necessary to determine the predicted bit rates of all prediction frames in the first i-1 prediction frames and the actual bit rates of all prediction frames. When predicting the bit rate of the i-th prediction frame, the predicted bit rates of all prediction frames in the first i-1 prediction frames (i.e., from the first prediction frame to the i-1 prediction frame) have been predicted, and after encoding all prediction frames in the first i-1 prediction frames, the actual bit rates of all prediction frames in the first i-1 prediction frames can be determined based on the encoding results. In this way, based on the second parameter of the i-1-th prediction frame in each picture group, the predicted bit rates of all prediction frames in the first i-1 prediction frames, the actual bit rates of all prediction frames, and the number of frames of multiple images included in each picture group, the second parameter of the i-th prediction frame in each picture group can be updated to obtain the second parameter of the i-th prediction frame in each picture group.
[0057] In some embodiments, in step 105, after determining the second parameter of the i-th predicted frame in each image group, a predicted bit rate corresponding to the i-th predicted frame in each image group can be determined through calculation based on the first parameter of each image group, the predicted bit rate of the i-1-th predicted frame in each image group, and the second parameter. In this way, for the i-th predicted frame in each image group, after updating the second parameter of the current predicted frame, the predicted bit rate corresponding to the current predicted frame is predicted based on the predicted bit rate of the previous predicted frame and the updated second parameter, thereby achieving dynamic bit rate control.
[0058] In an embodiment of the present application, a video sequence is divided into multiple image groups, and then a predicted bit rate corresponding to each image group and a first parameter of each image group are determined. Based on the predicted bit rate corresponding to each image group and the number of frames of multiple frames included in each image group, the predicted bit rate of the first predicted frame in each image group is determined; for the i-th predicted frame in each image group, the second parameter of the i-th predicted frame is updated based on the second parameter of the i-1-th predicted frame in each image group, the predicted bit rates of all predicted frames in the first i-1 predicted frames, the actual bit rates of all predicted frames, and the number of frames of multiple frames included in each image group; then, based on the first parameter of each image group, the predicted bit rate of the i-1-th predicted frame of each image group, and the second parameter of the i-th predicted frame of each image group, the predicted bit rate corresponding to the i-th predicted frame of each image group is determined. In this way, the predicted bit rate of the next predicted frame is determined based on the predicted bit rate of the previous predicted frame, the first parameter and the second parameter of the linear model, which can realize the variable bit rate control of the predicted frame. At the same time, since this solution does not involve a pre-processing module, it will not introduce additional resource consumption and delay, nor will it increase hardware costs.
[0059] In some embodiments, determining the first parameter of each image group includes: for the first image group, determining a first preset value as the first parameter of the first image group; for the non-first image group, determining the first parameter of the non-first image group based on the first parameter of the previous image group of the non-first image group, the actual bit rate of the previous image group, and the predicted bit rate of the previous image group.
[0060] It can be understood that the first parameter of the first image group can be expressed by the following formula (2):
[0061] α(j)=a, j=1 (2)
[0062] Wherein, α(j) represents the first parameter of the j-th image group; a represents a first preset value, which can be understood as the initial value of the first parameter, which belongs to the model coefficient of the GOP level; the first preset value is an integer or decimal greater than 0, and its value range can be: greater than or equal to 0.1, and less than or equal to 2. This value range is only for exemplary description, and the present disclosure does not make specific limitations on this.
[0063] Here, the actual bit rates of all image frames included in the previous image group other than the first image group can be obtained after encoding these image frames. The actual bit rate of the previous image group other than the first image group can be obtained by adding the actual bit rates of all image frames included in the previous image group. In this way, based on the first parameter of the previous image group other than the first image group, the actual bit rate of the previous image group, and the predicted bit rate of the previous image group, the first parameter of the non-first image group can be determined through calculation.
[0064] In some embodiments, the image frame may be encoded using intra-frame encoding, which mainly utilizes spatial redundant information for encoding.
[0065] In some embodiments, determining the first parameter of the non-first image group based on the first parameter of the previous image group of the non-first image group, the actual bit rate of the previous image group, and the predicted bit rate of the previous image group includes: obtaining a second product of the first parameter of the previous image group of the non-first image group and the actual bit rate of the previous image group; dividing the second product by the predicted bit rate of the previous image group to obtain the first parameter of the non-first image group.
[0066] It can be understood that after obtaining the first parameter of the previous picture group of the non-first picture group, the actual bit rate of the previous picture group, and the predicted bit rate of the previous picture group, the first parameter of the previous picture group of the non-first picture group is multiplied by the actual bit rate of the previous picture group to obtain the product of the two, i.e., the second product; then, the second product is divided by the predicted bit rate of the previous picture group to obtain the first parameter of the non-first picture group. In this way, by determining the first parameter of the non-first picture group in the above manner, with reference to the relevant information of the previous picture group of the non-first picture group (i.e., the first parameter of the previous picture group, the actual bit rate of the previous picture group, and the predicted bit rate of the previous picture group), it can be ensured that the change in the first parameter between adjacent picture groups is not too large, thereby avoiding sudden changes.
[0067] In one embodiment, the process of determining the first parameter of the non-first image group can be expressed by the following formula (3):
[0068]
[0069] Wherein, α(j-1) represents the first parameter of the j-1th group of pictures; realGopBitrate(j-1) represents the actual bitrate of the j-1th group of pictures; GopBitrate(j-1) represents the predicted bitrate of the j-1th group of pictures.
[0070] In some embodiments, based on the second parameter of the i-1th predicted frame in each image group, the predicted bit rates of all predicted frames in the first i-1 predicted frames, the actual bit rates of all predicted frames, and the number of frames of the multi-frame images included in each image group, the second parameter of the i-th predicted frame is updated, including: determining the bit rate difference of all predicted frames based on the predicted bit rates of all predicted frames in the first i-1 predicted frames and the actual bit rates of all predicted frames; dividing the bit rate difference by the number of frames of the multi-frame images included in each image group to obtain the average bit rate difference of all predicted frames; obtaining the sum of the second parameter of the i-1th predicted frame in each image group and the average bit rate difference to obtain the second parameter of the i-1th predicted frame; wherein the second parameter of the first predicted frame is a second preset value.
[0071] Here, the bit rate difference of all predicted frames in the first i-1 predicted frames in each picture group can be expressed by the following formula (4):
[0072]
[0073] Among them, biterror(i-1,j) represents the bitrate difference of all predicted frames among the first i-1 predicted frames in the j-th picture group; frameBitrate(1,j) represents the predicted bitrate of the first predicted frame in the j-th picture group; realframeBitrate(1,j) represents the actual bitrate of the first predicted frame in the j-th picture group; frameBitrate(i-1,j) represents the predicted bitrate of the i-1-th predicted frame in the j-th picture group; realframeBitrate(i-1,j) represents the actual bitrate of the i-1-th predicted frame in the j-th picture group.
[0074] Here, the second parameter of the i-th predicted frame in each image group can be expressed by the following formula (5):
[0075]
[0076] in, represents the second parameter of the i-th predicted frame in the j-th image group; represents the second parameter of the i-1th predicted frame in the j-th GOP. Thus, determining the second parameter of the i-th predicted frame in each GOP dynamically determines the second parameter of the current (i-th) predicted frame based on the previously encoded (i-1th) predicted frame, and using this second parameter for rate prediction of the current (i-th) predicted frame, thereby strengthening the connection between the two previous predicted frames.
[0077] In one example, the second parameter of the first prediction frame in the first group of pictures can be expressed by the following equation (6):
[0078]
[0079] in, Represents the second parameter of the i-th predicted frame in the first image group, b represents a second preset value, which can be understood as the initial value of the second parameter, which belongs to the model coefficient at the frame level; the second preset value is a number greater than 0, and its value range can be: greater than 0 and less than or equal to 50% of frameBitrate(1,1) (representing the predicted bit rate of the first predicted frame in the first image group). This value range is only for exemplary description, and the present disclosure does not make specific limitations on this.
[0080] In some embodiments, when j>1, the second parameter of the first prediction frame of the non-first image group, that is, The value of may be the second parameter corresponding to the last predicted frame in the previous picture group (i.e., the j-1th picture group) that is not the first picture group; The value of can also be other numerical values, which is not limited in this disclosure.
[0081] In some embodiments, the predicted bit rate corresponding to the i-th predicted frame of each image group is determined based on the first parameter of each image group, the predicted bit rate of the i-1th predicted frame of each image group, and the second parameter of the i-th predicted frame of each image group, including: obtaining a first product between the first parameter of each image group and the predicted bit rate of the i-1th predicted frame of each image group; summing the first product and the second parameter of the i-th predicted frame of each image group to obtain the predicted bit rate corresponding to the i-th predicted frame of each image group.
[0082] It can be understood that after obtaining the first parameter of each image group, the predicted bit rate of the i-1th predicted frame of each image group, and the second parameter of the i-th predicted frame of each image group, since the first parameter is the slope of the linear model and the second parameter is the intercept of the linear model, the first parameter of each image group is multiplied by the predicted bit rate of the i-1th predicted frame of each image group to obtain the product of the two, that is, the first product; then, the first product is added to the second parameter of the i-th predicted frame of each image group to obtain the predicted bit rate corresponding to the i-th predicted frame of each image group. In this way, the predicted bit rate corresponding to the current predicted frame is predicted in the above manner, and the predicted bit rate of the previous predicted frame is referred to, which can achieve dynamic bit rate control and will not cause the predicted bit rate between the two predicted frames to differ too much. Moreover, in static scenes, a lower bit rate can be allocated through the first parameter (e.g., the first parameter is relatively low), and in dynamic scenes, a higher bit rate can be allocated through the first parameter (e.g., the first parameter is relatively high), thereby improving the video quality of dynamic scenes while keeping the average bit rate unchanged; or reducing the size of the video while keeping the quality of dynamic scenes unchanged (e.g., static scenes are the main and dynamic scenes are the auxiliary, in this case, the bit rate of static scenes is small and the bit rate of dynamic scenes is large, the total bit rate is small, and the video size is relatively small), thereby making it more convenient to store and transmit.
[0083] In one embodiment, the process of determining the predicted bit rate corresponding to the i-th predicted frame of each image group can be expressed by the following formula (7):
[0084]
[0085] Wherein, frameBitrate(i,j) represents the predicted bitrate of the i-th predicted frame in the j-th image group; α(j) represents the first parameter corresponding to the j-th image group; frameBitrate(i-1,j) represents the predicted bitrate of the i-1-th predicted frame in the j-th image group; Represents the second parameter of the i-1th predicted frame in the jth picture group.
[0086] In some embodiments, determining the predicted bit rate corresponding to each image group includes: for the first image group, determining the predicted bit rate corresponding to the first image group based on a first preset bit rate, the number of frames of multiple frames included in the first image group, and the frame rate; for the non-first image group, determining the predicted bit rate corresponding to the non-first image group based on the average intra-frame macroblock coding ratio of the previous image group of the non-first image group, the second preset bit rate, and the third preset bit rate.
[0087] Here, the first preset bit rate, the second preset bit rate, and the third preset bit rate can all be preset bit rate values, and their values can be related to the resolution of the video sequence and the current network scenario. For example, when the resolution is 1080P, the value of the first preset bit rate can be 2 megabytes (M) or 3M, and this disclosure does not limit this. The second preset bit rate (also known as the preset maximum bit rate) is greater than the first preset bit rate, and the first preset bit rate is greater than the third preset bit rate (also known as the preset minimum bit rate). The value of the second preset bit rate can be 2 times or 3 times the first preset bit rate; the value of the third preset bit rate can be half or one third of the first preset bit rate, and this disclosure does not limit this.
[0088] It can be understood that for the first image group, after determining the first preset bit rate, the number of frames of the multiple frames included in the first image group, and the frame rate, the first preset bit rate is multiplied by the number of frames of the multiple frames included in the first image group to obtain a fourth product, and then the fourth product is divided by the frame rate to obtain the predicted bit rate corresponding to the first image group.
[0089] In one embodiment, the process of determining the predicted bit rate corresponding to the first image group can be expressed by the following formula (8):
[0090]
[0091] Wherein, GopBitrate1 represents the predicted bit rate of the first image group; TargetBitrate1 represents the first preset bit rate; GopLen(1) represents the number of frames of the multi-frame images included in the first image group; and fps represents the frame rate.
[0092] For a non-first group of pictures, based on statistical information after encoding of each frame in the previous group of pictures of the non-first group of pictures, namely, the number of intra-coded macroblocks in each predicted frame and the number of all coded macroblocks in the previous group of pictures, an average intra-frame macroblock coding ratio can be determined. Then, based on the average intra-frame macroblock coding ratio, the second preset bit rate, and the third preset bit rate, a predicted bit rate corresponding to the non-first group of pictures can be obtained through calculation. In this way, after the predicted bit rate corresponding to the non-first group of pictures is determined, the predicted bit rate of the first predicted frame in the non-first group of pictures can be determined based on the predicted bit rate.
[0093] In some embodiments, the predicted bit rate corresponding to the non-first image group is determined based on the average intra-frame macroblock coding ratio of the previous image group of the non-first image group, the second preset bit rate and the third preset bit rate, including: obtaining the difference between the second preset bit rate and the third preset bit rate; obtaining a third product of the average intra-frame macroblock coding ratio and the difference; summing the third product and the third preset bit rate to obtain the predicted bit rate corresponding to the non-first image group.
[0094] It can be understood that after determining the average intra-frame macroblock coding ratio, the second preset bit rate and the third preset bit rate of the previous image group other than the first image group, the second preset bit rate and the third preset bit rate are subtracted to obtain the difference between the two; then the average intra-frame macroblock coding ratio and the difference are multiplied to obtain the third product of the two; finally, the third product is added to the third preset bit rate to obtain the predicted bit rate corresponding to the non-first image group.
[0095] In one embodiment, the process of determining the predicted bit rate corresponding to the non-first image group can be expressed by the following formula (9):
[0096] GopBitrate(j)=avgIntraPercent(j-1)*(TargetBitrate2-TargetBitrate3)+TargetBitrate3 (9)
[0097] Wherein, avgIntraPercent(j-1) represents the average intra-frame macroblock coding ratio of the j-1th image group; TargetBitrate2 represents the second preset bit rate; and TargetBitrate3 represents the third preset bit rate.
[0098] In some embodiments, the above method also includes: obtaining the ratio value of the intra-frame coded macroblocks of each predicted frame in the previous picture group that is not the first picture group in all coded macroblocks; determining the average intra-frame macroblock coding ratio of the previous picture group that is not the first picture group based on the ratio value and the number of frames of the multi-frame images included in the previous picture group.
[0099] It can be understood that based on the statistical information of all predicted frames in the previous picture group other than the first picture group after encoding, namely, the number of intra-frame coded macroblocks of each predicted frame and the number of all coded macroblocks in the previous picture group, the number of intra-frame coded macroblocks of each predicted frame in the previous picture group is divided by the number of all coded macroblocks to obtain the ratio of the intra-frame coded macroblocks of each predicted frame in the previous picture group to all coded macroblocks. Then, the corresponding ratio values of all predicted frames in the previous picture group are added together to obtain the total ratio value. Finally, the total ratio value is divided by the number of frames of the multiple images included in the previous picture group to obtain the average intra-frame macroblock coding ratio of the previous picture group other than the first picture group.
[0100] In one embodiment, the process of determining the average intra-frame macroblock coding ratio of the previous picture group other than the first picture group can be expressed by the following formula (10):
[0101]
[0102] Among them, avgIntraPercent(j-1) represents the average intra-frame macroblock coding ratio of the j-1th picture group; intraPercent(1,j-1) represents the ratio of the intra-frame coded macroblocks of the first predicted frame in the j-1th picture group to all coded macroblocks; intraPercent(2,j-1) represents the ratio of the intra-frame coded macroblocks of the second predicted frame in the j-1th picture group to all coded macroblocks at the third preset bit rate; intraPercent(N,j-1) represents the ratio of the intra-frame coded macroblocks of the Nth predicted frame in the j-1th picture group to all coded macroblocks at the third preset bit rate; N represents the last predicted frame in the j-1th picture group.
[0103] In some embodiments, the ratio of the intra-coded macroblocks of the i-th predicted frame in the previous picture group other than the first picture group to all coded macroblocks can be determined by the following formula (11):
[0104]
[0105] Among them, intraPercent(i,j-1) represents the proportion of intra-frame coded macroblocks of the i-th predicted frame in the j-1-th picture group in all coded macroblocks; intraMbCount(i,j-1) represents the number of intra-frame coded macroblocks of the i-th predicted frame in the j-1-th picture group; frameMbCount(j-1) represents the number of all coded macroblocks in the j-1-th picture group, which is also the number of all coded macroblocks corresponding to each predicted frame in the j-1-th picture group.
[0106] It should be noted that within the same GOP, the number of all coded macroblocks corresponding to each predicted frame is the same.
[0107] In some embodiments, taking a macroblock of 16x16 as an example, frameMbCount(j-1) can be determined by the following formula (12):
[0108] frameMbCount(j-1)=(width+15)*(height+15) / (16*16) (12)
[0109] Wherein, width represents the width of the image frame in the j-1th image group; height represents the height of the image frame in the j-1th image group.
[0110] In one example, the rate control process of the predicted frame in a group of pictures is described using GOP1 as an example:
[0111] 1. Taking the frame rate as the length of GOP1 (i.e., the first group of pictures), the predicted bit rate corresponding to GOP1 can be determined by the above formula (8). In this case, GopLen(1)=fps.
[0112] 2. The bit rate of the first predicted frame (eg, P1 frame) in GOP1 can be calculated based on the average bit rate, see the above formula (1).
[0113] 3. Based on the encoding result of the previous frame (P1 frame), the actual bit rate of the P1 frame can be determined. The number of intra-frame coded macroblocks and the total number of macroblocks in the P1 frame can also be obtained. Therefore, according to the above formula (11), the proportion of intra-frame coded macroblocks in all coded macroblocks of the P1 frame can be determined. According to the above formulas (2), (6) and (7), the predicted bit rate of the second predicted frame (e.g., P2 frame) in GOP1 can be determined.
[0114] 4. According to the encoding result of the P2 frame, the actual bit rate of the P2 frame can be determined. According to the predicted bit rate of the P2 frame, the actual bit rate of the P2 frame, the predicted bit rate of the P1 frame and the actual bit rate of the P1 frame, the bit rate difference between the first two P frames in GOP1 is determined by the above formula (4). Then, the second parameter of the third predicted frame (e.g., P3 frame) in GOP1 is determined by the above formula (5). The parameter is used for bit rate prediction of the P3 frame. Then, the predicted bit rate of the P3 frame is determined by the above formula (7). And according to the above formula (11), the proportion of intra-frame coded macroblocks of the P2 frame in all coded macroblocks can be determined.
[0115] 5. Perform the relevant calculations in step 4 above on the third predicted frame in GOP1 (e.g., P3 frame) until the encoding of all predicted frames in GOP1 is completed. Based on the relevant bit rates of the image frames in GOP1, the first parameter is updated in combination with the above formula (3) to obtain the first parameter of GOP2 (the second group of pictures).
[0116] 6. Determine the ratio of intra-frame coded macroblocks of each predicted frame in GOP1 to all coded macroblocks based on the above formula (11), determine the average intra-frame macroblock coding ratio of GOP1 based on the above formula (10), and then determine the corresponding predicted bit rate of GOP2 based on the above formula (9). Repeat steps 2 to 6 until the predicted bit rates of the predicted frames of all image groups are determined.
[0117] Figure 3 FIG. 1 is a flow chart showing a method for bit rate control according to an exemplary embodiment. Figure 3 As shown, the method mainly includes the following steps:
[0118] In step 301 , a video sequence is divided into a plurality of image groups, each of which includes a plurality of temporally continuous image frames.
[0119] In step 302, a prediction bit rate corresponding to each group of pictures and a first parameter of each group of pictures are determined.
[0120] In step 303, the predicted bit rate of the first predicted frame in each image group is determined according to the predicted bit rate corresponding to each image group and the number of frames of the multi-frame images included in each image group.
[0121] In step 304, the second parameter of the i-th prediction frame is updated based on the second parameter of the i-1-th prediction frame in each image group, the predicted bit rates of all prediction frames in the first i-1 prediction frames, the actual bit rates of all prediction frames, and the number of frames of the multi-frame images included in each image group.
[0122] In step 305, a first product of a first parameter of each group of pictures and a predicted bit rate of the (i-1)th predicted frame of each group of pictures is obtained.
[0123] In step 306, the first product is summed with the second parameter of the i-th predicted frame of each image group to obtain the predicted bit rate corresponding to the i-th predicted frame of each image group.
[0124] Figure 4 FIG. 1 is a block diagram of a rate control device according to an exemplary embodiment. Figure 4 As shown, the apparatus mainly includes: a division module 401, configured to divide a video sequence into a plurality of image groups, each image group including a plurality of frames of images that are continuous in time; a first determination module 402, configured to determine a prediction bit rate corresponding to each image group and a first parameter of each image group, the first parameter being the slope of a linear model, the linear model being used to predict a prediction bit rate of the i-th prediction frame in each image group, i being an integer greater than 1; a second determination module 403, configured to determine a prediction bit rate of the first prediction frame in each image group according to the prediction bit rate corresponding to each image group and the number of frames of images included in each image group; bit rate; a third determination module 404 is configured to perform the following steps for the i-th predicted frame in each image group: based on the second parameter of the i-1-th predicted frame in each image group, the predicted bit rates of all predicted frames in the first i-1 predicted frames, the actual bit rates of all predicted frames, and the number of frames of the multi-frame image, update the second parameter of the i-th predicted frame, where the second parameter is the intercept of the linear model; according to the first parameter of each image group, the predicted bit rate of the i-1-th predicted frame of each image group, and the second parameter of the i-th predicted frame of each image group, determine the predicted bit rate corresponding to the i-th predicted frame of each image group.
[0125] In some embodiments, the third determination module 404 is configured to: obtain a first product between the first parameter of each image group and the predicted bit rate of the i-1th predicted frame of each image group; sum the first product and the second parameter of the i-th predicted frame of each image group to obtain the predicted bit rate corresponding to the i-th predicted frame of each image group.
[0126] In some embodiments, the first determination module 402 includes a first determination submodule and a second determination submodule; the first determination submodule is configured to: for the first image group, determine the first preset value as the first parameter of the first image group; the second determination submodule is configured to: for the non-first image group, determine the first parameter of the non-first image group based on the first parameter of the previous image group of the non-first image group, the actual bit rate of the previous image group, and the predicted bit rate of the previous image group.
[0127] In some embodiments, the second determination submodule 403 is configured to: obtain the second product of the first parameter of the previous image group that is not the first image group and the actual bit rate of the previous image group; divide the second product by the predicted bit rate of the previous image group to obtain the first parameter of the non-first image group.
[0128] In some embodiments, the third determination module 404 is configured to: determine the rate difference of all predicted frames based on the predicted bit rates of all predicted frames in the first i-1 predicted frames and the actual bit rates of all predicted frames; divide the rate difference by the number of frames of the multi-frame images included in each image group to obtain the average rate difference of all predicted frames; obtain the sum of the second parameter of the i-1th predicted frame in each image group and the average bit rate difference to obtain the second parameter of the i-1th predicted frame; wherein the second parameter of the first predicted frame is the second preset value.
[0129] In some embodiments, the first determination module 402 also includes a third determination submodule and a fourth determination submodule; the third determination submodule is configured to: for the first image group, determine the predicted bit rate corresponding to the first image group based on the first preset bit rate, the number of frames of the multiple frames included in the first image group, and the frame rate; the fourth determination submodule is configured to: for the non-first image group, determine the predicted bit rate corresponding to the non-first image group based on the average intra-frame macroblock coding ratio of the previous image group of the non-first image group, the second preset bit rate, and the third preset bit rate, the second preset bit rate is greater than the first preset bit rate, and the first preset bit rate is greater than the third preset bit rate.
[0130] In some embodiments, the fourth determination submodule is configured to: obtain the difference between the second preset bit rate and the third preset bit rate; obtain the third product of the average intra-frame macroblock coding ratio and the difference; sum the third product and the third preset bit rate to obtain the predicted bit rate corresponding to the non-first image group.
[0131] In some embodiments, the above-mentioned device also includes: an acquisition module, configured to: obtain the ratio value of the intra-frame coded macroblock of each predicted frame in the previous image group that is not the first image group in all coded macroblocks; a fourth determination module, configured to: determine the average intra-frame macroblock coding ratio of the previous image group that is not the first image group based on the ratio value and the number of frames of multiple frames included in the previous image group.
[0132] Regarding the apparatus in the above embodiment, the specific manner in which each module performs operations has been described in detail in the embodiment of the method, and will not be elaborated here.
[0133] Figure 5 1 is a block diagram showing a structure of an electronic device 500 according to an exemplary embodiment. For example, the electronic device 500 may be a mobile phone, a computer, a digital broadcast terminal, a messaging device, a game console, a tablet device, a medical device, a fitness device, a personal digital assistant, etc.
[0134] Reference Figure 5 , electronic device 500 may include one or more of the following components: a processing component 502 , a memory 504 , a power component 506 , a multimedia component 508 , an audio component 510 , an input / output (I / O) interface 512 , a sensor component 514 , and a communication component 516 .
[0135] The processing component 502 generally controls the overall operation of the electronic device 500, such as operations associated with at least one of display, phone calls, data communications, camera operation, and recording operations. The processing component 502 may include one or more processors 520 to execute instructions to perform all or part of the steps of the above-described method. In addition, the processing component 502 may include one or more modules to facilitate interaction between the processing component 502 and other components. For example, the processing component 502 may include a multimedia module to facilitate interaction between the multimedia component 508 and the processing component 502.
[0136] The memory 504 is configured to store various types of data to support operations on the electronic device 500. Examples of such data include at least one of the following: instructions for any application or method operating on the electronic device 500, contact data, phone book data, messages, pictures, and videos. The memory 504 can be implemented by any type of volatile or non-volatile storage device, or a combination thereof, such as static random access memory (SRAM), electrically erasable programmable read-only memory (EEPROM), erasable programmable read-only memory (EPROM), programmable read-only memory (PROM), read-only memory (ROM), magnetic memory, flash memory, magnetic disk, or optical disk.
[0137] The power supply component 506 provides power to various components of the electronic device 500. The power supply component 506 may include at least one of the following: a power management system, one or more power supplies, and other components associated with generating, managing, and distributing power to the electronic device 500.
[0138] The multimedia component 508 includes a screen that provides an output interface between the electronic device 500 and the user. In some embodiments, the screen may include a liquid crystal display (LCD) and a touch panel (TP). If the screen includes a touch panel, the screen may be implemented as a touch screen to receive input signals from the user. The touch panel includes one or more touch sensors to sense touches, slides, and gestures on the touch panel. The touch sensor can not only sense the boundaries of a touch or slide action, but also detect the duration and pressure associated with the touch or slide operation. In some embodiments, the multimedia component 508 includes a front camera and / or a rear camera. When the electronic device 500 is in an operating mode, such as a shooting mode or a video mode, the front camera and / or the rear camera can receive external multimedia data. Each front camera and rear camera can be a fixed optical lens system or have focal length and optical zoom capabilities.
[0139] The audio component 510 is configured to output and / or input audio signals. For example, the audio component 510 includes a microphone (MIC), which is configured to receive external audio signals when the electronic device 500 is in an operating mode, such as a call mode, a recording mode, and a voice recognition mode. The received audio signal can be further stored in the memory 504 or transmitted via the communication component 516. In some embodiments, the audio component 510 also includes a speaker for outputting audio signals.
[0140] I / O interface 512 provides an interface between processing component 502 and peripheral interface modules, such as a keyboard, click wheel, and buttons. These buttons may include, but are not limited to, a home button, volume buttons, a start button, and a lock button.
[0141] The sensor assembly 514 includes one or more sensors for providing various aspects of the status assessment of the electronic device 500. For example, the sensor assembly 514 can detect the open / closed state of the electronic device 500, the relative positioning of components, such as the display and keypad of the electronic device 500. The sensor assembly 514 can also detect changes in the position of the electronic device 500 or a component thereof, the presence or absence of user contact with the electronic device 500, the orientation or acceleration / deceleration of the electronic device 500, and changes in the temperature of the electronic device 500. The sensor assembly 514 can include a proximity sensor configured to detect the presence of nearby objects without any physical contact. The sensor assembly 514 can also include an optical sensor, such as a complementary metal oxide semiconductor (CMOS) or charge coupled device (CCD) image sensor, for use in imaging applications. In some embodiments, the sensor assembly 514 can also include, but is not limited to, at least one of the following: an accelerometer, a gyroscope, a magnetic sensor, a pressure sensor, and a temperature sensor.
[0142] The communication component 516 is configured to facilitate communication between the electronic device 500 and other devices in a wired or wireless manner. The electronic device 500 can access a wireless network based on a communication standard, such as Wi-Fi, 4G, 5G, or a combination thereof. In an exemplary embodiment, the communication component 516 receives a broadcast signal or broadcast-related information from an external broadcast management system via a broadcast channel. In an exemplary embodiment, the communication component 516 also includes a near field communication (NFC) module to facilitate short-range communication. For example, the NFC module can be implemented based on radio frequency identification (RFID) technology, infrared data association (IrDA) technology, ultra wide band (UWB) technology, Bluetooth (BT) technology and other technologies.
[0143] In an exemplary embodiment, the electronic device 500 may be implemented by one or more application specific integrated circuits (ASICs), digital signal processors (DSPs), digital signal processing devices (DSPDs), programmable logic devices (PLDs), field programmable gate arrays (FPGAs), controllers, microcontrollers, microprocessors, or other electronic components.
[0144] In an exemplary embodiment, a non-transitory computer-readable storage medium including instructions is further provided, such as a memory 504 including executable instructions or a computer program. The instructions or computer program can be executed by the processor 520 of the electronic device 500 to perform the above method. For example, the non-transitory computer-readable storage medium can be a ROM, a random access memory (RAM), a compact disc read-only memory (CD-ROM), a magnetic tape, a floppy disk, an optical data storage device, etc.
[0145] A non-transitory computer-readable storage medium, when the instructions in the storage medium are executed by a processor of a mobile terminal, enables the mobile terminal to perform any of the above-mentioned rate control methods of the embodiments of the present disclosure. For example, the method includes:
[0146] A video sequence is divided into a plurality of image groups, each image group including a plurality of temporally continuous image frames; a predicted bit rate corresponding to each image group and a first parameter of each image group are determined, where the first parameter is the slope of a linear model, and the linear model is used to predict the predicted bit rate of the i-th predicted frame in each image group, where i is an integer greater than 1; a predicted bit rate of the first predicted frame in each image group is determined based on the predicted bit rate corresponding to each image group and the number of frames of the plurality of images included in each image group; for the i-th predicted frame in each image group, the following steps are performed: based on the second parameter of the i-1-th predicted frame in each image group, the predicted bit rates of all predicted frames in the first i-1 predicted frames, the actual bit rates of all predicted frames, and the number of frames of the plurality of images included in each image group, the second parameter is the intercept of the linear model; and a predicted bit rate corresponding to the i-th predicted frame of each image group is determined based on the first parameter of each image group, the predicted bit rate of the i-1-th predicted frame of each image group, and the second parameter of the i-th predicted frame of each image group.
[0147] The present disclosure provides a computer program product comprising a computer program or executable instructions stored in a computer-readable storage medium. A processor of a computer device reads the computer program or executable instructions from the computer-readable storage medium and executes the computer program or executable instructions, causing the computer device to perform any of the rate control methods described above in the present disclosure.
[0148] Figure 6 FIG. 6 is a block diagram of a server 600 according to an exemplary embodiment. Figure 6 The server 600 includes a processing component 622, which further includes one or more processors and a memory resource represented by a memory 632 for storing instructions executable by the processing component 622, such as an application. The application stored in the memory 632 may include one or more modules, each corresponding to a set of instructions. In addition, the processing component 622 is configured to execute instructions to perform any of the above-mentioned rate control methods. For example, the method includes:
[0149] A video sequence is divided into a plurality of image groups, each image group including a plurality of temporally continuous image frames; a predicted bit rate corresponding to each image group and a first parameter of each image group are determined, where the first parameter is the slope of a linear model, and the linear model is used to predict the predicted bit rate of the i-th predicted frame in each image group, where i is an integer greater than 1; a predicted bit rate of the first predicted frame in each image group is determined based on the predicted bit rate corresponding to each image group and the number of frames of the plurality of images included in each image group; for the i-th predicted frame in each image group, the following steps are performed: based on the second parameter of the i-1-th predicted frame in each image group, the predicted bit rates of all predicted frames in the first i-1 predicted frames, the actual bit rates of all predicted frames, and the number of frames of the plurality of images included in each image group, the second parameter is the intercept of the linear model; and a predicted bit rate corresponding to the i-th predicted frame of each image group is determined based on the first parameter of each image group, the predicted bit rate of the i-1-th predicted frame of each image group, and the second parameter of the i-th predicted frame of each image group.
[0150] The server 600 may also include a power supply component 626 configured to perform power management of the server 600, a wired or wireless network interface 650 configured to connect the server 600 to a network, and an input / output (I / O) interface 658. The server 600 may operate an operating system stored in the memory 632, such as Windows Server™, Mac OS X™, Unix™, Linux™, FreeBSD™, or the like.
[0151] Other embodiments of the present disclosure will readily occur to those skilled in the art after considering the specification and practicing the invention disclosed herein. This disclosure is intended to cover any variations, uses, or adaptations of the present disclosure that follow the general principles of the present disclosure and include common knowledge or customary techniques in the art not disclosed herein. The description and examples are to be considered as exemplary only, with the true scope and spirit of the present disclosure being indicated by the claims.
[0152] It should be understood that the present disclosure is not limited to the exact structures that have been described above and shown in the drawings, and that various modifications and changes can be made without departing from the scope thereof. The scope of the present disclosure is limited only by the appended claims.
Claims
1. A rate control method, characterized in that: include: Dividing a video sequence into a plurality of image groups, each image group including a plurality of temporally continuous frame images; Determining a predicted bit rate corresponding to each group of pictures and a first parameter of each group of pictures, where the first parameter is a slope of a linear model, and the linear model is used to predict a predicted bit rate of an i-th predicted frame in each group of pictures, where i is an integer greater than 1; Determining a predicted bit rate of a first predicted frame in each image group according to the predicted bit rate corresponding to each image group and the number of frames of the multiple images included in each image group; For the i-th predicted frame in each group of pictures, perform the following steps: updating the second parameter of the i-th predicted frame based on the second parameter of the i-1th predicted frame in each image group, the predicted bit rates of all predicted frames in the first i-1 predicted frames, the actual bit rates of all predicted frames, and the number of frames of the multi-frame images included in each image group, where the second parameter is the intercept of the linear model; The predicted bit rate corresponding to the i-th predicted frame of each image group is determined according to the first parameter of each image group, the predicted bit rate of the i-1th predicted frame of each image group, and the second parameter of the i-th predicted frame of each image group.
2. The method according to claim 1, characterized in that The determining, based on the first parameter of each image group, the predicted bit rate of the (i-1)th predicted frame of each image group, and the second parameter of the (i)th predicted frame of each image group, the predicted bit rate corresponding to the (i)th predicted frame of each image group includes: Obtaining a first product between the first parameter of each group of pictures and the predicted bit rate of the (i-1)th predicted frame of each group of pictures; The first product is summed with the second parameter of the i-th predicted frame of each image group to obtain a predicted bit rate corresponding to the i-th predicted frame of each image group.
3. The method according to claim 1 or 2, characterized in that The determining of the first parameter of each image group includes: For a first image group, determining a first preset value as a first parameter of the first image group; For a non-first group of pictures, the first parameter of the non-first group of pictures is determined according to the first parameter of a previous group of pictures of the non-first group of pictures, the actual bit rate of the previous group of pictures, and the predicted bit rate of the previous group of pictures.
4. The method according to claim 3, characterized in that The determining the first parameter of the non-first group of pictures according to the first parameter of a previous group of pictures of the non-first group of pictures, the actual bit rate of the previous group of pictures, and the predicted bit rate of the previous group of pictures includes: Obtaining a second product of a first parameter of a previous picture group that is not the first picture group and an actual bit rate of the previous picture group; The second product is divided by the predicted bit rate of the previous picture group to obtain the first parameter of the non-first picture group.
5. The method according to claim 1, wherein The updating of the second parameter of the i-th predicted frame based on the second parameter of the i-1-th predicted frame in each group of pictures, the predicted bit rates of all predicted frames in the first i-1 predicted frames, the actual bit rates of all predicted frames, and the number of frames of the multi-frame images included in each group of pictures includes: Determining a bit rate difference of all the predicted frames based on the predicted bit rates of all the predicted frames in the first i-1 predicted frames and the actual bit rates of all the predicted frames; Dividing the bit rate difference by the number of frames of the multi-frame images included in each image group to obtain an average bit rate difference of all the predicted frames; Obtaining the sum of the second parameter of the i-1th predicted frame in each image group and the average bit rate difference to obtain the second parameter of the i-th predicted frame; The second parameter of the first prediction frame is a second preset value.
6. The method according to claim 1, wherein The determining the predicted bit rate corresponding to each image group includes: For a first image group, determining a predicted bit rate corresponding to the first image group according to a first preset bit rate, the number of frames and the frame rate of the multiple frames of images included in the first image group; For a non-first image group, the predicted bit rate corresponding to the non-first image group is determined based on the average intra-frame macroblock coding ratio of the previous image group of the non-first image group, the second preset bit rate and the third preset bit rate, where the second preset bit rate is greater than the first preset bit rate, and the first preset bit rate is greater than the third preset bit rate.
7. The method according to claim 6, characterized in that The determining, according to the average intra-frame macroblock coding ratio of a previous picture group other than the first picture group, the second preset bit rate, and the third preset bit rate, of the predicted bit rate corresponding to the non-first picture group includes: Obtaining a difference between the second preset bit rate and the third preset bit rate; Obtaining a third product of the average intra-frame macroblock coding ratio and the difference; The third product and the third preset bit rate are summed to obtain a predicted bit rate corresponding to the non-first image group.
8. The method according to claim 6 or 7, characterized in that The method further comprises: Obtaining a ratio value of the intra-frame coded macroblocks in all coded macroblocks of each predicted frame in a previous picture group other than the first picture group; An average intra-frame macroblock coding ratio of a previous picture group other than the first picture group is determined according to the ratio value and the number of frames of the multiple pictures included in the previous picture group.
9. A rate control device, characterized in that: include: a dividing module configured to divide the video sequence into a plurality of image groups, each image group including a plurality of temporally continuous frames of images; a first determining module configured to determine a predicted bitrate corresponding to each image group and a first parameter of each image group, wherein the first parameter is a slope of a linear model, the linear model being used to predict a predicted bitrate of an i-th predicted frame in each image group, where i is an integer greater than 1; a second determining module configured to determine a predicted bit rate of a first predicted frame in each image group according to the predicted bit rate corresponding to each image group and the number of frames of the multiple frames included in each image group; The third determining module is configured to perform the following steps for the i-th predicted frame in each image group: updating the second parameter of the i-th predicted frame based on the second parameter of the i-1th predicted frame in each image group, the predicted bit rates of all predicted frames in the first i-1 predicted frames, the actual bit rates of all predicted frames, and the number of frames of the multi-frame image, where the second parameter is the intercept of the linear model; The predicted bit rate corresponding to the i-th predicted frame of each image group is determined according to the first parameter of each image group, the predicted bit rate of the i-1th predicted frame of each image group, and the second parameter of the i-th predicted frame of each image group.
10. An electronic device, characterized in that: include: processor; memory for storing computer programs or instructions; The processor executes the computer program or instructions to implement the steps of the method according to any one of claims 1 to 8.
11. A non-transitory computer-readable storage medium storing a computer program or instruction, characterized in that: When the computer program or instructions in the storage medium are executed by a processor, the steps of the method according to any one of claims 1 to 8 are implemented.
12. A computer program product comprising a computer program or instructions, characterized in that When the computer program or instruction is executed by a processor, the steps of the method according to any one of claims 1 to 8 are implemented.
Citation Information
Patent Citations
Code rate controlling method for video coding based on Rho domain
CN101287123A
Image coding method and device, equipment and storage medium
CN113766226A