#include <dvmbasic.h>
A Vector represents a motion vector, (e.g., in a MPEG video). It has x and y components, and a flag to indicate if the vector exists. (The exists flags can be used for other purposes as the programmer sees fit.)
typedef struct Vector { char exists; char down; char right; } Vector;
- exists
- 0 if the vector is not initialized. 1 if the down and right are initialized. 2 if the vector is skipped (in MPEG B-frame encoding only).
- down
- Down vector component
- right
- Right vector component
A VectorImage is a buffer storing 2D array of Vector. Just like a ByteImage, a VectorImage can be either physical or virtual.
typedef struct VectorImage { int width; int height; int x; int y; int parentWidth; unsigned char isVirtual; Vector *firstVector; } VectorImage;
- width
- the width of the VectorImage
- height
- the height of the VectorImage
- x
- the x-offset of the top-left corner of the VectorImage from it's parent.
- y
- the y-offset of the top-left corner of the VectorImage from it's parent.
- parentWidth
- the width of the physical parent of this VectorImage. (should be called rootWidth since the parent might not be physical)
- virtual
- 1 iff the VectorImage is virtual. 0 otherwise.
- firstVector
- pointer to the first vector in this VectorImage.
Return codes from various vector primitives. DVM_VECTOR_OK indicates the primitives executed successfully. DVM_VECTOR_ERROR indicates some error has occurs. We may defined more error codes to indicates different type of errors.
#define DVM_VECTOR_OK 0 #define DVM_VECTOR_ERROR 1
VectorNew *VectorNew (int w, int h)
Create a new physical VectorImage with w x h vectors and return a pointer to that VectorImage.
void VectorFree (VectorImage *vectorImage)
Deallocate vectorImage.
VectorImage *VectorClip (VectorImage *vectorImage, int x, int y, int w, int h)
Create a virtual VectorImage of size w by h, with vectorImage as the parent, and offset (x, y) from the upper-left corner of vectorImage. A pointer to the new VectorImage is returned.
void VectorReclip (VectorImage *vectorImage, int x, int y, int w, int h, VectorImage *clipped)
This function is identical to VectorClip, except that it destructively modifies the virtual VectorImage clipped (instead of creating a new virtual VectorImage). Warning : memory leaks will occurs if clipped is a physical VectorImage.
void VectorCopy (VectorImage *src, VectorImage *dest)
Copy the top-left w x h area of VectorImage src into VectorImage dest, where w and h are minimum width and height of src and dest.
int VectorGetX(VectorImage *vectorImage)
int VectorGetY(VectorImage *vectorImage)
int VectorGetWidth(VectorImage *vectorImage)
int VectorGetHeight(VectorImage *vectorImage)
int VectorGetVirtual(VectorImage *vectorImage)
These functions (macros in the C version) access various fields in the VectorImage data structure. The first two function return the x or y offset of vectorImage within its parent, the next two return the width or height of vectorImage, and the last function returns 1 if vectorImage is virtual, 0 otherwise.
Last updated : Tuesday, February 02, 1999, 04:51 PM