Your application can use a series of ICCompress functions and macros to compress data. The functions and macros can help you perform the following tasks:
Your application can increase control over the compression process by using the ICCompress functions and macros. This group of functions and macros handles individual frames, rather than the sequence as a whole. For example, your application can identify the frames to compress as key frames by using the ICCompress function.
A compressor receives data in one format, compresses the data, and returns a compressed version of the data using a specified format. The typical input format specifies DIBs using the BITMAPINFO structure. The typical output format specifies compressed DIBs, also using the BITMAPINFO structure.
Note To minimize image and audio degradation during playback, avoid compressing an AVI file more than once. Combine uncompressed pieces of video in your editing system and then compress the final product.
If you want to compress data and your application requires a specific output format, send the ICM_COMPRESS_QUERY message (or use the ICCompressQuery macro) to query the compressor to determine if it supports the input and output formats.
If the output format is not important to your application, you need only find a compressor that can handle the input format. To determine if a compressor can handle the input format, you can send ICM_COMPRESS_QUERY, specifying NULL for the lParam parameter. This message does not return the output format to your application. Your application can determine the buffer size needed for the data specifying the compression format by sending the ICM_COMPRESS_GET_FORMAT message (or use the ICCompressGetFormatSize macro). You can also retrieve the format data by sending ICM_COMPRESS_GET_FORMAT (or the ICCompressGetFormat macro).
If you want to determine the largest buffer that the compressor could require for compression, send the ICM_COMPRESS_GET_SIZE message (or use the ICCompressGetSize macro). You can use the number of bytes returned by the ICSendMessage function to allocate a buffer for subsequent image compressions.
After your application selects a compressor that can handle the input and output formats it needs, you can initialize the compressor by using the ICM_COMPRESS_BEGIN message (or use the ICCompressBegin macro). This message requires the compressor handle and the input and output formats.
You can use the ICCompress function to compress a frame. Your application must use this function repeatedly until all the frames in a sequence are compressed. Your application must also track and increment the number of each frame compressed with ICCompress. The compressor uses this value to check if frames are sent out of order during fast temporal compression (storing differences between successive frames). If your application recompresses a frame, it should use the same frame number as when the frame was first compressed. If your application compresses a still-frame image, it can specify a frame number of zero.
Your application can use the ICCOMPRESS_KEYFRAME flag to make the frame compressed by ICCompress a key frame.
When VCM returns control to your application after compressing a frame, VCM stores the compressed data in the structures referenced by the lpbiOutput and lpData parameters. If your application needs to move the compressed data, it can find its size in the biSizeImage member of the BITMAPINFO structure specified in lpbiOutput.
Note Your application must allocate the structures and buffers that store the uncompressed and compressed data. If the compressor supports temporal compression, your application must also allocate a structure and buffer to hold the format and data for the previous frame of information.
After your application has compressed the data, it can use the ICCompressEnd macro to notify the compressor that it has finished. If you want to restart compression after using this function, your application must reinitialize the compressor by sending the ICM_COMPRESS_BEGIN message (or use the ICCompressBegin macro).