|
|||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
java.lang.Objectfi.helsinki.cs.ohtu.mpeg2.video.MotionVector
public class MotionVector
Represents a motion vector.
Motion vectors are used in MPEG-2 to specify the reference points for motion compensation. The other input is the motion residual, which conveys the difference between the image data at the reference point in the reference frame and at the point to be reconstructed.
Motion vector values are specified at half-pixel precision. Therefore, a motion vector having values (7, -20) corresponds to an image-space offset of (3.5, -10).
The picture layer F code parameter affects the encoding and allowable values in motion vectors. Motion vector range will be restricted to [-(2^(fCode+3))..2^(fCode+3)-1] for both components. Additionally, constantly using motion vectors in the high end of the range is not space-efficient, but neither is always using a really high F code. The space taken, in bits, by a motion vector's (X or Y) component with value v is given roughly by fCode + v / 2^fCode. However, the encoded size of a zero component is always exactly one bit.
Nested Class Summary | |
---|---|
static class |
MotionVector.Predictors
Preserves that context of previously written motion vectors to determine correct binary encoding when writing motion vectors. |
Field Summary | |
---|---|
private static int[][] |
COARSE_VALUE_CODES
|
private static int[][] |
DIFFERENTIAL_CODES
|
private int[] |
differentials
|
private int |
fCode
|
private java.lang.Boolean |
isBottomField
|
private int[] |
values
|
Constructor Summary | |
---|---|
MotionVector(int fCode)
Constructs a zero-length motion vector. |
|
MotionVector(int fCode,
int horizontalValue,
int verticalValue)
Constructs a motion vector with the given value. |
Method Summary | |
---|---|
int |
getFCode()
Gets the F code the motion vector is subject to. |
int |
getHorizontalDPDifferential()
If the motion vector specifies dual-prime differentials, returns the horizontal differential value. |
int |
getHorizontalValue()
Gets the horizontal value. |
int |
getVerticalDPDifferential()
If the motion vector specifies dual-prime differentials, returns the vertical differential value. |
int |
getVerticalValue()
Gets the vertical value. |
boolean |
hasDPDifferentials()
Determines if the motion vector specifies dual-prime differentials. |
boolean |
hasFieldSelect()
Determines if the motion vector specifies (the parity of) a reference field. |
boolean |
isFromBottomField()
If the motion vector specifies the reference field parity, determines whether it selects a bottom field. |
boolean |
isFromTopField()
If the motion vector specifies the reference field parity, determines whether it selects a top field. |
void |
setDPDifferentials(int horizontalDifferential,
int verticalDifferential)
Sets the motion vector to specify dual-prime differentials. |
void |
setFromBottomField()
Sets the motion vector to specify that a bottom field should be used as the reference field. |
void |
setFromTopField()
Sets the motion vector to specify that a top field should be used as the reference field. |
void |
setHorizontalValue(int value)
Sets the horizontal value. |
void |
setValues(int horizontalValue,
int verticalValue)
Sets both the horizontal and vertical value. |
void |
setVerticalValue(int value)
Sets the vertical value. |
void |
unsetFieldReferenceExtras()
Makes the motion vector specify neither a dual-prime differential or a reference field parity. |
void |
writeTo(BitOutputStream stream,
MotionVector.Predictors predictors)
Writes the motion vector to a bit-by-bit output stream. |
Methods inherited from class java.lang.Object |
---|
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
Field Detail |
---|
private static final int[][] COARSE_VALUE_CODES
private static final int[][] DIFFERENTIAL_CODES
private int fCode
private int[] values
private java.lang.Boolean isBottomField
private int[] differentials
Constructor Detail |
---|
public MotionVector(int fCode)
fCode
- The F code corresponding to the motion vector from the picture layer. Must be in range [1..9].public MotionVector(int fCode, int horizontalValue, int verticalValue)
fCode
- The F code corresponding to the motion vector from the picture layer. Must be in range [1..9].horizontalValue
- The horizontal value. Subject to the restrictions of setHorizontalValue().verticalValue
- The vertical value. Subject to the restrictions of setVerticalValue().Method Detail |
---|
public int getFCode()
public int getHorizontalValue()
public void setHorizontalValue(int value)
value
- The value to set. Must be in range [-(2^(fCode+3))..2^(fCode+3)-1]public int getVerticalValue()
public void setVerticalValue(int value)
value
- The value to set. Must be in range [-(2^(fCode+3))..2^(fCode+3)-1]public void setValues(int horizontalValue, int verticalValue)
horizontalValue
- The horizontal value. Subject to the restrictions of setHorizontalValue().verticalValue
- The vertical value. Subject to the restrictions of setVerticalValue().public void setFromTopField()
public void setFromBottomField()
public boolean hasFieldSelect()
public boolean isFromTopField()
public boolean isFromBottomField()
public void setDPDifferentials(int horizontalDifferential, int verticalDifferential)
horizontalDifferential
- The horizontal differential value. Must be in range [-1..1].verticalDifferential
- The vertical differential value. Must be in range [-1..1].public boolean hasDPDifferentials()
public int getHorizontalDPDifferential()
public int getVerticalDPDifferential()
public void unsetFieldReferenceExtras()
public void writeTo(BitOutputStream stream, MotionVector.Predictors predictors) throws java.io.IOException
stream
- The stream to write to.predictors
- The Predictors instance to use.
java.io.IOException
- Propagated from the stream write.
|
|||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |