Motion Compensation: Difference between revisions

From MultimediaWiki
Jump to navigation Jump to search
(Add images of equations as LaTeX interpreter plugin isn't in place.)
No edit summary
Line 8: Line 8:
The '''spatial''' mode calculates motion vectors from the vectors (left, top left, top? if available?) of neighbouring blocks. Depending on the prediction method used in said neighbouring blocks, the resultant B-frame prediction mode can be one of forward, backward or interpolation.
The '''spatial''' mode calculates motion vectors from the vectors (left, top left, top? if available?) of neighbouring blocks. Depending on the prediction method used in said neighbouring blocks, the resultant B-frame prediction mode can be one of forward, backward or interpolation.


'''Temporal''' direct prediction necessarily uses the interpolation mode. The temporal mode considers the forward motion vector of the collocated block in the first list 1 reference frame. If there are no reference B-frames or B-frame reordering, the first list 1 reference frame is usually the next P-frame.
'''Temporal''' direct prediction necessarily uses the interpolation mode. The temporal mode considers the forward motion vector of the colocated block in the first list 1 reference frame. If there are no reference B-frames or B-frame reordering, the first list 1 reference frame is usually the next P-frame.


[[Image:H264_direct_temporal_3.png]]
[[Image:H264_direct_temporal_3.png]]
LaTeX notation: {MV}_{forward} = \frac { {MV}_{L1}^{collocated} *  \left ( poc \left ( cur \right ) - poc \left ( L0 \right ) \right ) } { \left | poc \left ( L1 \right ) - poc \left ( L0 \right ) \right | }


[[Image:H264_direct_temporal_4.png]]
[[Image:H264_direct_temporal_4.png]]
Line 18: Line 16:
''Note: As poc(L1) > poc(cur), the signs of the directions of MV_L1 are swapped.''
''Note: As poc(L1) > poc(cur), the signs of the directions of MV_L1 are swapped.''


LaTeX notation: {MV}_{backward} = \frac { {MV}_{L1}^{collocated} *  \left ( poc \left ( cur \right ) - poc \left ( L1 \right ) \right ) } { \left | poc \left ( L1 \right ) - poc \left ( L0 \right ) \right | }
Where MV_L1 colocated is the motion vector of the colocated block in the first L1 reference frame and poc(*) gives the position of frame * in the sequence of frames.
 
Where MV_L1 collocated is the motion vector of the collocated block in the first L1 reference frame and poc(*) gives the position of frame * in the sequence of frames.


Consider the following setup where we have a sequence of frames PbbbP with no reference B-frames / frame reordering:
Consider the following setup where we have a sequence of frames PbbbP with no reference B-frames / frame reordering:

Revision as of 19:00, 19 May 2007

Motion compensation encompasses a number of methods for using predicted motion vectors to recreate pixels within a frame from past, future video frames or even the current video frame. Wikipedia has a fairly extensive article discussing and detailing some of the defined techniques.


Direct Prediction

Direct prediction offers methods for calculating motion vectors for already coded vectors to reduce the bit cost of coding B-frames and take advantage of motion coherences in different domains. There are two methods of direct prediction - spatial and temporal.

The spatial mode calculates motion vectors from the vectors (left, top left, top? if available?) of neighbouring blocks. Depending on the prediction method used in said neighbouring blocks, the resultant B-frame prediction mode can be one of forward, backward or interpolation.

Temporal direct prediction necessarily uses the interpolation mode. The temporal mode considers the forward motion vector of the colocated block in the first list 1 reference frame. If there are no reference B-frames or B-frame reordering, the first list 1 reference frame is usually the next P-frame.

H264 direct temporal 3.png

H264 direct temporal 4.png

Note: As poc(L1) > poc(cur), the signs of the directions of MV_L1 are swapped.

Where MV_L1 colocated is the motion vector of the colocated block in the first L1 reference frame and poc(*) gives the position of frame * in the sequence of frames.

Consider the following setup where we have a sequence of frames PbbbP with no reference B-frames / frame reordering:

H264 direct temporal 1.png

To visualise the process, the end points of the forward motion vector remain in the same frames (starting at P2, ending at P1) but the vector is translated such that it appropriately intersects the current macroblock (in red) in the current frame (B1).

H264 direct temporal 2.png

The translated vector is essentially 'split' setting the start point at the appropriate position of the current macroblock and pointing along the translated vector forward to P1 and backward to P2.