Motion estimation method and device, electronic equipment, storage medium and program product
By using a surface fitting algorithm to determine sub-pixel motion vectors in video coding, the problem of high computational complexity in motion estimation in the existing technology is solved, and more efficient motion estimation and video coding efficiency are achieved.
Patent Information
- Application Number
- CN202410767550.X
- Authority / Receiving Office
- CN · China
- Patent Type
- Applications(China)
- Current Assignee / Owner
- Filing Date
- 2024-06-14
- Publication Date
- 2024-10-22
AI Technical Summary
Existing video coding technology has high computational complexity in motion estimation and consumes a lot of computing resources. Especially when obtaining sub-pixel precision motion vectors, the interpolation method increases the computational complexity.
By obtaining the image blocks in the reference video frame and the current video frame, the integer motion vector is determined, and based on the vector, the integer motion vector is searched for an integer motion vector whose difference does not exceed the preset threshold, and the surface fitting algorithm is used to determine the integer motion vector under the condition of stable rate distortion cost. Sub-pixel motion vectors reduce the number of interpolation calculations and reduce computational complexity.
It effectively reduces the computational complexity and resource consumption of motion estimation, improves the efficiency and accuracy of motion estimation, reduces unnecessary computing overhead, and at the same time ensures the quality of video encoding.
Smart Images

Figure CN118827992A_ABST
Abstract
Description
Technical Field
[0001] The present invention belongs to the technical field of video coding, and in particular relates to a motion estimation method, device, electronic equipment, storage medium and program product. Background Art
[0002] Inter-frame prediction coding is a method in video compression technology, which is mainly used to reduce the redundant information between adjacent frames or close frames in a video sequence. In inter-frame prediction coding, motion estimation is a crucial link. It predicts the pixel displacement of the corresponding image block (current coding unit) in the current video frame relative to the corresponding image block in the reference video frame, that is, the motion vector, by analyzing the image block (reference coding unit) in the previous reference video frame (the frame that has been encoded and used for prediction). Subsequently, the encoder can use the calculated motion vector, combined with the reference coding unit corresponding to the current coding unit, to predict the predicted image of the current coding unit.
[0003] Accurate motion estimation can ensure that the difference between the predicted image and the actual encoded image is minimized, thereby improving the quality of video compression. Based on this, modern video coding standards use sub-pixel precision motion vectors to further improve prediction accuracy. Sub-pixel precision motion vectors can capture the displacement of continuous image blocks between adjacent frames that is less than one pixel width, thereby generating more accurate predicted images and improving the accuracy and efficiency of video coding.
[0004] However, in order to obtain motion vectors with sub-pixel accuracy, it is necessary to use interpolation to estimate pixel values at non-integer coordinate positions based on known pixels in the reference video frame. This process increases the computational complexity of motion estimation and consumes more computing resources. Summary of the invention
[0005] The embodiments of the present invention provide a motion estimation method, device, electronic device, storage medium and program product, which can reduce the computational complexity of motion estimation and reduce the consumption of computing resources.
[0006] In a first aspect, an embodiment of the present application provides a motion estimation method, the method comprising:
[0007] Acquire a reference video frame and a current video frame, wherein the reference video frame includes a plurality of first image blocks, and the current video frame includes a plurality of second image blocks;
[0008] For each second image block, do the following:
[0009] Obtaining a first motion vector corresponding to the current second image block, where the first motion vector is an integer pixel motion vector determined according to a relative displacement of a target image block between a reference video frame and a current video frame, and the target image block is a first image block having the highest matching degree with the current second image block;
[0010] Taking the first motion vector as the center, determining an integer pixel motion vector whose distance from the first motion vector does not exceed a preset threshold unit as a second motion vector;
[0011] For each second motion vector, when a standard deviation of a rate-distortion cost between the current second motion vector and the first motion vector is less than a preset threshold, a surface fitting algorithm is used to determine a sub-pixel motion vector of the current second image block;
[0012] Determining a target motion vector of a current second image block according to the sub-pixel motion vector and the first motion vector;
[0013] Motion estimation is performed on the current second image block according to the target motion vector.
[0014] As a possible implementation manner, before determining the target motion vector of the current second image block according to the sub-pixel motion vector and the first motion vector, the method further includes:
[0015] For each second motion vector, when the standard deviation of the rate-distortion cost between the current second motion vector and the first motion vector is greater than or equal to a preset threshold, an interpolation method is used to determine the sub-pixel motion vector of the current second image block.
[0016] As a possible implementation manner, a surface fitting algorithm is used to determine the sub-pixel motion vector of the current second image block, including:
[0017] constructing a quadratic surface equation according to the plurality of second motion vectors;
[0018] Solving a quadratic surface equation according to rate-distortion costs corresponding to the first motion vector and the plurality of second motion vectors;
[0019] quantize the motion vector corresponding to the lowest point position of the surface corresponding to the quadratic surface equation to a first sub-pixel accuracy to obtain a first reference motion vector;
[0020] A sub-pixel motion vector of the current second image block is determined according to the first reference motion vector.
[0021] As a possible implementation manner, determining the sub-pixel motion vector of the current second image block according to the first reference motion vector includes:
[0022] When the first reference motion vector is equal to the first motion vector, the first reference motion vector is determined as the sub-pixel motion vector of the current second image block.
[0023] As a possible implementation manner, determining the sub-pixel motion vector of the current second image block according to the first reference motion vector includes:
[0024] When the first reference motion vector is not equal to the first motion vector, solving a quadratic surface equation according to the rate-distortion costs corresponding to the first reference motion vector and four second motion vectors closest to the first reference motion vector in terms of distance;
[0025] quantizing the motion vector corresponding to the lowest point position of the surface corresponding to the quadratic surface equation to a second sub-pixel precision to obtain a second reference motion vector, where the second sub-pixel precision is higher than the first sub-pixel precision;
[0026] The sub-pixel motion vector of the current second image block is determined according to the second reference motion vector.
[0027] As a possible implementation manner, determining the sub-pixel motion vector of the current second image block according to the second reference motion vector includes:
[0028] When the second reference motion vector has the first sub-pixel precision or the integer-pixel precision, determining the first reference motion vector as a sub-pixel motion vector between the first motion vector and the second motion vector;
[0029] When the second reference motion vector is not of the first sub-pixel precision or the integer-pixel precision, the second reference motion vector and the first reference motion vector are determined as the sub-pixel motion vector of the current second image block.
[0030] In a second aspect, an embodiment of the present application provides a motion estimation device, the device comprising:
[0031] A first acquisition module, used to acquire a reference video frame and a current video frame, the reference video frame includes a plurality of first image blocks, and the current video frame includes a plurality of second image blocks;
[0032] A first determination module is used to obtain, for each second image block, a first motion vector corresponding to the current second image block, where the first motion vector is an integer pixel motion vector determined according to a relative displacement of a target image block between a reference video frame and a current video frame, and the target image block is a first image block having the highest matching degree with the current second image block;
[0033] A second determination module is used to determine, with the first motion vector as the center, an integer pixel motion vector whose distance from the first motion vector is not more than a preset threshold unit as a second motion vector;
[0034] A third determination module is configured to, for each second motion vector, determine a sub-pixel motion vector of a current second image block by using a surface fitting algorithm when a standard deviation of a rate-distortion cost between the current second motion vector and the first motion vector is less than a preset threshold;
[0035] a fourth determination module, configured to determine a target motion vector of a current second image block according to the sub-pixel motion vector and the first motion vector;
[0036] The motion estimation module is used to perform motion estimation on the current second image block according to the target motion vector.
[0037] In a third aspect, an embodiment of the present application provides an electronic device, comprising: a processor and a memory storing computer program instructions; when the processor executes the computer program instructions, the motion estimation method as described in any one of the first aspects is implemented.
[0038] In a fourth aspect, an embodiment of the present application provides a computer storage medium, on which computer readable storage medium is stored computer program instructions, and when the computer program instructions are executed by a processor, a motion estimation method as described in any one of the first aspects is implemented.
[0039] In a fifth aspect, an embodiment of the present application provides a computer program product, characterized in that it includes a computer program, and when the computer program is processed and executed, it implements the motion estimation method as any one of the first aspects.
[0040] The motion estimation method, device, electronic device, storage medium and program product of the embodiments of the present application, when performing motion estimation on the current second image block in the current video frame, usually first determine the target image block with the highest matching degree with the current second image block, and determine the first motion vector according to the relative displacement of the target image block between the reference video frame and the current video frame. Then, search for the second motion vector based on the first motion vector.
[0041] Furthermore, the standard deviation of the rate-distortion cost between the second motion vector and the first motion vector is calculated. When the standard deviation of the rate-distortion cost between the second motion vector and the first motion vector is less than a preset threshold, it indicates that within a given search area, the change of the motion vector is relatively stable and consistent, and there is no significant fluctuation or inconsistent motion estimation, which means that between the current video frame and the reference video frame, the first motion vector can already describe the motion trajectory of the second image block more accurately, so there is no need to perform a more refined motion vector search. For this type of second image block, a surface fitting algorithm can be used for further optimization search. The surface fitting algorithm uses a surface fitting method, which can reduce the computational complexity by reducing the number of interpolation calculations, thereby effectively avoiding unnecessary computational overhead, thereby effectively improving the efficiency of motion estimation while ensuring the accuracy of motion estimation. BRIEF DESCRIPTION OF THE DRAWINGS
[0042] In order to more clearly illustrate the technical solution of the embodiments of the present application, the following is a brief introduction to the drawings required for use in the embodiments of the present application. For ordinary technicians in this field, other drawings can be obtained based on these drawings without any creative work.
[0043] Figure 1 A schematic diagram of a motion estimation method provided by an embodiment of the present application is shown;
[0044] Figure 2a One of the schematic diagrams showing motion vector search results provided by one embodiment of the present application is shown;
[0045] Figure 2b A second schematic diagram showing a motion vector search result provided by an embodiment of the present application;
[0046] Figure 2c A third schematic diagram showing a motion vector search result provided by an embodiment of the present application;
[0047] Figure 3 A schematic diagram showing a first motion vector and a second motion vector of a second image block provided by an embodiment of the present application is shown;
[0048] Figure 4 A flowchart of a specific implementation method of S104 provided in an embodiment of the present application is shown;
[0049] Figure 5 A flowchart of a specific implementation method of S304 provided in an embodiment of the present application is shown;
[0050] Figure 6 A flowchart of a specific implementation method of S3045 provided in one embodiment of the present application is shown;
[0051] Figure 7 A schematic diagram of a sub-pixel motion vector provided by an embodiment of the present application is shown;
[0052] Figure 8 A schematic diagram showing the structure of a motion estimation device provided by an embodiment of the present application is shown;
[0053] Fig. 9 A schematic diagram of the hardware structure of an electronic device provided in an embodiment of the present application is shown. DETAILED DESCRIPTION
[0054] The features and exemplary embodiments of various aspects of the present application will be described in detail below. In order to make the purpose, technical solutions and advantages of the present application clearer, the present application will be further described in detail below in conjunction with the accompanying drawings and specific embodiments. It should be understood that the specific embodiments described herein are only intended to explain the present application, rather than to limit the present application. For those skilled in the art, the present application can be implemented without the need for some of these specific details. The following description of the embodiments is only to provide a better understanding of the present application by illustrating the examples of the present application.
[0055] It should be noted that, in this article, relational terms such as first and second, etc. are only used to distinguish one entity or operation from another entity or operation, and do not necessarily require or imply any such actual relationship or order between these entities or operations. Moreover, the terms "include", "comprise" or any other variants thereof are intended to cover non-exclusive inclusion, so that a process, method, article or device including a series of elements includes not only those elements, but also other elements not explicitly listed, or also includes elements inherent to such process, method, article or device. In the absence of further restrictions, the elements defined by the sentence "include..." do not exclude the existence of other identical elements in the process, method, article or device including the elements.
[0056] In order to solve the problems in the prior art, the embodiments of the present application provide a motion estimation method, device, electronic device, storage medium and program product. The motion estimation method provided by the embodiments of the present application is first introduced below.
[0057] Figure 1 FIG. 1 is a flow chart of a motion estimation method provided by an embodiment of the present application. Figure 1 As shown, the motion estimation method may include: S101 to S106.
[0058] S101: Acquire a reference video frame and a current video frame, where the reference video frame includes a plurality of first image blocks, and the current video frame includes a plurality of second image blocks;
[0059] S102: For each second image block, obtain a first motion vector corresponding to the current second image block, where the first motion vector is an integer pixel motion vector determined according to a relative displacement of a target image block between a reference video frame and a current video frame, and the target image block is a first image block having the highest matching degree with the current second image block;
[0060] S103: Taking the first motion vector as the center, determining an integer pixel motion vector whose distance from the first motion vector does not exceed a preset threshold unit as a second motion vector;
[0061] S104: for each second motion vector, when a standard deviation of a rate-distortion cost between the current second motion vector and the first motion vector is less than a preset threshold, using a surface fitting algorithm to determine a sub-pixel motion vector of the current second image block;
[0062] S105: determining a target motion vector of a current second image block according to the sub-pixel motion vector and the first motion vector;
[0063] S106: Perform motion estimation on the current second image block according to the target motion vector.
[0064] In an embodiment of the present application, when performing motion estimation for the current second image block in the current video frame, the target image block with the highest matching degree with the current second image block is usually determined first, and the first motion vector is determined according to the relative displacement of the target image block between the reference video frame and the current video frame. Subsequently, the second motion vector is searched based on the first motion vector. Further, the standard deviation of the rate-distortion cost between the second motion vector and the first motion vector is calculated. When the standard deviation of the rate-distortion cost between the second motion vector and the first motion vector is less than a preset threshold, it indicates that within a given search area, the change of the motion vector is relatively stable and consistent, and there is no significant fluctuation or inconsistent motion estimation, which means that between the current video frame and the reference video frame, the first motion vector can already describe the motion trajectory of the second image block more accurately, so there is no need to perform a more refined motion vector search. For this type of second image block, a surface fitting algorithm can be used for further optimization search. The surface fitting algorithm adopts a surface fitting method, which can reduce the computational complexity by reducing the number of calculations and interpolations, thereby effectively avoiding unnecessary computational overhead, thereby effectively improving the efficiency of motion estimation while ensuring the accuracy of motion estimation.
[0065] In some embodiments, in S101, the current video frame is a video frame being processed by an encoder for video encoding, specifically, a video frame captured in real time or a video frame read from a video file. The reference video frame is one or more frames used as reference in video encoding, and is usually selected by the encoder for video encoding from an encoded video sequence and is located in the previous frame or previous frames of the current video frame. The current video frame is divided into a plurality of second image blocks. The reference video frame is divided into a plurality of first image blocks. As an example, the sizes of the first image blocks and the second image blocks are fixed, such as 16*16, 8*8 or 4*4 pixels.
[0066] In some embodiments, before S102, the method further includes searching the reference video frame for a first image block having the highest matching degree with the current second image block, and determining it as the target image block. As an example, each first image block can be used as a candidate image block, and the matching degree between the current second image block and each candidate image block can be calculated using a matching degree metric, and the candidate image block with the best matching degree can be selected as the target image block.
[0067] In some embodiments, in S102, the first motion vector is an optimal integer pixel motion vector determined in the initial motion estimation process, and a hexagonal algorithm may be used to search for the optimal integer pixel motion vector, i.e., the first motion vector. The first motion vector is determined based on the relative displacement between a first image block in a reference video frame and a second image block corresponding to the first image block in a current video frame, and indicates the integer pixel movement of the current second image block in the horizontal and vertical directions.
[0068] In some embodiments, in S103, when further refining the motion estimation, the first motion vector is taken as the center, and the regular polygon algorithm can be used for search and refinement, and the integer pixel motion vectors around the first motion vector are searched within the preset threshold unit range to find the second motion vector. The preset threshold unit is a pre-set value and is a parameter used to determine the search range. When searching for the second motion vector, only the integer pixel motion vectors whose distance from the first motion vector does not exceed this preset threshold are considered. In an implementation scenario, if the video content contains fast or complex motion, the preset threshold can be set larger to cover the possible range of motion. On the contrary, for videos with less or simple motion, the preset threshold can be smaller.
[0069] In some embodiments, in S104, the rate-distortion cost is an indicator used to measure the bit rate required at a given distortion level during the video encoding process. The rate-distortion cost helps the encoder to minimize the data transmission or storage requirements while ensuring video quality. The standard deviation of the rate-distortion cost reflects the fluctuations of these rate-distortion cost values under different circumstances, and then evaluates whether the efficiency of video encoding using the parameters corresponding to the current second motion vector is relatively stable. Specifically, if the standard deviation is small, it means that under a variety of different encoding parameters, the rate-distortion cost value does not change much, that is, the encoding efficiency is relatively stable; if the standard deviation is large, it means that different parameter settings have a significant impact on the encoding efficiency, and it may be necessary to further adjust or optimize the accuracy of the motion vector.
[0070] The preset threshold is a parameter set according to an empirical value or according to a coding strategy, and is used to determine whether the accuracy of the motion vector needs to be further optimized. If the standard deviation of the rate-distortion cost is not less than the preset threshold, the encoder may believe that the current coding efficiency is not stable enough and needs to further adjust the coding parameters to reduce the standard deviation of the rate-distortion cost. On the contrary, if the standard deviation of the rate-distortion cost is less than the preset threshold, the encoder may believe that the current coding efficiency is relatively stable and has reached the predicted optimization goal. In this case, in order to further fine-tune the motion vector to improve the coding efficiency, a method that focuses on efficiency and consumes less computing resources can be used, such as using a surface fitting algorithm to determine the sub-pixel motion vector of the second image block.
[0071] The surface fitting algorithm is a mathematical method that estimates a smooth surface through known data points. In video coding, surface fitting can be applied to the optimization process of motion vectors to find vector values that provide better rate-distortion performance. Since the computational complexity of surface fitting is relatively small, it is more suitable for use when the standard deviation is small and the coding efficiency is relatively stable, so as to further improve the accuracy of motion estimation and coding quality without significantly increasing the computational burden.
[0072] It is worth noting here that the motion vectors refined by the hexagonal algorithm and the square algorithm may be temporarily stored to be used in the surface fitting algorithm in the search of sub-pixel motion vectors.
[0073] Figure 2a One of the schematic diagrams showing motion vector search results provided by one embodiment of the present application is shown; Figure 2b A second schematic diagram showing a motion vector search result provided by an embodiment of the present application; Figure 2c A third schematic diagram shows a motion vector search result provided by an embodiment of the present application.
[0074] like Figure 2a to 2c As shown in the figure, each square represents an integer pixel motion vector, x ij Indicates the motion vector that needs to temporarily store the rate distortion cost. The search for sub-pixel motion vector is based on the best square refinement centered motion vector. The rate distortion cost of the middle 9 motion vectors is calculated and compared. The position of the optimal integer pixel motion vector is mainly divided into Figure 2a , Figure 2b and Figure 2c Three situations.
[0075] like Figure 2a As shown, the optimal integer pixel motion vector is located at the exact center of the search area. In this case, the 9 motion vectors within the square refinement area can be temporarily stored with a rate-distortion cost to ensure a comprehensive evaluation of all potential candidate vectors around the center point.
[0076] for Figure 2b and Figure 2c As shown, the optimal integer pixel motion vector is not located at the exact center of the search area. In this case, due to the position offset of the optimal motion vector, 6 or 4 rate-distortion costs calculated during the temporary square refinement process can be selected.
[0077] Based on this, for each second motion vector, when the standard deviation of the rate-distortion cost between the current second motion vector and the first motion vector is greater than or equal to a preset threshold, an interpolation method is used to determine the sub-pixel motion vector of the current second image block.
[0078] In the embodiment of the present application, when the standard deviation is greater than or equal to the preset threshold, it means that there are one or more motion vectors that can significantly improve the coding efficiency or image quality. In this case, an interpolation method (such as linear interpolation, bilinear interpolation, etc.) is used to determine a more accurate sub-pixel motion vector, which can further improve the accuracy of the coding.
[0079] It is worth noting here that the choice of the preset threshold directly affects whether the surface fitting algorithm is used to search for sub-pixel motion vectors. In order to balance the encoding speed and encoding quality, the preset threshold can be flexibly adjusted according to actual needs. When the encoding speed becomes the primary consideration, it is usually possible to choose to increase the preset threshold to tolerate a larger rate-distortion cost standard deviation, thereby relying more on the surface fitting method that consumes less computing resources to search for sub-pixel motion vectors. By reducing complex interpolation calculations, the encoder can significantly increase the encoding speed to meet the needs of real-time or high frame rate video processing.
[0080] However, in the scenario of pursuing higher encoding quality, the preset threshold needs to be lowered accordingly, which can more strictly limit the standard deviation of the rate-distortion cost and prompt the encoder to use more interpolation methods to optimize motion vectors. Interpolation methods can usually provide more accurate motion vector estimates, thereby improving video compression effects, reducing visual distortion, and improving overall encoding quality.
[0081] Figure 3 A schematic diagram of a first motion vector and a second motion vector of a second image block provided by an embodiment of the present application is shown.
[0082] exist Figure 3 In , MV plane refers to the motion vector plane, and RD cost value refers to the rate-distortion cost value. Figure 3 On the MV plane shown, each point corresponds to an RD cost value, thus forming an RD cost surface, P0 represents the first motion vector, P1~P8 represent 8 integer pixel vectors around the first motion vector, that is, the second motion vector.
[0083] calculate Figure 1 There are 5 standard deviations of RD cost at positions P0 to P4 in the figure, and the interval of the standard deviation is determined according to the preset threshold t. If the standard deviation is less than t, the surface fitting algorithm is used to search for sub-pixel motion vectors, otherwise the interpolation method is used to search for sub-pixel motion vectors.
[0084] In video coding, the calculation formula for the RD cost of a motion vector is as follows:
[0085] RDcost = SAD(MV x , MV y ) + λ MVcost(MV x, MV y ) (1)
[0086] RDcost = SATD(MVx, MVy) + λ MVcost(MVx, MVy) (2)
[0087] In formula (1) and formula (2), MV x and MV y are the x and y components of the motion vector MV; MVcost is the cost of the motion vector, representing the information rate; SAD and SATD both represent distortion, SAD represents the sum of the absolute differences of the motion vectors between the current video frame and the reference video frame, SATD is a variant of SAD, representing the sum of the saturated absolute transformation differences of the motion vectors, and SATD transforms the image blocks (such as DCT transformation) before calculation; λ is the Lagrange multiplier.
[0088] In some embodiments, Figure 4 As shown, in the aforementioned S104, using the surface fitting algorithm to determine the sub-pixel motion vector of the current second image block may specifically include: S401 to S404.
[0089] S401: constructing a quadratic surface equation according to a plurality of second motion vectors.
[0090] In some embodiments, in S301, the function corresponding to the quadratic surface equation is as follows:
[0091] f (x, y) = Ax 2 + Bx 2 + Cx + Dy + E (3)
[0092] S402: Solving a quadratic surface equation according to rate-distortion costs corresponding to the first motion vector and multiple second motion vectors.
[0093] The specific calculation method of the rate-distortion cost can be calculated by referring to the aforementioned formula (1), which will not be further described here.
[0094] S403: quantize the motion vector corresponding to the lowest point position of the surface corresponding to the quadratic surface equation to a first sub-pixel accuracy to obtain a first reference motion vector.
[0095] The first sub-pixel accuracy refers to the subdivision between two adjacent pixels, which may generally include one-half, one-third or one-quarter.
[0096] S404: Determine a sub-pixel motion vector of the current second image block according to the first reference motion vector.
[0097] In the embodiment of the present application, by dividing each pixel into smaller units and performing motion estimation based on these units, the motion of the current second image block is analyzed at a finer granularity level, so that we can capture the motion details of the current second image block more carefully, including those small changes that may be ignored in larger pixel units. The first reference motion vector obtained in this way can more accurately reflect the actual motion of the second image block, further improve the accuracy of the motion estimation of the second image block, and optimize the coding efficiency.
[0098] In some embodiments, in order to further improve the efficiency of motion estimation and reduce the amount of calculation while ensuring the accuracy of motion estimation. Figure 5 As shown, the aforementioned S304 may specifically include the following steps: S3041 to S3045.
[0099] S3041: Determine whether the first reference motion vector is equal to the first motion vector. If the judgment result is yes, execute S3042; if the judgment result is no, execute S3043.
[0100] S3042: Determine the first reference motion vector as the sub-pixel motion vector of the current second image block.
[0101] In some embodiments, in S3042, when the first reference motion vector is equal to the first motion vector, it means that a suitable motion vector has been searched and no further search is required. At this time, the more refined sub-pixel motion vector search is stopped, which can effectively save computing resources. Conversely, if the first reference motion vector is not equal to the first motion vector, it means that there is a more suitable or more refined motion vector, and further more refined search is required.
[0102] S3043: Solve a quadratic surface equation according to the first reference motion vector and rate-distortion costs corresponding to four second motion vectors that are closest to the first reference motion vector.
[0103] S3044: quantize the motion vector corresponding to the lowest point position of the surface corresponding to the quadratic surface equation to a second sub-pixel precision to obtain a second reference motion vector, where the second sub-pixel precision is higher than the first sub-pixel precision.
[0104] As an example, the first sub-pixel precision may be half-pixel precision, and the second sub-pixel precision may be quarter-pixel precision.
[0105] S3045: Determine a sub-pixel motion vector of the current second image block according to the second reference motion vector.
[0106] In the embodiment of the present application, when the motion vector with the first sub-pixel precision fails to directly determine the optimal motion vector, the search precision can be further refined to the second sub-pixel precision based on the search with the first sub-pixel precision. Specifically, this can be achieved by solving the quadratic surface equation, which significantly improves the accuracy of motion estimation while saving computing resources.
[0107] In some embodiments, in order to further improve the accuracy of motion estimation of the second image block, the waste of computing resources is reduced. Figure 6 As shown, the aforementioned S3045 may specifically include the following steps: S3045a~S3045b.
[0108] S3045a: When the second reference motion vector has the first sub-pixel precision or the integer-pixel precision, determine the first reference motion vector as a sub-pixel motion vector between the first motion vector and the second motion vector;
[0109] S3045b: When the second reference motion vector is not of the first sub-pixel precision or integer-pixel precision, determine the second reference motion vector and the first reference motion vector as the sub-pixel motion vector of the current second image block.
[0110] The embodiment of the present application provides an adaptive sub-pixel motion vector determination strategy to select a suitable processing method according to the vector accuracy of the second reference motion vector, which can increase the flexibility and accuracy of sub-pixel motion vector determination.
[0111] The number of sub-pixel motion vectors is at least one, and the aforementioned S105 may specifically include:
[0112] For each sub-pixel motion vector and the first motion vector, the corresponding rate-distortion cost is calculated respectively, and the motion vector with the lowest rate-distortion cost is determined as the target motion vector of the current second image block.
[0113] The embodiments of the present application can find the motion vector that achieves the minimum distortion under a given bit rate limit by searching for the optimal motion vector with the lowest rate-distortion cost at multiple pixel precision levels (including whole pixel, half pixel and quarter pixel), and reduce residual data by improving the accuracy of motion estimation. Therefore, during video encoding, the bit rate can be reduced while maintaining the video quality, thereby helping to maximize the video encoding efficiency.
[0114] Next, the above motion estimation method will be further described in detail in conjunction with a specific implementation scenario.
[0115] Figure 7 A schematic diagram of a sub-pixel motion vector provided by an embodiment of the present application is shown.
[0116] exist Figure 7 In the example, each grid represents a specific motion vector with 1 / 4 pixel accuracy. P0 to P8 represent integer pixel motion vectors, P0 is the optimal integer pixel motion vector, H1 to H8 represent motion vectors with 1 / 2 pixel accuracy, and the remaining grids represent motion vectors with 1 / 4 pixel accuracy.
[0117] In an implementation scenario, when determining a sub-pixel motion vector, it is first considered that the first sub-pixel accuracy is 1 / 2 pixel accuracy and the second sub-pixel accuracy is 1 / 4 pixel accuracy.
[0118] Reference Figure 3 First, the quadratic surface equation in equation (2) is solved according to the rate-distortion cost of P0, P1, P2, P3, and P4. By calculating the lowest point position of the surface corresponding to the quadratic surface equation, the corresponding motion vector is approximated to a motion vector with 1 / 2 pixel accuracy, that is, it is quantized to one of P0, H1~H8, denoted as h. If h is P0, the algorithm terminates, and at this time, the sub-pixel motion vector of the second image block is determined to be P0.
[0119] However, if h is not P0, the quadratic surface equation is solved again based on the rate-distortion cost of h and the four nearest integer pixel motion vectors to h (for example, when h is H1, the four integer pixel motion vectors are P0, P1, P2, and P5). Then, the surface minimum point is approximated to a motion vector with 1 / 4 pixel precision, recorded as q. If q is 1 / 2 pixel precision or integer pixel precision, the search for the motion vector with 1 / 4 pixel precision is abandoned, and we believe that there is no optimal 1 / 4 pixel motion vector for the current second image block. On the contrary, if q has quarter pixel precision, we regard it as the motion vector with the optimal 1 / 4 pixel precision.
[0120] Finally, by calculating and comparing the rate-distortion costs of the optimal integer-pixel motion vector, the optimal 1 / 2 pixel precision motion vector, and the optimal 1 / 4 pixel precision motion vector, the motion vector with the lowest rate-distortion cost is determined as the overall optimal motion vector, that is, the target motion vector.
[0121] Based on the motion estimation method provided in the above embodiment, the present application also provides a specific implementation of the motion estimation device. Please refer to the following embodiment.
[0122] See first Figure 8 The motion estimation device 800 provided in the embodiment of the present application includes the following modules:
[0123] A first acquisition module 801 is used to acquire a reference video frame and a current video frame, the reference video frame includes a plurality of first image blocks, and the current video frame includes a plurality of second image blocks;
[0124] A first determination module 802 is configured to obtain, for each second image block, a first motion vector corresponding to the current second image block, where the first motion vector is an integer pixel motion vector determined according to a relative displacement of a target image block between a reference video frame and a current video frame, and the target image block is a first image block having the highest matching degree with the current second image block;
[0125] A second determination module 803 is used to determine, with the first motion vector as the center, an integer pixel motion vector whose distance from the first motion vector is not more than a preset threshold unit as a second motion vector;
[0126] A third determination module 804 is configured to determine, for each second motion vector, a sub-pixel motion vector of a current second image block by using a surface fitting algorithm when a standard deviation of a rate-distortion cost between the current second motion vector and the first motion vector is less than a preset threshold;
[0127] A fourth determination module 805, configured to determine a target motion vector of a current second image block according to the sub-pixel motion vector and the first motion vector;
[0128] The motion estimation module 806 is configured to perform motion estimation on the current second image block according to the target motion vector.
[0129] In the embodiment of the present application, when performing motion estimation for the current second image block in the current video frame, the target image block with the highest matching degree with the current second image block is usually determined first, and the first determination module 802 is used to determine the first motion vector according to the relative displacement of the target image block between the reference video frame and the current video frame. Subsequently, the second determination module 803 is used to search for the second motion vector according to the first motion vector. Further, the third determination module 804 is used to calculate the standard deviation of the rate-distortion cost between the second motion vector and the first motion vector. When the standard deviation of the rate-distortion cost between the second motion vector and the first motion vector is less than a preset threshold, it indicates that within a given search area, the change of the motion vector is relatively stable and consistent, and there is no significant fluctuation or inconsistent motion estimation, which means that between the current video frame and the reference video frame, the first motion vector can already describe the motion trajectory of the second image block more accurately, so there is no need to perform a more refined motion vector search. For this type of second image block, a surface fitting algorithm can be used for further optimization search. The surface fitting algorithm uses a surface fitting method, which can reduce the computational complexity by reducing the number of interpolation calculations, thereby effectively avoiding unnecessary computational overhead. Afterwards, the motion estimation module 806 performs motion estimation on the current second image block according to the target motion vector determined by the fourth determination module 805, which can effectively improve the efficiency of motion estimation and the accuracy of motion estimation on the current second image block.
[0130] As an implementation of the present application, in order to search for a better motion vector, the aforementioned device may further include:
[0131] The fifth determination module is used to determine the sub-pixel motion vector of the current second image block by using an interpolation method for each second motion vector when the standard deviation of the rate-distortion cost between the current second motion vector and the first motion vector is greater than or equal to a preset threshold.
[0132] As an implementation of the present application, in order to improve the effectiveness and accuracy of sub-pixel motion vector determination, the third determination module 804 may include:
[0133] A construction submodule, used for constructing a quadratic surface equation according to a plurality of second motion vectors;
[0134] A solving submodule, used for solving a quadratic surface equation according to rate-distortion costs corresponding to the first motion vector and a plurality of second motion vectors;
[0135] A first determination submodule is used to quantize the motion vector corresponding to the lowest point position of the surface corresponding to the quadratic surface equation to a first sub-pixel accuracy to obtain a first reference motion vector;
[0136] The second determining submodule is used to determine the sub-pixel motion vector of the current second image block according to the first reference motion vector.
[0137] As an implementation of the present application, in order to save computing resources, the aforementioned second determination submodule may further include:
[0138] The first determining unit is configured to determine the first reference motion vector as the sub-pixel motion vector of the current second image block when the first reference motion vector is equal to the first motion vector.
[0139] As an implementation of the present application, in order to further improve the fineness of the sub-pixel motion vector and thus improve the accuracy of motion estimation, the aforementioned second determination submodule may include:
[0140] A first solving unit is used to solve the quadratic surface equation according to the rate-distortion costs corresponding to the first reference motion vector and four second motion vectors closest to the first reference motion vector in distance when the first reference motion vector is not equal to the first motion vector;
[0141] A first determining unit is used to quantize the motion vector corresponding to the lowest point position of the surface corresponding to the quadratic surface equation to a second sub-pixel precision to obtain a second reference motion vector, where the second sub-pixel precision is higher than the first sub-pixel precision;
[0142] The second determining unit is used to determine the sub-pixel motion vector of the current second image block according to the second reference motion vector.
[0143] As an implementation of the present application, in order to further improve the accuracy of motion estimation and reduce the waste of computing resources, the aforementioned second determination unit may include:
[0144] A first determining subunit is used to determine the first reference motion vector as a sub-pixel motion vector between the first motion vector and the second motion vector when the second reference motion vector has a first sub-pixel precision or an integer pixel precision;
[0145] The second determining subunit is used to determine the second reference motion vector and the first reference motion vector as the sub-pixel motion vector of the current second image block when the second reference motion vector is not of the first sub-pixel precision or the integer pixel precision.
[0146] As an implementation method of the present application, in order to find the motion vector that achieves minimum distortion under a given bit rate limit, the aforementioned fourth determination module 805 is specifically used to calculate the corresponding rate-distortion cost for each sub-pixel motion vector and the first motion vector, and determine the motion vector with the lowest rate-distortion cost as the target motion vector of the current second image block.
[0147] Fig. 9 A schematic diagram of the hardware structure of an electronic device provided in an embodiment of the present application is shown.
[0148] The electronic device may include a processor 901 and a memory 902 storing computer program instructions.
[0149] Specifically, the processor 901 may include a central processing unit (CPU), or an application specific integrated circuit (ASIC), or may be configured to implement one or more integrated circuits of the embodiments of the present application.
[0150] The memory 902 may include a large capacity memory for data or instructions. By way of example and not limitation, the memory 902 may include a hard disk drive (HDD), a floppy disk drive, a flash memory, an optical disk, a magneto-optical disk, a magnetic tape, or a universal serial bus (USB) drive or a combination of two or more of these. In appropriate cases, the memory 902 may include a removable or non-removable (or fixed) medium. In appropriate cases, the memory 902 may be inside or outside the integrated gateway disaster recovery device. In a specific embodiment, the memory 902 is a non-volatile solid-state memory.
[0151] The memory may include read-only memory (ROM), random access memory (RAM), magnetic disk storage media devices, optical storage media devices, flash memory devices, electrical, optical or other physical / tangible memory storage devices. Thus, typically, the memory includes one or more tangible (non-transitory) computer-readable storage media (e.g., memory devices) encoded with software including computer-executable instructions, and when the software is executed (e.g., by one or more processors), it is operable to perform the operations described with reference to the method according to an aspect of the present disclosure.
[0152] The processor 901 implements any one of the motion estimation methods in the above embodiments by reading and executing computer program instructions stored in the memory 902 .
[0153] In one example, the electronic device may further include a communication interface 903 and a bus 910. Fig. 9 As shown, the processor 901, the memory 902, and the communication interface 903 are connected via a bus 910 and communicate with each other.
[0154] The communication interface 903 is mainly used to implement communication between various modules, devices, units and / or equipment in the embodiments of the present application.
[0155] Bus 910 includes hardware, software or both, and the parts of the aforementioned electronic equipment are coupled to each other. For example, but not limitation, bus may include accelerated graphics port (AGP) or other graphics bus, enhanced industrial standard architecture (EISA) bus, front side bus (FSB), hypertransport (HT) interconnection, industrial standard architecture (ISA) bus, infinite bandwidth interconnection, low pin count (LPC) bus, memory bus, micro channel architecture (MCA) bus, peripheral component interconnection (PCI) bus, PCI-Express (PCI-X) bus, serial advanced technology attachment (SATA) bus, video electronics standard association local (VLB) bus or other suitable bus or two or more of these combinations. In appropriate cases, bus 910 may include one or more buses. Although the present application embodiment describes and shows a specific bus, the application considers any suitable bus or interconnection.
[0156] The electronic device can execute the motion estimation method in the embodiment of the present application, thereby realizing the combination Figure 1 and Figure 8 The motion estimation method and device.
[0157] In addition, in combination with the motion estimation method in the above embodiments, the present application embodiment may provide a computer storage medium for implementation. The computer storage medium stores computer program instructions; when the computer program instructions are executed by a processor, any one of the motion estimation methods in the above embodiments is implemented.
[0158] In combination with the motion estimation method in the above-mentioned embodiment, the embodiment of the present application may provide a computer program product, including a computer program, which implements the above-mentioned motion estimation method when it is processed and executed.
[0159] It should be clear that the present application is not limited to the specific configuration and processing described above and shown in the figures. For the sake of simplicity, a detailed description of the known method is omitted here. In the above embodiments, several specific steps are described and shown as examples. However, the method process of the present application is not limited to the specific steps described and shown, and those skilled in the art can make various changes, modifications and additions, or change the order between the steps after understanding the spirit of the present application.
[0160] The functional blocks shown in the above-described block diagram can be implemented as hardware, software, firmware or a combination thereof. When implemented in hardware, it can be, for example, an electronic circuit, an application specific integrated circuit (ASIC), appropriate firmware, a plug-in, a function card, etc. When implemented in software, the elements of the present application are programs or code segments that are used to perform the required tasks. The program or code segment can be stored in a machine-readable medium, or transmitted on a transmission medium or a communication link by a data signal carried in a carrier wave. "Machine-readable medium" can include any medium capable of storing or transmitting information. Examples of machine-readable media include electronic circuits, semiconductor memory devices, ROM, flash memory, erasable ROM (EROM), floppy disks, CD-ROMs, optical disks, hard disks, optical fiber media, radio frequency (RF) links, etc. The code segment can be downloaded via a computer network such as the Internet, an intranet, etc.
[0161] It should also be noted that the exemplary embodiments mentioned in this application describe some methods or systems based on a series of steps or devices. However, this application is not limited to the order of the above steps, that is, the steps can be performed in the order mentioned in the embodiment, or in a different order from the embodiment, or several steps can be performed simultaneously.
[0162] Aspects of the present disclosure are described above with reference to the flowchart and / or block diagram of the method, device (system) and computer program product according to the embodiment 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 program instructions. These computer program instructions can be provided to a processor of a general-purpose computer, a special-purpose computer, or other programmable data processing device to produce a machine so that these instructions executed by the processor of the computer or other programmable data processing device enable the implementation of the function / action specified in one or more boxes of the flowchart and / or block diagram. Such a processor can be, but is not limited to, a general-purpose processor, a special-purpose processor, a special application processor, or a field programmable logic circuit. It can also be understood that each box in the block diagram and / or flowchart and the combination of boxes in the block diagram and / or flowchart can also be implemented by dedicated hardware that performs a specified function or action, or can be implemented by a combination of dedicated hardware and computer instructions.
[0163] The above is only a specific implementation of the present application. Those skilled in the art can clearly understand that for the convenience and simplicity of description, the specific working processes of the systems, modules and units described above can refer to the corresponding processes in the aforementioned method embodiments, and will not be repeated here. It should be understood that the protection scope of the present application is not limited to this. Any technician familiar with the technical field can easily think of various equivalent modifications or replacements within the technical scope disclosed in this application, and these modifications or replacements should be included in the protection scope of this application.
Claims
1. A motion estimation method, characterized in that: The method comprises: Acquire a reference video frame and a current video frame, wherein the reference video frame includes a plurality of first image blocks, and the current video frame includes a plurality of second image blocks; For each second image block, do the following: Acquire a first motion vector corresponding to the current second image block, where the first motion vector is an integer pixel motion vector determined according to a relative displacement of a target image block between the reference video frame and the current video frame, and the target image block is a first image block with the highest matching degree with the current second image block; Taking the first motion vector as the center, determining an integer pixel motion vector whose distance from the first motion vector does not exceed a preset threshold unit as a second motion vector; For each second motion vector, when a standard deviation of a rate-distortion cost between the current second motion vector and the first motion vector is less than a preset threshold, using a surface fitting algorithm to determine a sub-pixel motion vector of the current second image block; Determining a target motion vector of the current second image block according to the sub-pixel motion vector and the first motion vector; Perform motion estimation on the current second image block according to the target motion vector.
2. The motion estimation method according to claim 1, characterized in that: Before determining the target motion vector of the current second image block according to the sub-pixel motion vector and the first motion vector, the method further includes: For each second motion vector, when a standard deviation of a rate-distortion cost between the current second motion vector and the first motion vector is greater than or equal to a preset threshold, an interpolation method is used to determine a sub-pixel motion vector of the current second image block.
3. The motion estimation method according to claim 2, characterized in that: The adopting a surface fitting algorithm to determine the sub-pixel motion vector of the current second image block includes: constructing a quadratic surface equation according to the plurality of second motion vectors; Solving the quadratic surface equation according to rate-distortion costs corresponding to the first motion vector and the plurality of second motion vectors; quantizing the motion vector corresponding to the lowest point position of the surface corresponding to the quadratic surface equation to a first sub-pixel accuracy to obtain a first reference motion vector; A sub-pixel motion vector of the current second image block is determined according to the first reference motion vector.
4. The motion estimation method according to claim 3, characterized in that: The determining the sub-pixel motion vector of the current second image block according to the first reference motion vector comprises: When the first reference motion vector is equal to the first motion vector, the first reference motion vector is determined as the sub-pixel motion vector of the current second image block.
5. The motion estimation method according to claim 3, characterized in that: The determining the sub-pixel motion vector of the current second image block according to the first reference motion vector comprises: When the first reference motion vector is not equal to the first motion vector, solving the quadratic surface equation according to the rate-distortion costs corresponding to the first reference motion vector and four second motion vectors closest to the first reference motion vector in terms of distance; quantizing the motion vector corresponding to the lowest point position of the surface corresponding to the quadratic surface equation to a second sub-pixel precision to obtain a second reference motion vector, where the second sub-pixel precision is higher than the first sub-pixel precision; The sub-pixel motion vector of the current second image block is determined according to the second reference motion vector.
6. The motion estimation method according to claim 5, characterized in that: The determining the sub-pixel motion vector of the current second image block according to the second reference motion vector comprises: When the second reference motion vector has a first sub-pixel precision or an integer-pixel precision, determining the first reference motion vector as a sub-pixel motion vector between the first motion vector and the second motion vector; When the second reference motion vector is not of the first sub-pixel precision or the integer-pixel precision, the second reference motion vector and the first reference motion vector are determined as the sub-pixel motion vector of the current second image block.
7. The motion estimation method according to any one of claims 1 to 6, characterized in that: The number of the sub-pixel motion vectors is at least one, and determining the target motion vector of the current second image block according to the sub-pixel motion vector and the first motion vector includes: For each of the sub-pixel motion vectors and the first motion vector, the corresponding rate-distortion cost is calculated respectively, and the motion vector with the lowest rate-distortion cost is determined as the target motion vector of the current second image block.
8. A motion estimation device, characterized in that: The device comprises: A first acquisition module, used to acquire a reference video frame and a current video frame, wherein the reference video frame includes a plurality of first image blocks, and the current video frame includes a plurality of second image blocks; A first determination module is configured to obtain, for each second image block, a first motion vector corresponding to a current second image block, where the first motion vector is an integer pixel motion vector determined according to a relative displacement of a target image block between the reference video frame and the current video frame, and the target image block is a first image block with the highest matching degree with the current second image block; A second determination module is used to determine, with the first motion vector as the center, an integer pixel motion vector whose distance from the first motion vector is not more than a preset threshold unit as a second motion vector; A third determination module is configured to, for each second motion vector, determine the sub-pixel motion vector of the current second image block by using a surface fitting algorithm when a standard deviation of a rate-distortion cost between the current second motion vector and the first motion vector is less than a preset threshold; a fourth determining module, configured to determine a target motion vector of the current second image block according to the sub-pixel motion vector and the first motion vector; A motion estimation module is used to perform motion estimation on the current second image block according to the target motion vector.
9. An electronic device, characterized in that: The device comprises: a processor and a memory storing computer program instructions; When the processor executes the computer program instructions, the motion estimation method according to any one of claims 1 to 7 is implemented.
10. A computer-readable storage medium, characterized in that: The computer-readable storage medium stores computer program instructions, and when the computer program instructions are executed by a processor, the motion estimation method according to any one of claims 1 to 7 is implemented.
11. A computer program product, characterized in that The invention comprises a computer program, wherein when the computer program is processed and executed, the motion estimation method according to any one of claims 1 to 7 is implemented.
Citation Information
Patent Citations
Method and system for carrying out reliability classification on motion vector in video
CN101835037A
Method and system for calculating fractional motion estimation based on error curved surface
CN117376581A
