Prediction macroblock coding type determination method and device
By using the motion vector information of adjacent macroblocks, we can determine whether the macroblock in video encoding is a skipped block, thereby determining its encoding type, solving the problem of excessive calculation volume at high resolution and high frame rate, and improving encoding Efficiency and real-time processing performance.
Patent Information
- Application Number
- CN202411325873.X
- Authority / Receiving Office
- CN · China
- Patent Type
- Applications(China)
- Current Assignee / Owner
- Filing Date
- 2024-09-23
- Publication Date
- 2024-12-27
AI Technical Summary
In high resolution and high frame rate scenarios, the existing video encoding technology needs to calculate the intra- and inter-frame prediction costs for each macroblock, resulting in an increase in the calculation amount, affecting the encoding efficiency and real-time processing performance.
By obtaining the first motion vector and intra and inter prediction costs of the current macroblock, and calculating the second motion vector based on the target motion vector of the adjacent macroblock, we judge whether the macroblock is a skipped block, thereby determining its prediction encoding type , reduce redundant calculations.
The calculation complexity is reduced, the efficiency of predicting macroblock encoding type determination is improved, unnecessary calculations are reduced, and encoding efficiency is improved.
Smart Images

Figure CN119211576A_ABST
Abstract
Description
Technical Field
[0001] The present application relates to the technical field of video encoding processing, and more specifically, to a method and device for determining a prediction macroblock encoding type. Background Art
[0002] The core goal of video coding is to achieve efficient compression by reducing temporal and spatial redundancy in video frames. In coding standards such as H.264 / AVC, the selection of predictive macroblock coding type is crucial to compression efficiency and image quality.
[0003] The existing macroblock prediction coding type selection method needs to calculate the intra-frame prediction cost and inter-frame prediction cost of each macroblock separately, and determine the final coding type based on the smaller cost. However, in high-resolution (such as 4K, 8K) or high frame rate (such as 60fps and above) scenarios, this method requires two cost calculations for each macroblock, resulting in a linear increase in the amount of calculation, which greatly increases the coding complexity and affects the real-time processing performance of the encoder.
[0004] In addition, the existing scheme cannot fully utilize the correlation between motion vectors, which further increases the amount of redundant calculations. Therefore, a method for determining the prediction macroblock coding type that can reduce computational complexity and improve coding efficiency is needed. Summary of the invention
[0005] The present application is provided to solve the above problems existing in the prior art. According to a method and device for determining a prediction macroblock coding type according to an embodiment of the present application, the amount of calculation can be reduced, thereby improving coding efficiency.
[0006] In a first aspect, an embodiment of the present application provides a method for determining a prediction macroblock encoding type, comprising:
[0007] Obtaining the first motion vector, intra-frame prediction cost and inter-frame prediction cost of the current macroblock from the forward prediction module;
[0008] Calculating a second motion vector of the current macroblock based on target motion vectors of a plurality of other macroblocks adjacent to the current macroblock;
[0009] Determining whether the current macroblock is a skip block based on a difference between the first motion vector and the second motion vector;
[0010] In response to the current macroblock not being a skip block, determining a prediction coding type of the current macroblock based on the intra prediction cost and the inter prediction cost;
[0011] The prediction coding type is inter-frame prediction or intra-frame prediction.
[0012] In a second aspect, an embodiment of the present application provides a device for determining a prediction macroblock encoding type, comprising:
[0013] An acquisition module, configured to acquire a first motion vector, an intra-frame prediction cost, and an inter-frame prediction cost of a current macroblock from a forward prediction module;
[0014] A calculation module, configured to calculate a second motion vector of the current macroblock based on target motion vectors of a plurality of other macroblocks adjacent to the current macroblock;
[0015] a determination module configured to determine whether the current macroblock is a skip block based on a difference between the first motion vector and the second motion vector, and in response to the current macroblock not being a skip block, determine a prediction coding type of the current macroblock based on the intra prediction cost and the inter prediction cost;
[0016] The prediction coding type is inter-frame prediction or intra-frame prediction.
[0017] In a third aspect, the present application provides an electronic device, including:
[0018] one or more processors;
[0019] a storage device for storing one or more programs,
[0020] When the one or more programs are executed by the one or more processors, the one or more processors implement the method described in any of the above embodiments.
[0021] In a fourth aspect, the present application provides a computer-readable medium having a computer program stored thereon, wherein the program, when executed by a processor, implements the method described in any of the above embodiments.
[0022] The beneficial effect of the embodiments of the present application is that the prediction coding type is determined based on the first motion vector, intra-frame prediction cost and inter-frame prediction cost provided by the forward prediction module, without calculating the intra-frame prediction cost and inter-frame prediction cost for each macroblock, which can improve the efficiency of determining the prediction coding type. BRIEF DESCRIPTION OF THE DRAWINGS
[0023] In the drawings, which are not necessarily drawn to scale, the same reference numerals may describe similar parts in different views. The same reference numerals with letter suffixes or different letter suffixes may represent different instances of similar parts. The accompanying drawings generally illustrate various embodiments by way of example and not limitation, and together with the specification and claims, are used to illustrate the disclosed embodiments. When appropriate, the same reference numerals are used throughout the drawings to refer to the same or similar parts. Such embodiments are illustrative and are not intended to be exhaustive or exclusive embodiments of the present apparatus or method.
[0024] Figure 1 is a flowchart of a method for determining a prediction macroblock encoding type provided by an embodiment of the present application;
[0025] Figure 2 is a flowchart of a method for determining a prediction macroblock encoding type provided by another embodiment of the present application;
[0026] Figure 3 It is a schematic diagram of a device for determining a prediction macroblock encoding type provided by an embodiment of the present application. DETAILED DESCRIPTION
[0027] In order to enable those skilled in the art to better understand the technical solution of the present application, the present application is described in detail below in conjunction with the accompanying drawings and specific embodiments. The embodiments of the present application are further described in detail below in conjunction with the accompanying drawings and specific embodiments, but are not intended to limit the present application. The terms "first", "second" and "third" used in the present application are only intended to distinguish the corresponding features, do not represent the need for such an order, and do not necessarily represent only the singular form.
[0028] like Figure 1 As shown, the embodiment of the present application provides a method for determining a prediction macroblock encoding type, comprising:
[0029] Step 101: Obtain the first motion vector, intra-frame prediction cost and inter-frame prediction cost of the current macroblock from the forward prediction module.
[0030] The forward prediction module is the lookahead module, which corresponds to the lookahead stage, such as the lookahead stage of the H.264 encoder.
[0031] In the encoding process, the lookahead stage is a step that occurs after the raw data is input and before the actual encoding process. It is responsible for analyzing future frames in order to make better decisions during the encoding process. This pre-analysis allows the encoder to optimize bitrate allocation, determine frame types (such as I-frames, P-frames, or B-frames), predict motion vectors, and make other encoding optimization decisions.
[0032] The intra prediction cost represents the cost incurred for encoding the current macroblock during the intra prediction process, while the inter prediction cost represents the cost incurred for encoding the macroblock during the inter prediction process.
[0033] Step 102: Calculate a second motion vector of the current macroblock based on target motion vectors of a plurality of other macroblocks adjacent to the current macroblock.
[0034] Prediction coding types include inter-frame prediction and intra-frame prediction.
[0035] A skip block refers to a macroblock that does not need to be encoded during the encoding process.
[0036] Take the example that other macroblocks are adjacent macroblocks to the left and above the current macroblock. Specifically, the reference frame index and target motion vector of each other macroblock can be obtained. If there are other macroblocks whose reference frame index is invalid or whose target motion vector is a zero vector, the second motion vector of the current macroblock is a zero vector. Otherwise, each other macroblock is compared with the reference frame index of the current macroblock. If the reference frames of more than two other macroblocks are the same as the reference frame of the current macroblock, the second motion vector of the current macroblock is determined to be the average of the target motion vectors of the other macroblocks with the same reference frame. If only one other macroblock has the same reference frame as the reference frame of the current macroblock, the second motion vector of the current macroblock is determined to be the target motion vector of the other macroblock. If the reference frames of each other macroblock are different from the reference frame of the current macroblock, the second motion vector of the current macroblock is determined to be the average of the target motion vectors of the other macroblocks with the same reference frame.
[0037] Of course, in actual application scenarios, adjacent macroblocks in other directions may be used as other macroblocks, and the second motion vector may also be calculated in other ways, such as the second motion vector being the target motion vector of any other macroblock.
[0038] Through the embodiments of the present application, it is possible to accurately determine whether the current macroblock is a non-skipped block, and then accurately identify the prediction coding type of the current macroblock.
[0039] Step 103: Based on the difference between the first motion vector and the second motion vector, determine whether the current macroblock is a skip block; if so, terminate the current process; otherwise, execute step 104.
[0040] Step 104: Determine the prediction coding type of the current macroblock based on the intra-frame prediction cost and the inter-frame prediction cost.
[0041] The embodiment of the present application determines the prediction coding type based on the first motion vector, intra-frame prediction cost and inter-frame prediction cost provided by the forward prediction module. There is no need to calculate the intra-frame prediction cost and inter-frame prediction cost for each macroblock, which can improve the efficiency of determining the prediction coding type.
[0042] In one embodiment of the present application, determining whether the current macroblock is a skip block based on the difference between the first motion vector and the second motion vector includes:
[0043] Determine whether an absolute value of a difference between a projection length of the first motion vector on the X-axis and a projection length of the second motion vector on the X-axis, and an absolute value of a difference between a projection length of the first motion vector on the Y-axis and a projection length of the second motion vector on the Y-axis are both less than a preset first credibility threshold;
[0044] It is determined whether the current macroblock is a skip block based on the determination result.
[0045] Specifically, if both are less than the preset first credibility threshold, it means that the first motion vector provided by the lookahead module is credible and can be used for subsequent prediction coding type determination operations. Otherwise, it means that the error of the first motion vector is large. In the case where both are less than the preset first credibility threshold, the embodiment of the present application can further determine whether the current macroblock is a skip block based on the intra-frame prediction cost and the inter-frame prediction cost. If the inter-frame prediction cost is less than the intra-frame prediction cost, the current macroblock is a skip block, otherwise, it is a non-skip block.
[0046] The first credibility threshold can be set according to the actual business scenario. For example, in a video conference scenario, since the background of the picture is fixed and the characters do not move frequently, a higher first credibility threshold can be set for this scenario, thereby increasing the probability that the first motion vector participates in the subsequent prediction coding type determination, so as to reduce the subsequent amount of calculation and improve the coding efficiency. In complex motion scenes, a smaller first credibility threshold can be set to appropriately reduce the number of skipped blocks to ensure that subtle movements can also be captured and the picture quality is guaranteed.
[0047] In actual application scenarios, it is possible to determine whether only the absolute value of the difference between the projection length of the first motion vector on the X-axis and the projection length of the second motion vector on the X-axis is less than a preset first credibility threshold, or to determine whether only the absolute value of the difference between the projection length of the first motion vector on the Y-axis and the projection length of the second motion vector on the Y-axis is less than a preset first credibility threshold, and it is not limited to one implementation method.
[0048] In one embodiment of the present application, determining whether the current macroblock is a skip block based on the determination result includes:
[0049] In response to the absolute values of the differences being less than a first credibility threshold, calculating a prediction factor based on a ratio of an inter-frame prediction cost to an intra-frame prediction cost;
[0050] The prediction factor is compared with a preset first type threshold, and whether the current macroblock is a skip block is determined based on the comparison result.
[0051] When both are less than the preset first credibility threshold, directly comparing the size of the intra-frame prediction cost and the inter-frame prediction cost, the result is relatively simple, and it is not possible to dynamically adjust the number of skipped blocks and non-skipped blocks according to the business scenario. Therefore, the embodiment of the present application calculates the prediction factor based on the inter-frame prediction cost and the intra-frame prediction cost, and identifies the skipped block by comparing the prediction factor with the first type threshold. Similar to the first credibility threshold, the first type threshold can be adjusted according to the actual business scenario.
[0052] The prediction factor may be a ratio of the inter-frame prediction cost to the intra-frame prediction cost, or may be as shown in formula (1).
[0053] S=(1-a / b)×1024 (1)
[0054] Wherein, a is the inter-frame prediction cost, b is the intra-frame prediction cost. Taking formula (1) as an example, the first type threshold is 500. If S is greater than 500, the current macroblock is a skip block, otherwise, the current macroblock is a non-skipped block.
[0055] In one embodiment of the present application, comparing the prediction factor with a preset first type threshold, and determining whether the current macroblock is a skip block based on the comparison result includes:
[0056] In response to the prediction factor being greater than a first type threshold, determining the current macroblock to be a skip block;
[0057] In response to the prediction factor being not greater than the first type threshold, determining whether the current macroblock is a skip block based on the luminance and chrominance of the current macroblock.
[0058] In actual application scenarios, it is also possible to determine whether the current macroblock is a skip block based only on brightness or chrominance. Alternatively, when the prediction factor is not greater than the first type threshold, the current macroblock is determined to be a non-skipped block. In the embodiment of the present application, when the prediction factor is not greater than the first type threshold, in order to divide the current macroblock more accurately, the macroblock type is further determined based on the brightness and chrominance of the current macroblock.
[0059] In one embodiment of the present application, determining whether the current macroblock is a skip block based on the brightness and chrominance of the current macroblock includes:
[0060] Performing motion compensation on the luminance and chrominance of the current macroblock based on the second motion vector to generate a prediction block of the luminance plane and a prediction block of the chrominance plane;
[0061] The prediction block based on the luma plane calculates the luma residual, and the prediction block based on the chroma plane calculates the chroma residual;
[0062] Performing discrete cosine transform on the luminance residual and the chrominance residual respectively to obtain corresponding luminance discrete cosine transform coefficients and chrominance discrete cosine transform coefficients;
[0063] Calculate the luminance residual energy based on the luminance discrete cosine transform coefficient, and calculate the chrominance residual energy based on the chrominance discrete cosine transform coefficient;
[0064] In response to the luminance residual energy being less than a preset luminance energy threshold and the chrominance residual energy being less than a preset chrominance energy threshold, determining that the current macroblock is a skip block, otherwise, determining that the current macroblock is not a skip block;
[0065] The luminance residual is used to characterize the difference between the prediction block of the luminance plane and the current macroblock, and the chrominance residual is used to characterize the difference between the prediction block of the chrominance plane and the current macroblock.
[0066] Discrete cosine transform is a mathematical transform that converts macroblocks from the spatial domain to the frequency domain. It can concentrate most of the energy in the image into fewer frequency components, making subsequent compression more effective.
[0067] After obtaining the discrete cosine transform coefficients, these coefficients will be quantized. Quantization is to reduce the frequency domain data after discrete cosine transform according to the quantization parameter, erase the subtle high-frequency information, and further compress the data volume. The quantized result is used to calculate the residual energy. The luminance energy threshold and the chrominance energy threshold are pre-set values, which are used to determine whether the luminance residual energy and the chrominance residual energy are small enough. If the residual energy is lower than the corresponding threshold, it means that the prediction of the block is very close to the actual value and the encoding can be skipped; conversely, if the residual energy exceeds the corresponding threshold, the macroblock needs to be encoded.
[0068] The embodiment of the present application further confirms the type of the current macroblock through motion compensation, thereby improving the accuracy of macroblock classification and improving the encoding quality.
[0069] In actual application scenarios, only the luminance residual or the chrominance residual may be calculated, and the type of the current macroblock may be determined based on the luminance residual or the chrominance residual. Of course, when the prediction factor is not greater than the first type threshold, the current macroblock may be directly determined to be a non-skipped block.
[0070] In one embodiment of the present application, determining the prediction coding type of the current macroblock based on the intra-frame prediction cost and the inter-frame prediction cost includes:
[0071] Calculating a prediction factor based on a ratio of an inter-frame prediction cost to an intra-frame prediction cost;
[0072] The prediction factor is compared with a preset second type threshold, and the prediction coding type of the current macroblock is determined based on the comparison result.
[0073] The calculation method of the prediction factor can refer to the aforementioned embodiment. It should be noted that the prediction factor in this embodiment can be calculated in the same way as the aforementioned embodiment, or can be calculated in a different way from the aforementioned embodiment. For example, the prediction factor can be: 1-a / b.
[0074] In order to make more macroblocks conform to the skip macroblock type and improve coding efficiency, the first type threshold is generally smaller than the second type threshold. The embodiment of the present application can accurately identify the prediction coding type of the macroblock based on the prediction factor and the second type threshold, thereby improving the subsequent coding quality.
[0075] like Figure 2 As shown, the embodiment of the present application provides a method for determining a prediction macroblock encoding type, comprising:
[0076] Step 201: Obtain the first motion vector, intra-frame prediction cost and inter-frame prediction cost of the current macroblock from the forward prediction module.
[0077] Step 202: Calculate a second motion vector of the current macroblock based on target motion vectors of a plurality of other macroblocks adjacent to the current macroblock.
[0078] Step 203: In response to the absolute value of the difference between the projection length of the first motion vector on the X-axis and the projection length of the second motion vector on the X-axis, and the absolute value of the difference between the projection length of the first motion vector on the Y-axis and the projection length of the second motion vector on the Y-axis being less than a preset first credibility threshold, a prediction factor is calculated based on a ratio of the inter-frame prediction cost to the intra-frame prediction cost. In response to the prediction factor being greater than the first type threshold, step 204 is executed; otherwise, step 205 is executed.
[0079] Step 204: Determine whether the current macroblock is a skip block.
[0080] The skipped block does not participate in subsequent operations.
[0081] Step 205: Perform motion compensation on the current macroblock based on the second motion vector, generate a prediction block of the luminance plane and a prediction block of the chrominance plane, and calculate the luminance residual and the chrominance residual; perform discrete cosine transform on the luminance residual and the chrominance residual, respectively, to obtain corresponding luminance discrete cosine transform coefficients and chrominance discrete cosine transform coefficients, calculate the luminance residual energy based on the luminance discrete cosine transform coefficients, and calculate the chrominance residual energy based on the chrominance discrete cosine transform coefficients.
[0082] Step 206: Determine whether the current macroblock is a skip block based on the luminance residual energy and the preset luminance energy threshold, as well as the chrominance residual energy and the preset chrominance energy threshold; if so, execute step 204; otherwise, execute step 207.
[0083] Step 207: Calculate a prediction factor based on the ratio of the inter-frame prediction cost to the intra-frame prediction cost, compare the prediction factor with a preset second type threshold, and determine the prediction coding type of the current macroblock based on the comparison result.
[0084] The embodiment of the present application can effectively utilize the data provided by the forward prediction module and improve the efficiency of determining the prediction coding type.
[0085] like Figure 3 As shown, the present application provides a device for determining a prediction macroblock encoding type, comprising:
[0086] An acquisition module 301 is configured to acquire a first motion vector, an intra-frame prediction cost, and an inter-frame prediction cost of a current macroblock from a forward prediction module;
[0087] A calculation module 302, configured to calculate a second motion vector of the current macroblock based on target motion vectors of a plurality of other macroblocks adjacent to the current macroblock;
[0088] The determination module 303 is configured to determine whether the current macroblock is a skip block based on a difference between the first motion vector and the second motion vector, and in response to the current macroblock not being a skip block, determine a prediction coding type of the current macroblock based on an intra prediction cost and an inter prediction cost;
[0089] Among them, the prediction coding type is inter-frame prediction or intra-frame prediction.
[0090] In one embodiment of the present application, the determination module 303 is configured to determine whether the absolute value of the difference between the projection length of the first motion vector on the X-axis and the projection length of the second motion vector on the X-axis, and the absolute value of the difference between the projection length of the first motion vector on the Y-axis and the projection length of the second motion vector on the Y-axis are both less than a preset first credibility threshold; and determine whether the current macroblock is a skip block based on the determination result.
[0091] In one embodiment of the present application, the determination module 303 is configured to calculate a prediction factor based on the ratio of the inter-frame prediction cost to the intra-frame prediction cost in response to the absolute values of the differences being less than a first credibility threshold; compare the prediction factor with a preset first type threshold, and determine whether the current macroblock is a skip block based on the comparison result.
[0092] In one embodiment of the present application, the determination module 303 is configured to determine that the current macroblock is a skip block in response to the prediction factor being greater than the first type threshold; and to determine whether the current macroblock is a skip block based on the brightness and chrominance of the current macroblock in response to the prediction factor being not greater than the first type threshold.
[0093] In one embodiment of the present application, the determination module 303 is configured to perform motion compensation on the brightness and chrominance of the current macroblock based on the second motion vector, respectively, to generate a prediction block of the brightness plane and a prediction block of the chrominance plane; calculate the brightness residual based on the prediction block of the brightness plane, and calculate the chrominance residual based on the prediction block of the chrominance plane; perform discrete cosine transform on the brightness residual and the chrominance residual, respectively, to obtain corresponding brightness discrete cosine transform coefficients and chrominance discrete cosine transform coefficients; calculate the brightness residual energy based on the brightness discrete cosine transform coefficient, and calculate the chrominance residual energy based on the chrominance discrete cosine transform coefficient; in response to the brightness residual energy being less than a preset brightness energy threshold and the chrominance residual energy being less than a preset chrominance energy threshold, determine that the current macroblock is a skip block, otherwise, determine that the current macroblock is not a skip block; wherein the brightness residual is used to characterize the difference between the prediction block of the brightness plane and the current macroblock, and the chrominance residual is used to characterize the difference between the prediction block of the chrominance plane and the current macroblock.
[0094] In one embodiment of the present application, the determination module 303 is configured to calculate a prediction factor based on the ratio of the inter-frame prediction cost to the intra-frame prediction cost; compare the prediction factor with a preset second type threshold, and determine the prediction coding type of the current macroblock based on the comparison result.
[0095] In one embodiment of the present application, the determination module 303 is configured to calculate the prediction factor based on Formula 1;
[0096] Formula 1:
[0097] S=(1-a / b)×1024
[0098] Among them, a is the inter-frame prediction cost, b is the intra-frame prediction cost, and S is the prediction factor.
[0099] An embodiment of the present application provides an electronic device, including:
[0100] one or more processors;
[0101] a storage device for storing one or more programs,
[0102] When one or more programs are executed by one or more processors, the one or more processors implement the method of any of the above embodiments.
[0103] An embodiment of the present application provides a computer-readable medium on which a computer program is stored. When the program is executed by a processor, a method as described in any of the above embodiments is implemented.
[0104] In addition, although exemplary embodiments have been described herein, the scope includes any and all embodiments based on the present application with equivalent elements, modifications, omissions, combinations (e.g., various embodiments intersecting schemes), adaptations or changes. Although several embodiments are listed and described for the wireless communication method and the wireless communication component, it should be noted that the method details involved in the description of the wireless communication component can also be incorporated into the various embodiments of the wireless communication method, and vice versa.
[0105] The elements in the claims are to be interpreted broadly based on the language employed in the claims and are not limited to the examples described in this specification or during the prosecution of the application, which examples are to be interpreted as non-exclusive. Therefore, this specification and examples are intended to be considered as examples only, with the true scope and spirit being indicated by the claims and the full scope of their equivalents.
[0106] The order of each step in the present application is merely exemplary and not restrictive. Without affecting the implementation of the present application (without destroying the required logical relationship between the steps), the execution order of the steps can be adjusted, and the various embodiments obtained after the adjustment still fall within the scope of the present application.
[0107] The above description is intended to be illustrative rather than restrictive. For example, the above examples (or one or more of them) can be used in combination with each other. For example, those of ordinary skill in the art can use other embodiments when reading the above description. In addition, in the above-mentioned specific embodiments, various features can be grouped together to simplify the application. This should not be interpreted as an intention that a disclosed feature that does not require protection is necessary for any claim. On the contrary, the subject matter of the present invention may be less than all the features of a specific disclosed embodiment. Thus, the claims are incorporated into the specific embodiments as examples or embodiments, wherein each claim is independently used as a separate embodiment, and it is considered that these embodiments can be combined with each other in various combinations or arrangements. The scope of the present invention should be determined with reference to the attached claims and the full scope of equivalent forms granted by these claims.
Claims
1. A method for determining a prediction macroblock encoding type, characterized in that: include: Obtaining the first motion vector, intra-frame prediction cost and inter-frame prediction cost of the current macroblock from the forward prediction module; Calculating a second motion vector of the current macroblock based on target motion vectors of a plurality of other macroblocks adjacent to the current macroblock; Determining whether the current macroblock is a skip block based on a difference between the first motion vector and the second motion vector; In response to the current macroblock not being a skip block, determining a prediction coding type of the current macroblock based on the intra prediction cost and the inter prediction cost; The prediction coding type is inter-frame prediction or intra-frame prediction.
2. The method according to claim 1, characterized in that Determining whether the current macroblock is a skip block based on a difference between the first motion vector and the second motion vector includes: Determine whether an absolute value of a difference between a projection length of the first motion vector on the X-axis and a projection length of the second motion vector on the X-axis, and an absolute value of a difference between a projection length of the first motion vector on the Y-axis and a projection length of the second motion vector on the Y-axis are both less than a preset first credibility threshold; It is determined whether the current macroblock is a skip block based on the determination result.
3. The method according to claim 2, characterized in that Determining whether the current macroblock is a skip block based on the determination result includes: In response to the absolute values of the differences being less than the first credibility threshold, calculating a prediction factor based on a ratio of the inter-frame prediction cost to the intra-frame prediction cost; The prediction factor is compared with a preset first type threshold, and whether the current macroblock is a skip block is determined based on the comparison result.
4. The method according to claim 3, characterized in that Comparing the prediction factor with a preset first type threshold, and determining whether the current macroblock is a skip block based on the comparison result, includes: In response to the prediction factor being greater than the first type threshold, determining that the current macroblock is a skip block; In response to the prediction factor being not greater than the first type threshold, determining whether the current macroblock is a skip block based on the luminance and chrominance of the current macroblock.
5. The method according to claim 4, characterized in that Determining whether the current macroblock is a skip block based on the brightness and chrominance of the current macroblock includes: Performing motion compensation on the luminance and chrominance of the current macroblock based on the second motion vector to generate a prediction block of a luminance plane and a prediction block of a chrominance plane; Calculate a luma residual based on the prediction block of the luma plane, and calculate a chroma residual based on the prediction block of the chroma plane; Performing discrete cosine transform on the luminance residual and the chrominance residual respectively to obtain corresponding luminance discrete cosine transform coefficients and chrominance discrete cosine transform coefficients; Calculate the luminance residual energy based on the luminance discrete cosine transform coefficient, and calculate the chrominance residual energy based on the chrominance discrete cosine transform coefficient; In response to the luminance residual energy being less than a preset luminance energy threshold and the chrominance residual energy being less than a preset chrominance energy threshold, determining that the current macroblock is a skip block, otherwise, determining that the current macroblock is not a skip block; The luminance residual is used to characterize the difference between the prediction block of the luminance plane and the current macroblock, and the chrominance residual is used to characterize the difference between the prediction block of the chrominance plane and the current macroblock.
6. The method according to claim 1, characterized in that Determining the prediction coding type of the current macroblock based on the intra-frame prediction cost and the inter-frame prediction cost includes: Calculating a prediction factor based on a ratio of the inter-frame prediction cost to the intra-frame prediction cost; The prediction factor is compared with a preset second type threshold, and the prediction coding type of the current macroblock is determined based on the comparison result.
7. The method according to claim 1, characterized in that Calculating a prediction factor based on a ratio of the inter-frame prediction cost to the intra-frame prediction cost includes: Calculate the prediction factor based on Formula 1; Formula 1: S=(1-a / b)×1024 Wherein, a is the inter-frame prediction cost, b is the intra-frame prediction cost, and S is the prediction factor.
8. A device for determining a prediction macroblock encoding type, characterized in that: include: An acquisition module, configured to acquire a first motion vector, an intra-frame prediction cost, and an inter-frame prediction cost of a current macroblock from a forward prediction module; A calculation module, configured to calculate a second motion vector of the current macroblock based on target motion vectors of a plurality of other macroblocks adjacent to the current macroblock; a determination module configured to determine whether the current macroblock is a skip block based on a difference between the first motion vector and the second motion vector, and in response to the current macroblock not being a skip block, determine a prediction coding type of the current macroblock based on the intra prediction cost and the inter prediction cost; The prediction coding type is inter-frame prediction or intra-frame prediction.
9. An electronic device, characterized in that: include: one or more processors; a storage device for storing one or more programs, When the one or more programs are executed by the one or more processors, the one or more processors implement the method according to any one of claims 1 to 7.
10. A computer readable medium having a computer program stored thereon, characterized in that: When the program is executed by a processor, the method according to any one of claims 1 to 7 is implemented.
