## About Compression Filters

A compression filter is a specialized type of transform filter. Compression filters (compressors) accept data, use a compression scheme to transform the data, and pass the compressed data downstream.

Microsoft® DirectShow™ includes an AVI Compressor filter and an ACM Audio Compressor filter, which will use any Microsoft Video for Windows® video or audio codec to compress data. You can write your own compressor filter if you need to compress data in a format that isn't supported by the default filters that DirectShow provides.

To begin writing a compression filter, write a transform filter that includes one input pin and one output pin. See the following articles for more information about writing a transform filter.

- Creating a Transform Filter
- Using the CTransformFilter and CTransInPlaceFilter Transform Base Classes
- Connecting Transform Filters

After you've written a transform filter, you should review the following points when completing your compression filter:

- Register your filter.

  Register your compression filter by using the AMovieDllRegisterServer2 function. This enables applications to enumerate your filter with all the other compression filters on the system. See Enumerate and Access Hardware Devices in DirectShow Applications for more information about device enumeration.

- Implement the recommended compressor interfaces.

  It is strongly recommended that you implement the IAMStreamConfig interface on the output pin of all compression filters and IAMVideoCompression on the output pin of video compressors so that applications can access the compression features of your filter.

  IAMStreamConfig enables you to inform applications about the formats to which you can compress data, and enables the application to configure your compressor to compress to a particular data type.

  IAMVideoCompression enables an application set video-specific settings, like keyframe frequency, that do not appear in the AM_MEDIA_TYPE structure.

The VidCap Sample (Video Capture Filter) sample video capture filter included with the DirectShow SDK implements the IAMStreamConfig and IAMVideoCompression interfaces, and performs filter registration. Note that this sample code is for a capture filter, but the filter registration and implementation of these two interfaces is similar to that of a compression filter.

© 1997 Microsoft Corporation. All rights reserved. Terms of Use.