Providing a Custom Video Resizer
Note This feature requires DirectX 9.0 or later.
When DirectShow Editing Services (DES) resizes a video source clip, the default behavior is a StretchBlt, which is fast but not anti-aliased. You can change the resizing behavior by implementing a custom resizer as a DirectShow transform filter. The filter must expose the IResize interface, which enables DES to specify the input and output video size. For information about writing a transform filter, see Writing Transform Filters. The CTransformFilter base class is recommended as the starting point. When you implement the filter, note the following:
- Support the IResize interface on the filter (not the pins).
- The filter should accept only VIDEOINFOHEADER formats (FORMAT_VideoInfo). Reject other format types.
- The video format from DES may be any uncompressed RGB type, including 32-bit RGB with alpha (MEDIASUBTYPE_ARGB32). Your filter can safely reject formats with biHeight < 0.
- Before the Render Engine connects the filter's output pin, it calls IResize::put_MediaType to set the output type. It may also call IResize::put_Size to adjust the output size. It can call these two methods in any order, any number of times, before it connects the output pin.
- After the Render Engine connects the output pin, it might call put_Size again. The resizer filter should reconnect its output pin with the new size.
- Inside the filter's CTransformFilter::Transform method, stretch the input video to the output size.
- Your filter should never set the discontinuity flag on the output sample, or attach a media type to the output sample.
- To save the filter's state in a GraphEdit (.grf) file, implement the IPersistStream interface. (This is optional, but useful for testing.)
To use the resizer filter, the filter must be registered as a COM object on the user's system. Before the application renders the video project, query the Render Engine for the IRenderEngine2 interface and call IRenderEngine2::SetResizerGUID with the CLSID of the resizer filter.