A fast motion estimation method and device applied to inter-frame prediction

By designing a fast motion estimation method, and utilizing multi-round search and the correlation of adjacent motion vectors, the motion estimation of inter-frame prediction is optimized, which solves the problem of high computational cost of inter-frame prediction and improves the efficiency of inter-frame prediction.

CN116112686BActive Publication Date: 2026-11-24PENG CHENG LAB
View PDF 1 Cites 0 Cited by

Patent Information

Application Number
CN202310108545.3
Authority / Receiving Office
CN · China
Patent Type
Patents(China)
Current Assignee / Owner
Filing Date
2023-01-17
Publication Date
2026-11-24
Estimated Expiration
2043-01-17

AI Technical Summary

Technical Problem

The computational cost of motion estimation for inter-frame prediction in existing video coding techniques is too high, especially in forward, backward, and bidirectional modes, which leads to an increase in inter-frame prediction time.

Method used

A fast motion estimation method is adopted. Through multiple rounds of searching for motion vectors with integer precision and sub-precision, and by utilizing the correlation between adjacent motion vectors, a fast search rule is designed, including diamond search and grid search with integer precision, and half-pixel and 1/4-pixel search with sub-precision, which reduces the motion vector residuals of the search traversal.

Benefits of technology

It significantly reduces the computational cost of inter-frame prediction, improves the efficiency of inter-frame prediction, is suitable for real-time encoders, and has almost no impact on coding performance.

✦ Generated by Eureka AI based on patent content.

Smart Images

  • Figure CN116112686B_ABST
    Figure CN116112686B_ABST
Patent Text Reader

Abstract

This invention provides a fast motion estimation method and apparatus for inter-frame prediction. The method includes: acquiring a reference frame and motion vector predictions of the block to be encoded within the reference frame, and acquiring a matching reference block based on the motion vector predictions; using the matching reference block as the starting point for integer-precision motion vector search, performing an integer-precision motion vector search according to a first preset fast search rule to obtain an optimal integer-precision motion vector; and using the optimal integer-precision motion vector as the starting point for sub-precision motion vector search, performing a sub-precision motion vector search according to a second preset fast search rule to obtain an optimal sub-precision motion vector. This invention, by performing integer-precision motion vector search according to the first preset fast search rule and sub-precision motion vector search according to the second preset fast search rule, selectively searches at each pixel step size, reducing computational load and improving inter-frame prediction efficiency.
Need to check novelty before this filing date? Find Prior Art

Description

Technical Field

[0001] This invention relates to the field of video coding technology, and in particular to a fast motion estimation method and apparatus for inter-frame prediction. Background Technology

[0002] Due to limitations in transmission network bandwidth and storage resources, video signal compression is becoming increasingly important. Video compression, also known as video coding, aims to eliminate redundant information between video signals. Video coding standards employ a hybrid coding framework based on "block-based prediction and transform," meaning that the input video signal undergoes processing in the encoder using techniques such as prediction, transform, quantization, scanning, and entropy coding, before outputting a bitstream for transmission or storage.

[0003] To reduce transmission bandwidth and storage space, the input video signal first passes through a prediction module. The encoder selects the optimal prediction mode from several prediction modes to predict the predicted signal. The difference between the predicted signal and the original signal is calculated to obtain the residual signal. The residual signal is then transformed and quantized before being encoded by an entropy encoder, ultimately outputting a bitstream. Therefore, prediction technology is one of the most critical technologies in video coding.

[0004] Existing prediction techniques mainly include intra-frame prediction and inter-frame prediction. Inter-frame prediction divides each frame of the image sequence into many non-overlapping prediction units. Using the already encoded block as a reference frame, and assuming that all pixels within the block have the same displacement, it searches for the optimal matching reference block of the block to be encoded in the reference frame. The relative displacement between the matching reference block and the block to be encoded is called the motion vector (MV), and the process of searching for the motion vector is called motion estimation.

[0005] Motion estimation is the most complex module in inter-frame prediction, especially in forward, backward, and bidirectional modes. When searching for each pixel step, it is necessary to test all motion vector residuals under that pixel step. Thus, the whole process will traverse a large number of integer precision MV and sub-precision MV, which is computationally intensive and greatly increases the inter-frame prediction time.

[0006] Therefore, existing technologies have shortcomings and need to be improved and developed. Summary of the Invention

[0007] The technical problem to be solved by the present invention is to provide a fast motion estimation method and apparatus for inter-frame prediction, which addresses the above-mentioned deficiencies of the prior art and aims to solve the problem of the large amount of computation required for inter-frame prediction in the prior art.

[0008] The technical solution adopted by this invention to solve the technical problem is as follows:

[0009] A fast motion estimation method for inter-frame prediction includes:

[0010] Obtain a reference frame and the motion vector prediction of the block to be encoded in the reference frame, and obtain a matching reference block based on the motion vector prediction;

[0011] Using the matching reference block as the starting point for integer precision motion vector search, integer precision motion vector search is performed according to the first preset fast search rule to obtain the optimal integer precision motion vector;

[0012] Using the optimal integer precision motion vector as the starting point for the sub-precision motion vector search, the sub-precision motion vector search is performed according to the second preset fast search rule to obtain the optimal sub-precision motion vector.

[0013] In one implementation, the matching reference block is used as the starting point for integer-precision motion vector search. An integer-precision motion vector search is performed according to a first preset fast search rule to obtain the optimal integer-precision motion vector, including:

[0014] The matching reference block is used as the starting point for integer precision motion vector search. In the integer precision motion vector search, the first round of diamond search, grid search and the second round of diamond search are performed in sequence according to the first preset fast search rule.

[0015] After the first round of diamond search, grid search, and the second round of diamond search, the optimal integer precision motion vector is obtained.

[0016] In one implementation, the step of sequentially performing a first round of diamond search, a grid search, and a second round of diamond search according to a first preset fast search rule includes:

[0017] During the first round of diamond search, a first candidate motion vector is obtained with a first preset step size, and the first candidate motion vector is searched to obtain the first optimal motion vector among the first candidate motion vectors.

[0018] The motion vector adjacent to the first optimal motion vector is taken as the second candidate motion vector, and the first optimal motion vector is taken as the starting point to search all the second candidate motion vectors to obtain the second optimal motion vector among the second candidate motion vectors.

[0019] Obtain a second preset step size, where the second preset step size is greater than the first preset step size;

[0020] Starting from the matching reference block, and obtaining the third candidate motion vector with the second preset step size, the second optimal motion vector is added to the third candidate motion vector, and the third candidate motion vector is searched to obtain the third optimal motion vector;

[0021] If the third optimal motion vector satisfies the first preset constraint, then the optimal motion vector among the first optimal motion vector, the second optimal motion vector, and the third optimal motion vector is taken as the search result of the first round of diamond search.

[0022] In one implementation, after obtaining the third optimal motion vector, the following steps are also included:

[0023] If the third optimal motion vector does not meet the first preset constraint, then a third preset step size is obtained, which is greater than the second preset step size;

[0024] Starting from the matching reference block, a fourth candidate motion vector is obtained with a third preset step size, and the fourth candidate motion vector is searched to obtain the fourth optimal motion vector;

[0025] If the fourth optimal motion vector satisfies the first preset constraint, then the optimal motion vector among the first optimal motion vector, the second optimal motion vector, the third optimal motion vector, and the fourth optimal motion vector is taken as the search result of the first round of diamond search.

[0026] In one implementation, after obtaining a fourth candidate motion vector by starting from the matching reference block and taking a third preset step size, and then searching for the fourth candidate motion vector to obtain the fourth optimal motion vector, the method further includes:

[0027] If the fourth optimal motion vector does not satisfy the first preset constraint, then a fourth preset step size is obtained, and the fourth preset step size is greater than the third preset step size;

[0028] Starting from the matching reference block, a fifth candidate motion vector is obtained with a fourth preset step size, and the fifth candidate motion vector is searched to obtain the fifth optimal motion vector;

[0029] The optimal motion vector among the first, second, third, fourth, and fifth optimal motion vectors is used as the search result for the first round of diamond search.

[0030] In one implementation, the first preset step size is 2 pixels, the second preset step size is 4 pixels, the third preset step size is 8 pixels, and the fourth preset step size is 16 pixels.

[0031] In one implementation, the step of sequentially performing a first round of diamond search, a grid search, and a second round of diamond search according to a first preset fast search rule further includes:

[0032] During grid search, the sixth candidate motion vector within a preset search range is obtained, and the sixth candidate motion vector is searched to obtain the sixth optimal motion vector;

[0033] In the square template, starting from the sixth optimal motion vector, the search is performed on the seventh candidate motion vector within the preset search range, and the search is iterated until the search range is 0, thus obtaining the search results of the grid search.

[0034] Each iteration of the search involves two rounds of searching.

[0035] In one implementation, the two-round search in each iteration includes:

[0036] During the first round of search in the current iteration, the first round of motion vector candidates in the seventh candidate motion vector are obtained, the first round of motion vector candidates are traversed, and the optimal motion vector and the second-best motion vector in the current iteration are recorded.

[0037] During the second round of the current iteration search, if the optimal motion vector and the second-best motion vector are adjacent, then test the motion vector between the optimal and second-best motion vectors.

[0038] If the optimal motion vector and the second-best motion vector are not adjacent, then test the two motion vectors adjacent to the optimal motion vector.

[0039] In one implementation, the optimal integer-precision motion vector is used as the starting point for the sub-precision motion vector search. A sub-precision motion vector search is performed according to a second preset fast search rule to obtain the optimal sub-precision motion vector, including:

[0040] Using the optimal integer precision motion vector as the starting point for sub-precision motion vector search, a half-pixel motion vector search is performed to obtain the optimal half-pixel precision motion vector.

[0041] Using the optimal half-pixel precision motion vector as the starting point for the 1 / 4 pixel search, a 1 / 4 pixel motion vector search is performed to obtain the optimal 1 / 4 pixel precision motion vector.

[0042] The optimal 1 / 4 pixel precision motion vector is taken as the optimal sub-precision motion vector.

[0043] In one implementation, the optimal integer-precision motion vector is used as the starting point for a sub-precision motion vector search, and a half-pixel motion vector search is performed to obtain the optimal half-pixel-precision motion vector, including:

[0044] In the first round of the half-pixel motion vector search, four half-precision candidate motion vectors corresponding to the optimal integer precision motion vector are obtained;

[0045] Traverse the candidate motion vectors for half-precision and record the optimal and second-best half-precision motion vectors among them.

[0046] If the optimal half-precision motion vector and the suboptimal half-precision motion vector are adjacent, then test the motion vector between the optimal half-precision motion vector and the suboptimal half-precision motion vector.

[0047] If the optimal half-precision motion vector and the suboptimal half-precision motion vector are not adjacent, then test the two motion vectors adjacent to the optimal half-precision motion vector;

[0048] The test is complete, and the optimal half-pixel precision motion vector has been obtained.

[0049] The present invention also provides a fast motion estimation device for inter-frame prediction, comprising:

[0050] An acquisition module is used to acquire a reference frame and motion vector predictions of the block to be encoded in the reference frame, and to acquire a matching reference block based on the motion vector predictions;

[0051] The first search module is used to take the matching reference block as the starting point for integer precision motion vector search, and perform integer precision motion vector search according to the first preset fast search rule to obtain the optimal integer precision motion vector;

[0052] The second search module is used to take the optimal integer precision motion vector as the starting point for sub-precision motion vector search, and perform sub-precision motion vector search according to the second preset fast search rule to obtain the optimal sub-precision motion vector.

[0053] The present invention also provides a terminal, comprising: a memory, a processor, and a fast motion estimation program for inter-frame prediction stored in the memory and executable on the processor, wherein the fast motion estimation program for inter-frame prediction, when executed by the processor, implements the steps of the fast motion estimation method for inter-frame prediction as described above.

[0054] The present invention also provides a computer-readable storage medium storing a computer program that can be executed to implement the steps of the fast motion estimation method applied to inter-frame prediction as described above.

[0055] This invention provides a fast motion estimation method and apparatus for inter-frame prediction. The method includes: acquiring a reference frame and motion vector predictions of the block to be encoded in the reference frame, and acquiring a matching reference block based on the motion vector predictions; using the matching reference block as the starting point for integer-precision motion vector search, performing integer-precision motion vector search according to a first preset fast search rule to obtain an optimal integer-precision motion vector; using the optimal integer-precision motion vector as the starting point for sub-precision motion vector search, performing sub-precision motion vector search according to a second preset fast search rule to obtain an optimal sub-precision motion vector. This invention, by performing integer-precision motion vector search according to the first preset fast search rule and sub-precision motion vector search according to the second preset fast search rule, reduces computational load and improves inter-frame prediction efficiency by selectively searching for motion vector residuals at each pixel step size instead of testing all motion vector residuals at that pixel step size. Attached Figure Description

[0056] Figure 1 It is a diamond search based on motion estimation in the existing technology AVS3.

[0057] Figure 2 It is a grid search for motion estimation in the existing technology AVS3.

[0058] Figure 3 It is a sub-precision MV search in the existing technology AVS3.

[0059] Figure 4 This is a flowchart of a preferred embodiment of the fast motion estimation method applied to inter-frame prediction in this invention.

[0060] Figure 5 This is the accelerated diamond search in this invention.

[0061] Figure 6 This is the accelerated grid search in this invention.

[0062] Figure 7 This is the accelerated sub-precision MV search in this invention.

[0063] Figure 8 This is a functional principle block diagram of a preferred embodiment of the fast motion estimation device applied to inter-frame prediction in this invention.

[0064] Figure 9 This is a functional principle block diagram of a preferred embodiment of the terminal in this invention. Detailed Implementation

[0065] To make the objectives, technical solutions, and advantages of this invention clearer and more explicit, the invention will be further described in detail below with reference to the accompanying drawings and embodiments. It should be understood that the specific embodiments described herein are merely illustrative of the invention and are not intended to limit the invention.

[0066] To reduce the number of bits required to encode the motion vector prediction (MV), inter-frame prediction utilizes the correlation between the block to be encoded and its spatiotemporally adjacent reconstructed blocks. That is, it uses the MV of adjacent encoded blocks as motion vector prediction (MVP). In this case, only the difference between the MVP and the actual MV, i.e., the motion vector difference (MVD), needs to be transmitted. Therefore, searching for the optimal MV in the encoder is equivalent to searching for the optimal MVD starting from the optimal MVP.

[0067] In the AVS3 standard, inter-frame prediction mainly includes forward, backward, bidirectional, skip / direct, and Affine modes, all of which involve motion estimation techniques. The forward, backward, and bidirectional modes use the same motion estimation strategy, which comprises two steps: integer-precision MV search and sub-precision MV search.

[0068] The integer-precision MV search employs two strategies: Diamond Search and Raster Search. Starting with the MVP, the integer-precision MV search utilizes a three-round MV search.

[0069] First, a coarse search is performed using a diamond search, with steps 2, 4, 8, and 16. The specific search process is as follows: Figure 1 As shown, for the search with step 2, all MVDs within 2 pixels of {Δx, Δy} are tested; for the searches with steps 4 and 8, all MVDs are tested as follows:

[0070] {Δx, Δy}∈(step>>1)*{{-2,0},f-1,1},{0,2},f1,1},{2,0},{1,-1},{0,-2},f-1,-1}}

[0071] For a search with step 16, test all the following MVDs:

[0072]

[0073] After the search is complete, record the optimal MV and its corresponding step.

[0074] Second, if the optimal step in the first step is greater than 5 and the current mode is not bidirectional, perform the second step of grid search. First, set the maximum search range r based on the distance between the current frame and the reference frame. max and with stride x =stride y =(refi+1)*max(5, min(w>>1, h>>1)) represents all MVDs within the step-size test search range, where w and h are the width and height of the current block to be encoded, and refi is the index of the current search reference frame in the reference frame list. After the search is completed, the search range r is reset to the current optimal MV as the starting point:

[0075] r=(refi+1)*max(5,min(w>>1,h>>1))>>1

[0076] Iterative search is performed using a square template, i.e., searching for 8 MVDs:

[0077] {Δx, Δy}∈{{-r,-r},{-r,0},{-r,r},{0,r},{r,r},{r,0},{r,-r},{0,-r}}

[0078] After each search, set r = r >> 1 and iterate until r = 0. The grid search process is as follows: Figure 2 As shown (taking the MV of a 16x16 pixel block searched in the 0th reference frame as an example, at which time refi=0, w=h=16).

[0079] Third, after completing the first and second steps of the search, repeat the diamond search from the first step for a finer search, the difference being that this round only searches for MVDs with steps 2 and 4. After completing the third step of the search, the optimal MV for integer precision MV search can be obtained.

[0080] In sub-precision MV search, the optimal MV from integer-precision MV search is used as the starting point. First, sub-precision pixels are generated by linear interpolation of adjacent integer pixels. Then, the optimal sub-precision MV is searched using half-pixel and 1 / 4-pixel search templates. The 1 / 4-pixel precision MV search starts with the optimal half-pixel precision MV. An example of sub-precision MV search is shown below. Figure 3 As shown.

[0081] Motion estimation is the most complex module in inter-frame prediction, especially in forward, backward, and bidirectional modes. It involves traversing a large number of integer-precision and sub-precision motion estimation (MV) values, requiring multiple SAD or SATD calculations during the traversal process, which significantly increases the inter-frame prediction time. Optimizing the motion estimation search process to improve the speed of inter-frame prediction without significant performance loss is a key research issue in the development of video coding technology.

[0082] To address the high complexity of existing motion estimation algorithms, this invention proposes a fast motion estimation method for inter-frame prediction. Specifically, fast algorithms are designed for integer-precision motion vector search and sub-precision motion vector search in forward, backward, and bidirectional modes. The fast algorithms for integer-precision and sub-precision motion vector search primarily utilize the correlation between adjacent motion vectors, following a multi-round search approach and a coarse-to-fine approach. In real-time encoder design, this fast algorithm can significantly reduce encoding time with almost no loss in encoding performance.

[0083] Please see Figure 4 , Figure 4 This is a flowchart of the fast motion estimation applied to inter-frame prediction in this invention. For example... Figure 4 As shown, the fast motion estimation applied to inter-frame prediction according to the embodiments of the present invention includes:

[0084] Step S100: Obtain a reference frame and the motion vector prediction of the block to be encoded in the reference frame, and obtain a matching reference block based on the motion vector prediction.

[0085] This invention designs three fast search algorithms for motion estimation in inter-frame prediction: fast diamond search with integer-precision pixels, fast raster search with integer-precision pixels, and fast search with sub-precision pixels. During the design of a real-time encoder, testing revealed that these three methods not only significantly reduce encoding complexity but also have negligible impact on encoding performance, making them highly suitable for commercial real-time encoders with high encoding time requirements.

[0086] like Figure 4 As shown, the fast motion estimation applied to inter-frame prediction described in this embodiment further includes:

[0087] Step S200: Using the matching reference block as the starting point for integer precision motion vector search, perform integer precision motion vector search according to the first preset fast search rule to obtain the optimal integer precision motion vector.

[0088] Specifically, this step involves a fast integer-precision motion vector search in forward, backward, and bidirectional modes. In AVS3's existing integer-precision MV search, two rounds of diamond search and one round of grid search are performed. In this invention, the number of search rounds remains unchanged, and acceleration is only applied to the specific search details within the search itself.

[0089] In one implementation, step S200 specifically includes:

[0090] Step S210: Take the matching reference block as the starting point of the integer precision motion vector search. In the integer precision motion vector search, perform the first round of diamond search, grid search and the second round of diamond search in sequence according to the first preset fast search rule.

[0091] Step S220: After the first round of diamond search, grid search and the second round of diamond search, the optimal integer precision motion vector is obtained.

[0092] Specifically, in the first round of diamond search, acceleration strategies were designed for searches with steps of 2, 8, and 16. Compared to AVS3's existing integer-precision MV search, this search method first roughly determines the object's direction of motion through a coarse estimate, and then performs a fine search along that direction. The advantage is that it not only reduces the number of MVDs traversed (from 25 to 17), but also expands the range of MVDs searched, without overlapping with subsequent searches. This expanded search range provides faster algorithmic support for subsequent searches.

[0093] In one embodiment, step S210, "performing the first round of diamond search, grid search, and second round of diamond search sequentially according to the first preset fast search rule," specifically includes:

[0094] Step S211: During the first round of diamond search, the first candidate motion vector is obtained with a first preset step size, and the first candidate motion vector is searched to obtain the first optimal motion vector among the first candidate motion vectors.

[0095] Step S212: Take the motion vector adjacent to the first optimal motion vector as the second candidate motion vector, and take the first optimal motion vector as the starting point to search all the second candidate motion vectors to obtain the second optimal motion vector among the second candidate motion vectors;

[0096] Step S213: Obtain a second preset step size, which is larger than the first preset step size; starting from the matching reference block, obtain a third candidate motion vector with the second preset step size, add the second optimal motion vector to the third candidate motion vector, and search the third candidate motion vector to obtain the third optimal motion vector;

[0097] Step S214: If the third optimal motion vector satisfies the first preset constraint, then the optimal motion vector among the first optimal motion vector, the second optimal motion vector, and the third optimal motion vector is taken as the search result of the first round of diamond search.

[0098] Specifically, the first preset step size is 2 pixels, and the second preset step size is 4 pixels. For a search with step 2, instead of searching for all MVs whose MVD(Δx,Δy) is within 2 pixels, the search is divided into two steps. First, a search is performed with a step size of 2, that is, the following 9 MVD candidates are searched:

[0099] {Δx, Δy}∈{{-2,-2},{-2,0},{-2,2},{0,2},{2,2},{2,0},{2,-2},{0,-2},{0,0}}

[0100] Starting with the optimal MV found in the first step, search for its eight neighboring MVD candidates:

[0101] {Δx, Δy}∈{{-1,-1},{-1,0},{-1,1},{0,1},{1,1},{1,0},{1,-1},{0,-1}}

[0102] For the search at step 4, only four MVD candidates are searched:

[0103] {Δx,Δy}∈{{-4,0},{4,0},{0,-4},{0,4}}

[0104] This embodiment first roughly determines the direction of the object's motion by coarse estimation, and then performs a fine search in the direction of motion. The advantage is that it not only reduces the number of MVDs traversed, but also expands the range of MVDs searched, and does not overlap with subsequent searches.

[0105] In one embodiment, after obtaining the third optimal motion vector, the method further includes:

[0106] Step A10: If the third optimal motion vector does not satisfy the first preset constraint, then obtain the third preset step size, which is greater than the second preset step size;

[0107] Step A20: Starting from the matching reference block, obtain the fourth candidate motion vector with the third preset step size, and search the fourth candidate motion vector to obtain the fourth optimal motion vector;

[0108] Step A30: If the fourth optimal motion vector satisfies the first preset constraint, then the optimal motion vector among the first optimal motion vector, the second optimal motion vector, the third optimal motion vector, and the fourth optimal motion vector is taken as the search result of the first round of diamond search.

[0109] Specifically, the first preset restriction condition is:

[0110] abs(CurBestMV_x-MVP_x)+abs(CurBestMV_y-MVP_y)<(step>>1)

[0111] Where CurBestMV is the best MV found so far, and step is the current search step size.

[0112] The third preset step size is 8 pixels. For an 8-pixel search, a first preset constraint is added before the search. If the first preset constraint is true, the search is skipped. This is because the search range in the step 2 search is increased. It can be determined that if the search still tends to select a smaller MVD, the object's motion tends to be small, and in this case, the larger step search should be skipped. Accelerated diamond search is as follows: Figure 5 As shown.

[0113] In this embodiment, it is first determined whether the third optimal motion vector meets the first preset constraint condition. If it does, there is no need to perform an 8-pixel search, which reduces the amount of computation and saves prediction time.

[0114] In one embodiment, step A20 is followed by:

[0115] Step B10: If the fourth optimal motion vector does not satisfy the first preset constraint, then obtain the fourth preset step size, which is greater than the third preset step size;

[0116] Step B20: Starting from the matching reference block, obtain the fifth candidate motion vector with the fourth preset step size, and search the fifth candidate motion vector to obtain the fifth optimal motion vector;

[0117] Step B30: The optimal motion vector among the first optimal motion vector, the second optimal motion vector, the third optimal motion vector, the fourth optimal motion vector, and the fifth optimal motion vector is taken as the search result of the first round of diamond search.

[0118] Specifically, the fourth preset step size is 16 pixels. For the 16-pixel search, a first preset constraint is added before the search. If the first preset constraint is true, the search is skipped. In this embodiment, it is first determined whether the fourth optimal motion vector satisfies the first preset constraint. If it does, the 16-pixel search is no longer needed, reducing the computational load and saving prediction time.

[0119] In one embodiment, step S210, which involves "performing the first round of diamond search, grid search, and second round of diamond search sequentially according to the first preset fast search rule," further includes:

[0120] Step S215: When performing grid search, obtain the sixth candidate motion vector within the preset search range, and search the sixth candidate motion vector to obtain the sixth optimal motion vector;

[0121] Step S216: In the square template, starting from the sixth optimal motion vector, search within the seventh candidate motion vector in the preset search range, and iterate the search until the search range is 0 to obtain the search results of the grid search.

[0122] In this invention, two rounds of searching are performed in each iteration. Specifically, the present invention also designs an accelerated search algorithm for square template matching in grid search. The existing square template matching in AVS3 searches for 8 MVDs within the search range r and sets r = r >> 1 after the search is completed, iterating until r = 0. In the designed accelerated algorithm, the same acceleration strategy is designed for square template matching in each round of traversal. Similarly, the search in each iteration is divided into two rounds.

[0123] In one implementation, "performing two rounds of search in each iteration" specifically includes:

[0124] Step C10: When performing the first round of search in the current iteration search, obtain the first round of motion vector candidates in the seventh candidate motion vector, traverse the first round of motion vector candidates, and record the optimal motion vector and the second-best motion vector in the current iteration search.

[0125] Step C20: During the second round of search in the current iteration, if the optimal motion vector and the second-best motion vector are adjacent, then test the motion vector between the optimal motion vector and the second-best motion vector.

[0126] Step C30: If the optimal motion vector and the second-best motion vector are not adjacent, then test the two motion vectors adjacent to the optimal motion vector.

[0127] Specifically, the first round of search traverses four MVDs, meaning the first round of motion vector residuals includes:

[0128] {Δx,Δy}∈{{-r,0},{0,r},{r,0},{0,-r}}

[0129] After the search is complete, record the two best and second-best MVDs: BestMVD and SecBestMVD. The second round of testing will have four candidate MVDs:

[0130] {Δx,Δy}∈{{-r,r},{r,r},{r,-r},{-r,-r}}

[0131] Perform conditional checks before the search; if the following conditions are met:

[0132] (BestMVD x ≠SecBestMVD x )&&(BestMVD y ≠SecBestMVD y )

[0133] In the second round of testing, only MVDs that meet the following conditions will be tested:

[0134] (Δx==BestMVD x &&Δy==SecBestMVD y )||(Δx==SecBestMVD x &&Δ==BestMVD y )

[0135] Otherwise, only test MVD that meets the following conditions:

[0136] (Δx==BestMVD x ||Δy==BestMVD y )

[0137] The condition for judgment in this embodiment is as follows: if the optimal and second-best MVDs found in the first step of the search are adjacent, it indicates that the object has a tendency to move in that direction. In this case, only the MVD between the optimal and second-best MVDs needs to be tested further. If the optimal and second-best MVDs are not adjacent, then the two MVDs adjacent to the optimal MVD are tested further. This acceleration algorithm can effectively reduce the number of MVDs traversed in each round of grid search (from 8 to 5 or 6). Figure 6 This is an example of an accelerated grid search, in which three rounds of traversal search are performed, with MV counts of 5, 5, and 6 in each round.

[0138] like Figure 4 As shown, the fast motion estimation applied to inter-frame prediction described in this embodiment further includes:

[0139] Step S300: Using the optimal integer precision motion vector as the starting point for sub-precision motion vector search, perform sub-precision motion vector search according to the second preset fast search rule to obtain the optimal sub-precision motion vector.

[0140] Specifically, this step involves a fast sub-precision motion vector search in forward, backward, and bidirectional modes.

[0141] In one embodiment, step S300 specifically includes:

[0142] Step S310: Using the optimal integer precision motion vector as the starting point for sub-precision motion vector search, perform half-pixel motion vector search to obtain the optimal half-pixel precision motion vector;

[0143] Step S320: Using the optimal half-pixel precision motion vector as the starting point of the 1 / 4 pixel search, perform a 1 / 4 pixel motion vector search to obtain the optimal 1 / 4 pixel precision motion vector;

[0144] Step S330: The optimal 1 / 4 pixel precision motion vector is taken as the optimal sub-precision motion vector.

[0145] Specifically, in the sub-precision MV search of AVS3, the optimal MV from the integer precision MV search is used as the starting point. The optimal sub-precision MV is searched using half-pixel and 1 / 4-pixel search templates respectively, with the 1 / 4-pixel precision MV search starting from the optimal half-pixel precision MV. The half-pixel and 1 / 4-pixel search templates are essentially equivalent to square search templates with r=1 / 2 and r=1 / 4 respectively. Therefore, the fast sub-precision MV search algorithm references the fast algorithm of grid search, also employing a multi-round search, coarse-to-fine search strategy.

[0146] In one implementation, step S310 includes:

[0147] Step S311: During the first round of searching for half-pixel motion vectors, obtain the four half-precision candidate motion vectors corresponding to the optimal integer precision motion vector;

[0148] Step S312: Traverse the candidate motion vectors for half-precision and record the optimal and suboptimal half-precision motion vectors among them;

[0149] Step S313: If the optimal half-precision motion vector and the suboptimal half-precision motion vector are adjacent, then test the motion vector between the optimal half-precision motion vector and the suboptimal half-precision motion vector.

[0150] Step S314: If the optimal half-precision motion vector and the suboptimal half-precision motion vector are not adjacent, then test the two motion vectors adjacent to the optimal half-precision motion vector.

[0151] Step S315: Test completed, obtaining the optimal half-pixel precision motion vector.

[0152] Specifically, taking the search of half-precision MV as an example, after completing pixel interpolation, the following four MVDs are searched first:

[0153] {Δx, Δy}∈{{-1 / 2, 0}, {0, 1 / 2}, {1 / 2, 0}, {0, -1 / 2}}

[0154] After the search is completed, record the two optimal and second-best MVDs: BestMVD and SecBestMVD. If the two satisfy:

[0155] (BestMVD x ≠SecBestMVD x )&&(bestMVD y ≠SecBestMVD y )

[0156] This indicates that BestMVD and SecBestMVD are adjacent and can reflect the object's tendency to move in a certain direction. In this case, only the middle MVD needs to be tested; otherwise, the two MVDs closest to BestMVD are tested. The search algorithm for 1 / 4 precision MVD is exactly the same as that for half precision MVD. This acceleration algorithm can reduce the number of MVDs traversed in sub-precision MV search from 16 to 10-12. Figure 7 This is an example of an accelerated sub-precision MV search, where the number of searches for half-precision MV is 6 and the number of searches for quarter-precision MV is 5.

[0157] Compared to existing diamond search methods, this invention further increases the number of search rounds with motion vectors refined from coarse to fine. This significantly reduces the number of MVs traversed while expanding the search range of short-step MVs. Furthermore, it designs an early termination strategy based on the magnitude of the current optimal MVD. Compared to existing square template matching-based searches, a fast algorithm relying on the correlation of motion vector directions is designed. Specifically, the position and number of MV candidates for the next search round are determined by the optimal and second-best MVs from the previous search round.

[0158] This invention employs numerous multi-round searches, where the number and position of motion vectors in a particular round depend on the search results of the previous round, and the dependency between the two is flexible and variable. Taking search optimization based on square template matching as an example, the position and number of MV candidates in the next round of search are determined by the optimal and suboptimal MVs of the previous round.

[0159] In one embodiment, such as Figure 8 As shown, based on the above-described fast motion estimation method applied to inter-frame prediction, the present invention also provides a fast motion estimation device applied to inter-frame prediction, comprising:

[0160] The acquisition module 100 is used to acquire a reference frame and motion vector predictions of the block to be encoded in the reference frame, and to acquire a matching reference block based on the motion vector predictions;

[0161] The first search module 200 is used to take the matching reference block as the starting point for integer precision motion vector search, and perform integer precision motion vector search according to the first preset fast search rule to obtain the optimal integer precision motion vector.

[0162] The second search module 300 is used to take the optimal integer precision motion vector as the starting point for sub-precision motion vector search, and perform sub-precision motion vector search according to the second preset fast search rule to obtain the optimal sub-precision motion vector.

[0163] In one embodiment, the present invention also provides a terminal, such as... Figure 9 As shown, it includes: a memory 20, a processor 10, and a fast motion estimation program 30 for inter-frame prediction stored in the memory 20 and executable on the processor 10. When the fast motion estimation program 30 for inter-frame prediction is executed by the processor 10, it implements the steps of the fast motion estimation method for inter-frame prediction as described above.

[0164] The present invention also provides a computer-readable storage medium storing a computer program that can be executed to implement the steps of the fast motion estimation method applied to inter-frame prediction as described above.

[0165] In summary, this invention discloses a fast motion estimation method and apparatus for inter-frame prediction. The method includes: acquiring a reference frame and motion vector predictions of the block to be encoded in the reference frame, and acquiring a matching reference block based on the motion vector predictions; using the matching reference block as the starting point for integer-precision motion vector search, performing integer-precision motion vector search according to a first preset fast search rule to obtain an optimal integer-precision motion vector; using the optimal integer-precision motion vector as the starting point for sub-precision motion vector search, performing sub-precision motion vector search according to a second preset fast search rule to obtain an optimal sub-precision motion vector. This invention, by performing integer-precision motion vector search according to the first preset fast search rule and sub-precision motion vector search according to the second preset fast search rule, reduces computational load and improves inter-frame prediction efficiency by selectively searching for motion vector residuals at each pixel step size instead of testing all motion vector residuals at that pixel step size.

[0166] It should be understood that the application of the present invention is not limited to the examples above. Those skilled in the art can make improvements or modifications based on the above description, and all such improvements and modifications should fall within the protection scope of the appended claims.

Claims

1. A fast motion estimation method for inter-frame prediction, characterized in that, include: Obtain a reference frame and the motion vector prediction of the block to be encoded in the reference frame, and obtain a matching reference block based on the motion vector prediction; Using the matching reference block as the starting point for integer precision motion vector search, integer precision motion vector search is performed according to the first preset fast search rule to obtain the optimal integer precision motion vector; Using the optimal integer precision motion vector as the starting point for the sub-precision motion vector search, the sub-precision motion vector search is performed according to the second preset fast search rule to obtain the optimal sub-precision motion vector; Using the matching reference block as the starting point for integer-precision motion vector search, and performing integer-precision motion vector search according to the first preset fast search rule to obtain the optimal integer-precision motion vector, includes: using the matching reference block as the starting point for integer-precision motion vector search, and in the integer-precision motion vector search, performing a first round of diamond search, a grid search, and a second round of diamond search sequentially according to the first preset fast search rule; after the first round of diamond search, grid search, and second round of diamond search, the optimal integer-precision motion vector is obtained; The first round of diamond search, grid search, and second round of diamond search are performed sequentially according to the first preset fast search rule, including: during the first round of diamond search, obtaining a first candidate motion vector with a first preset step size, and searching the first candidate motion vector to obtain the first optimal motion vector among the first candidate motion vectors; taking the motion vector adjacent to the first optimal motion vector as the second candidate motion vector, and using the first optimal motion vector as the starting point, searching all the second candidate motion vectors to obtain the second optimal motion vector among the second candidate motion vectors; obtaining a second preset step size, which is larger than the first preset step size; taking the matching reference block as the starting point, obtaining a third candidate motion vector with the second preset step size, and searching the third candidate motion vector to obtain the third optimal motion vector; if the third optimal motion vector meets the first preset restriction condition, then skipping the search of 8 pixels, and taking the optimal motion vector among the first optimal motion vector, the second optimal motion vector, and the third optimal motion vector as the search result of the first round of diamond search; The step of sequentially performing the first round of diamond search, grid search, and second round of diamond search according to the first preset fast search rule further includes: during the grid search, obtaining the sixth candidate motion vector within a preset search range, and searching the sixth candidate motion vector to obtain the sixth optimal motion vector; in the square template, starting from the sixth optimal motion vector, searching within the seventh candidate motion vector within the preset search range, and iterating the search until the search range is 0 to obtain the search result of the grid search; wherein, in each iteration of the search, two rounds of search are performed, and the same acceleration strategy is matched to the square template in each round of traversal; After obtaining the third optimal motion vector, the process further includes: if the third optimal motion vector does not meet the first preset constraint, then obtaining a third preset step size, which is larger than the second preset step size; starting from the matching reference block, obtaining a fourth candidate motion vector with the third preset step size, and searching the fourth candidate motion vector to obtain the fourth optimal motion vector; if the fourth optimal motion vector meets the first preset constraint, then skipping the search for 16 pixels, and using the optimal motion vector among the first optimal motion vector, the second optimal motion vector, the third optimal motion vector, and the fourth optimal motion vector as the search result of the first round of diamond search; Starting from the matching reference block, a fourth candidate motion vector is obtained with a third preset step size, and the fourth candidate motion vector is searched to obtain a fourth optimal motion vector. The process further includes: if the fourth optimal motion vector does not meet a first preset constraint, a fourth preset step size is obtained, where the fourth preset step size is greater than the third preset step size; starting from the matching reference block, a fifth candidate motion vector is obtained with a fourth preset step size, and the fifth candidate motion vector is searched to obtain a fifth optimal motion vector; the optimal motion vector among the first optimal motion vector, the second optimal motion vector, the third optimal motion vector, the fourth optimal motion vector, and the fifth optimal motion vector is used as the search result for the first round of diamond search. The first preset step size is 2 pixels, the second preset step size is 4 pixels, the third preset step size is 8 pixels, and the fourth preset step size is 16 pixels; The process of performing two rounds of search in each iteration includes: in the first round of search in the current iteration, obtaining the first round of motion vector candidates from the seventh candidate motion vectors, traversing the first round of motion vector candidates, and recording the optimal motion vector and the second-best motion vector in the current iteration; in the second round of search in the current iteration, if the optimal motion vector and the second-best motion vector are adjacent, then testing the motion vector between the optimal motion vector and the second-best motion vector; if the optimal motion vector and the second-best motion vector are not adjacent, then testing the two motion vectors adjacent to the optimal motion vector. Using the optimal integer-precision motion vector as the starting point for the sub-precision motion vector search, and performing a sub-precision motion vector search according to the second preset fast search rule to obtain the optimal sub-precision motion vector, includes: using the optimal integer-precision motion vector as the starting point for the sub-precision motion vector search, performing a half-pixel motion vector search to obtain the optimal half-pixel-precision motion vector; using the optimal half-pixel-precision motion vector as the starting point for a 1 / 4-pixel search, performing a 1 / 4-pixel motion vector search to obtain the optimal 1 / 4-pixel-precision motion vector; and using the optimal 1 / 4-pixel-precision motion vector as the optimal sub-precision motion vector. Using the optimal integer-precision motion vector as the starting point for sub-precision motion vector search, a half-pixel motion vector search is performed to obtain the optimal half-pixel-precision motion vector. This includes: in the first round of the half-pixel motion vector search, obtaining four half-precision candidate motion vectors corresponding to the optimal integer-precision motion vector; traversing the half-precision candidate motion vectors and recording the optimal and second-best half-precision motion vectors among them; if the optimal and second-best half-precision motion vectors are adjacent, then testing one of the motion vectors between them; if the optimal and second-best half-precision motion vectors are not adjacent, then testing the two motion vectors adjacent to the optimal half-precision motion vector; after the test is completed, the optimal half-pixel-precision motion vector is obtained. The motion vector prediction is the motion vector of the adjacent coded block. The difference between the motion vector prediction and the actual motion vector is the motion vector residual. Only the motion vector residual is transmitted, and the optimal motion vector residual is searched starting from the optimal motion vector prediction. The same search algorithm as the half-pixel motion vector search is used for the 1 / 4 pixel motion vector search.

2. A fast motion estimation device for inter-frame prediction, characterized in that, include: An acquisition module is used to acquire a reference frame and motion vector predictions of the block to be encoded in the reference frame, and to acquire a matching reference block based on the motion vector predictions; The first search module is used to take the matching reference block as the starting point for integer precision motion vector search, and perform integer precision motion vector search according to the first preset fast search rule to obtain the optimal integer precision motion vector; The second search module is used to take the optimal integer precision motion vector as the starting point for sub-precision motion vector search, and perform sub-precision motion vector search according to the second preset fast search rule to obtain the optimal sub-precision motion vector. Using the matching reference block as the starting point for integer-precision motion vector search, and performing integer-precision motion vector search according to the first preset fast search rule to obtain the optimal integer-precision motion vector, includes: using the matching reference block as the starting point for integer-precision motion vector search, and in the integer-precision motion vector search, performing a first round of diamond search, a grid search, and a second round of diamond search sequentially according to the first preset fast search rule; after the first round of diamond search, grid search, and second round of diamond search, the optimal integer-precision motion vector is obtained; The first round of diamond search, grid search, and second round of diamond search are performed sequentially according to the first preset fast search rule, including: during the first round of diamond search, obtaining a first candidate motion vector with a first preset step size, and searching the first candidate motion vector to obtain the first optimal motion vector among the first candidate motion vectors; taking the motion vector adjacent to the first optimal motion vector as the second candidate motion vector, and using the first optimal motion vector as the starting point, searching all the second candidate motion vectors to obtain the second optimal motion vector among the second candidate motion vectors; obtaining a second preset step size, which is larger than the first preset step size; taking the matching reference block as the starting point, obtaining a third candidate motion vector with the second preset step size, and searching the third candidate motion vector to obtain the third optimal motion vector; if the third optimal motion vector meets the first preset restriction condition, then skipping the search of 8 pixels, and taking the optimal motion vector among the first optimal motion vector, the second optimal motion vector, and the third optimal motion vector as the search result of the first round of diamond search; The step of sequentially performing the first round of diamond search, grid search, and second round of diamond search according to the first preset fast search rule further includes: during the grid search, obtaining the sixth candidate motion vector within a preset search range, and searching the sixth candidate motion vector to obtain the sixth optimal motion vector; in the square template, starting from the sixth optimal motion vector, searching within the seventh candidate motion vector within the preset search range, and iterating the search until the search range is 0 to obtain the search result of the grid search; wherein, in each iteration of the search, two rounds of search are performed, and the same acceleration strategy is matched to the square template in each round of traversal; After obtaining the third optimal motion vector, the process further includes: if the third optimal motion vector does not meet the first preset constraint, then obtaining a third preset step size, which is larger than the second preset step size; starting from the matching reference block, obtaining a fourth candidate motion vector with the third preset step size, and searching the fourth candidate motion vector to obtain the fourth optimal motion vector; if the fourth optimal motion vector meets the first preset constraint, then skipping the search for 16 pixels, and using the optimal motion vector among the first optimal motion vector, the second optimal motion vector, the third optimal motion vector, and the fourth optimal motion vector as the search result of the first round of diamond search; Starting from the matching reference block, a fourth candidate motion vector is obtained with a third preset step size, and the fourth candidate motion vector is searched to obtain a fourth optimal motion vector. The process further includes: if the fourth optimal motion vector does not meet a first preset constraint, a fourth preset step size is obtained, where the fourth preset step size is greater than the third preset step size; starting from the matching reference block, a fifth candidate motion vector is obtained with a fourth preset step size, and the fifth candidate motion vector is searched to obtain a fifth optimal motion vector; the optimal motion vector among the first optimal motion vector, the second optimal motion vector, the third optimal motion vector, the fourth optimal motion vector, and the fifth optimal motion vector is used as the search result for the first round of diamond search. The first preset step size is 2 pixels, the second preset step size is 4 pixels, the third preset step size is 8 pixels, and the fourth preset step size is 16 pixels; The process of performing two rounds of search in each iteration includes: in the first round of search in the current iteration, obtaining the first round of motion vector candidates from the seventh candidate motion vectors, traversing the first round of motion vector candidates, and recording the optimal motion vector and the second-best motion vector in the current iteration; in the second round of search in the current iteration, if the optimal motion vector and the second-best motion vector are adjacent, then testing the motion vector between the optimal motion vector and the second-best motion vector; if the optimal motion vector and the second-best motion vector are not adjacent, then testing the two motion vectors adjacent to the optimal motion vector. Using the optimal integer-precision motion vector as the starting point for the sub-precision motion vector search, and performing a sub-precision motion vector search according to the second preset fast search rule to obtain the optimal sub-precision motion vector, includes: using the optimal integer-precision motion vector as the starting point for the sub-precision motion vector search, performing a half-pixel motion vector search to obtain the optimal half-pixel-precision motion vector; using the optimal half-pixel-precision motion vector as the starting point for a 1 / 4-pixel search, performing a 1 / 4-pixel motion vector search to obtain the optimal 1 / 4-pixel-precision motion vector; and using the optimal 1 / 4-pixel-precision motion vector as the optimal sub-precision motion vector. Using the optimal integer-precision motion vector as the starting point for sub-precision motion vector search, a half-pixel motion vector search is performed to obtain the optimal half-pixel-precision motion vector. This includes: in the first round of the half-pixel motion vector search, obtaining four half-precision candidate motion vectors corresponding to the optimal integer-precision motion vector; traversing the half-precision candidate motion vectors and recording the optimal and second-best half-precision motion vectors among them; if the optimal and second-best half-precision motion vectors are adjacent, then testing one of the motion vectors between them; if the optimal and second-best half-precision motion vectors are not adjacent, then testing the two motion vectors adjacent to the optimal half-precision motion vector; after the test is completed, the optimal half-pixel-precision motion vector is obtained. The motion vector prediction is the motion vector of the adjacent coded block. The difference between the motion vector prediction and the actual motion vector is the motion vector residual. Only the motion vector residual is transmitted, and the optimal motion vector residual is searched starting from the optimal motion vector prediction. The same search algorithm as the half-pixel motion vector search is used for the 1 / 4 pixel motion vector search.

3. A terminal, characterized in that, include: The memory, the processor, and a fast motion estimation program for inter-frame prediction stored in the memory and executable on the processor, wherein the fast motion estimation program for inter-frame prediction, when executed by the processor, implements the steps of the fast motion estimation method for inter-frame prediction as described in claim 1.

4. A computer-readable storage medium, characterized in that, The computer-readable storage medium stores a computer program that can be executed to implement the steps of the fast motion estimation method for inter-frame prediction as described in claim 1.

Citation Information

Patent Citations

  • Method for fast searching mass movement self-adapting sub pixel

    CN101699865A