In a kind of video coding based on the searching method of motion-vector prediction
Technical field
The present invention relates to the video signal coding field, the method for the motion-vector prediction in particularly a kind of video coding process.
Technical background
In the present video coding technique, motion vector (Motion Vector is called for short MV) prediction is the starting point of calculating kinematical vector field.If effective motion vectors field has been reduced the complexity and the amount of calculation of estimation so on the one hand, also help removing data redundancy on the other hand, improve the code efficiency of whole system.
But in the prior art, the MV prediction generally is a similitude of utilizing the motion of adjacent area in the frame, and level, vertical adjacent data blocks piece MV predicts the motion vector of current data block, is direct MV prediction.Shown in 1,2, suppose that E is current macro block, macroblock partition or child partition with reference to the accompanying drawings, A is the subregion or the child partition in E left side, and B is the subregion or the child partition of E top, and C is top-right subregion of E or child partition.If at the subregion of the left side of E appearance more than 1, the highest part will be selected by A in these subregions so; If the subregion more than 1 occurs above E, the part of the leftmost side will be selected by B in these subregions so.Fig. 1 represents is the selection of all subregions (being 16*16 here) adjacent sectors when all having same size.What Fig. 2 represented is, how to predict the selection of subregion when adjacent sectors and current subregion E have different size.Specify as follows:
(1), do not comprise that the motion vectors (MVp) of the partitions sizes of 16*8 and 8*16: E is the average of the motion vector of subregion A, B, C for the subregion that has transmitted;
(2) for the subregion of 16*8: the MVp of the subregion of the 16*8 of top is that the MVp of the subregion of the 16*8 of below is predicted by A by the B prediction.
(3) for the subregion of 8*16: the MVp of the subregion of the 8*16 of top is that the MVp of the subregion of the 8*16 of below is predicted by C by the A prediction.
(4) for the macro block of skipping: a 16*16 vector MVp will produce as the situation described in (1).(for example, encoding with the 16*16Inter pattern) just as piece.
Therefore such MV Forecasting Methodology amount of calculation is very little, but inaccuracy only adopts the prediction of direct MV at macro block seldom in an image, and the MV prediction of a large amount of macro blocks remains with traditional motion estimation algorithm calculates.
Traditional motion estimation algorithm is based upon on the motion search basis, and three-step approach is arranged, four step rule etc., and basic principle is:
At first, adopt an initial template, shown in the stain in the accompanying drawing 3, calculate mean square deviation (MSE, Mean Square Error) or absolute error and (SAD, the Sumof Absolute Difference) of each point and piece each point to be predicted then;
Then, template center is moved on to the difference smallest point, step-length reduces half, gets new template, shown in the point of the black and white in the accompanying drawing 3 half and half, recomputates the MSE or the SAD of each point;
At last, repeat previous step, shown in the white point of accompanying drawing 3, obtain predicting MV up to the end condition that satisfies search.
Traditional various motion estimation algorithm is to adopt different templates, and to reduce the amount of calculation of search, meticulousr search also can be adopted the calculating of both full-pixel and half-pix (even 1/4 pixel) position.Motion estimation algorithm accounts for whole amount of calculation 70% greatly in video coding, and the calculating of SAD is up to 60%, if adopt MSE, operand is just bigger so.
Summary of the invention
The objective of the invention is: in the video coding that at the deficiencies in the prior art, provide a kind of and predict accurately, algorithm is simple fast, operand is little based on the searching method of motion-vector prediction.
In order to solve the problems of the technologies described above, the technical solution used in the present invention is: based on the searching method of motion-vector prediction, comprise the steps: in a kind of video coding
The motion vector of a plurality of data blocks that step 1, acquisition are adjacent with described current data block position;
Step 2, according to the motion vector of described each data block, obtain the motion vectors of current data block;
Step 3, be the center, carry out the search of little template, until the motion vector that obtains local optimum with the motion vectors position of described current data block.
In the described step 1, a plurality of data blocks adjacent with the current data block position can comprise left data block, top data block and the upper right side data block of current data block.
In the described step 2, the motion vectors of current data block=(2* left data block motion vector+top data block motion vector+upper right side data block motion vector)/4.
Described step 2 is specifically as follows according to the gradient of described each data block to current data block, obtains the motion vectors of current data block.
In the described step 2, can calculate the gradient of described each data block to current data block respectively, the motion vector of getting gradient minimal data piece is the motion vectors of current data block.
Further, described step 3 can be specially:
A, be the center, with one 5 little template, read the data of the data block in the little template, and carry out SAD and calculate with the motion vectors position of current data block;
B, judge whether described SAD result of calculation smallest point overlaps with the center, if, then jump to steps d, otherwise execution in step c;
C, to get SAD result of calculation smallest point be new center, reads the data of the data block in one 5 the little template again, and carry out SAD and calculate, and returns step b then;
D, the center when described SAD result of calculation smallest point overlaps with the center are the motion vector position of local optimum.
Described data block can be macro block or piece.
In technique scheme, the present invention has realized a kind of novel fast search algorithm, it utilizes the correlation of adjacent data blocks, reduced computational complexity, dwindle the hunting zone of current data block, thereby can improve the internal memory reading speed, and on this basis, adopt the search of little template to calculate, can obtain very accurate prediction MV and very low amount of calculation.
Description of drawings
Accompanying drawing 1 is the schematic diagram when the direct predicted method adjacent data of MV block size is consistent in the prior art;
Accompanying drawing 2 is the schematic diagram during not of uniform size the causing of the direct predicted method adjacent data blocks of MV in the prior art;
Accompanying drawing 3 is the schematic diagram of motion estimation algorithm in the prior art;
Accompanying drawing 4 is the flow chart of the inventive method;
Accompanying drawing 5 is the schematic diagram that adopts little template search in a kind of specific embodiment of the present invention.
Embodiment
Below in conjunction with Figure of description and specific embodiment the present invention is described in further detail.
With reference to the accompanying drawings 4, a kind of specific embodiment of the present invention provides in a kind of video coding the searching method based on motion-vector prediction, because the processing procedure of video coding mainly is at macro block (MacroBlock at present, MB) or piece (Block) carry out, the size of a macro block is 16 * 16 pixels, wherein can be divided into the piece of 48 * 8 pixels.Therefore, present embodiment is also operated at macro block or piece.Its step is as follows:
The a plurality of macro blocks that step 1, acquisition and described current macro or piece position are adjacent or the motion vector of piece.
Wherein, adjacent a plurality of macro blocks or piece follow the example of can with prior art in identical, with reference to the accompanying drawings 1,2, described current macro/piece is E, described adjacent a plurality of macro blocks or piece comprise left macroblock/block A, top macroblock/block B and upper right side macroblock/block C.When the varying in size of ABC and E, it is followed the example of can be with reference to the introduction of this specification technical background part.
Step 2, according to the motion vector of described each macroblock/block, obtain the motion vectors of current macro/piece.
The concrete method of implementing can have multiple, also can adopt method of the prior art.
Two kinds of preferable embodiments are provided in the specific embodiments of the invention:
Method one:
The predictor formula of getting E is: MV
E=(2*MV
A+ MV
B+ MV
C)/4.
Be the motion vectors MV of E
EMotion vector MV by A
A, B motion vector MV
BMotion vector MV with C
CCalculate.
Therefore this predictor formula can obtain the motion vectors of E comparatively accurately owing to considered the correlation of the macroblock/block that E is adjacent.
Method two:
Be based on the Forecasting Methodology of gradient calculation,, obtain the motion vectors of current macro/piece promptly according to the gradient of described each macroblock/block to current macro/piece.
Be specially: calculate described each macroblock/block A, B, the C gradient to current macro/piece E respectively, the motion vector of getting the macroblock/block of gradient minimum is the motion vectors of current macro/piece E.
In the actual implementation process, can choose the method for prior art according to the different images and the diverse location of image, a kind of enforcement in two kinds of methods perhaps provided by the invention.Its prediction accuracy is difference slightly.
Step 3, be the center, carry out the search of little template, until the motion vector that obtains local optimum with the motion vectors position of described current macro/piece.
The purpose of this step is to have obtained to carry out searching algorithm fast on the basis of preliminary motion vectors in step 2, thereby search obtains optimum motion vector.
The purpose of getting little template search is exactly in order to reduce amount of calculation, to improve search efficiency, guaranteeing the accuracy of search.Described little template can adopt step-length less, the less template of counting.As, adopting step-length is 23 point templates, perhaps step-length is 15 point templates etc.When adopting step-length greater than 1 the time, can reduce step-length and search for reference in the conventional motion estimation algorithm.Present embodiment is in order to improve the accuracy of search as much as possible, and having adopted step-length as shown in Figure 5 is 15 little template.
Its concrete search procedure is as follows:
The first step is the center with the motion vectors position of current macro/piece, gets one 5 little template, sees among Fig. 55 macroblock/block shown in a, b, c, d, the e, and wherein, the motion vectors MV that a represents in the step 2 to be obtained
EThe position.
Read the data of this little template interior a, b, c, d, e macroblock/block, and carry out SAD respectively and calculate.
In second step, judge whether described SAD result of calculation smallest point overlaps with center a, if then jumped to for the 4th step, otherwise carried out for the 3rd step;
In the 3rd step, getting SAD result of calculation smallest point is new center, is b as new center, then gets one 5 little template again, promptly is made up of a, b, g, f, these 5 macroblock/block of h.
Read the data of the macroblock/block in this little template again, and carry out SAD respectively and calculate, returned for second step then;
In the 4th step, the center when described SAD result of calculation smallest point overlaps with the center is the motion vector position of local optimum.
So, then reached the purpose of this search optimal motion vector.
Clearly, the present invention at first passes through the correlation of adjacent macroblocks/piece, carry out preliminary motion-vector prediction, thereby can obtain the position of motion vectors roughly, and then the fast search algorithm by little template, predicted position is carried out quick search among a small circle again, and obtains the optimal motion vector.The relative undoubtedly prior art of this method, both accurate, quick again, also can significantly reduce operand.Facts have proved, after employing this method, owing to can only read the data block of motion vectors direction, so the hunting zone can be reduced into 1/3~1/4 of prior art.And its precision of prediction is than simple direct MV prediction algorithm height, and the complexity of calculating is lower than traditional motion estimation algorithm, is well positioned to meet the compromise requirement of the precision and the complexity of estimation.
Though above more at large described the present invention, these descriptions only are illustrative and not restrictive.Obviously, the present invention can change in many ways for those of ordinary skill.All such variations all belong within the scope of the present invention, and should not be considered to depart from scope of the present invention.The present invention is limited by marrow of claims and scope only.