The method of motion vector prediction that is used for video coding
Technical field
The present invention relates to a kind of method of motion vector prediction that is used for video coding, be meant a kind of direct coding pattern that can be used for the B frame especially, to obtain motion-vector prediction more accurately, thereby embody method object of which movement, that utilize the motion-vector prediction of macro block in the linear interpolation principle realization B frame in the video more realistically, belong to digital audio/video coding techniques field.
Background technology
Video coding and decoding technology is to realize high-quality, storage of low-cost multi-medium data and the key of transmitting efficiently.Coding method commonly used at present has predictive coding, orthogonal transform coding, vector quantization coding or the like.These methods are also referred to as first generation coding techniques usually all based on signal processing theory.Now popular image encoding international standard is all based on this coding theory, the coding method that the motion compensation, discrete cosine transform and the quantification that are based on the piece coupling of employing combines.The MPEG-1 that typically has International Standards Organization/International Electrotechnical Commissio first United Technologies group (ISO/IEC JTC1) to release, international standards such as MPEG-2 and MPEG-4, and the H.26x series that International Telecommunications Union (ITU-T) proposes is recommended.These video encoding standards have obtained extensive use in industrial quarters.
Above-mentioned video encoding standard has all adopted hybrid video coding (Hybrid Video Coding) strategy, generally includes: four main modular such as prediction, conversion, quantification and comentropy coding.The major function of prediction module is to utilize the encoded image of building of laying equal stress on that the current image encoded of wanting is predicted (inter prediction), perhaps utilizes in the image the encoded image block of building (or macro block) of laying equal stress on that the current image encoded piece (or macro block) of wanting is predicted (infra-frame prediction).The major function of conversion module is that the image block that will import transforms to the another one space, the energy of input signal is concentrated on the low frequency transform coefficient as much as possible, and then reduce the correlation between the image block interior element, helps compression.The major function of quantization modules is that the coefficient with conversion is mapped on the finite element collection that helps encoding; The major function of comentropy coding module is according to statistical law, and the conversion coefficient after quantizing is represented with variable length code.
Video decoding system comprises the module similar to video coding, and is main by the code stream of input is rebuild decoded picture by processes such as entropy decoding, inverse quantization, inverse transformations.Except above-mentioned module, also comprise some auxiliary coding toolses in the video coding and decoding system usually, these instruments also can contribute to the coding efficiency (compression ratio) of whole system.
Major function based on motion compensated prediction is to eliminate video sequence redundancy in time.Most of code efficiency of video coding comes from prediction module.Video coding process is exactly the process that each two field picture of video sequence is encoded.Video coding system commonly used is that elementary cell is carried out with the macro block to the coding of each two field picture.When each two field picture of coding, can be divided into (I frame) coding in the frame, prediction (P frame) coding and bi-directional predicted (B frame) coding etc. again.In general, during coding, I frame, P frame and B frame are encoded to intert and are carried out, such as the order according to IBBPBBP.
The introducing of B frame can solve between the moving object effectively or object and background between " occlusion issue " that cause owing to the different direction of motion or movement rate.The coding of B frame can be so that encoding compression efficient reaches 200: 1 above code checks.The coding that macro block in the B frame is carried out comprises: direct (Direct), forward prediction (Forward Prediction), back forecast (BackwardPrediction) and bi-directional predicted (Bi-directional Prediction) four kinds of patterns.Since the B frame technique need carry out simultaneously forward direction with the back to estimation, therefore, computational complexity is higher; Simultaneously, in order to distinguish front and back, also to introduce extra identification information to motion vector.And adopt the Direct coding mode motion vector information not to be encoded, and therefore, can reduce the bit of encoding motion vector information, improve code efficiency effectively.
In coding, whether a macro block adopts the key of Direct coding mode to be: whether the prediction of motion vector is accurate.Direct Model in the traditional B frame coding adopts the time domain neighboring macro-blocks to realize that motion vector predicts.In other words, in the B frame during certain macroblock coding, derive by the motion vector of relevant position macro block in first reference frame of back obtains, and therefore, this prediction mode is based upon on the hypothesis basis that adjacent macroblocks has similar movement locus.But because the motion of time domain adjacent macroblocks is also not exclusively depended in the motion of current macro, particularly when the edge of object, because the relativity shift that moves between the object, this prediction tends to obtain inaccurate predicting the outcome.The piece size of motion compensated prediction was reduced to 4 * 4 o'clock, and this situation will be more obvious.
Can partly reply in the video image between two reference frames by the method for linear interpolation; Therefore, this method can be applied in the B frame coding.Referring to Fig. 7, traditional linear interpolation technology is based on that Pixel-level realizes, B wherein is the frame that needs interpolation, and former and later two P frames to be normal encodings form; When decoding, can utilize former and later two P frames to insert out the B frame simply, promptly the position of each piece is corresponding with the position of P frame, then the pixel of front and back P frame relevant block is done linear weighted function.Though this technology can realize static scene coding effectively, often can not reach good effect for the object of complicated movement.
In view of this, can introduce the method for motion compensated interpolation, solve the coding of the object of linearity, uniform motion by the mode of interpolation motion vector.Yet because the object of motion is always along rectilinear motion, and because the variation of noise or brightness tends to cause the inaccurate of motion-vector prediction, discontinuous (as the object edge part) that particularly forms in moving object.
Summary of the invention
Main purpose of the present invention is to provide a kind of method of motion vector prediction that is used for video coding, utilize the linear interpolation principle to realize the motion-vector prediction of macro block in the B frame, the Direct coding mode that can be used for the B frame, obtaining motion-vector prediction more accurately, thereby embody the motion of object in the video more realistically; Combine with forward predictive coded, back forecast coding simultaneously, realize a kind of new predictive coding type.
The object of the present invention is achieved like this:
The motion vector of each macro block in the B frame that will encode by the motion-vector prediction between two adjacent reference frames, the motion vector that does not come from the macro block of corresponding position in first reference frame of back for the prediction of certain macroblock motion vector in the B frame, if in first reference frame on the movement locus of certain macro block, then its motion vector is identical with the movement locus of this macro block in the back for this macroblocks.
In order to estimate the motion vector of each macro block in the B frame more accurately, predict the motion vector of each motion estimation block in each macro block by the mode of similar linear interpolation.When the B frame is encoded, at first all to carry out preliminary treatment to each macroblock prediction direction of reference frame to the back, to the movement locus of reference frame, can find the macro block in the corresponding B frame by the back with respect to forward reference frame.Concrete Forecasting Methodology is:
1, obtains the motion vector of back to each piece of reference frame;
2,, obtain from the forward direction reference frame to the movement locus of back to reference frame at each fast motion vector;
3, utilize this movement locus, calculate the piece that mates most that drops in the present image on this track;
4, finish after after whole piece motion estimation process of reference frame, will in present image, obtain corresponding motion vector.
Because the noise of image and the irregular movement of different objects, may cause some piece institutes " are passed " in the present image motion vector more than one.Can solve by one of following mode in this case:
First method is: adopt " nearby principle ", object of which movement at continuous images on the time domain is linear basically, and it is not too large to depart from the corresponding position of another frame, can consider therefore that on the spatial domain motion vector from the nearest piece gained of current location is as candidate vector.
Second method is: adopt the method for " average value " to ask for candidate vector; Because under many circumstances, tend to cause " occlusion issue " of motion in the edge block of object, therefore adopt several different motion vector averaged to " passing " relevant block, with this averaged motion vector as candidate vector.
In addition, when the motion vector that " passes " when some piece institutes is zero, can suppose that this piece does not have the direct pattern; Perhaps utilize the mode of spatial domain prediction to come motion vectors; Perhaps utilize the mode of forward motion vector to realize the prediction of motion vector; Perhaps utilize the mode of zero motion vector to come motion vectors.
According to above-mentioned technical scheme as can be known: the present invention can embody the motion of object in the video more realistically, obtains motion-vector prediction more accurately; With forward predictive coded, the back forecast coding combines, a kind of new predictive coding type of available realization, and its effect is similar to traditional B frame coding.
Description of drawings
Fig. 1 is the schematic diagram that a motion vector passes the present encoding piece;
Fig. 2 passes the schematic diagram of present encoding piece for a plurality of motion vectors;
Fig. 3 decides the schematic diagram of choosing real motion vector from a plurality of vectors for the present invention by adjacent piece;
Fig. 4 comes the schematic diagram of motion vectors for the present invention by adjacent piece;
Fig. 5 does not all have the schematic diagram of motion vector situation for adjacent piece;
Fig. 6 comes the schematic diagram of motion vectors for the present invention utilizes the extension of forward motion vector;
Fig. 7 is existing frame interpolation method schematic diagram;
The flow chart of Fig. 8 embodiment of the invention.
Embodiment
The present invention is described in further detail below in conjunction with accompanying drawing and specific embodiment:
See also Fig. 1 and Fig. 8, the present invention is for the step of present encoding piece calculating kinematical vector:
1. carry out the estimation of back, obtain the optimum movement vector of each n * n piece to reference frame;
2. the candidate motion vector of each n of preliminary treatment present frame * n piece;
Wide and the height of supposing image is respectively width, height.The piece of this always total height/n estimation of width/n x.For the piece of each n * n size of back in reference frame, suppose that the motion vector of the position of its central point is its estimated movement vector, the track that obtains moving along the direction of this motion vector, and in present frame, find the piece of coupling.
When the back to the block motion vector (supposing that from then on set out in the centre of n * n piece) of each n * n moving mass of reference frame when passing present image, can obtain the present image intersection point of vector therewith, calculating this intersection point then can drop in which n * n piece, the forward motion vector of this piece is the same to the motion vector direction of reference frame with the back, mould be its 1/2, the backward motion vector of current block then direction is opposite, mould be its 1/2.
Do estimation for each piece, can try to achieve best match block with given criterion (as SAD, SSD etc.) for different match block, and from present image, obtain corresponding motion vector with respect to reference frame.
If, when the position, the upper left corner of a certain moving mass of forward and backward reference frame be BACK_POS (x, y), its motion vector is (mvx, mvy) (mvx, mvy are that motion vector is x on the two-dimensional coordinate axle here, the value on the y direction of principal axis), then the position FOR_POS in forward reference frame (x y) is:
FOR_POS(x,y)=BACK_POS(x-n/2,y-n/2)+(mvx,mvy);
The position CURR_POS of corresponding current block (x y) is:
CURR_POS(x,y)=BACK_POS(x-n/2,y-n/2)+(mvx/2,mvy/2);
Thus, can in the hope of corresponding piece position be CURR_BLOCK=CURR_POS (X, Y)/n, the motion vector of this piece forward direction be respectively (mvx/2, mvy/2), the back to motion vector be respectively (mvx/2 ,-mvy/2).
3. referring to Fig. 2, when the same estimation piece of a plurality of motion vector points,, on the estimation piece that has, may obtain two or more motion vectors through after the above-mentioned processing.At this moment, adopt the method for spatial domain prediction to obtain real motion vector.Specifically being to select the motion vector that mates most according to the piece of the contiguous motion vector of having tried to achieve, promptly getting average by the motion vector to adjacent block, draw a candidate motion vector, is the reference motion vector of current block then with this candidate vector.As shown in Figure 3, can draw a candidate motion vector by the mode of the motion vector of adjacent piece being got average, a plurality of motion vectors and the candidate vector to current block compares then, gets the most close piece of its direction at last.Wherein, the piece that the square of dotted line representative is adjacent, the current piece of square representative of solid line, n1 wherein, n2 is the motion vector of adjacent block.Owing to two motion vectors that pass current block are arranged, therefore can find out and n1 the motion vector that the n2 direction vector is the most close.
4. for there not being motion vector to pass, but adjacent block can adopt the mode of spatial domain prediction to obtain corresponding motion vector when motion vector is arranged; Shown in Fig. 4,5, can draw a candidate motion vector by the mode of the motion vector of adjacent block being got average, be the reference motion vector of current block then with the candidate vector.The front and back that are current block are the same with the direction of reference motion vector to motion vector, and mould too.Referring to Fig. 4, the piece that the square of dotted line representative is adjacent, the current piece of square representative of solid line, n1 wherein, n2 is the motion vector of adjacent block, and the square representative that contains character A does not have motion vector to pass current block (square of solid line); Since there is not motion vector to pass current block, therefore can be with n1, and the vector of n2 on average is used as the motion vector of current block.Referring to Fig. 5, the piece that the square of dotted line representative is adjacent, the current piece of square representative of solid line, and the square representative that contains character A does not have motion vector to pass current block (square of solid line).
5. for not having motion vector to pass current block and when simultaneously adjacent block does not have motion vector, can utilizing the motion vector of forward direction to handle yet; As shown in Figure 6, be used as the reference motion vector of current block with the motion vector of forward reference frame relevant position piece.Be current block forward motion vector opposite with the direction of reference motion vector, mould is the same.The direction of backward motion vector is the same with the direction of reference vector, and mould too.Referring to Fig. 6, it comes the schematic diagram of motion vectors for the present invention utilizes the extension of forward motion vector; Wherein, the piece that the square of dotted line representative is adjacent, the current piece of square representative of solid line, and the square representative that contains character A does not have motion vector to pass current block (square of solid line), F represents that the forward reference frame motion vector passes the situation of current block.
6. if when the extension of forward direction motion vector was not passed this moving mass yet, then establishing its motion vector was zero.
Referring to Fig. 8, a concrete handling process of the present invention is:
Step a: carry out the back to the estimation of reference frame, its movement locus is obtained to each 4 * 4 of reference frame in this back;
Step b: according to described movement locus, obtain the present frame that falls into movement locus 4 * 4;
Step c: if the motion vector of intact each macro block, then end as calculated;
Steps d: statistics is passed the number of current 4 * 4 motion vector;
Step e:, carry out step d if this number greater than 1, then adopts the method for spatial domain prediction to obtain real motion vector;
Step f:, then establish the motion vector that this motion vector is a current block, execution in step d if this number equals 1;
Step g:, judge further then whether adjacent block has motion vector if this number equals 0;
Step h: if having, then utilize adjacent block to carry out spatial domain prediction, obtain motion vector; Execution in step d;
Step I:, judge further then whether the extension of forward motion vector passes through current block if do not have;
Step j: if then utilize the motion vector of the motion vector of forward block as current block; Execution in step d;
Step k: if not, the motion vector that current block then is set is zero; Execution in step d.
It should be noted that at last: above embodiment only in order to the explanation the present invention and and unrestricted technical scheme described in the invention; Therefore, although this specification has been described in detail the present invention with reference to each above-mentioned embodiment,, those of ordinary skill in the art should be appreciated that still and can make amendment or be equal to replacement the present invention; And all do not break away from the technical scheme and the improvement thereof of the spirit and scope of the present invention, and it all should be encompassed in the middle of the claim scope of the present invention.