Compressing the Video

The client application sends ICM_COMPRESS for each frame it wants compressed. It uses dwParam1 to point to an ICCOMPRESS structure containing the parameters used for compression. Your driver uses the buffers pointed to by the members of ICCOMPRESS for returning information about the compressed data.

Your driver returns the actual size of the compressed data in the biSizeImage member in the BITMAPINFOHEADER data structure pointed to by the lpbiOutput member of ICCOMPRESS.

The format of the input data is specified in a BITMAPINFOHEADER structure pointed to by lpbiInput. The input data is in a buffer specified by lpInput. The lpbiOutput and lpOutput members contain pointers to the format data and buffer used for the output data. Your driver must indicate the size of the compressed video data in the biSizeImage member in the BITMAPINFO structure specified for lpbiOutput.

The dwFlags member specifies flags used for compression. The client application sets the ICCOMPRESS_KEYFRAME flag if the input data should be treated as a key frame. (A key frame is one that does not require data from a previous frame for decompression.) When this flag is set, your driver should treat the image as the initial image in a sequence.

The lpckid member specifies a pointer to a buffer used to return the chunk ID for data in the AVI file. Your driver should assign a two-character code for the chunk ID only if it uses a custom chunk ID.

The lpdwFlags member specifies a pointer to a buffer used to return flags for the AVI index. The client application will add the returned flags to the file index for this chunk. If the compressed frame is a key frame (a frame that does not require a previous frame for decompression), your driver should set the AVIIF_KEYFRAME flag in this member. Your driver can define its own flags, but they must be set in the high word only.

The lFrameNum member specifies the frame number of the frame to compress. If your driver is performing fast temporal compression, check this member to see if frames are being sent out of order or if the client application is having a frame recompressed.

The dwFrameSize member indicates the maximum size (in bytes) for the compressed frame. If it specifies zero, your driver determines the size of the compressed image. If it is nonzero, your driver should try to compress the frame to within the specified size. This might require your driver to sacrifice image quality (or make some other trade-off) to obtain the size goal. Your driver should support this if it sets the VIDCF_CRUNCH flag when it responds to the ICM_GETINFO message.

The dwQuality member specifies the compression quality. Your driver should support this if it sets the VIDCF_QUALITY flag when it responds to the ICM_GETINFO message.

The format of the previous data is specified in a BITMAPINFOHEADER structure pointed to by lpbiPrev. The input data is in a buffer specified by lpPrev. Your driver will use this information if it performs temporal compression (that is, it needs the previous frame to compress the current frame). If your driver supports temporal compression, it should set the VIDCF_TEMPORAL flag when it responds to the ICM_GETINFO message. If your driver supports temporal compression and does not need the information in the lpbiPrev and lpPrev members, it should set the VIDCF_FASTTEMPORALC flag when it responds to the ICM_GETINFO message. The VIDCF_FASTEMPORALC flag can decrease the processing time because your driver does not need to access data specified in lpbiPrev and lpPrev.

When your driver has finished compressing the data, it returns ICERR_OK.