Frame type determination method, device, electronic device and storage medium
By analyzing the foreground and background areas of video frames to judge the scene complexity, the problem of high data processing cost of P frame judgment method in the prior art is solved, and higher accuracy and lower cost are achieved.
Patent Information
- Application Number
- CN202411897210.5
- 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 P frame judgment method has the problem of excessive data processing cost. How to accurately judge the P frame in the video frame sequence with a smaller data processing cost has become a technical problem that needs to be solved urgently in this field.
By analyzing the foreground and background areas of the video frames, the scene complexity of the current video frame relative to other video frames is analyzed based on the data processing results, and the forward predicted coded frames in the video frame sequence are judged based on the scene complexity.
It improves the accuracy of determining P frames, reduces data processing costs, has high data processing speed and real-time performance, and achieves both speed and accuracy.
Smart Images

Figure CN119788846A_ABST
Abstract
Description
Technical Field
[0001] The present disclosure relates to the field of video coding and decoding, and in particular to a frame type determination method, device, electronic device and storage medium. Background Art
[0002] The data volume of the video frame sequence is very large. In order to reduce transmission power consumption and storage cost, the video frame sequence is usually encoded before transmission or storage. In order to obtain a better encoding effect, it is necessary to first determine the type of each video frame in the video frame sequence. Different types of video frames can be encoded in different ways. Video frames can be divided into three types: intra coded picture, forward predictive coded frame, and bi-directional predictive interpolation coded frame.
[0003] Among them, intra-frame coded frames are also called I frames, forward predictive coded frames are also called P frames, and bidirectional predictive interpolation coded frames are also called B frames. I frames refer to video frames that have scene switching with the previous frame (the content of the frame changes significantly). After being encoded, 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 coding. P frames need to refer to the data of the previous video frame to complete encoding, and also need to refer to the encoding result of the previous video frame when decoding, so the encoding method of P frames is forward predictive coding. B frames need to refer to the data of the previous video frame and the next video frame to complete encoding, and also need to refer to the encoding results of the previous video frame and the next video frame when decoding, so the encoding method of B frames is bidirectional predictive interpolation coding. Usually, I frames are determined first, and then P frames are determined from the remaining frames, and finally B frames are left. Obviously, the accuracy of determining P frames directly affects the accuracy of determining B frames, so the higher the accuracy of determining P frames, the better the video encoding effect.
[0004] The P frame determination method proposed in the prior art has the disadvantage of excessively high data processing cost. How to accurately determine the P frame in a video frame sequence with a lower data processing cost has become a technical problem to be solved urgently in this field. Summary of the invention
[0005] In view of this, the present disclosure proposes a frame type determination method, device, electronic device and storage medium. The frame type determination method of the embodiment of the present disclosure analyzes the foreground area and the background area of the video frame respectively, analyzes the scene complexity of the current video frame relative to other video frames according to the data processing result, and then judges the forward prediction coding frame in the video frame sequence based on the scene complexity, so that the accuracy of determining the forward prediction coding frame is higher; and there is no need for prediction coding cost, and the data processing cost is lower.
[0006] According to one aspect of the present disclosure, a frame type determination method is provided, the method being used to determine a forward predictive coding frame in a video frame sequence, the video frame sequence comprising a plurality of video frames, each video frame comprising a foreground area and a background area, each area comprising at least one pixel block, the method comprising: taking each video frame as a current video frame, taking other video frames in the video frame sequence except the current video frame as first reference frames, analyzing the current video frame and the first reference frame, determining the similarity of the content of the background area of the current video frame relative to the first reference frame, and the complexity of the relative motion of the pixel blocks in the foreground area; determining the scene complexity of the current video frame relative to the first reference frame based on the similarity of the content of the background area and the complexity of the relative motion of the pixel blocks in the foreground area, the scene complexity representing the complexity of the scene difference; determining the current video frame and the first reference frame corresponding to the scene complexity greater than a first threshold as candidate video frames, and determining the forward predictive coding frame from the candidate video frames.
[0007] In a possible implementation manner, the video frame sequence is a video frame sequence between two adjacent intra-coded frames.
[0008] In a possible implementation, determining the forward predictive coding frame from the candidate video frames includes: when the number of the candidate video frames is less than a second threshold, directly determining the candidate video frames as the forward predictive coding frames.
[0009] In one possible implementation, determining the forward prediction coding frame from the candidate video frames includes: when the number of the candidate video frames is greater than or equal to a second threshold, counting the number of scene complexities corresponding to each candidate video frame and greater than a first threshold as the number of references of the candidate video frame; and selecting the candidate video frame with a first value as the forward prediction coding frame, starting from the candidate video frame with the highest number of references, in descending order of the number of references.
[0010] In a possible implementation, the analyzing the current video frame and the first reference frame to determine the similarity of the content of the current video frame relative to the background area of the first reference frame and the complexity of the relative motion of pixel blocks in the foreground area includes: for each pixel block in the foreground area of the current video frame, searching for a pixel block matching the pixel block in the foreground area of the first reference frame; determining a first motion vector of the pixel block based on the displacement of the pixel block and the matching pixel block; determining a matching residual of the pixel block based on the pixel values of the pixel block and the matching pixel block; and determining the complexity of the relative motion of pixel blocks in the foreground area based on the first motion vector and the matching residual of each pixel block in the foreground area of the current video frame.
[0011] In a possible implementation, each pixel block includes multiple pixel points, and the analyzing the current video frame and the first reference frame to determine the similarity of the content of the background area of the current video frame relative to the first reference frame and the complexity of the relative motion of the pixel blocks in the foreground area includes: using a similarity analysis algorithm to analyze the similarity of the content of the pixel blocks in the background area of the current video frame and the first reference frame, or the similarity of the content of the pixel points in the background area of the current video frame and the first reference frame; determining the similarity of the content of the background area based on the similarity of the content of the pixel blocks in the background area, or the similarity of the content of the pixel points in the background area.
[0012] In a possible implementation, the method further includes: taking the intra-frame coded frame closest to the front of the video frame sequence as a second reference frame, analyzing the current video frame and the second reference frame, and determining the types of each pixel block included in the current video frame; determining the foreground area of the current video frame according to the pixel blocks of foreground type, and determining the background area of the current video frame according to the pixel blocks of background type.
[0013] In a possible implementation, the analyzing the current video frame and the second reference frame to determine the type of each pixel block included in the current video frame includes: performing motion estimation on each pixel block included in the current video frame according to the second reference frame to determine a second motion vector of each pixel block; determining a reference motion vector corresponding to the current video frame according to the second motion vector of each pixel block included in the current video frame; determining the type of the pixel block as foreground when the absolute value of the difference between the second motion vector of any pixel block included in the current video frame and the reference motion vector corresponding to the current video frame is greater than a third threshold; determining the type of the pixel block as background when the absolute value of the difference between the second motion vector of any pixel block included in the current video frame and the reference motion vector corresponding to the current video frame is less than or equal to a third threshold.
[0014] According to another aspect of the present disclosure, a frame type determination device is provided, the device is used to determine a forward prediction coding frame in a video frame sequence, the video frame sequence includes multiple video frames, each video frame includes a foreground area and a background area, each area includes at least one pixel block, the device includes: a first determination module, used to take each video frame as a current video frame, take other video frames in the video frame sequence except the current video frame as first reference frames, analyze the current video frame and the first reference frame, and determine the similarity of the content of the background area of the current video frame relative to the first reference frame and the complexity of the relative motion of the pixel blocks in the foreground area; a second determination module, used to determine the scene complexity of the current video frame relative to the first reference frame based on the similarity of the content of the background area and the complexity of the relative motion of the pixel blocks in the foreground area, the scene complexity indicating the complexity of the scene difference; a third determination module, used to determine the current video frame and the first reference frame corresponding to the scene complexity greater than a first threshold as candidate video frames, and determine the forward prediction coding frame from the candidate video frames.
[0015] In a possible implementation manner, the video frame sequence is a video frame sequence between two adjacent intra-coded frames.
[0016] In a possible implementation manner, the third determination module is used to directly determine the candidate video frames as the forward prediction coding frames when the number of the candidate video frames is less than a second threshold.
[0017] In one possible implementation, the third determination module is used to, when the number of candidate video frames is greater than or equal to a second threshold, count the number of scene complexities corresponding to each candidate video frame that is greater than a first threshold as the number of references of the candidate video frame; and select the candidate video frame with the first value as the forward prediction coding frame in descending order of the number of references, starting from the candidate video frame with the highest number of references.
[0018] In a possible implementation, the first determination module is used to, for each pixel block in the foreground area of the current video frame, search for a pixel block matching the pixel block in the foreground area of the first reference frame; determine a first motion vector of the pixel block based on the displacement of the pixel block and the matching pixel block; determine a matching residual of the pixel block based on the pixel values of the pixel block and the matching pixel block; and determine the complexity of the relative motion of the pixel blocks in the foreground area based on the first motion vector and the matching residual of each pixel block in the foreground area of the current video frame.
[0019] In a possible implementation, each pixel block includes multiple pixel points, and the first determination module is used to use a similarity analysis algorithm to analyze the similarity of the contents of the pixel blocks in the background area of the current video frame and the first reference frame, or the similarity of the contents of the pixel points in the background area of the current video frame and the first reference frame; and determine the similarity of the content of the background area based on the similarity of the contents of the pixel blocks in the background area, or the similarity of the contents of the pixel points in the background area.
[0020] In a possible implementation manner, the device further includes:
[0021] a fourth determination module, configured to use the intra-frame coded frame closest to the video frame sequence as a second reference frame, analyze the current video frame and the second reference frame, and determine the type of each pixel block included in the current video frame;
[0022] The fifth determination module is used to determine the foreground area of the current video frame according to the pixel blocks of the foreground type, and determine the background area of the current video frame according to the pixel blocks of the background type.
[0023] In a possible implementation, the fourth determination module is used to perform motion estimation on each pixel block included in the current video frame according to the second reference frame to determine the second motion vector of each pixel block; determine the reference motion vector corresponding to the current video frame according to the second motion vector of each pixel block included in the current video frame; determine the type of the pixel block as foreground when the absolute value of the difference between the second motion vector of any pixel block included in the current video frame and the reference motion vector corresponding to the current video frame is greater than a third threshold; determine the type of the pixel block as background when the absolute value of the difference between the second motion vector of any pixel block included in the current video frame and the reference motion vector corresponding to the current video frame is less than or equal to a third 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 frame type determination method of the embodiment of the present disclosure, each video frame is used as the current video frame, and other video frames except the current video frame in the video frame sequence are used as the first reference frames, and the current video frame and the first reference frame are analyzed to determine the similarity of the content of the background area of the current video frame relative to the first reference frame and the complexity of the relative motion of the pixel blocks in the foreground area, so that the similarity of the content of the background area can reflect the inter-frame similarity of the video frames, and the complexity of the relative motion of the pixel blocks in the foreground area can reflect the difference of the video frames; according to the similarity of the content of the background area and the complexity of the relative motion of the pixel blocks in the foreground area, the scene complexity of the current video frame relative to the first reference frame is determined. clutter, so that the scene complexity is more accurate when representing the complexity of scene differences; the current video frame and the first reference frame corresponding to the scene complexity greater than the first threshold are determined as candidate video frames, and the forward prediction coding frame is determined from the candidate video frames. Since the scene complexity represents the complexity of scene differences and is obtained based on the similarity of the content of the background area and the complexity of the relative motion of the pixel blocks in the foreground area, it is more accurate to determine the candidate video frame based on the comparison of the scene complexity with the first threshold, thereby making it more accurate to determine the forward prediction coding frame from the candidate video frame; and there is no need for predictive coding cost, which can reduce the data processing cost and have higher data processing speed and real-time performance. In this case, the frame type determination method of the embodiment of the present disclosure can achieve a balance between speed and accuracy, and a better bit rate control effect can be achieved based on the determined frame type.
[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 1 An exemplary application scenario of the frame type determination method according to an embodiment of the present disclosure is shown.
[0031] Figure 2 A schematic diagram showing the process of a frame type determination method according to an embodiment of the present disclosure.
[0032] Figure 3A schematic diagram showing the process of a frame type determination method according to an embodiment of the present disclosure.
[0033] Figure 4 A schematic diagram showing the process of a frame type determination method according to an embodiment of the present disclosure.
[0034] Figure 5 A schematic diagram showing a method for selecting a second reference frame according to an embodiment of the present disclosure.
[0035] Figure 6 A schematic diagram showing the structure of a frame type determination device according to an embodiment of the present disclosure.
[0036] Figure 7 A block diagram of an electronic device 1900 according to an embodiment of the present disclosure is shown. DETAILED DESCRIPTION
[0037] 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.
[0038] 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.
[0039] 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.
[0040] The P frame judgment methods proposed in the prior art mainly include the following two methods. The common point of these two methods is that each frame needs to be encoded twice to obtain the final encoding result. Among them, the second encoding is the formal encoding, and the first encoding is the pre-encoding. Before the formal encoding, pre-encoding can be performed to estimate the encoding cost. If the type of a video frame is a P frame, the video frame should use the forward prediction encoding method. If the type of a video frame is a B frame, the video frame should use the bidirectional prediction interpolation encoding method.
[0041] The first method is to pre-encode each frame in the video frame sequence as a P frame and a B frame respectively, calculate the encoding cost as different types of frames, and determine the total encoding cost corresponding to different types of combinations of each frame of multiple video frames as a P frame or a B frame based on the calculation results. Determine the type of each video frame based on the type combination with the smallest total encoding cost. The disadvantage of this method is that the estimation of the encoding cost requires a large data processing cost, and it is also necessary to search all combinations to calculate the total encoding cost, which further increases the data processing cost, resulting in large computational complexity, data processing cost, and delay.
[0042] The second method is to pre-encode each frame in the video frame sequence as a P frame or a B frame, and calculate the encoding cost when it is a frame of the current type. If the encoding cost of the current frame does not exceed the preset threshold under the encoding method corresponding to the current type, the current frame is determined to be the current type; if the encoding cost exceeds the preset threshold, the current frame is determined to be another type. The disadvantage of this method is that the data processing cost of estimating the encoding cost is large, and the type of the current frame is determined only based on the encoding cost of a single frame, and the accuracy is low.
[0043] In summary, the P frame determination method proposed in the prior art has the disadvantage of excessively high data processing cost. How to accurately determine the P frame in a video frame sequence with a lower data processing cost has become a technical problem to be solved urgently in this field.
[0044] In view of this, the present disclosure proposes a frame type determination method, device, electronic device and storage medium. The frame type determination method of the embodiment of the present disclosure analyzes the foreground area and the background area of the video frame respectively, analyzes the scene complexity of the current video frame relative to other video frames according to the data processing result, and then judges the forward prediction coding frame in the video frame sequence based on the scene complexity, so that the accuracy of determining the forward prediction coding frame is higher; and there is no need for prediction coding cost, and the data processing cost is lower.
[0045] Figure 1 An exemplary application scenario of the frame type determination method according to an embodiment of the present disclosure is shown.
[0046] 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 can determine the I frame according to the prior art (for example, an I frame is determined for every video frame with a certain value interval, or the I frame is determined by detecting the scene switch of adjacent video frames), and then execute the frame type determination method of the embodiment of the present disclosure to determine the P frame, and the remaining video frames whose types have not yet been determined are B frames. After the type of each video frame is determined, the first device can further determine the reference relationship of the video frame, that is, which video frames each video frame refers to and is referenced by which video frames. Based on the reference relationship, the encoding order of the video frames can be determined 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.
[0047] The first device can encode each video frame according to the determined encoding order. 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, the encoding method of the P frame is forward prediction encoding, and the encoding method of the B frame is bidirectional prediction interpolation encoding. When the first device encodes each video frame, it can encode it only once to achieve higher encoding efficiency, or it can perform pre-coding and formal encoding, and adjust the formal encoding process according to the result of pre-coding to achieve better encoding effect. The embodiment of the present disclosure does not limit this. Intra-frame coding, forward prediction coding, and bidirectional prediction interpolation coding can all be implemented based on existing technologies, and adjusting the formal encoding process according to the result of pre-coding can also be implemented based on existing technologies. The specific encoding process will not be repeated here.
[0048] The first device can transmit the encoded code stream and the reference relationship, type and other information of each video frame to the second device. After receiving the code stream, the second device can decode it according to the reference relationship, type and other information of each video frame, thereby restoring each video frame, and then rearrange the video frames according to the acquisition order of the video frames themselves (such as recording by the video frame numbers) to restore the video frame sequence.
[0049] Figure 2 and Figure 3 A schematic diagram showing the process of a frame type determination method according to an embodiment of the present disclosure.
[0050] In a possible implementation, the present disclosure provides a frame type determination method, the method being used to determine a forward prediction coding frame in a video frame sequence, the video frame sequence comprising a plurality of video frames, each video frame comprising a foreground area and a background area, each area comprising at least one pixel block,
[0051] like Figure 2 As shown, the method includes:
[0052] Step S21, taking each video frame as a current video frame, taking other video frames in the video frame sequence except the current video frame as first reference frames, analyzing the current video frame and the first reference frame, and determining the similarity of the content of the background area of the current video frame relative to the first reference frame, and the complexity of the relative motion of the pixel blocks in the foreground area;
[0053] Step S22, determining the scene complexity of the current video frame relative to the first reference frame according to the similarity of the content of the background area and the complexity of the relative motion of the pixel blocks in the foreground area, where the scene complexity indicates the complexity of the scene difference;
[0054] Step S23: determine the current video frame and the first reference frame corresponding to the scene complexity greater than the first threshold as candidate video frames, and determine a forward prediction coding frame from the candidate video frames.
[0055] For example, if Figure 3 As shown in FIG. 1 , it is assumed that the video frame sequence includes video frame 1 to video frame 4. Each video frame is numbered in the order of acquisition time. The smaller the number, the earlier the acquisition time of the video frame. Each video frame may include a foreground area and a background area, and each area includes at least one pixel block. Figure 3 Taking the video frame 1 in FIG. 1 as an example, the foreground area 1A and the background area 1B may be included therein.
[0056] First, step S21 can be executed, with each video frame as the current video frame, and other video frames in the video frame sequence except the current video frame as the first reference frames, analyzing the current video frame and the first reference frame, and determining the similarity of the content of the current video frame relative to the background area of the first reference frame and the complexity of the relative motion of the pixel blocks in the foreground area.
[0057] by Figure 3 For example, when video frame 1 is used as the current video frame, video frame 2, video frame 3, and video frame 4 can be used as the first reference frame respectively; when video frame 2 is used as the current video frame, video frame 1, video frame 3, and video frame 4 can be used as the first reference frame respectively; when video frame 3 is used as the current video frame, video frame 1, video frame 2, and video frame 4 can be used as the first reference frame respectively; when video frame 4 is used as the current video frame, video frame 1, video frame 2, and video frame 3 can be used as the first reference frame respectively.
[0058] Taking video frame 1 as the current video frame and video frame 2 as the first reference frame as an example, video frame 1 and video frame 2 can be analyzed to determine the similarity of the content of video frame 1 relative to the background area of video frame 2 (hereinafter referred to as background similarity) and the complexity of the relative motion of pixel blocks in the foreground area (hereinafter referred to as foreground motion complexity). Among them, the background similarity of video frame 1 relative to video frame 2 refers to the similarity of the content of the background area of video frame 1 compared with the background area of video frame 2. The foreground motion complexity of video frame 1 relative to video frame 2 refers to the complexity of the relative motion between the pixel blocks in the foreground area of video frame 1 and the pixel blocks in the foreground area of video frame 2.
[0059] The pixel blocks in the background area show stationary objects or objects with small motion amplitudes. Therefore, the pixel blocks in the background area usually have little or no displacement. When determining the background similarity, only the pixel value can be considered without considering the displacement of the pixels. The pixel blocks in the foreground area show objects with large motion amplitudes. Therefore, the displacement of the pixel blocks in the foreground area of adjacent video frames may be large, and the movement of the object may also cause certain changes in the content of the pixel blocks. Therefore, the foreground motion complexity is mainly determined based on the displacement of the pixel blocks in the foreground area and the content differences of the pixel blocks. Exemplary calculation methods for background similarity and foreground motion complexity are given later.
[0060] By analogy, for each video frame in the video frame sequence, the background similarity and foreground motion complexity relative to any video frame other than the video frame can be obtained.
[0061] Thereafter, step S22 may be executed to determine the scene complexity of the current video frame relative to the first reference frame according to the background similarity and the foreground motion complexity, where the scene complexity indicates the complexity of the scene difference.
[0062] Still taking video frame 1 as the current video frame and video frame 2 as the first reference frame as an example, the scene complexity of video frame 1 relative to video frame 2 can be determined based on the background similarity and foreground motion complexity of video frame 1 relative to video frame 2.
[0063] The scene difference can be evaluated by combining the background difference and the foreground difference. Taking the scene difference between video frame 1 and video frame 2 as an example, the more similar the content of the background area of video frame 1 and video frame 2 is, the smaller the content difference of the background area is, the simpler the background difference is, and the simpler the scene difference is; the smaller the displacement in the foreground area of video frame 1 and video frame 2 is, the simpler the foreground difference is, and the simpler the scene difference is; the smaller the content difference of the pixel block in the foreground area is, the simpler the foreground difference is, and the simpler the scene difference is.
[0064] In the disclosed embodiment, the scene complexity may be equal to the weighted sum of the background similarity and the foreground motion complexity. An example of a method for calculating the scene complexity is given below.
[0065] Thereafter, step S23 may be performed to determine the current video frame and the first reference frame corresponding to the scene complexity greater than the first threshold as candidate video frames, and determine the forward prediction coding frame from the candidate video frames. The first threshold may be calculated by statistical data of encoding a sample video frame sequence at different bit rates, and the present disclosure does not limit the specific value of the first threshold.
[0066] Still taking video frame 1 as the current video frame and video frame 2 as the first reference frame as an example, Figure 3 As shown, if the scene complexity of video frame 1 relative to video frame 2 is greater than the first threshold, then both video frame 1 and video frame 2 are determined as candidate video frames. When each video frame is used as the current video frame, the scene complexity of the current video frame relative to each first reference frame is compared with the first threshold, and then a forward prediction coding frame can be determined from the candidate video frames. The details of determining the forward prediction coding frame from the candidate video frames are given later.
[0067] According to the frame type determination method of the embodiment of the present disclosure, each video frame is used as the current video frame, and other video frames except the current video frame in the video frame sequence are used as the first reference frames, and the current video frame and the first reference frame are analyzed to determine the similarity of the content of the background area of the current video frame relative to the first reference frame and the complexity of the relative motion of the pixel blocks in the foreground area, so that the similarity of the content of the background area can reflect the inter-frame similarity of the video frames, and the complexity of the relative motion of the pixel blocks in the foreground area can reflect the difference of the video frames; according to the similarity of the content of the background area and the complexity of the relative motion of the pixel blocks in the foreground area, the scene complexity of the current video frame relative to the first reference frame is determined. clutter, so that the scene complexity is more accurate when representing the complexity of scene differences; the current video frame and the first reference frame corresponding to the scene complexity greater than the first threshold are determined as candidate video frames, and the forward prediction coding frame is determined from the candidate video frames. Since the scene complexity represents the complexity of scene differences and is obtained based on the similarity of the content of the background area and the complexity of the relative motion of the pixel blocks in the foreground area, it is more accurate to determine the candidate video frame based on the comparison of the scene complexity with the first threshold, thereby making it more accurate to determine the forward prediction coding frame from the candidate video frame; and there is no need for predictive coding cost, which can reduce the data processing cost and have higher data processing speed and real-time performance. In this case, the frame type determination method of the embodiment of the present disclosure can achieve a balance between speed and accuracy, and a better bit rate control effect can be achieved based on the determined frame type.
[0068] In a possible implementation, the video frame sequence is a video frame sequence between two adjacent intra-coded frames.
[0069] For example, the frame type determination method of the embodiment of the present disclosure can be performed after an I frame is determined, that is, the type of each video frame in the video frame sequence has not yet been determined, and the type is a P frame or a B frame. Further, in order to improve the accuracy of the frame type determination, the video frame sequence can be a video frame sequence between two adjacent I frames. Among them, no other I frames are included between adjacent I frames. At this time, the adjacent video frames in the video frame sequence are continuous, and the length of the video frame sequence can be less than or equal to the number of video frames between the two adjacent I frames.
[0070] Those skilled in the art should understand that the frame type determination method disclosed herein is also applicable to a video frame sequence between two non-adjacent I frames. In this case, adjacent video frames in the video frame sequence may be continuous or discontinuous, as long as the video frames in the video frame sequence are numbered in the order of acquisition and do not include I frames. The embodiments of the present disclosure do not impose any restriction on whether adjacent video frames in the video frame sequence are continuous.
[0071] In this way, the application of the frame type determination method disclosed in the present invention is made more flexible.
[0072] The foreground area and background area of each video frame can be determined by a pre-stage video preprocessing module (not shown) before executing the frame type determination method of the present disclosure. If the foreground area and background area of each video frame in the video frame sequence have not been determined when executing the frame type determination method of the present disclosure, it is necessary to first determine the foreground area and background area of each video frame, and then execute step S21. The following is an exemplary method for determining the foreground area and background area of a video frame according to an embodiment of the present disclosure.
[0073] Figure 4 A schematic diagram showing the process of a frame type determination method according to an embodiment of the present disclosure.
[0074] like Figure 4 As shown, in a possible implementation, the method further includes:
[0075] Step S41, taking the nearest intra-frame coded frame in the video frame sequence as the second reference frame, analyzing the current video frame and the second reference frame to determine the type of each pixel block included in the current video frame;
[0076] Step S42, determining the foreground area of the current video frame according to the pixel blocks of the foreground type, and determining the background area of the current video frame according to the pixel blocks of the background type.
[0077] For example, first, step S41 may be performed to use the most recent intra-frame coded frame in the video frame sequence as the second reference frame. The most recent intra-frame coded frame in the video frame sequence refers to an intra-frame coded frame that is acquired earlier than the earliest video frame in the video frame sequence and is closest to the video frame in the video frame sequence.
[0078] Figure 5 A schematic diagram showing a method for selecting a second reference frame according to an embodiment of the present disclosure.
[0079] like Figure 5 As shown, it is assumed that video frames 11 to 19 are continuously captured video frames. Each video frame is numbered in the order of the capture time, and the smaller the number, the earlier the capture time of the video frame. Among them, video frame 11, video frame 15, and video frame 19 are I frames, and the video frame sequence to be determined for frame type includes video frame 16 to video frame 18. Then video frame 15 can be used as the second reference frame.
[0080] Next, each video frame can be used as the current video frame, and the current video frame and the second reference frame can be analyzed to determine the types of each pixel block included in the current video frame. The current video frame and the second reference frame can be analyzed by conventional methods of the prior art (such as frame difference method, motion estimation method, histogram matching, etc.). An example of analyzing the current video frame and the second reference frame by the motion estimation method is given below, and the specific implementation of analyzing the current video frame and the second reference frame by other prior art methods will not be described here.
[0081] Those skilled in the art should understand that there are more ways to analyze the current video frame and the second reference frame to determine the types of each pixel block included in the current video frame. For example, a separation network for distinguishing foreground and background can be built based on a neural network method, and the current video frame and the second reference frame can be input into the separation network. The separation network automatically marks the pixel blocks of the foreground type and the pixel blocks of the background type in the current video frame. The embodiments of the present disclosure do not limit the specific implementation method for analyzing the current video frame and the second reference frame to determine the types of each pixel block included in the current video frame.
[0082] The following describes an exemplary method of analyzing the current video frame and the second reference frame using a motion estimation method.
[0083] In a possible implementation, in step S41, analyzing the current video frame and the second reference frame to determine the type of each pixel block included in the current video frame includes:
[0084] According to the second reference frame, performing motion estimation on each pixel block included in the current video frame to determine a second motion vector of each pixel block;
[0085] Determine a reference motion vector corresponding to the current video frame according to the second motion vector of each pixel block included in the current video frame;
[0086] When the absolute value of the difference between the second motion vector of any pixel block included in the current video frame and the reference motion vector corresponding to the current video frame is greater than a third threshold, determining that the type of the pixel block is foreground;
[0087] When the absolute value of the difference between the second motion vector of any pixel block included in the current video frame and the reference motion vector corresponding to the current video frame is less than or equal to the third threshold, the type of the pixel block is determined to be background.
[0088] For example, first, motion estimation can be performed on each pixel block included in the current video frame according to the second reference frame to determine the second motion vector of each pixel block. For each pixel block included in the current video frame, a corresponding reference pixel block can be found from the second reference frame, and the displacement of the two pixel blocks is used as the second motion vector of the pixel block. Motion estimation can be implemented based on existing technologies, and the details of motion estimation will not be repeated here.
[0089] In this case, if the current video frame includes M pixel blocks, M second motion vectors corresponding to the M pixel blocks can be calculated (M is an integer greater than 1). The values of any two second motion vectors corresponding to the current video frame may be the same or different, and the reference motion vector corresponding to the current video frame can be determined from the second motion vectors according to the values of the second motion vectors corresponding to the current video frame. For example, the value of the second motion vector with the most occurrences can be selected as the value of the reference motion vector; the value of the second motion vector greater than a certain threshold can also be used as the value of the reference motion vector. The disclosed embodiment does not limit how to determine the reference motion vector.
[0090] The second motion vector of each pixel block included in the current video frame may be compared with a reference motion vector corresponding to the current video frame. When the absolute value of the difference between the second motion vector of any pixel block included in the current video frame and the reference motion vector corresponding to the current video frame is greater than a third threshold, the type of the pixel block is determined to be foreground; when the absolute value of the difference between the second motion vector of any pixel block included in the current video frame and the reference motion vector corresponding to the current video frame is less than or equal to the third threshold, the type of the pixel block is determined to be background.
[0091] The third threshold value may be set according to application scenario requirements, and the embodiment of the present disclosure does not limit the specific value of the third threshold value.
[0092] In this way, the types of pixel blocks in each video frame can be distinguished.
[0093] The following describes an exemplary method for determining the similarity of the contents of a background area (background similarity) according to an embodiment of the present disclosure.
[0094] In a possible implementation, each pixel block includes a plurality of pixel points.
[0095] In step S21, the current video frame and the first reference frame are analyzed to determine the similarity of the content of the background area of the current video frame relative to the first reference frame and the complexity of the relative motion of the pixel blocks in the foreground area, including:
[0096] Using a similarity analysis algorithm, analyzing the similarity of the contents of pixel blocks in the background area of the current video frame and the first reference frame, or the similarity of the contents of pixel points in the background area of the current video frame and the first reference frame;
[0097] The similarity of the content of the background area is determined according to the similarity of the content of the pixel blocks in the background area or the similarity of the content of the pixel points in the background area.
[0098] For example, the calculation of background similarity can be based on pixel blocks in the background area or pixel points in the background area. That is, the similarity analysis algorithm can be used to analyze the similarity of the content of pixel blocks in the background area of the current video frame and the first reference frame, and then determine the background similarity based on the similarity of the content of pixel blocks in the background area; or the similarity of the content of pixel points in the background area of the current video frame and the first reference frame can be analyzed, and then determine the background similarity based on the similarity of the content of pixel points in the background area.
[0099] When calculating the background similarity based on the pixel blocks in the background area, each pixel block in the background area may be downsampled to obtain a pixel point, and then the background similarity may be determined based on the similarity of the content of each pixel point after downsampling. When sampling the pixel block into pixel points, the pixel value of the pixel point after the sampling point may be equal to the absolute average of the pixel values of all the pixel points included in the pixel block.
[0100] The similarity of the content of the pixel points can be analyzed and calculated based on the similarity analysis algorithm of the prior art, such as any one of the histogram algorithm, the hash algorithm, and the cosine similarity algorithm. The specific analysis method of the similarity of the content of the pixel points will not be described in detail here.
[0101] When analyzing the similarity of the contents of pixel blocks, a similarity value is analyzed for each pixel block in the background area of the current video frame, and the average value of the analyzed similarity values can be used as the background similarity between the current video frame and the first reference frame.
[0102] When analyzing the similarity of the content of the pixel points, a similarity value is analyzed for each pixel point in the background area of the current video frame, and the average value of the analyzed similarity values can be used as the background similarity between the current video frame and the first reference frame.
[0103] Assuming that the current video frame is the i-th frame in the video frame sequence, and the first reference frame is the j-th frame in the video frame sequence, the background similarity between the current video frame and the first reference frame can be bgd_similarity[i][j]. The calculated background similarity value can be less than 1, and can be multiplied by the weight to scale up the scene complexity in the subsequent calculation, and then calculated with the foreground motion complexity.
[0104] Those skilled in the art should understand that the above similarity analysis algorithm is only an example. When analyzing the similarity of the content of the background area, other algorithms that can implement similarity analysis in the prior art can also be used. The embodiments of the present disclosure do not limit the specific algorithm used to analyze the background similarity.
[0105] In this way, the similarity of the contents of the background regions of any two video frames in the video frame sequence can be determined.
[0106] The following is an exemplary method for determining the complexity of relative motion of pixel blocks in a foreground area (foreground motion complexity) according to an embodiment of the present disclosure.
[0107] In a possible implementation, in step S21, analyzing the current video frame and the first reference frame to determine the similarity of the content of the background area of the current video frame relative to the first reference frame and the complexity of the relative motion of the pixel blocks in the foreground area include:
[0108] For each pixel block in the foreground area of the current video frame, searching for a pixel block matching the pixel block in the foreground area of the first reference frame;
[0109] Determining a first motion vector of the pixel block according to a displacement between the pixel block and a matching pixel block;
[0110] Determine a matching residual of the pixel block according to pixel values of the pixel block and a matching pixel block;
[0111] The complexity of the relative motion of the pixel blocks in the foreground area of the current video frame is determined according to the first motion vector and the matching residual of each pixel block in the foreground area.
[0112] For example, first, for each pixel block in the foreground area of the current video frame, a pixel block matching the pixel block can be searched in the foreground area of the first reference frame. The matching pixel blocks can be pixel blocks with greater texture similarity (smaller content difference). In this case, if the foreground area of the current video frame includes R pixel blocks (R is an integer greater than 1), and the foreground area of the first reference frame includes L pixel blocks (L is an integer greater than 1), then for each pixel block in the R pixel blocks, a matching pixel block is searched from the L pixel blocks. The search for matching pixel blocks can be implemented based on the existing technology and will not be repeated here.
[0113] The first motion vector of the pixel block can be determined based on the displacement between the pixel block and the matching pixel block. The first motion vector can reflect the displacement of the two pixel blocks. The matching residual of the pixel block is determined based on the pixel values of the pixel block and the matching pixel block. In one example, the matching residual can be equal to the average of the absolute values of the difference between the pixel values of the corresponding pixel points in the two matching pixel blocks. Those skilled in the art should understand that the matching residual can also be calculated using other existing technologies, such as being equal to the variance of the absolute values of the difference between the pixel values of the corresponding pixel points in the two matching pixel blocks, etc. As long as the matching residual can reflect the content difference between the two pixel blocks, the embodiments of the present disclosure do not limit the specific calculation method of the matching residual.
[0114] The foreground motion complexity of the current video frame can be determined based on the first motion vector and the matching residual of each pixel block in the foreground area of the current video frame. Exemplarily, the first motion vector can be rate estimated, the matching residual can be Hadamard transformed, and the product of the rate estimation value of the first motion vector and the weight value, plus the Hadamard transform value of the matching residual, can obtain the foreground motion complexity of the current video frame, as shown in the following formula:
[0115] fgd_motion_complexity[i][j]=lambda×rate_mv+satd_residual
[0116] Where i represents the number of the current video frame, j represents the number of the first reference frame, fgd_motion_complexity[i][j] represents the foreground motion complexity of the current video frame and the first reference frame, lambda represents the scale factor of the first motion vector, rate_mv represents the estimated bit rate of the first motion vector, and satd_residual represents the Hadamard transform value of the matching residual.
[0117] Those skilled in the art should understand that the matching pixel blocks may also be determined by the feature point matching method in the prior art, and the embodiments of the present disclosure do not limit the specific method used to search for the matching pixel blocks.
[0118] One way to calculate the scene complexity of the current video frame relative to the first reference frame is as follows:
[0119] scene_complexity[i][j]=alpha×bgd_similarity[i][j]+beta×fgd_motion_complexity[i][j]
[0120] Among them, scene_complexity[i][j] represents the scene complexity of the current video frame (video frame i) relative to the first reference frame (video frame j), alpha is the weight of the background similarity of the current video frame relative to the first reference frame, and beta is the weight of the foreground motion complexity of the current video frame relative to the first reference frame. Among them, beta is a number less than 1, and alpha is a number less than 1 multiplied by a proportional factor K, which is used to convert the background similarity to the same order of magnitude as the foreground motion complexity. The specific values of beta, alpha, and K can be set according to the requirements of the application scenario, so that the greater the background similarity, the smaller the scene complexity; the greater the foreground motion complexity, the greater the scene complexity. The present disclosure does not limit the specific values of beta, alpha, and K.
[0121] Those skilled in the art should understand that the scene complexity may also be calculated using other methods, as long as the scene complexity can reflect the complexity of scene differences. The embodiments of the present disclosure do not limit the specific method for calculating the scene complexity.
[0122] The following describes an exemplary method for determining a forward prediction coding frame from candidate video frames according to an embodiment of the present disclosure.
[0123] In a possible implementation, determining a forward prediction coding frame from candidate video frames includes:
[0124] When the number of candidate video frames is less than the second threshold, the candidate video frames are directly determined as forward prediction coding frames.
[0125] For example, if the number of candidate video frames is small, such as less than a preset second threshold, the candidate video frames can be directly determined as forward prediction coding frames, and the redundancy of forward prediction coding frames is low. In this way, the data processing cost of the frame type determination method disclosed in the present invention can be further reduced and the data processing efficiency can be improved.
[0126] The second threshold value may be set according to application scenario requirements, and the embodiment of the present disclosure does not limit the specific value of the second threshold value.
[0127] In a possible implementation, determining a forward prediction coding frame from candidate video frames includes:
[0128] When the number of the candidate video frames is greater than or equal to the second threshold, counting the number of scene complexities corresponding to each candidate video frame and greater than the first threshold as the number of times the candidate video frame is referenced;
[0129] In descending order of the number of references, starting from the candidate video frame with the highest number of references, the candidate video frame with the first value is selected as the forward prediction coding frame.
[0130] For example, if the number of candidate video frames is large, such as greater than or equal to the second threshold, it may be considered that a small number of candidate video frames need to be further screened to be determined as forward prediction coding frames.
[0131] The ratio of the number of P frames to the number of candidate video frames 1 / Q can be calculated based on the statistical data of encoding the sample video frame sequence at different bit rates, or 1 / Q can be configured by the user, where Q is an integer greater than 1, and the specific value of Q is not limited in the embodiment of the present disclosure. Assuming that there are a total of X candidate video frames (X is an integer greater than 1), and X / Q is an integer, then the first value can be equal to X / Q. If X / Q is not an integer, X / Q can be rounded and used as the first value. At this time, the first value can be the expected value of the number of P frames in the video frame sequence.
[0132] The number of scene complexities corresponding to each candidate video frame and greater than the first threshold value may be counted as the number of times the candidate video frame is referenced. For example, when the scene complexity of video frame 1 relative to video frame 2 is greater than the first threshold value, both video frame 1 and video frame 2 are determined as candidate video frames. At this time, the number of scene complexities corresponding to video frame 1 and greater than the first threshold value is increased by 1, and the number of times video frame 1 is determined as a candidate video frame is also increased by 1. The number of scene complexities corresponding to video frame 2 and greater than the first threshold value is increased by 1, and the number of times video frame 2 is determined as a candidate video frame is also increased by 1.
[0133] Since the scene complexity of the current video frame relative to any first reference frame may be greater than the first threshold, and at the same time, when the current video frame is used as the first reference frame, the scene complexity of any other video frame relative to the current video frame may also be greater than the first threshold, therefore, the number of scene complexities greater than the first threshold corresponding to each candidate video frame may be more than one, that is, each video frame may be determined as a candidate video frame more than once.
[0134] The number of scene complexities corresponding to each candidate video frame and greater than the first threshold value, that is, the number of times the candidate video frame is determined as a candidate video frame, can be counted as the number of times the candidate video frame is referenced. In descending order of the number of times referenced, starting from the candidate video frame with the highest number of times referenced, the candidate video frame with the first value (X / Q) is selected as the forward prediction coding frame.
[0135] Furthermore, if the reference times of multiple candidate video frames are the same, the priorities of the multiple candidate video frames may be determined according to the sum of scene complexities corresponding to the candidate video frames and greater than the first threshold, wherein the candidate video frame with a greater sum of scene complexities has a greater priority.
[0136] The number of times a candidate video frame is referenced can reflect the reference value of the candidate video frame. In this way, video frames that make a greater reference contribution to the entire video frame sequence can be selected as P frames, thereby improving the accuracy of P frame determination, improving subsequent encoding effects, and reducing the redundancy of forward prediction encoding frames.
[0137] Figure 6 A schematic diagram showing the structure of a frame type determination device according to an embodiment of the present disclosure.
[0138] like Figure 6 As shown, the present disclosure also provides a frame type determination device, the device is used to determine a forward prediction coding frame in a video frame sequence, the video frame sequence includes a plurality of video frames, each video frame includes a foreground area and a background area, each area includes at least one pixel block, the device includes:
[0139] A first determination module 61 is used to use each video frame as a current video frame, use other video frames in the video frame sequence except the current video frame as first reference frames, analyze the current video frame and the first reference frame, and determine the similarity of the content of the background area of the current video frame relative to the first reference frame and the complexity of the relative motion of the pixel blocks in the foreground area;
[0140] A second determination module 62, configured to determine the scene complexity of the current video frame relative to the first reference frame according to the similarity of the content of the background area and the complexity of the relative motion of the pixel blocks in the foreground area, wherein the scene complexity indicates the complexity of the scene difference;
[0141] The third determination module 63 is used to determine the current video frame and the first reference frame corresponding to the scene complexity greater than the first threshold as candidate video frames, and determine the forward prediction coding frame from the candidate video frames.
[0142] In a possible implementation manner, the video frame sequence is a video frame sequence between two adjacent intra-coded frames.
[0143] In a possible implementation manner, the third determination module is used to directly determine the candidate video frames as the forward prediction coding frames when the number of the candidate video frames is less than a second threshold.
[0144] In one possible implementation, the third determination module is used to, when the number of candidate video frames is greater than or equal to a second threshold, count the number of scene complexities corresponding to each candidate video frame that is greater than a first threshold as the number of references of the candidate video frame; and select the candidate video frame with the first value as the forward prediction coding frame in descending order of the number of references, starting from the candidate video frame with the highest number of references.
[0145] In a possible implementation, the first determination module is used to, for each pixel block in the foreground area of the current video frame, search for a pixel block matching the pixel block in the foreground area of the first reference frame; determine a first motion vector of the pixel block based on the displacement of the pixel block and the matching pixel block; determine a matching residual of the pixel block based on the pixel values of the pixel block and the matching pixel block; and determine the complexity of the relative motion of the pixel blocks in the foreground area based on the first motion vector and the matching residual of each pixel block in the foreground area of the current video frame.
[0146] In a possible implementation, each pixel block includes multiple pixel points, and the first determination module is used to use a similarity analysis algorithm to analyze the similarity of the contents of the pixel blocks in the background area of the current video frame and the first reference frame, or the similarity of the contents of the pixel points in the background area of the current video frame and the first reference frame; and determine the similarity of the content of the background area based on the similarity of the contents of the pixel blocks in the background area, or the similarity of the contents of the pixel points in the background area.
[0147] In a possible implementation manner, the device further includes:
[0148] a fourth determination module, configured to use the intra-frame coded frame closest to the video frame sequence as a second reference frame, analyze the current video frame and the second reference frame, and determine the type of each pixel block included in the current video frame;
[0149] The fifth determination module is used to determine the foreground area of the current video frame according to the pixel blocks of the foreground type, and determine the background area of the current video frame according to the pixel blocks of the background type.
[0150] In a possible implementation, the fourth determination module is used to perform motion estimation on each pixel block included in the current video frame according to the second reference frame to determine the second motion vector of each pixel block; determine the reference motion vector corresponding to the current video frame according to the second motion vector of each pixel block included in the current video frame; determine the type of the pixel block as foreground when the absolute value of the difference between the second motion vector of any pixel block included in the current video frame and the reference motion vector corresponding to the current video frame is greater than a third threshold; determine the type of the pixel block as background when the absolute value of the difference between the second motion vector of any pixel block included in the current video frame and the reference motion vector corresponding to the current video frame is less than or equal to a third threshold.
[0151] 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.
[0152] 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.
[0153] The present disclosure also provides an electronic device, comprising: a processor; 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. Figure 1 And the first device in the related description.
[0154] 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.
[0155] 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.
[0156] 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.
[0157] 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.
[0158] 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.
[0159] 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.
[0160] 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.
[0161] 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.
[0162] 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.
[0163] 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.
[0164] 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.
[0165] 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.
[0166] 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 determining a frame type, characterized in that: The method is used to determine a forward prediction coding frame in a video frame sequence, wherein the video frame sequence includes a plurality of video frames, each video frame includes a foreground area and a background area, each area includes at least one pixel block, and the method includes: Taking each video frame as a current video frame, taking other video frames in the video frame sequence except the current video frame as first reference frames, analyzing the current video frame and the first reference frame, and determining the similarity of the content of the current video frame relative to the background area of the first reference frame and the complexity of the relative motion of the pixel blocks in the foreground area; Determining the scene complexity of the current video frame relative to the first reference frame according to the similarity of the content of the background area and the complexity of the relative motion of the pixel blocks in the foreground area, wherein the scene complexity indicates the complexity of the scene difference; The current video frame and the first reference frame corresponding to the scene complexity greater than a first threshold are determined as candidate video frames, and the forward prediction coding frame is determined from the candidate video frames.
2. The method according to claim 1, characterized in that The video frame sequence is a video frame sequence between two adjacent intra-coded frames.
3. The method according to claim 1, characterized in that The determining the forward prediction coding frame from the candidate video frames comprises: When the number of the candidate video frames is less than a second threshold, the candidate video frames are directly determined as the forward prediction coding frames.
4. The method according to claim 1, characterized in that The determining the forward prediction coding frame from the candidate video frames comprises: When the number of the candidate video frames is greater than or equal to the second threshold, counting the number of scene complexities corresponding to each candidate video frame and greater than the first threshold as the number of times the candidate video frame is referenced; In descending order of the number of references, starting from the candidate video frame with the highest number of references, the candidate video frame with the first value is selected as the forward prediction coding frame.
5. The method according to claim 1, characterized in that: The analyzing the current video frame and the first reference frame to determine the similarity of the content of the current video frame relative to the background area of the first reference frame and the complexity of the relative motion of the pixel blocks in the foreground area includes: For each pixel block in the foreground area of the current video frame, searching for a pixel block matching the pixel block in the foreground area of the first reference frame; Determining a first motion vector of the pixel block according to a displacement between the pixel block and a matching pixel block; Determine a matching residual of the pixel block according to pixel values of the pixel block and a matching pixel block; The complexity of the relative motion of the pixel blocks in the foreground area of the current video frame is determined according to the first motion vector and the matching residual of each pixel block in the foreground area.
6. The method according to claim 1, characterized in that Each pixel block includes multiple pixels. The analyzing the current video frame and the first reference frame to determine the similarity of the content of the current video frame relative to the background area of the first reference frame and the complexity of the relative motion of the pixel blocks in the foreground area includes: Using a similarity analysis algorithm, analyzing the similarity of contents of pixel blocks in the background area between the current video frame and the first reference frame, or the similarity of contents of pixel points in the background area between the current video frame and the first reference frame; The similarity of the content of the background area is determined according to the similarity of the content of the pixel blocks in the background area or the similarity of the content of the pixel points in the background area.
7. The method according to claim 1, characterized in that The method further comprises: Taking the most recent intra-frame coded frame in the video frame sequence as a second reference frame, analyzing the current video frame and the second reference frame to determine the type of each pixel block included in the current video frame; The foreground area of the current video frame is determined according to the pixel blocks of foreground type, and the background area of the current video frame is determined according to the pixel blocks of background type.
8. The method according to claim 7, characterized in that The analyzing the current video frame and the second reference frame to determine the type of each pixel block included in the current video frame includes: According to the second reference frame, performing motion estimation on each pixel block included in the current video frame to determine a second motion vector of each pixel block; Determining a reference motion vector corresponding to the current video frame according to a second motion vector of each pixel block included in the current video frame; When the absolute value of the difference between the second motion vector of any pixel block included in the current video frame and the reference motion vector corresponding to the current video frame is greater than a third threshold, determining that the type of the pixel block is foreground; When the absolute value of the difference between the second motion vector of any pixel block included in the current video frame and the reference motion vector corresponding to the current video frame is less than or equal to a third threshold, the type of the pixel block is determined to be background.
9. A frame type determination device, characterized in that: The device is used to determine a forward prediction coding frame in a video frame sequence, the video frame sequence includes a plurality of video frames, each video frame includes a foreground area and a background area, each area includes at least one pixel block, and the device includes: A first determination module is used to use each video frame as a current video frame, use other video frames in the video frame sequence except the current video frame as first reference frames, analyze the current video frame and the first reference frame, and determine the similarity of the content of the background area of the current video frame relative to the first reference frame and the complexity of the relative motion of the pixel blocks in the foreground area; a second determination module, configured to determine the scene complexity of the current video frame relative to the first reference frame according to the similarity of the content of the background area and the complexity of the relative motion of the pixel blocks in the foreground area, wherein the scene complexity indicates the complexity of the scene difference; The third determination module is used to determine the current video frame and the first reference frame corresponding to the scene complexity greater than the first threshold as candidate video frames, and determine the forward prediction coding frame from the candidate video frames.
10. An electronic device, characterized in that: include: processor; a memory for storing processor-executable instructions; The processor is configured to implement the method described in any one of claims 1 to 8 when executing the instructions stored in the memory.
11. 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 8 is implemented.