Coordinate Mapping in the VMR
This topic applies to Windows XP Home Edition and Windows XP Professional only.
This section describes the five transformations that are applied to a source data image before it is mapped by the VMR onto the final output image.
- The transformation T(Src) maps the source rectangle to the destination rectangle. These are specified by the rcSource and rcTarget members of the VIDEOINFOHEADER and VIDEOINFOHEADER2 structure in the media type. This mapping preprocesses the source image as it passes to the VMR.
- The transformation T(Flag) performs any image manipulations specified by flags in the media sample. These included transformations such as the vertical translation and scale to accommodate the bob interlace flags.
- The aspect correction transformation T(AR) converts the image to square pixels.
- The transformation T(Mix) transforms the square pixel image to the destination image, by the normalized rectangles specified in the IVMRMixerControl methods. The normalized rectangles enable the application to organize how the source streams are positioned and scaled relative to each other. The VMR computes the destination image by computing the maximum dimensions of all square pixel images and centering each inside of the overall bounding rectangle. The corners of the image are assigned the range (0,0) to (1,1). The bounding rectangle is fixed before the graph runs and remains constant even if streams are added or deleted. Destination rectangles for each stream can lie outside of the range (0,0) to (1,1) and still be valid. The normalized destination rectangle also has a pair of flags that modify the usage semantics of the destination coordinate. The flags can take the following values:
VMRDest_AdjustHeight (0x00000001)
: The height will be adjusted (and centered about the middle of the normalized rectangle) to maintain the image’s aspect ratio.
VMRDest_AdjustWidth (0x00000002)
: The width will be adjusted (and centered about the middle of the normalized rectangle) to maintain the image’s aspect ratio.
- Finally, a portion of the mixed image can be transformed by the mapping T(Dst), specified by the source and destination rectangles in the IBasicVideo interface on the VMR. If the Allocator-Presenter is replaced and the IBasicVideo interface is not used, the application must implement the IVMRWindowlessControl interface and map the coordinates back into a 2D linear space. The mouse coordinates returned to the DVD navigator must also be in this space. For example, if an application renders video onto a spinning cube, they would report back the entire display for the windowless control and return mouse coordinates relative to the display.
The overall image transformation from the source data to the final renderer is:
T = T(Src)* T(Flag) T(Ar) T(Mix)* T(Dst)*
where * indicates that the image could be clipped to the destination image at that stage, and T(Flag) = T(Interlace). The interlace transformation doubles the image height and possibly translates the image by half of a video line if it is in the odd field.
The inverse of the transformation is:
The factor T(Src) T(Flag) T(Ar) is relative to the source resolution. In the factor T(Mix), the normalized source rectangle is relative to the aspect corrected image. The normalized destination rectangle is relative to the output resolution. The following diagram shows these relationships.