A motion estimation method, comprising:
- setting a plurality of block patterns;
- for each of the plurality of set block patterns:
- dividing a current macro block into calculating blocks based on each of the plurality of the set block patterns;
- calculating motion vectors of all the calculating blocks of the current macro block;
- and
- calculating the sum of matching values between all the calculating blocks of the current macro block and calculating blocks corresponding to their respective motion vectors;
- and
- selecting, from the plurality of set block patterns, the block pattern corresponding to the minimum out of the sums of matching values corresponding to each of the plurality of the set block patterns, and regarding a motion vector corresponding to the selected block pattern as the motion vector of the current macro block;
- wherein calculating the motion vectors of all the calculating blocks of the current macro block comprises calculating the motion vectors of all the calculating blocks of the current macro block point by point;
- wherein calculating the motion vectors of one of the calculating blocks point by point comprises:
- determining a start point for a diamond search and regarding the determined start point as the center of the diamond search;
- for the one calculating block, calculating respectively matching values between the one calculating block and calculating blocks corresponding to four points surrounding the center of the diamond search;
- determining whether there is a matching value satisfying a preset exit condition;
- and
- if there is a matching value satisfying the preset exit condition:
- verifying whether the radius of the diamond search is 1;
- and
- if the radius of the diamond search is 1, regarding the motion vector of the point corresponding to the matching value satisfying the exit condition as the motion vector of the one calculating block;
- and
- if the radius of the diamond search is not 1, setting the radius of the diamond search as 1, regarding the point corresponding to the matching value satisfying the exit condition as a new center of the diamond search, calculating matching values between the one calculating block and calculating blocks corresponding to the four points surrounding the new center of the diamond search, and regarding the motion vector of the point having the minimum matching value as the motion vector of the one calculating block;
- and
- if there is not any matching value satisfying the preset exit condition regarding the point having the minimum matching value as a new center of the diamond search, calculating matching values between the one calculating block and calculating blocks corresponding to the four points surrounding the new center of the diamond search, and until there is a matching value satisfying the preset exit condition, repeatedly executing the following steps:
- regarding the point having the minimum matching value as a new center of the diamond search, and
- calculating matching values between the one calculating block and calculating blocks corresponding to the four points surrounding the new center of the diamond search;
- wherein, the four points surrounding the center of a diamond search comprise four points which are on the top, bottom, left and right of the center of the diamond search respectively, with distance from the center of the diamond search being the radius of the diamond search.