Method, device, electronic device and storage medium for adjusting quantization group size
During the video frame sequence encoding process, the block-level statistical information of each video frame packet is adjusted and the quantization group size is dynamically adjusted, which solves the problem of unstable encoding performance caused by fixed quantization group size in the prior art, and achieves more efficient video frame encoding.
Patent Information
- Application Number
- CN202411897153.0
- Authority / Receiving Office
- CN · China
- Patent Type
- Applications(China)
- Current Assignee / Owner
- Filing Date
- 2024-12-20
- Publication Date
- 2025-04-08
AI Technical Summary
In the prior art, the quantization group size used by different video frames in the video frame sequence is fixed when encoding, resulting in unstable encoding performance and inability to effectively match the content and motion degree of the video frame.
During the encoding process of the video frame sequence, the block-level statistical information of each video frame packet is adjusted dynamically to make it more matched with the video frame, thereby improving the encoding performance.
By dynamically adjusting the quantization group size, the characteristics of the video frame can be better matched, encoding performance can be improved, and the stability and efficiency of the encoding results can be enhanced.
Smart Images

Figure CN119788843A_ABST
Abstract
Description
Technical Field
[0001] The present disclosure relates to the field of video coding and decoding, and in particular to a method, device, electronic device and storage medium for adjusting the size of a quantization group. Background Art
[0002] Quantization Parameter (QP) is a very important parameter in video encoding, and its value directly affects the bit rate of the video. Bit rate control is actually to adjust the QP for different business scenarios to achieve better encoding performance.
[0003] A video frame may include a large number of pixels. Due to the differences in the content and texture of the pixels, the matching degree between a single QP and each pixel of the video frame is also quite different. The effect of encoding the entire video frame using a single QP is poor. In response to this, some encoders propose to divide the video frame into multiple quantization groups (QGs), set a QP for each quantization group, and use the corresponding QP for encoding each quantization group to improve the encoding effect.
[0004] A quantization group is usually a square pixel block. However, in the prior art, when encoding different video frames in a video frame sequence, the quantization group size is usually fixed. The content and motion degree of different video frames may vary greatly, resulting in unstable encoding performance. How to flexibly adjust the quantization group size during the encoding process of a video frame sequence to improve encoding performance has become a technical problem that needs to be solved in the field. Summary of the invention
[0005] In view of this, the present disclosure proposes a method, device, electronic device and storage medium for adjusting the quantization group size. In the encoding process of a video frame sequence, the method adjusts the quantization group size once each time block-level statistical information of a video frame group is obtained, so that the quantization group size used in video frame encoding is more matched with the video frame, which can improve the encoding performance.
[0006] According to one aspect of the present disclosure, a method for adjusting a quantization group size is provided, wherein the quantization group size is a coding parameter used when encoding a video frame, and the method comprises: predicting the coding cost of each video frame in a video frame sequence under different coding methods, and determining frame-level statistical information of each video frame based on the prediction result, wherein the frame-level statistical information represents statistical information in units of video frames obtained based on the prediction result; determining at least one block-level statistical information of each video frame grouping based on the frame-level statistical information of video frames belonging to the same video frame grouping, wherein the block-level statistical information represents statistical information in units of coding units; judging whether the block-level statistical information of the current video frame grouping meets a preset condition, and determining a first value based on the judgment result; and when the coding result of the second encoding of the video frame is used as the final coding result, adjusting the quantization group size used in the second encoding of the current video frame grouping to the first value.
[0007] In a possible implementation, the method further includes: when the encoding result of the first encoding of the video frame is used as the final encoding result, adjusting the quantization group size used in the first encoding of the next video frame group to a first value.
[0008] In a possible implementation, when the encoding result of the second encoding of the video frame is used as the final encoding result, the method further includes: judging the type of each video frame according to the frame-level statistical information of each video frame; grouping each video frame according to the type, wherein, when the type of the current video frame is a forward predictive coding frame, the current video frame and the forward N consecutive video frames of the type of bidirectional predictive interpolation coding frame belong to the same video frame group, and N is a natural number.
[0009] In a possible implementation, the frame-level statistical information includes one or more of a first number of coding units, a first frame-level coding cost, a second frame-level coding cost, a third frame-level coding cost, and a second number of coding units, and the coding method includes intra-frame coding and inter-frame coding, wherein the first number of coding units represents the total number of coding units of a single video frame in the video frame sequence; the first frame-level coding cost represents the coding cost of intra-frame coding of the current video frame; the second number of coding units represents the number of coding units in the coding units included in the current video frame, where the coding cost for intra-frame coding is lower than the coding cost for inter-frame coding with reference to the first reference frame, and the first The reference frame is the previous video frame of the current video frame; the second frame-level coding cost represents the coding cost of inter-frame coding of the current video frame with reference to the first reference frame; the third frame-level coding cost represents the minimum coding cost of inter-frame coding of the current video frame, which is equal to the sum of the minimum coding costs of inter-frame coding of each coding unit of the current video frame, and the minimum coding cost of inter-frame coding of each coding unit is equal to the smaller of the coding cost of inter-frame coding of the coding unit with reference to the first reference frame and the coding cost of inter-frame coding with reference to the second reference frame, and the second reference frame is the intra-frame coded frame or forward predicted coded frame closest to the current video frame.
[0010] In a possible implementation, the preset condition includes at least one sub-condition, each type of block-level statistical information corresponds to a sub-condition, and the judging whether the block-level statistical information of the current video frame grouping satisfies the preset condition and determining the first value according to the judgment result includes: judging respectively whether each type of block-level statistical information of the current video frame grouping satisfies the corresponding sub-condition; when the actual value of the quantization group size is less than the maximum value of the quantization group size, when any type of block-level statistical information satisfies the corresponding sub-condition, determining the first value so that the first value is greater than the actual value and less than or equal to the maximum value; when all types of block-level statistical information do not meet the corresponding sub-condition, determining the first value so that the first value is equal to the actual value of the quantization group size; when the actual value of the quantization group size is equal to the maximum value of the quantization group size, when any type of block-level statistical information does not meet the corresponding sub-condition, determining the first value so that the first value is less than the actual value and greater than or equal to the initial value of the quantization group size; when all types of block-level statistical information meet the corresponding sub-condition, determining the first value so that the first value is equal to the actual value of the quantization group size.
[0011] In a possible implementation, the block-level statistical information includes a first block-level coding cost, and the method of determining at least one block-level statistical information of each video frame grouping based on the frame-level statistical information of video frames belonging to the same video frame grouping includes: obtaining a second value corresponding to the video frame based on a ratio of a second frame-level coding cost of each video frame belonging to the current video frame grouping to the first number of coding units; obtaining a first block-level coding cost of the current video frame grouping based on a ratio of a sum of second values corresponding to each video frame belonging to the current video frame grouping to the number of video frames in the current video frame group; and a sub-condition corresponding to the first block-level coding cost is that the first block-level coding cost of the current video frame grouping is less than a first threshold.
[0012] In a possible implementation, the block-level statistical information includes a second block-level coding cost, and the determining of at least one block-level statistical information of each video frame grouping based on the frame-level statistical information of video frames belonging to the same video frame grouping includes: obtaining a third value corresponding to the video frame based on a ratio of a first frame-level coding cost of each video frame belonging to the current video frame grouping to the first number of coding units; obtaining a second block-level coding cost of the current video frame grouping based on a ratio of a sum of third values corresponding to each video frame belonging to the current video frame grouping to the number of video frames in the current video frame group; and a sub-condition corresponding to the second block-level coding cost is that the second block-level coding cost of the current video frame grouping is less than a second threshold.
[0013] In a possible implementation, the block-level statistical information includes a motion level and a proportion of first coding units, and the determining of at least one block-level statistical information of each video frame grouping based on the frame-level statistical information of video frames belonging to the same video frame grouping includes: obtaining the motion level of the current video frame grouping based on the ratio of the sum of the first frame-level coding costs of each video frame belonging to the current video frame grouping to the sum of the third frame-level coding costs; obtaining a fourth value corresponding to the video frame grouping based on the ratio of the sum of the number of second coding units of each video frame belonging to the current video frame grouping to the number of video frames in the current video frame grouping; obtaining the proportion of first coding units of the current video frame grouping based on the ratio of the fourth value corresponding to the video frame grouping to the first number of coding units; the sub-conditions corresponding to the motion level and the proportion of first coding units are that the motion level of the current video frame grouping is less than or equal to the third threshold and the proportion of first coding units of the current video frame grouping is greater than the fourth threshold, or that the motion level of the current video frame grouping is greater than the third threshold and the proportion of first coding units of the current video frame grouping is greater than the fifth threshold.
[0014] In a possible implementation manner, the fourth threshold is greater than the fifth threshold.
[0015] According to another aspect of the present disclosure, a device for adjusting a quantization group size is provided, wherein the quantization group size is a coding parameter used when encoding a video frame, and the device comprises: a prediction module, for predicting the coding cost of each video frame in a video frame sequence under different coding methods, and determining frame-level statistical information of each video frame according to the prediction result, wherein the frame-level statistical information represents statistical information in units of video frames obtained based on the prediction result; a first determination module, for determining at least one block-level statistical information of each video frame grouping according to the frame-level statistical information of video frames belonging to the same video frame grouping, wherein the block-level statistical information represents statistical information in units of coding units; a first judgment module, for judging whether the block-level statistical information of the current video frame grouping meets a preset condition, and determining a first value according to the judgment result; and a first adjustment module, for adjusting the quantization group size used in the second encoding of the current video frame grouping to the first value when the encoding result of the second encoding of the video frame is used as the final encoding result.
[0016] In a possible implementation, the device further includes: a second adjustment module, configured to adjust the quantization group size used in the first encoding of the next video frame group to a first value when the encoding result of the first encoding of the video frame is used as the final encoding result.
[0017] In a possible implementation, when the encoding result of the second encoding of the video frame is used as the final encoding result, the device also includes: a second judgment module, used to judge the type of each video frame according to the frame-level statistical information of each video frame; a grouping module, used to group each video frame according to the type, wherein, when the type of the current video frame is a forward predictive coding frame, the current video frame and the forward N consecutive video frames of the type of bidirectional predictive interpolation coding frame belong to the same video frame group, and N is a natural number.
[0018] In a possible implementation, the frame-level statistical information includes one or more of a first number of coding units, a first frame-level coding cost, a second frame-level coding cost, a third frame-level coding cost, and a second number of coding units, and the coding method includes intra-frame coding and inter-frame coding, wherein the first number of coding units represents the total number of coding units of a single video frame in the video frame sequence; the first frame-level coding cost represents the coding cost of intra-frame coding of the current video frame; the second number of coding units represents the number of coding units in the coding units included in the current video frame, where the coding cost for intra-frame coding is lower than the coding cost for inter-frame coding with reference to the first reference frame, and the first The reference frame is the previous video frame of the current video frame; the second frame-level coding cost represents the coding cost of inter-frame coding of the current video frame with reference to the first reference frame; the third frame-level coding cost represents the minimum coding cost of inter-frame coding of the current video frame, which is equal to the sum of the minimum coding costs of inter-frame coding of each coding unit of the current video frame, and the minimum coding cost of inter-frame coding of each coding unit is equal to the smaller of the coding cost of inter-frame coding of the coding unit with reference to the first reference frame and the coding cost of inter-frame coding with reference to the second reference frame, and the second reference frame is the intra-frame coded frame or forward predicted coded frame closest to the current video frame.
[0019] In a possible implementation, the preset condition includes at least one sub-condition, each type of block-level statistical information corresponds to a sub-condition, and the judging whether the block-level statistical information of the current video frame grouping satisfies the preset condition and determining the first value according to the judgment result includes: judging respectively whether each type of block-level statistical information of the current video frame grouping satisfies the corresponding sub-condition; when the actual value of the quantization group size is less than the maximum value of the quantization group size, when any type of block-level statistical information satisfies the corresponding sub-condition, determining the first value so that the first value is greater than the actual value and less than or equal to the maximum value; when all types of block-level statistical information do not meet the corresponding sub-condition, determining the first value so that the first value is equal to the actual value of the quantization group size; when the actual value of the quantization group size is equal to the maximum value of the quantization group size, when any type of block-level statistical information does not meet the corresponding sub-condition, determining the first value so that the first value is less than the actual value and greater than or equal to the initial value of the quantization group size; when all types of block-level statistical information meet the corresponding sub-condition, determining the first value so that the first value is equal to the actual value of the quantization group size.
[0020] In a possible implementation, the block-level statistical information includes a first block-level coding cost, and the method of determining at least one block-level statistical information of each video frame grouping based on the frame-level statistical information of video frames belonging to the same video frame grouping includes: obtaining a second value corresponding to the video frame based on a ratio of a second frame-level coding cost of each video frame belonging to the current video frame grouping to the first number of coding units; obtaining a first block-level coding cost of the current video frame grouping based on a ratio of a sum of second values corresponding to each video frame belonging to the current video frame grouping to the number of video frames in the current video frame group; and a sub-condition corresponding to the first block-level coding cost is that the first block-level coding cost of the current video frame grouping is less than a first threshold.
[0021] In a possible implementation, the block-level statistical information includes a second block-level coding cost, and the determining of at least one block-level statistical information of each video frame grouping based on the frame-level statistical information of video frames belonging to the same video frame grouping includes: obtaining a third value corresponding to the video frame based on a ratio of a first frame-level coding cost of each video frame belonging to the current video frame grouping to the first number of coding units; obtaining a second block-level coding cost of the current video frame grouping based on a ratio of a sum of third values corresponding to each video frame belonging to the current video frame grouping to the number of video frames in the current video frame group; and a sub-condition corresponding to the second block-level coding cost is that the second block-level coding cost of the current video frame grouping is less than a second threshold.
[0022] In a possible implementation, the block-level statistical information includes a motion level and a proportion of first coding units, and the determining of at least one block-level statistical information of each video frame grouping based on the frame-level statistical information of video frames belonging to the same video frame grouping includes: obtaining the motion level of the current video frame grouping based on the ratio of the sum of the first frame-level coding costs of each video frame belonging to the current video frame grouping to the sum of the third frame-level coding costs; obtaining a fourth value corresponding to the video frame grouping based on the ratio of the sum of the number of second coding units of each video frame belonging to the current video frame grouping to the number of video frames in the current video frame grouping; obtaining the proportion of first coding units of the current video frame grouping based on the ratio of the fourth value corresponding to the video frame grouping to the first number of coding units; the sub-conditions corresponding to the motion level and the proportion of first coding units are that the motion level of the current video frame grouping is less than or equal to the third threshold and the proportion of first coding units of the current video frame grouping is greater than the fourth threshold, or that the motion level of the current video frame grouping is greater than the third threshold and the proportion of first coding units of the current video frame grouping is greater than the fifth threshold.
[0023] In a possible implementation manner, the fourth threshold is greater than the fifth threshold.
[0024] According to another aspect of the present disclosure, an electronic device is provided, comprising: a processor; and a memory for storing processor-executable instructions; wherein the processor is configured to implement the above method when executing the instructions stored in the memory.
[0025] According to another aspect of the present disclosure, a non-volatile computer-readable storage medium is provided, on which computer program instructions are stored, wherein the computer program instructions implement the above method when executed by a processor.
[0026] According to another aspect of the present disclosure, a computer program product is provided, including a computer-readable code, or a non-volatile computer-readable storage medium carrying the computer-readable code. When the computer-readable code runs in a processor of an electronic device, the processor in the electronic device executes the above method.
[0027] According to the method for adjusting the quantization group size of the embodiment of the present disclosure, the encoding cost of each video frame in a video frame sequence under different encoding methods is predicted, and frame-level statistical information of each video frame is determined according to the prediction result, wherein the frame-level statistical information represents statistical information in units of video frames obtained based on the prediction result, so as to realize feature extraction of the video frame; at least one block-level statistical information of each video frame group is determined according to the frame-level statistical information of video frames belonging to the same video frame group, wherein the block-level statistical information represents statistical information in units of encoding units, so as to realize feature extraction of encoding units; it is determined whether the block-level statistical information of the current video frame group meets a preset condition, and a first value is determined according to the judgment result, and when the encoding result of the second encoding of the video frame is used as the final encoding result, the quantization group size used in the second encoding of the current video frame group is adjusted to the first value, so as to realize adaptive quantization group size adjustment. This method is applicable to 2pass encoding scenarios. The quantization group size used by a video frame group is adjusted each time. Therefore, the quantization group size has high real-time performance. The quantization group size used when encoding the video frame is more matched with the video frame, which can improve the encoding performance of the video frame. In addition, in the 2pass encoding scenario, the block-level statistical information of the current video frame group is used to adjust the quantization group size used by the current video frame group, which further improves the encoding performance of each video frame group in the 2pass encoding scenario.
[0028] Further features and aspects of the present disclosure will become apparent from the following detailed description of exemplary embodiments with reference to the attached drawings. BRIEF DESCRIPTION OF THE DRAWINGS
[0029] The accompanying drawings, which are incorporated in and constitute a part of the specification, illustrate exemplary embodiments, features, and aspects of the disclosure and, together with the description, serve to explain the principles of the disclosure.
[0030] Figure 1An exemplary application scenario of the method for adjusting the quantization group size according to an embodiment of the present disclosure is shown.
[0031] Figure 2 An example of a video frame sequence according to an embodiment of the present disclosure is shown.
[0032] Figure 3 A schematic diagram showing the process of a method for adjusting a quantization group size according to an embodiment of the present disclosure.
[0033] Figure 4 A schematic diagram showing the process of a method for adjusting a quantization group size according to an embodiment of the present disclosure.
[0034] Figure 5a A schematic diagram showing how to determine a first numerical value according to an embodiment of the present disclosure is shown.
[0035] Figure 5b A schematic diagram showing how to determine a first numerical value according to an embodiment of the present disclosure is shown.
[0036] Figure 6 A schematic diagram showing the structure of a device for adjusting a quantization group size according to an embodiment of the present disclosure.
[0037] Figure 7 A block diagram of an electronic device 1900 according to an embodiment of the present disclosure is shown. DETAILED DESCRIPTION
[0038] Various exemplary embodiments, features and aspects of the present disclosure will be described in detail below with reference to the accompanying drawings. The same reference numerals in the accompanying drawings represent elements with the same or similar functions. Although various aspects of the embodiments are shown in the accompanying drawings, the drawings are not necessarily drawn to scale unless otherwise specified.
[0039] The word “exemplary” is used exclusively herein to mean “serving as an example, example, or illustration.” Any embodiment described herein as “exemplary” is not necessarily to be construed as preferred or advantageous over other embodiments.
[0040] In addition, in order to better illustrate the present disclosure, numerous specific details are given in the following specific embodiments. It should be understood by those skilled in the art that the present disclosure can also be implemented without certain specific details. In some examples, methods, means, components and circuits well known to those skilled in the art are not described in detail in order to highlight the subject matter of the present disclosure.
[0041] The following introduces the prior art quantization group size setting solution.
[0042] Solution 1 sets a fixed quantization group size for all video frame sequences, and does not support adjusting the quantization group size. Since the content and motion levels of different video frames in a single video frame sequence and different video frame sequences are different, the matching degree between the quantization group size set in Solution 1 and the video frame sequence cannot be guaranteed, and the encoding performance during bit rate control cannot be guaranteed.
[0043] For example, for a certain video frame sequence, when a smaller quantization group is set, if the quantization parameter difference (the difference between the set value of the quantization parameter and its predicted value) of most areas of the video frame is the same, it means that the content (and degree of motion) of different areas of the video frame are similar, and encoding the video frame according to the set quantization group size will result in a waste of bit rate; when a larger quantization group is set, if the quantization parameter difference of most areas of the video frame is different, it means that the content (and degree of motion) of different areas of the video frame are greatly different, and encoding the video frame according to the set quantization group size will make it difficult to meet the encoding quality requirements.
[0044] Solution 2 is to let the user configure the quantization group size, but the user usually configures the quantization group size based on experience. Due to the accuracy of the experience, the matching degree between the quantization group size and the video frame sequence is still low, and the improvement of the encoding performance during bit rate control is limited. Moreover, for different video frame sequences, the user needs to set the quantization group size for each video frame sequence, which increases the labor cost.
[0045] In summary, how to flexibly adjust the quantization group size during the encoding process of a video frame sequence to improve encoding performance has become a technical problem that needs to be urgently solved in this field.
[0046] In view of this, the present disclosure proposes a method, device, electronic device and storage medium for adjusting the quantization group size. In the encoding process of a video frame sequence, the method adjusts the quantization group size once each time block-level statistical information of a video frame group is obtained, so that the quantization group size used in video frame encoding is more matched with the video frame, which can improve the encoding performance.
[0047] Since this method adjusts the quantization group size based on block-level statistical information of video frame grouping, the quantization group size is more closely matched with the video frame sequence. For different video frame sequences, the quantization group size with a higher degree of match with the current video frame sequence can also be automatically determined, thereby improving the encoding performance for different video frame sequences.
[0048] Figure 1 An exemplary application scenario of the method for adjusting the quantization group size according to an embodiment of the present disclosure is shown.
[0049] like Figure 1As shown, it is assumed that the video frame sequence stored on the first device needs to be transmitted to the second device. In this case, the first device may first determine the type of each video frame. The types of video frames may include intra-coded frames (Intra CodedPicture), forward predicted coded frames (Predicted Frame) and bi-directional predicted interpolated coded frames (Bi-directionalPredictive Frame). Among them, intra-coded frames are also called I frames, forward predicted coded frames are also called P frames, and bi-directional predicted interpolated coded frames are also called B frames. I frames refer to video frames with scene switching (large changes in the content of the frame) with the previous frame. After encoding, I frames still retain complete data and can be decoded independently without referring to other video frames. Therefore, the encoding method of I frames is intra-frame encoding. P frames need to refer to the data of the forward video frame to complete encoding, and also need to refer to the encoding results of the forward video frame when decoding. B frames need to refer to the forward and backward video frames to complete encoding, and also need to refer to the encoding results of the forward and backward video frames when decoding. Therefore, the encoding method of P frames and B frames is inter-frame encoding.
[0050] Figure 2 An example of a video frame sequence according to an embodiment of the present disclosure is shown.
[0051] like Figure 2 As shown, it is assumed that the video frame sequence includes continuously captured video frames 11 to 19. Video frame 11 is the video frame with the earliest position and the earliest capture time, and video frame 19 is the video frame with the latest position and the latest capture time. Among them, video frame 11 is an I frame, video frame 15 and video frame 19 are P frames, and video frames 12-14 and 16-18 are B frames.
[0052] The first device may support 1pass encoding and / or 2pass encoding. 1pass encoding means that the video frame only needs to be encoded once (first pass encoding), and 2pass encoding means that the video frame needs to be encoded twice (first pass encoding and second pass encoding). For 1pass encoding, the type of the video frame can be pre-set, the first pass encoding is the formal encoding stage of 1pass encoding, and the encoding result of the first pass encoding is used as the final encoding result. For 2pass encoding, the type of the video frame can be pre-set in the same way as 1pass encoding, or it can be determined by the first device based on frame-level statistical information; the encoding result of the first pass encoding can be used to calculate the encoding parameters used in the second pass encoding, such as quantization parameter QP, etc., and can also be used to obtain frame-level statistical information; the second pass encoding is the formal encoding stage of 2pass encoding, and the encoding result of the second pass encoding is used as the final encoding result. The first pass encoding and the second pass encoding are both encoding steps that can be implemented in the prior art, and the details of the first pass encoding and the second pass encoding are not repeated here. An example of the first device determining the type of the video frame is given later.
[0053] The first device can group the video frame sequence according to the type of the video frame, and the video frames in each group are continuous. Each I frame is individually regarded as a video frame group, and the video frame group is also called a group of pictures (Group Of Picture, GOP). Each P frame, the B frame between the P frame and the nearest non-B frame (i.e., I frame or P frame) in the forward direction are collectively regarded as a video frame group. Figure 2 In the example of FIG. 1 , video frame 11 is grouped as a video frame, video frames 12 to 15 are grouped as a video frame, and video frames 16 to 19 are grouped as a video frame.
[0054] Each video frame group is encoded separately. The first device can execute the method for adjusting the quantization group size of the embodiment of the present disclosure to adjust the quantization group size used when encoding each video frame group.
[0055] According to the type of video frames and the preset reference relationship, the first device can determine the encoding order of the video frames to ensure that when each video frame is encoded, the video frame referenced by the video frame has been encoded and the video frame referenced by the video frame has not yet started encoding.
[0056] The first device can encode each video frame group according to the determined encoding order and the adjusted quantization group size. When encoding each video frame, it is encoded according to the encoding method corresponding to the type of the video frame. For example, the encoding method of the I frame is intra-frame encoding, and the encoding method of the P frame and the B frame is inter-frame encoding. When the first device encodes each video frame, it can encode only once (1pass encoding), and use the encoding result of the first encoding as the final encoding result to achieve higher encoding efficiency. It can also encode twice (2pass encoding), adjust the second encoding process according to the encoding result of the first encoding, and use the encoding result of the second encoding as the final encoding result to achieve better encoding effect. The embodiments of the present disclosure do not limit this.
[0057] Both intra-frame coding and inter-frame coding can be implemented based on existing technologies. Adjusting the second-pass coding process according to the coding result of the first-pass coding can also be implemented based on existing technologies. The specific coding process will not be described in detail here.
[0058] The first device may output the final encoding result (code stream) and information such as the reference relationship and type of each video frame, and the quantization group size used when each video frame is grouped and encoded to the second device.
[0059] The second device can decode the final encoding result according to information such as the reference relationship, type, and quantization group size used when grouping and encoding each video frame, thereby restoring each video frame, and then reorder the video frames according to the acquisition order of the video frames themselves (such as recording by video frame numbers) to restore the video frame sequence.
[0060] Figure 3 A schematic diagram showing the process of a method for adjusting a quantization group size according to an embodiment of the present disclosure.
[0061] like Figure 3 As shown, in a possible implementation, the embodiment of the present disclosure proposes a method for adjusting a quantization group size, where the quantization group size is a coding parameter used when encoding a video frame, and the method includes:
[0062] Step S31, predicting the coding cost of each video frame in the video frame sequence under different coding modes, and determining frame-level statistical information of each video frame according to the prediction result, where the frame-level statistical information represents statistical information in units of video frames obtained based on the prediction result;
[0063] Step S32, determining at least one block-level statistical information of each video frame group according to the frame-level statistical information of the video frames belonging to the same video frame group, where the block-level statistical information represents statistical information in units of coding units;
[0064] Step S33, determining whether the block-level statistical information of the current video frame group meets a preset condition, and determining a first value according to the determination result;
[0065] Step S34, when the encoding result of the second encoding of the video frame is used as the final encoding result, the quantization group size used in the second encoding of the current video frame group is adjusted to the first value.
[0066] For example, in step S31, the coding cost of each video frame in the video frame sequence under different coding modes is first predicted. In one example, the coding mode may include the intra-frame coding and inter-frame coding described above. The video frame may be divided into a plurality of coding units (Coding Unit, CU). When predicting the coding cost of a video frame under any coding mode, the coding cost of each coding unit under the coding mode may be predicted respectively, and then the coding cost of the video frame under the coding mode is obtained by summing up. The prediction result may include the coding cost of each coding unit of the video frame under different coding modes, and the coding cost of the video frame under different coding modes. For example, it may include the coding cost of each coding unit of the video frame for intra-frame coding, the coding cost of inter-frame coding, and the coding cost of the video frame for intra-frame coding and the coding cost of inter-frame coding. Among them, when the video frame is inter-frame coded, more than one video frame may be referenced, so the coding cost of the coding unit of the video frame for inter-frame coding may include the coding cost corresponding to each referenced video frame, and the coding cost of the video frame for inter-frame coding may also include the coding cost corresponding to each referenced video frame.
[0067] Those skilled in the art should understand that there are a variety of existing methods to choose from for calculating the intra-frame coding cost and the inter-frame coding cost of the coding unit, and the present disclosure does not limit the specific implementation method of calculating the intra-frame coding cost and the inter-frame coding cost of the coding unit.
[0068] Then, frame-level statistical information of each video frame can be determined based on the prediction result. The frame-level statistical information represents statistical information in units of video frames obtained based on the prediction result, and records the characteristics of the video frame during encoding. The present disclosure does not limit the specific content of the frame-level statistical information. Examples of the types and determination methods of the frame-level statistical information are given later.
[0069] In step S32, at least one block-level statistical information of each video frame group may be determined based on the frame-level statistical information of the video frames belonging to the same video frame group, wherein the block-level statistical information represents statistical information in units of coding units, and records the characteristics of the coding units in the video frames during encoding. The present disclosure does not limit the specific content of the block-level statistical information, and examples of the types and determination methods of the block-level statistical information are given later.
[0070] After obtaining the block-level statistical information of any video frame group, step S33 can be started. In step S33, it can be determined whether the block-level statistical information of the current video frame group meets the preset condition, and the first value is determined according to the determination result.
[0071] The preset conditions corresponding to different types of block-level statistical information may be different. Exemplarily, the preset condition may include at least one sub-condition, and each type of block-level statistical information calculated in step S32 corresponds to a sub-condition. When each type of block-level statistical information satisfies the corresponding sub-condition, the block-level statistical information of the current video frame grouping satisfies the preset condition. When any type of block-level statistical information does not satisfy the corresponding sub-condition, the block-level statistical information of the current video frame grouping does not satisfy the preset condition. Examples of sub-conditions are given later.
[0072] When the block-level statistical information of the current video frame grouping meets the preset conditions, it can be considered that there is a quantization group size that matches the current video frame grouping more closely; when the block-level statistical information of the current video frame grouping does not meet the preset conditions, it can be considered that the current quantization group size matches the current video frame grouping more closely. Therefore, the first value determined when the block-level statistical information of the current video frame grouping meets the preset conditions may be different from the first value determined when the block-level statistical information of the current video frame grouping does not meet the preset conditions. In addition, when different encoders are used, the first values determined when the same video frame grouping meets the preset conditions (or does not meet the preset conditions) may also be different. Specific examples of preset conditions and first values are given later.
[0073] When the encoding result of the second encoding of the video frame is used as the final encoding result (2pass encoding scenario), the above steps S31-S33 can be completed before the second encoding of the video frame. Step S34 can be executed to adjust the quantization group size used in the second encoding of the current video frame group to the first value, and then encode the video frame for the second time. In this case, the final encoding result of the video frame is calculated using the adaptively adjusted quantization group size, and the quantization group size is obtained based on the block-level statistical information of the current video frame group, which has a higher match with the video frame group, and the encoding performance of the video frame group is better.
[0074] According to the method for adjusting the quantization group size of the embodiment of the present disclosure, the encoding cost of each video frame in a video frame sequence under different encoding methods is predicted, and frame-level statistical information of each video frame is determined according to the prediction result, wherein the frame-level statistical information represents statistical information in units of video frames obtained based on the prediction result, so as to realize feature extraction of the video frame; at least one block-level statistical information of each video frame group is determined according to the frame-level statistical information of video frames belonging to the same video frame group, wherein the block-level statistical information represents statistical information in units of encoding units, so as to realize feature extraction of encoding units; it is determined whether the block-level statistical information of the current video frame group meets a preset condition, and a first value is determined according to the judgment result, and when the encoding result of the second encoding of the video frame is used as the final encoding result, the quantization group size used in the second encoding of the current video frame group is adjusted to the first value, so as to realize adaptive quantization group size adjustment. This method is applicable to 2pass encoding scenarios. The quantization group size used by a video frame group is adjusted each time. Therefore, the quantization group size has high real-time performance. The quantization group size used when encoding the video frame is more matched with the video frame, which can improve the encoding performance of the video frame. In addition, in the 2pass encoding scenario, the block-level statistical information of the current video frame group is used to adjust the quantization group size used by the current video frame group, which further improves the encoding performance of each video frame group in the 2pass encoding scenario.
[0075] Figure 4 A schematic diagram showing the process of a method for adjusting a quantization group size according to an embodiment of the present disclosure.
[0076] like Figure 4 As shown, in a possible implementation, the method further includes:
[0077] Step S35 , when the encoding result of the first encoding of the video frame is used as the final encoding result, the quantization group size used in the first encoding of the next video frame group is adjusted to the first value.
[0078] For example, when the encoding result of the first pass encoding of the video frame is used as the final encoding result (1pass encoding scenario), the above steps S31-S33 can be completed after the first pass encoding of the video frame. After executing step S33, step S35 can be executed to adjust the quantization group size used in the first pass encoding of the next video frame group to the first value, and then perform the first pass encoding on the next video frame group.
[0079] In this case, the final encoding result of the video frame is calculated using an adaptively adjusted quantization group size, and the quantization group size used when encoding each video frame group is obtained based on the block-level statistical information of the previous video frame group. The contents of adjacent video frame groups are more similar and the degree of motion of the contents is less different. Therefore, the quantization group size used when encoding each video frame group has a higher degree of match with the video frame group.
[0080] In this way, the method for adjusting the quantization group size of the disclosed embodiment is also applicable to 1pass encoding scenarios. The quantization group size used by a video frame group is adjusted each time, so the quantization group size has high real-time performance, and the quantization group size used when encoding the video frame is more matched with the video frame, which can improve the encoding performance of the video frame; and in the 1pass encoding scenario, the block-level statistical information of the current video frame group is used to adjust the quantization group size used by the next video frame group, ensuring that the quantization group size used by each video frame group has a high degree of matching with the video frame group, further improving the encoding performance of each video frame group in the 1pass encoding scenario.
[0081] The following is an example of determining frame-level statistics.
[0082] In a possible implementation, the frame-level statistical information includes one or more of the first number of coding units, the first frame-level coding cost, the second frame-level coding cost, the third frame-level coding cost, and the second number of coding units, and the coding method includes intra-frame coding and inter-frame coding, wherein:
[0083] The first number of coding units represents the total number of coding units of a single video frame in the video frame sequence;
[0084] The first frame-level coding cost represents the coding cost of intra-frame coding of the current video frame;
[0085] The second number of coding units indicates the number of coding units in the coding units included in the current video frame, for which the coding cost of intra-frame coding is lower than the coding cost of inter-frame coding with reference to the first reference frame, where the first reference frame is a video frame before the current video frame;
[0086] The second frame-level coding cost represents the coding cost of inter-frame coding of the current video frame with reference to the first reference frame;
[0087] The third frame-level coding cost represents the minimum coding cost for inter-frame coding of the current video frame, which is equal to the sum of the minimum coding costs for inter-frame coding of each coding unit of the current video frame. The minimum coding cost for inter-frame coding of each coding unit is equal to the smaller of the coding cost for inter-frame coding of the coding unit with reference to the first reference frame and the coding cost for inter-frame coding with reference to the second reference frame. The second reference frame is the intra-frame coded frame or forward predicted coded frame closest to the current video frame.
[0088] For example, the frame-level statistical information may include the first coding unit number all_cu_count, where the coding unit may be an i×i pixel block, where i is a positive integer. The first coding unit number may be the total number of coding units included in a single video frame. In one example, when i=8 and the size of a single video frame is 1080×512, the first coding unit number may be (1080×512) / (8×8)=8640. The sizes of the video frames in the same video frame sequence are the same, so the first coding unit number of each video frame is also the same.
[0089] The frame-level statistical information may include a first frame-level coding cost intra_cost, which indicates the coding cost of intra-frame coding of the current video frame, and is equal to the sum of the coding costs of intra-frame coding of each coding unit included in the current video frame. The coding cost of the video frame in the intra-frame coding mode in the coding cost prediction result can be directly used as the first frame-level coding cost.
[0090] When calculating the coding cost of inter-frame coding, the coding cost of inter-frame coding can be calculated with reference to the first reference frame and the second reference frame. The first reference frame can be the previous video frame of the current video frame. The second reference frame can be the nearest non-B frame (I frame or P frame) before the current video frame. Figure 2 For example, the first reference frame and the second reference frame of video frame 12 are the same, namely, video frame 11; the first reference frame of video frame 13 is video frame 12, and the second reference frame is video frame 11.
[0091] The frame-level statistical information may include the second coding unit number num_intra_cu_l0_pk_intra, which indicates the number of coding units in the coding units included in the current video frame, where the coding cost for intra-frame coding is lower than the coding cost for inter-frame coding with reference to the first reference frame. For ease of description, hereinafter, the coding unit in the video frame where the coding cost for intra-frame coding is lower than the coding cost for inter-frame coding with reference to the first reference frame is referred to as the second coding unit.
[0092] by Figure 2For example, when video frame 12 is used as the current video frame, video frame 11 can be used as the first reference frame. The initial value of the second number of coding units of video frame 12 can be 0. For each coding unit of video frame 12, the coding cost of intra-frame coding of the coding unit in the prediction result and the coding cost of inter-frame coding of the coding unit with reference to video frame 11 are compared. If the coding cost of intra-frame coding is lower, the second number of coding units of video frame 12 is increased by one; after the coding costs of all coding units of video frame 12 are compared, the final value of the second number of coding units of video frame 12 is the number of coding units in the coding units included in video frame 12, where the coding cost of intra-frame coding is lower than the coding cost of inter-frame coding with reference to the first reference frame.
[0093] The frame-level statistical information may include a second frame-level coding cost inter_cost_l0, which indicates the coding cost of inter-frame coding of the current video frame with reference to the first reference frame, which is equal to the sum of the coding costs of inter-frame coding of each coding unit included in the current video frame with reference to the first reference frame. The coding cost of inter-frame coding of the video frame with reference to the first reference frame in the prediction result of the coding cost can be directly used as the second frame-level coding cost.
[0094] The frame-level statistical information may include a third frame-level coding cost inter_cost_l0_pk_l1, which represents the minimum coding cost for inter-frame coding of the current video frame, which is equal to the sum of the minimum coding costs for inter-frame coding of each coding unit of the current video frame, and the minimum coding cost for inter-frame coding of each coding unit is equal to the smaller one of the coding cost for inter-frame coding of the coding unit with reference to the first reference frame and the coding cost for inter-frame coding with reference to the second reference frame.
[0095] by Figure 2 For example, when video frame 13 is used as the current video frame, video frame 12 can be used as the first reference frame, and video frame 11 can be used as the second reference frame. The initial value of the third frame-level coding cost of video frame 13 can be 0. For each coding unit of video frame 13, the coding cost of inter-frame coding of the coding unit with reference to video frame 11 in the prediction result and the coding cost of inter-frame coding of the coding unit with reference to video frame 12 are compared, and the smaller one is added to the third frame-level coding cost of video frame 13. After the coding costs of all coding units of video frame 13 are compared, the final value of the third frame-level coding cost of video frame 13 is the minimum coding cost for inter-frame coding of video frame 13.
[0096] Those skilled in the art should understand that frame-level statistical information may also include more types of data. As long as the frame-level statistical information can represent statistical information in units of video frames obtained based on prediction results, the embodiments of the present disclosure do not limit the specific content of the frame-level statistical information.
[0097] An example of a preset condition and an example of determining the first numerical value according to a judgment result are described below.
[0098] In a possible implementation, the preset condition includes at least one sub-condition, and each type of block-level statistical information corresponds to a sub-condition.
[0099] Determining whether the block-level statistical information of the current video frame group meets a preset condition, and determining a first value according to the determination result, includes:
[0100] Determine whether each block-level statistical information of the current video frame grouping satisfies the corresponding sub-condition;
[0101] When the actual value of the quantization group size is less than the maximum value of the quantization group size, when any type of block-level statistical information satisfies the corresponding sub-condition, determine the first value so that the first value is greater than the actual value and less than or equal to the maximum value; when all types of block-level statistical information do not satisfy the corresponding sub-condition, determine the first value so that the first value is equal to the actual value of the quantization group size;
[0102] When the actual value of the quantization group size is equal to the maximum value of the quantization group size, when any type of block-level statistical information does not meet the corresponding sub-conditions, determine the first value so that the first value is less than the actual value and greater than or equal to the initial value of the quantization group size; when all types of block-level statistical information meet the corresponding sub-conditions, determine the first value so that the first value is equal to the actual value of the quantization group size.
[0103] For example, the preset condition may include at least one sub-condition, and the block-level statistical information includes at least one, and each type of block-level statistical information corresponds to a sub-condition. In practical applications, the type of block-level statistical information to be determined may be preset, and when executing step S33, the corresponding sub-condition is adaptively selected for judgment based on the type of block-level statistical information. The sub-conditions included in the preset condition may also be preset, and when executing step 32, the block-level statistical information of the type corresponding to the sub-condition is adaptively determined based on the set sub-condition. As long as each type of block-level statistical information determined when executing step S33 has a corresponding sub-condition, the present disclosure does not limit which sub-conditions are specifically included in the preset condition.
[0104] When executing step S33, it can be determined whether each block-level statistical information of the current video frame grouping meets the corresponding sub-condition. For each type of encoder, the quantization group size has a maximum value. For example, the maximum value of the quantization group size of the High Efficiency Video Coding (HEVC) can be 64, and the first value can be a value less than 64. The initial value of the quantization group size of the HEVC encoder can be 32. Before adjusting the quantization group size according to the first value, the actual value of the quantization group size is the initial value. After starting to adjust the quantization group size according to the first value, the actual value of the quantization group size is the value after the most recent adjustment. The first value can be determined based on the relationship between the actual value of the quantization group size and the maximum value, as well as the judgment result.
[0105] It can be understood that the larger the quantization group size, the higher the coding efficiency and the worse the coding quality; the smaller the quantization group size, the lower the coding efficiency and the better the coding quality. When the actual value of the quantization group size is less than the maximum value of the quantization group size, when any block-level statistical information meets the corresponding sub-condition, it can be considered that the current video frame grouping has a low demand for coding quality, and a higher coding efficiency can be strived for under the premise of ensuring that the coding quality meets the demand. For example, a first value can be determined so that the first value is greater than the actual value of the quantization group size and less than or equal to the maximum value of the quantization group size. If all types of block-level statistical information do not meet the corresponding sub-conditions, it can be considered that the current video frame grouping has a high demand for coding quality, and a higher coding quality can be strived for under the premise of ensuring that the coding efficiency meets the demand. However, according to past experience, setting a quantization group size that is too small may result in too low coding efficiency, so the first value can be made equal to the actual value of the quantization group size.
[0106] When the actual value of the quantization group size is equal to the maximum value of the quantization group size, if any type of block-level statistical information does not meet the corresponding sub-condition, it can be considered that the current video frame grouping has a high demand for encoding quality, and a higher encoding quality can be strived for under the premise of ensuring that the encoding efficiency meets the demand. For example, the first value can be determined so that the first value is less than the actual value of the quantization group size and greater than or equal to the initial value of the quantization group size. If all types of block-level statistical information meet the corresponding sub-conditions, it can be considered that the current video frame grouping has a low demand for encoding quality, and a higher encoding efficiency can be strived for under the premise of ensuring that the encoding quality meets the demand. Since the actual value of the quantization group size is already the maximum value, the first value can be made equal to the actual value of the quantization group size.
[0107] Figure 5a and Figure 5b A schematic diagram showing how to determine a first numerical value according to an embodiment of the present disclosure is shown.
[0108] like Figure 5a As shown, taking the HEVC encoder as an example, when the actual value of the quantization group size is 32, if any type of block-level statistical information satisfies the corresponding sub-condition, it can be determined that the first value is equal to 64. When all types of block-level statistical information do not meet the corresponding sub-condition, it can be determined that the first value is equal to 32.
[0109] like Figure 5b As shown, taking the HEVC encoder as an example, when the actual value of the quantization group size is 64, if any type of block-level statistical information does not meet the corresponding sub-condition, it can be determined that the first value is equal to 32. When all types of block-level statistical information meet the corresponding sub-conditions, it can be determined that the first value is equal to 64.
[0110] It is understandable that when determining the first value, a suitable value may be selected according to the application scenario requirements to ensure that neither the encoding quality nor the encoding efficiency is too low. The embodiment of the present disclosure does not limit the specific selection method of the first value.
[0111] In this way, there are more ways to trigger the adjustment of the quantization group size, so the quantization group size is more closely matched with the video frame sequence.
[0112] Those skilled in the art should understand that there are more ways to determine the first value according to the judgment result. For example, when there are an odd number of sub-conditions that can be judged, the actual value of the quantization group size is less than the maximum value of the quantization group size, and the number of sub-conditions that are satisfied is greater than the number of sub-conditions that are not satisfied, so that the first value is greater than the actual value of the quantization group size and less than or equal to the maximum value of the quantization group size; the number of sub-conditions that are satisfied is less than the number of sub-conditions that are not satisfied, so that the first value is equal to the actual value of the quantization group size. Similarly, when there are an odd number of sub-conditions that can be judged, the actual value of the quantization group size is equal to the maximum value of the quantization group size, and the number of sub-conditions that are satisfied is less than the number of sub-conditions that are not satisfied, so that the first value is less than the actual value of the quantization group size and greater than or equal to the initial value of the quantization group size; the number of sub-conditions that are satisfied is greater than the number of sub-conditions that are not satisfied, so that the first value is equal to the actual value of the quantization group size. The embodiment of the present disclosure does not limit the specific method of determining the first value according to the judgment result, as long as the encoding performance is not reduced when the adjusted quantization group size is used for encoding.
[0113] The following describes the types of block-level statistics, how to determine the block-level statistics, and examples of corresponding sub-conditions.
[0114] In a possible implementation, the block-level statistical information includes a first block-level encoding cost,
[0115] Determining at least one block-level statistical information of each video frame group according to the frame-level statistical information of the video frames belonging to the same video frame group includes:
[0116] Obtaining a second value corresponding to each video frame belonging to the current video frame group according to a ratio of a second frame-level coding cost to the number of first coding units;
[0117] Obtaining a first block-level encoding cost of the current video frame group according to a ratio of a sum of second values corresponding to each video frame belonging to the current video frame group to the number of video frames in the current video frame group;
[0118] The sub-condition corresponding to the first block-level encoding cost is that the first block-level encoding cost of the current video frame group is less than a first threshold.
[0119] For example, the second value inter_cost_l0_cu corresponding to the video frame can be obtained according to the ratio of the second frame-level coding cost inter_cost_l0 of each video frame belonging to the current video frame group to the first coding unit number all_cu_count, that is, inter_cost_l0_cu=inter_cost_l0 / all_cu_count. The second value corresponding to each video frame is the average value of the coding cost of each coding unit of the video frame when calculating the second frame-level coding cost.
[0120] The block-level statistical information may include the first block-level coding cost. The ratio of the sum of the second values corresponding to each video frame belonging to the current video frame group ∑_inter_cost_l0_cu to the number of video frames gop_size in the current video frame group is the first block-level coding cost inter_satd_l0_cu_avg of the current video frame group, which indicates the average coding cost of each coding unit of the video frame group when calculating the second frame-level coding cost. That is, inter_satd_l0_cu_avg = ∑_inter_cost_l0_cu / gop_size.
[0121] Since the second frame-level coding cost is the coding cost of inter-frame coding, the first block-level coding cost can represent the complexity of inter-frame coding. When the first block-level coding cost of the current video frame group is small, the complexity of inter-frame coding is also small, indicating that the inter-frame content moves slowly or the texture is simple, and the current video frame group has a low demand for coding quality. When the first block-level coding cost of the current video frame group is large, the complexity of inter-frame coding is also large, indicating that the inter-frame content moves quickly or the texture is complex, and the current video frame group has a high demand for coding quality.
[0122] Based on this, a first threshold can be preset. If the first block-level coding cost of the current video frame group is less than the first threshold, it can be considered that the inter-frame content moves slowly or the texture is simple; conversely, if the first block-level coding cost of the current video frame group is greater than or equal to the first threshold, it can be considered that the inter-frame content moves quickly or the texture is complex. Therefore, the sub-condition corresponding to the first block-level coding cost can be that the first block-level coding cost of the current video frame group is less than the first threshold.
[0123] The first threshold can be set according to application scenario requirements, for example, set to 200. The embodiment of the present disclosure does not limit the specific value of the first threshold.
[0124] Those skilled in the art should understand that the first block-level coding cost may also be calculated in other ways, and the embodiments of the present disclosure do not limit the specific calculation method of the first block-level coding cost, as long as the first block-level coding cost indicates the inter-frame coding complexity.
[0125] In this way, the first value can be determined according to the relationship between the first block-level coding cost and the first threshold, and adjusting the quantization group size according to the first value can improve the coding performance of the video frame sequence as much as possible.
[0126] In a possible implementation, the block-level statistical information includes a second block-level encoding cost,
[0127] Determining at least one block-level statistical information of each video frame group according to the frame-level statistical information of the video frames belonging to the same video frame group includes:
[0128] Obtaining a third value corresponding to each video frame belonging to the current video frame group according to a ratio of a first frame-level coding cost to the number of first coding units;
[0129] Obtaining a second block-level coding cost of the current video frame group according to a ratio of a sum of third values corresponding to each video frame belonging to the current video frame group to the number of video frames in the current video frame group;
[0130] The sub-condition corresponding to the second block-level encoding cost is that the second block-level encoding cost of the current video frame group is less than a second threshold.
[0131] For example, the third value intra_cost_cu corresponding to the video frame can be obtained according to the ratio of the first frame-level coding cost intra_cost of each video frame belonging to the current video frame group to the first coding unit number all_cu_count, that is, intra_cost_cu=intra_cost / all_cu_count. The third value corresponding to each video frame is the average value of the coding cost of each coding unit of the video frame when calculating the first frame-level coding cost.
[0132] The block-level statistical information may include the second block-level coding cost. The ratio of the sum of the third values corresponding to each video frame belonging to the current video frame group ∑_intra_cost_cu and the number of video frames gop_size in the current video frame group is the second block-level coding cost intra_satd_cu_avg of the current video frame group, which represents the average coding cost of each coding unit of the video frame group when calculating the first frame-level coding cost. That is, intra_satd_cu_avg = ∑_intra_cost_cu / gop_size.
[0133] Since the first frame-level coding cost is the coding cost of intra-frame coding, the second block-level coding cost can represent the complexity of intra-frame coding. When the second block-level coding cost of the current video frame group is small, the complexity of intra-frame coding is also small, indicating that the texture of the video frame is simple and the current video frame group has a low requirement for coding quality. When the second block-level coding cost of the current video frame group is large, the complexity of inter-frame coding is also large, indicating that the texture of the video frame is complex and the current video frame group has a high requirement for coding quality.
[0134] Based on this, a second threshold can be preset. If the second block-level coding cost of the current video frame group is less than the second threshold, the texture of the video frame can be considered simple; conversely, if the second block-level coding cost of the current video frame group is greater than or equal to the second threshold, the texture of the video frame can be considered complex. Therefore, the sub-condition corresponding to the second block-level coding cost can be that the second block-level coding cost of the current video frame group is less than the second threshold.
[0135] The second threshold value can be set according to the application scenario requirements, for example, set to 600. The embodiment of the present disclosure does not limit the specific value of the second threshold value.
[0136] Those skilled in the art should understand that the second block-level coding cost may also be calculated in other ways, and the embodiments of the present disclosure do not limit the specific calculation method of the second block-level coding cost, as long as the second block-level coding cost indicates the intra-frame coding complexity.
[0137] In this way, the first value can be determined according to the relationship between the second block-level coding cost and the second threshold, and adjusting the quantization group size according to the first value can improve the coding performance of the video frame sequence as much as possible.
[0138] In a possible implementation, the block-level statistical information includes the motion level and the first coding unit ratio.
[0139] Determining at least one block-level statistical information of each video frame group according to the frame-level statistical information of the video frames belonging to the same video frame group includes:
[0140] Obtaining a motion level of the current video frame group according to a ratio of a sum of first frame-level coding costs of each video frame belonging to the current video frame group to a sum of third frame-level coding costs;
[0141] Obtaining a fourth value corresponding to the video frame group according to a ratio of a sum of the number of second coding units of each video frame belonging to the current video frame group to the number of video frames in the current video frame group;
[0142] Obtaining a proportion of the first coding units of the current video frame group according to a ratio of the fourth value corresponding to the video frame group to the number of first coding units;
[0143] The sub-conditions corresponding to the motion level and the proportion of the first coding unit are that the motion level of the current video frame group is less than or equal to the third threshold and the proportion of the first coding unit of the current video frame group is greater than the fourth threshold, or, the motion level of the current video frame group is greater than the third threshold and the proportion of the first coding unit of the current video frame group is greater than the fifth threshold.
[0144] For example, the block-level statistical information includes a motion degree, and the motion degree indicates the difference in coding cost between intra-frame coding and inter-frame coding for the current video frame group. For example, the motion degree move_degree corresponding to the video frame group can be obtained according to the ratio of the sum of the first frame-level coding cost ∑_intra_cost of each video frame belonging to the current video frame group to the sum of the third frame-level coding cost ∑_inter_cost_l0_pk_l1, that is, move_degree=∑_intra_cost / ∑_inter_cost_l0_pk_l1.
[0145] Those skilled in the art should understand that the motion level can also be calculated in other ways, such as being equal to the ratio of the sum of the third frame level coding costs to the sum of the first frame level coding costs, etc. The embodiments of the present disclosure do not limit the specific calculation method of the motion level, as long as the motion level indicates the difference in coding costs for intra-frame coding and inter-frame coding of the current video frame grouping.
[0146] The block-level statistical information includes the proportion of first coding units, which indicates the average value of the proportion of the second coding units of each video frame in the current video frame group in all the coding units included in the video frames (the coding unit in the video frame whose coding cost for intra-frame coding is lower than the coding cost for inter-frame coding with reference to the first reference frame is referred to as the second coding unit). For example, according to the ratio of the sum of the number of second coding units of each video frame belonging to the current video frame group ∑_num_intra_cu_l0_pk_intra to the number of video frames gop_size in the current video frame group, the fourth value num_intra_cu_l0_pk_intra_avg corresponding to the video frame grouping can be obtained, that is, num_intra_cu_l0_pk_intra_avg=∑_num_intra_cu_l0_pk_intra / gop_size; and then according to the ratio of the fourth value num_intra_cu_l0_pk_intra_avg corresponding to the video frame grouping to the number of first coding units all_cu_count, the first coding unit ratio num_intra_cu_l0_pk_intra_avg_ratio of the current video frame grouping can be obtained, that is, num_intra_cu_l0_pk_intra_avg_ratio=num_intra_cu_l0_pk_intra_avg / all_cu_count.
[0147] When the first coding unit of the current video frame group accounts for a large proportion, there are more coding units with a lower cost for intra-frame coding, indicating that the content difference between frames may be large and there is more new content. When the first coding unit of the current video frame group accounts for a small proportion, there are more coding units with a higher cost for intra-frame coding, indicating that the content difference between frames is small and there is less new content.
[0148] Furthermore, since the motion level can indicate the difference in coding costs between intra-frame coding and inter-frame coding for the current video frame grouping, the reason for the difference in coding costs between intra-frame coding and inter-frame coding is related to the degree of motion and texture complexity of the content of the video frame. Therefore, it is more accurate to judge whether the actual value of the quantization group size of the current video frame grouping is appropriate by combining the motion level and the proportion of the first coding unit.
[0149] Based on this, the motion level and the first coding unit ratio may correspond to the same sub-condition. For example, the sub-conditions corresponding to the motion level and the first coding unit ratio may be: the motion level of the current video frame group is less than or equal to the third threshold and the first coding unit ratio of the current video frame group is greater than the fourth threshold, or the motion level of the current video frame group is greater than the third threshold and the first coding unit ratio of the current video frame group is greater than the fifth threshold.
[0150] The third threshold value can be set according to the application scenario requirements, for example, set to 5. The embodiment of the present disclosure does not limit the specific value of the third threshold value.
[0151] The fourth threshold and the fifth threshold may be set to different values. In a possible implementation, the fourth threshold is greater than the fifth threshold.
[0152] For any video frame group, if the motion level is less than or equal to the third threshold, it means that the difference in coding cost between intra-frame coding and inter-frame coding for the video frame group is small. If the proportion of the first coding unit is not large enough, then even if the quantization group size is increased, the improvement in coding performance brought about by the improvement in coding efficiency may not be able to make up for the loss of coding effect caused by the reduction in coding quality, resulting in a decrease in overall coding performance. Therefore, when the motion level is less than or equal to the third threshold, a larger fourth threshold can be set, and when the proportion of the first coding unit is greater than the fourth threshold, the corresponding sub-condition is met.
[0153] Similarly, if the motion level is greater than the third threshold, it means that the coding cost of intra-frame coding and inter-frame coding of the video frame grouping is quite different. As long as the proportion of the first coding unit is not particularly small, the improvement in coding performance brought about by the improvement in coding efficiency when the quantization group size is increased can make up for the loss of coding effect caused by the reduction in coding quality, thereby improving the overall coding performance. Therefore, when the motion level is greater than the third threshold, a smaller fifth threshold can be set, and when the proportion of the first coding unit is greater than the fifth threshold, the corresponding sub-condition is met.
[0154] The fourth threshold and the fifth threshold can be set according to the application scenario requirements, for example, the fourth threshold can be set to 0.4, and the fifth threshold can be set to 0.25. The embodiment of the present disclosure does not limit the specific values of the fourth threshold and the fifth threshold.
[0155] In this way, the video frame grouping is made to more closely match the first value.
[0156] Those skilled in the art should understand that the fourth threshold may also be less than the fifth threshold, or equal to the fifth threshold, as long as the motion level is less than or equal to the third threshold and the proportion of the first coding unit of the current video frame group is greater than the fourth threshold, and the motion level of the current video frame group is greater than the third threshold and the proportion of the first coding unit of the current video frame group is greater than the fifth threshold, increasing the quantization group size can improve the overall coding performance.
[0157] Those skilled in the art should understand that the proportion of the first coding unit can also be calculated in other ways. The embodiments of the present disclosure do not limit the specific calculation method of the proportion of the first coding unit, as long as the proportion of the first coding unit indicates the average proportion of the second coding unit of each video frame in the current video frame group in all the coding units included in the video frame.
[0158] In this way, the first value can be determined based on the relationship between the motion level and the third threshold, and the relationship between the first coding unit ratio and the fourth threshold (or the fifth threshold), and adjusting the quantization group size according to the first value can maximize the encoding performance of the video frame sequence.
[0159] In practical applications, when the quantization group size changes, the changed quantization group size can be included in the picture parameter set (Picture Parameter Set, PPS). During the formal encoding of any video frame group (the first encoding of 1pass encoding, the second encoding of 2pass encoding), the quantization group size is obtained from the PPS and used. In addition, during formal encoding, whether it is 1pass encoding or 2pass encoding, when each coding unit containing non-zero coefficients in the same quantization group corresponds to a different quantization parameter, the quantization parameters of each coding unit containing non-zero coefficients are averaged to obtain the average quantization parameter value, and then the quantization parameter corresponding to the coding unit containing non-zero coefficients is updated to the average quantization parameter value, and then the average quantization parameter value is used to encode each coding unit. That is, all coding units containing non-zero coefficients in the same quantization group are encoded using the same quantization parameter.
[0160] An exemplary method for determining the type of a video frame is described below.
[0161] In a possible implementation, when the encoding result of the second encoding of the video frame is used as the final encoding result, the method further includes:
[0162] Determine the type of each video frame according to the frame-level statistical information of each video frame;
[0163] The video frames are grouped according to their types, wherein when the type of the current video frame is a forward predictive coding frame, the current video frame and N forward consecutive video frames of bidirectional predictive interpolation coding frame type belong to the same video frame group, where N is a natural number.
[0164] For example, for 2pass encoding, the type of the video frame can be obtained based on the frame-level statistical information. This step can be implemented based on the existing technology. For example, the second frame-level encoding cost of the current video frame is inter_cost_l0, the current video frame includes all_cu_count coding units, and the preset threshold is p_thresh. If inter_cost_l0>p_thresh×all_cu_count, it can be determined that the current video frame is a P frame, otherwise it is determined that the current video frame is a B frame.
[0165] It is also possible to calculate the encoding feature parameters for determining the video frame type based on the frame-level statistical information, and pre-set the frame type determination condition, and determine whether the current video frame meets the frame type determination condition based on the position of the current video frame in the multiple video frames of unknown type included in the video frame sequence, the encoding feature parameters of the current video frame, and the preset threshold. If the frame type determination condition is met, the current video frame can be determined as a P frame, and if the frame type determination condition is not met, the current video frame can be determined as a B frame.
[0166] For example, the frame-level statistical information includes the number of second coding units. For each video frame, the proportion of the second coding units of the video frame can be determined according to the ratio of the number of second coding units to the number of first coding units, as one of the encoding feature parameters of the current video frame. A sixth threshold is preset, and as long as the proportion of the second coding units of the video frame is greater than the sixth threshold, the frame type judgment condition is met, and the video frame is determined to be a P frame.
[0167] For another example, the frame-level statistical information includes the second frame-level coding cost and the third frame-level coding cost. For each video frame, the reference degree of the second reference frame of the current video frame can be determined according to the ratio of the second frame-level coding cost to the third frame-level coding cost, as one of the coding feature parameters of the current video frame. A seventh threshold is preset, and as long as the reference degree of the second reference frame of the video frame is greater than the seventh threshold, the frame type judgment condition is met, and the video frame is determined to be a P frame.
[0168] For another example, the frame-level statistical information may also include the accumulated absolute displacement values of all coding units in the x direction mvx_sum_l0, the accumulated absolute displacement values in the y direction mvy_sum_l0, and the number of coding units with displacement in the x direction or in the y direction num_nzmv_l0 when the video frame is encoded with the first reference frame. When the current video frame is the kth video frame of a plurality of video frames of unknown type included in the video frame sequence, and k is an integer greater than 2, the encoding feature parameters of the current video frame may also include block-level motion displacement avg_mv_l0, avg_mv_l0=(mvx_sum_l0 / num_nzmv_l0) 2 +(mvy_sum_l0 / num_nzmv_l0) 2The eighth threshold value may be preset. If the proportion of the second coding unit of the video frame is less than or equal to the sixth threshold value, and the reference degree of the second reference frame of the video frame is less than or equal to the seventh threshold value, as long as the block-level motion displacement of the video frame is greater than the eighth threshold value, the frame type judgment condition is met, and the video frame is determined to be a P frame.
[0169] The sixth threshold, the seventh threshold, and the eighth threshold mentioned above can be set according to the application scenario requirements, and the present disclosure does not limit the specific values of the sixth threshold, the seventh threshold, and the eighth threshold.
[0170] Those skilled in the art should understand that there may be more types of coding feature parameters calculated based on frame-level statistical information, and there may be more ways to determine the type of video frame. The embodiments of the present disclosure do not limit the specific method of determining the type of video frame based on frame-level statistical information.
[0171] Figure 6 A schematic diagram showing the structure of a device for adjusting a quantization group size according to an embodiment of the present disclosure.
[0172] In a possible implementation, the present disclosure further proposes a device for adjusting a quantization group size, wherein the quantization group size is a coding parameter used when encoding a video frame, such as Figure 6 As shown, the device comprises:
[0173] A prediction module 61 is used to predict the coding cost of each video frame in the video frame sequence under different coding modes, and determine frame-level statistical information of each video frame according to the prediction result, wherein the frame-level statistical information represents statistical information in units of video frames obtained based on the prediction result;
[0174] A first determination module 62, configured to determine at least one block-level statistical information of each video frame group according to frame-level statistical information of video frames belonging to the same video frame group, wherein the block-level statistical information represents statistical information in units of coding units;
[0175] A first judgment module 63 is used to judge whether the block-level statistical information of the current video frame group meets a preset condition, and determine a first value according to the judgment result;
[0176] The first adjustment module 64 is configured to adjust the quantization group size used in the second encoding of the current video frame group to a first value when the encoding result of the second encoding of the video frame is used as the final encoding result.
[0177] In a possible implementation, the device further includes: a second adjustment module, configured to adjust the quantization group size used in the first encoding of the next video frame group to a first value when the encoding result of the first encoding of the video frame is used as the final encoding result.
[0178] In a possible implementation, when the encoding result of the second encoding of the video frame is used as the final encoding result, the device also includes: a second judgment module, used to judge the type of each video frame according to the frame-level statistical information of each video frame; a grouping module, used to group each video frame according to the type, wherein, when the type of the current video frame is a forward predictive coding frame, the current video frame and the forward N consecutive video frames of the type of bidirectional predictive interpolation coding frame belong to the same video frame group, and N is a natural number.
[0179] In a possible implementation, the frame-level statistical information includes one or more of a first number of coding units, a first frame-level coding cost, a second frame-level coding cost, a third frame-level coding cost, and a second number of coding units, and the coding method includes intra-frame coding and inter-frame coding, wherein the first number of coding units represents the total number of coding units of a single video frame in the video frame sequence; the first frame-level coding cost represents the coding cost of intra-frame coding of the current video frame; the second number of coding units represents the number of coding units in the coding units included in the current video frame, where the coding cost for intra-frame coding is lower than the coding cost for inter-frame coding with reference to the first reference frame, and the first The reference frame is the previous video frame of the current video frame; the second frame-level coding cost represents the coding cost of inter-frame coding of the current video frame with reference to the first reference frame; the third frame-level coding cost represents the minimum coding cost of inter-frame coding of the current video frame, which is equal to the sum of the minimum coding costs of inter-frame coding of each coding unit of the current video frame, and the minimum coding cost of inter-frame coding of each coding unit is equal to the smaller of the coding cost of inter-frame coding of the coding unit with reference to the first reference frame and the coding cost of inter-frame coding with reference to the second reference frame, and the second reference frame is the intra-frame coded frame or forward predicted coded frame closest to the current video frame.
[0180] In a possible implementation, the preset condition includes at least one sub-condition, each type of block-level statistical information corresponds to a sub-condition, and the judging whether the block-level statistical information of the current video frame grouping satisfies the preset condition and determining the first value according to the judgment result includes: judging respectively whether each type of block-level statistical information of the current video frame grouping satisfies the corresponding sub-condition; when the actual value of the quantization group size is less than the maximum value of the quantization group size, when any type of block-level statistical information satisfies the corresponding sub-condition, determining the first value so that the first value is greater than the actual value and less than or equal to the maximum value; when all types of block-level statistical information do not meet the corresponding sub-condition, determining the first value so that the first value is equal to the actual value of the quantization group size; when the actual value of the quantization group size is equal to the maximum value of the quantization group size, when any type of block-level statistical information does not meet the corresponding sub-condition, determining the first value so that the first value is less than the actual value and greater than or equal to the initial value of the quantization group size; when all types of block-level statistical information meet the corresponding sub-condition, determining the first value so that the first value is equal to the actual value of the quantization group size.
[0181] In a possible implementation, the block-level statistical information includes a first block-level coding cost, and the method of determining at least one block-level statistical information of each video frame grouping based on the frame-level statistical information of video frames belonging to the same video frame grouping includes: obtaining a second value corresponding to the video frame based on a ratio of a second frame-level coding cost of each video frame belonging to the current video frame grouping to the first number of coding units; obtaining a first block-level coding cost of the current video frame grouping based on a ratio of a sum of second values corresponding to each video frame belonging to the current video frame grouping to the number of video frames in the current video frame group; and a sub-condition corresponding to the first block-level coding cost is that the first block-level coding cost of the current video frame grouping is less than a first threshold.
[0182] In a possible implementation, the block-level statistical information includes a second block-level coding cost, and the determining of at least one block-level statistical information of each video frame grouping based on the frame-level statistical information of video frames belonging to the same video frame grouping includes: obtaining a third value corresponding to the video frame based on a ratio of a first frame-level coding cost of each video frame belonging to the current video frame grouping to the first number of coding units; obtaining a second block-level coding cost of the current video frame grouping based on a ratio of a sum of third values corresponding to each video frame belonging to the current video frame grouping to the number of video frames in the current video frame group; and a sub-condition corresponding to the second block-level coding cost is that the second block-level coding cost of the current video frame grouping is less than a second threshold.
[0183] In a possible implementation, the block-level statistical information includes a motion level and a proportion of first coding units, and the determining of at least one block-level statistical information of each video frame grouping based on the frame-level statistical information of video frames belonging to the same video frame grouping includes: obtaining the motion level of the current video frame grouping based on the ratio of the sum of the first frame-level coding costs of each video frame belonging to the current video frame grouping to the sum of the third frame-level coding costs; obtaining a fourth value corresponding to the video frame grouping based on the ratio of the sum of the number of second coding units of each video frame belonging to the current video frame grouping to the number of video frames in the current video frame grouping; obtaining the proportion of first coding units of the current video frame grouping based on the ratio of the fourth value corresponding to the video frame grouping to the first number of coding units; the sub-conditions corresponding to the motion level and the proportion of first coding units are that the motion level of the current video frame grouping is less than or equal to the third threshold and the proportion of first coding units of the current video frame grouping is greater than the fourth threshold, or that the motion level of the current video frame grouping is greater than the third threshold and the proportion of first coding units of the current video frame grouping is greater than the fifth threshold.
[0184] In a possible implementation manner, the fourth threshold is greater than the fifth threshold.
[0185] In some embodiments, the functions or modules included in the device provided by the embodiments of the present disclosure can be used to execute the method described in the above method embodiments. The specific implementation can refer to the description of the above method embodiments, and for the sake of brevity, it will not be repeated here.
[0186] The embodiment of the present disclosure also provides a computer-readable storage medium on which computer program instructions are stored, and the computer program instructions implement the above method when executed by a processor. The computer-readable storage medium can be a volatile or non-volatile computer-readable storage medium.
[0187] An embodiment of the present disclosure further proposes an electronic device, comprising: a processor; and a memory for storing instructions executable by the processor; wherein the processor is configured to implement the above method when executing the instructions stored in the memory.
[0188] The embodiments of the present disclosure also provide a computer program product, including a computer-readable code, or a non-volatile computer-readable storage medium carrying the computer-readable code. When the computer-readable code runs in a processor of an electronic device, the processor in the electronic device executes the above method.
[0189] Figure 7 1 is a block diagram of an electronic device 1900 according to an embodiment of the present disclosure. For example, the electronic device 1900 may be provided as a server or a terminal device. Figure 7, the electronic device 1900 includes a processing component 1922, which further includes one or more processors, and a memory resource represented by a memory 1932 for storing instructions executable by the processing component 1922, such as an application. The application stored in the memory 1932 may include one or more modules, each corresponding to a set of instructions. In addition, the processing component 1922 is configured to execute instructions to perform the above method.
[0190] The electronic device 1900 may also include a power supply component 1926 configured to perform power management of the electronic device 1900, a wired or wireless network interface 1950 configured to connect the electronic device 1900 to a network, and an input / output interface 1958 (I / O interface). The electronic device 1900 may operate based on an operating system stored in the memory 1932, such as Windows Server 2003. TM , Mac OS X TM , Unix TM ,Linux TM , FreeBSD TM or similar.
[0191] In an exemplary embodiment, a non-volatile computer-readable storage medium is also provided, such as a memory 1932 including computer program instructions, which can be executed by the processing component 1922 of the electronic device 1900 to perform the above method.
[0192] The present disclosure may be a system, a method and / or a computer program product. The computer program product may include a computer-readable storage medium carrying computer-readable program instructions for causing a processor to implement various aspects of the present disclosure.
[0193] A computer-readable storage medium may be a tangible device that can hold and store instructions used by an instruction execution device. A computer-readable storage medium may be, for example, but not limited to, an electrical storage device, a magnetic storage device, an optical storage device, an electromagnetic storage device, a semiconductor storage device, or any suitable combination of the foregoing. More specific examples of computer-readable storage media (a non-exhaustive list) include: a portable computer disk, a hard disk, a random access memory (RAM), a read-only memory (ROM), an erasable programmable read-only memory (EPROM or flash memory), a static random access memory (SRAM), a portable compact disk read-only memory (CD-ROM), a digital versatile disk (DVD), a memory stick, a floppy disk, a mechanical encoding device, such as a punch card or a raised structure in a groove on which instructions are stored, and any suitable combination of the foregoing. As used herein, a computer-readable storage medium is not to be interpreted as a transient signal per se, such as a radio wave or other freely propagating electromagnetic wave, an electromagnetic wave propagating through a waveguide or other transmission medium (e.g., a light pulse through a fiber optic cable), or an electrical signal transmitted through a wire.
[0194] The computer-readable program instructions described herein can be downloaded from a computer-readable storage medium to each computing / processing device, or downloaded to an external computer or external storage device via a network, such as the Internet, a local area network, a wide area network, and / or a wireless network. The network can include copper transmission cables, optical fiber transmissions, wireless transmissions, routers, firewalls, switches, gateway computers, and / or edge servers. The network adapter card or network interface in each computing / processing device receives the computer-readable program instructions from the network and forwards the computer-readable program instructions for storage in the computer-readable storage medium in each computing / processing device.
[0195] The computer program instructions for performing the operation of the present disclosure may be assembly instructions, instruction set architecture (ISA) instructions, machine instructions, machine-related instructions, microcode, firmware instructions, state setting data, or source code or object code written in any combination of one or more programming languages, including object-oriented programming languages, such as Smalltalk, C++, etc., and conventional procedural programming languages, such as "C" language or similar programming languages. Computer-readable program instructions may be executed completely on a user's computer, partially on a user's computer, as an independent software package, partially on a user's computer, partially on a remote computer, or completely on a remote computer or server. In the case of a remote computer, the remote computer may be connected to the user's computer via any type of network, including a local area network (LAN) or a wide area network (WAN), or may be connected to an external computer (e.g., using an Internet service provider to connect via the Internet). In some embodiments, an electronic circuit, such as a programmable logic circuit, a field programmable gate array (FPGA), or a programmable logic array (PLA), may be customized by utilizing the state information of the computer-readable program instructions, and the electronic circuit may execute the computer-readable program instructions, thereby realizing various aspects of the present disclosure.
[0196] Various aspects of the present disclosure are described herein with reference to the flowcharts and / or block diagrams of the methods, devices (systems) and computer program products according to the embodiments of the present disclosure. It should be understood that each box in the flowchart and / or block diagram and the combination of each box in the flowchart and / or block diagram can be implemented by computer-readable program instructions.
[0197] These computer-readable program instructions can be provided to a processor of a general-purpose computer, a special-purpose computer, or other programmable data processing device, thereby producing a machine, so that when these instructions are executed by the processor of the computer or other programmable data processing device, a device that implements the functions / actions specified in one or more boxes in the flowchart and / or block diagram is generated. These computer-readable program instructions can also be stored in a computer-readable storage medium, and these instructions cause the computer, programmable data processing device, and / or other equipment to work in a specific manner, so that the computer-readable medium storing the instructions includes a manufactured product, which includes instructions for implementing various aspects of the functions / actions specified in one or more boxes in the flowchart and / or block diagram.
[0198] Computer-readable program instructions may also be loaded onto a computer, other programmable data processing apparatus, or other device so that a series of operating steps are performed on the computer, other programmable data processing apparatus, or other device to produce a computer-implemented process, thereby causing the instructions executed on the computer, other programmable data processing apparatus, or other device to implement the functions / actions specified in one or more boxes in the flowchart and / or block diagram.
[0199] The flow chart and block diagram in the accompanying drawings show the possible architecture, function and operation of the system, method and computer program product according to multiple embodiments of the present disclosure. In this regard, each square box in the flow chart or block diagram can represent a part of a module, program segment or instruction, and a part of the module, program segment or instruction includes one or more executable instructions for realizing the specified logical function. In some alternative implementations, the function marked in the square box can also occur in a sequence different from that marked in the accompanying drawings. For example, two continuous square boxes can actually be executed substantially in parallel, and they can sometimes be executed in reverse order, depending on the functions involved. It should also be noted that each square box in the block diagram and / or flow chart, and the combination of the square boxes in the block diagram and / or flow chart can be implemented with a dedicated hardware-based system that performs the specified function or action, or can be implemented with a combination of special hardware and computer instructions.
[0200] The embodiments of the present disclosure have been described above, and the above description is exemplary, not exhaustive, and is not limited to the disclosed embodiments. Many modifications and changes will be apparent to those of ordinary skill in the art without departing from the scope and spirit of the described embodiments. The selection of terms used herein is intended to best explain the principles of the embodiments, practical applications, or technical improvements in the market, or to enable other persons of ordinary skill in the art to understand the embodiments disclosed herein.
Claims
1. A method for adjusting the size of a quantization group, characterized in that: The quantization group size is a coding parameter used when encoding a video frame, and the method comprises: Predicting the coding cost of each video frame in the video frame sequence under different coding modes, and determining frame-level statistical information of each video frame according to the prediction result, wherein the frame-level statistical information represents statistical information in units of video frames obtained based on the prediction result; Determine at least one block-level statistical information of each video frame group according to frame-level statistical information of video frames belonging to the same video frame group, wherein the block-level statistical information represents statistical information in units of coding units; Determine whether the block-level statistical information of the current video frame group meets a preset condition, and determine a first value according to the determination result; When the encoding result of the second encoding of the video frame is used as the final encoding result, the quantization group size used in the second encoding of the current video frame group is adjusted to the first value.
2. The method according to claim 1, characterized in that: The method further comprises: When the encoding result of the first encoding of the video frame is used as the final encoding result, the quantization group size used in the first encoding of the next video frame group is adjusted to the first value.
3. The method according to claim 1, characterized in that When the encoding result of the second encoding of the video frame is used as the final encoding result, the method further includes: Determine the type of each video frame according to the frame-level statistical information of each video frame; The video frames are grouped according to the type, wherein when the type of the current video frame is a forward predictive coding frame, the current video frame and forward N consecutive video frames of the type of bidirectional predictive interpolation coding frames belong to the same video frame group, where N is a natural number.
4. The method according to claim 1, characterized in that: The frame-level statistical information includes one or more of the first number of coding units, the first frame-level coding cost, the second frame-level coding cost, the third frame-level coding cost, and the second number of coding units, and the coding method includes intra-frame coding and inter-frame coding, wherein: The first number of coding units represents the total number of coding units of a single video frame in the video frame sequence; The first frame-level coding cost represents the coding cost of intra-frame coding of the current video frame; The second number of coding units represents the number of coding units in the coding units included in the current video frame, where the coding cost for intra-frame coding is lower than the coding cost for inter-frame coding with reference to the first reference frame, and the first reference frame is a video frame previous to the current video frame; The second frame-level coding cost represents the coding cost of inter-frame coding of the current video frame with reference to the first reference frame; The third frame-level coding cost represents the minimum coding cost for inter-frame coding of the current video frame, which is equal to the sum of the minimum coding costs for inter-frame coding of each coding unit of the current video frame. The minimum coding cost for inter-frame coding of each coding unit is equal to the smaller of the coding cost for inter-frame coding of the coding unit with reference to the first reference frame and the coding cost for inter-frame coding with reference to the second reference frame. The second reference frame is the intra-frame coded frame or forward predicted coded frame closest to the current video frame.
5. The method according to claim 4, characterized in that The preset condition includes at least one sub-condition, and each type of block-level statistical information corresponds to a sub-condition. The step of judging whether the block-level statistical information of the current video frame group meets a preset condition and determining a first value according to the judging result includes: Determine whether each block-level statistical information of the current video frame grouping satisfies the corresponding sub-condition; When the actual value of the quantization group size is less than the maximum value of the quantization group size, when any type of block-level statistical information satisfies the corresponding sub-condition, determine the first value so that the first value is greater than the actual value and less than or equal to the maximum value; when all types of block-level statistical information do not satisfy the corresponding sub-condition, determine the first value so that the first value is equal to the actual value of the quantization group size; When the actual value of the quantization group size is equal to the maximum value of the quantization group size, when any type of block-level statistical information does not meet the corresponding sub-conditions, determine a first value so that the first value is less than the actual value and greater than or equal to the initial value of the quantization group size; when all types of block-level statistical information meet the corresponding sub-conditions, determine a first value so that the first value is equal to the actual value of the quantization group size.
6. The method according to claim 5, characterized in that The block-level statistical information includes a first block-level encoding cost, The determining at least one block-level statistical information of each video frame group according to the frame-level statistical information of the video frames belonging to the same video frame group comprises: Obtaining a second value corresponding to each video frame belonging to the current video frame group according to a ratio of a second frame-level coding cost of each video frame to the number of the first coding units; Obtaining a first block-level encoding cost of the current video frame group according to a ratio of a sum of second values corresponding to each video frame belonging to the current video frame group to the number of video frames in the current video frame group; The sub-condition corresponding to the first block-level encoding cost is that the first block-level encoding cost of the current video frame group is less than a first threshold.
7. The method according to claim 5, characterized in that The block-level statistical information includes a second block-level encoding cost, The determining at least one block-level statistical information of each video frame group according to the frame-level statistical information of the video frames belonging to the same video frame group comprises: Obtaining a third value corresponding to each video frame belonging to the current video frame group according to a ratio of a first frame-level coding cost of the video frame to the number of the first coding units; Obtaining a second block-level coding cost of the current video frame group according to a ratio of a sum of third values corresponding to each video frame belonging to the current video frame group to the number of video frames in the current video frame group; The sub-condition corresponding to the second block-level encoding cost is that the second block-level encoding cost of the current video frame group is less than a second threshold.
8. The method according to claim 5, characterized in that The block-level statistical information includes motion level and first coding unit ratio, The determining at least one block-level statistical information of each video frame group according to the frame-level statistical information of the video frames belonging to the same video frame group comprises: Obtaining a motion level of the current video frame group according to a ratio of a sum of first frame-level coding costs of each video frame belonging to the current video frame group to a sum of third frame-level coding costs; Obtaining a fourth value corresponding to the video frame group according to a ratio of a sum of the number of second coding units of each video frame belonging to the current video frame group to the number of video frames in the current video frame group; Obtaining a proportion of the first coding units of the current video frame group according to a ratio of the fourth value corresponding to the video frame group to the number of the first coding units; The sub-conditions corresponding to the motion level and the proportion of the first coding unit are that the motion level of the current video frame group is less than or equal to the third threshold and the proportion of the first coding unit of the current video frame group is greater than the fourth threshold, or, the motion level of the current video frame group is greater than the third threshold and the proportion of the first coding unit of the current video frame group is greater than the fifth threshold.
9. The method according to claim 8, characterized in that The fourth threshold is greater than the fifth threshold.
10. A device for adjusting the size of a quantization group, characterized in that: The quantization group size is a coding parameter used when encoding a video frame, and the device includes: A prediction module, used to predict the coding cost of each video frame in the video frame sequence under different coding modes, and determine frame-level statistical information of each video frame according to the prediction result, wherein the frame-level statistical information represents statistical information in units of video frames obtained based on the prediction result; A first determination module, configured to determine at least one block-level statistical information of each video frame group according to frame-level statistical information of video frames belonging to the same video frame group, wherein the block-level statistical information represents statistical information in units of coding units; A first judgment module, used to judge whether the block-level statistical information of the current video frame group meets a preset condition, and determine a first value according to the judgment result; The first adjustment module is used to adjust the quantization group size used in the second encoding of the current video frame group to a first value when the encoding result of the second encoding of the video frame is used as the final encoding result.
11. An electronic device, characterized in that: include: processor; a memory for storing processor-executable instructions; Wherein, the processor is configured to implement the method described in any one of claims 1 to 9 when executing the instructions stored in the memory.
12. A non-volatile computer-readable storage medium having computer program instructions stored thereon, characterized in that: When the computer program instructions are executed by a processor, the method according to any one of claims 1 to 9 is implemented.