Microsoft DirectX 8.1 (C++)

Positioning and Moving Video Rectangles in Composition Space

An application can perform special effects with moving, stretching and shrinking video frames on a specified stream by specifying the destination or output rectangle in "composition space" using IVMRMixerControl::SetOutputRect. The following figure shows the relation of composition space to the visible video rectangle.

Composition space

As shown here, composition space includes the visible video rectangle as well as an area whose coordinate system allows a rectangle of any size to be positioned completely or partially "offscreen". By moving the output rectangle at specified intervals using some sort of timer, individual video streams can be made to move, stretch and shrink in many interesting ways. For example, assume that stream 1 contains the main video stream, and stream 2 contains some secondary video graphics to be displayed on top of stream 1. Assume also that stream 2's rectangle is the same size as stream 1, although this isn't required. Stream 2 can be positioned initially completely offscreen to the left by specifying a NORMALIZEDRECT of {-1, 0, 0, 1} (left, top, right, bottom). Then stream 2 can be moved into the visible area by modifying the left and right sides of the rectangle on successive calls to SetOutputRect:

At time 0: {-1, 0, 0, 1 }; at time 0+1, {-0.9, 0, 0.1, 1};at time 0+2, {-0.8, 0, 0.2, 1}; and so on, until at time 0+10 the output rectangle is {0, 0, 1, 1}. At this point the video from stream 2 has moved from completely offscreen to completely visible.

In this example, the native size of stream 2 was maintained while it was moving. You could also stretch or shrink the rectangle in any way to produce interesting effects. Furthermore, you may flip a rectangle upside down at any position in composition space, including the visible rectangle, by specifying a greater value for top than for bottom. Likewise, you can create a mirror effect by specifying a value for "right" that is less than the value for "left." If the specified rectangle is a different size than the native video rectangle, the native video will be shrunk or stretched to fit.