This driver specific messages for video compression and decompression drivers are covered by the three basic operations of these drivers: video compression, video decompression using the client-application, and video decompression directly to video hardware. Because video compression and decompression drivers typically use AVI files and bitmaps, this section includes a brief overview of the AVI RIFF format, the BITMAPINFO data structure, and the BITMAPINFOHEADER data structure.
Many of the video compression and decompression messages rely on information embedded in the AVI RIFF file. Drivers do not typically access this information directly. They rely on the client-application to read and write the AVI file and maintain the RIFF file structure. While your driver should not have to manipulate an AVI file, understanding its structure helps identify the purpose of the information your driver will supply and receive.
AVI files have the following general structure:
RIFF('AVI' LIST('hdrl' avih(<<MainAVIHeader>>) LIST ('strl' strh(<<Stream header>>) strf(<<Stream format>>) strd(<<Stream data>>) strn(<<Stream name>>) ) ) LIST('movi' '00??'(<<driver Data>>) . . . '00??'(<<driver Data>>) ) ' idx1'(<<AVIIndex>>) )
The following table summarizes the entries in the AVI file:
RIFF Chunk | Description |
RIFF 'AVI ' | Identifies the file as AVI RIFF file. |
LIST 'hdrl' | Identifies a chunk containing subchunks that define the format of the data. |
'avih' | Identifies a chunk containing general information about the file. This includes the number of streams and the width and height of the AVI sequence. |
LIST 'strl' | Identifies a chunk containing subchunks that describe the streams in a file. This chunk exists for each stream. |
'strh' | Identifies a chunk containing a stream header. This includes the type of stream. |
'strf' | Identifies a chunk describing the format of the data in the stream. For video streams, the information in this chunk is a BITMAPINFO structure. It includes palette information if appropriate. |
'strd' | Identifies a chunk containing information used by compressor and decompressors. For video compressors and decompressors, this includes the state formation. |
'strn' | Identifies a chunk containing a zero-terminated string specifying the name of the stream. |
LIST 'movi ' | Identifies a chunk containing subchunks used for the audio and video data. |
'00??' | Identifies a chunk containing the audio or video data. For this example, both the zeros (00) and the question marks (??) are used as place holders. The zeros are replaced by stream numbers. The question marks are replaced by codes indicating the type of data in the chunk. For example, a stream for a compressed DIB might use '01dc'. |
'idx1' | Identifies a chunk containing the file index. |
Video compression and decompression drivers operate on the information in the 'strf', 'strd', and 'oo??' chunks.
The BITMAPINFO data structure defined by Windows is used with many of the compression and decompression messages to pass information about the bitmaps being compressed and decompressed. This structure has the following members:
typedef struct tagBITMAPINFO { BITMAPINFOHEADER bmiHeader; // BITMAPINFOHEADER data RGBQUAD bmiColors[]; // Color table } BITMAPINFO;
The bmiColors member is used for the color table. The BITMAPINFOHEADER data defined for the bmiHeader member is used to pass information about the format of the bitmaps being compressed and decompressed. This structure has the following members:
typedef struct tagBITMAPINFOHEADER { DWORD biSize; // Structure size LONG biWidth; // Width of the bitmap LONG biHeight; // Heifht of the bitmap WORD biPlanes; // Planes of the target device WORD biBitCount; // Number of bits per pixel DWORD biCompression; // Compression type DWORD biSizeImage; // Bytes contained in the image LONG biXPelsPerMeter; // Horizontal resolution LONG biYPelsPerMeter; // Vertical resolutioni DWORD biClrUsed; // Number of color indexes DWORD biClrImportant; // Number of important colors } BITMAPINFOHEADER;
The biCompression member specifies the type of compression used or requested. Windows defines the following compression formats:
Format | Description |
BI_RGB | Specifies the bitmap is not compressed. |
BI_RLE8 | Specifies a run-length encoded format for bitmaps with 8 bits per pixel. |
BI_RLE4 | Specifies a run-length encoded format for bitmaps with 4 bits per pixel. |
Video for Windows extends the BI_RGB format to include 16 and 32 bits per pixel bitmap formats. These formats do not use a color table. They embed the colors in the WORD or DWORD representing each pixel.
The 16 bit BI_RGB format is identified by setting biCompression to BI_RGB and setting biBitCount to 16. For this format, each pixel is represented by a 16-bit RGB color value. The high-bit of this value is zero. The remaining bits are divided into 3 groups of 5-bits to represent the red, green, and blue color values.
The 32 bit BI_RGB format is identified by setting biCompression to BI_RGB and setting biBitCount to 32. For this format, each pixel is represented by a 32 bit (4 byte) RGB color value. One byte is used for each red, green, and blue color value. The fourth byte is set to zero.
Your driver should support the BI_RGB format for 8 bit per pixel bitmaps. If practical, it should also support this format for 16, 24, and 32 bits per pixel bitmaps.
In addition to the new BI_RGB formats, the BI_BITFIELD format adds new compression capabilities. This format specifies a bitmap is not compressed and color masks are defined in the bmiColors member of the BITMAPINFO data structure. The first DWORD in the bmiColors member is the red mask, the second DWORD is the green mask, and the third DWORD is the blue mask.
Your driver can also extend the format set by defining custom formats. Custom formats use a four character code for the format in the biCompression member in place of the standard constants. Your driver can use a custom format to support a unique or nonstandard compression type. When you define a custom format, you can specify values other than 1, 4, 8, 16, 24, or 32 for the biBitCount member.