The 'idx1' Chunk

AVI files can have an index chunk after the LIST 'movi' chunk. The index chunk essentially contains a list of the data chunks and their location in the file. This provides efficient random access to the data within the file, because an application can locate a particular sound sequence or video image in a AVI file without having to scan it.

Index chunks use the 'idx1' four-character code. The following data structure is defined for index entries:

typedef struct {
    ULONG   ckid;
    ULONG   ulFlags;
    ULONG   ulChunkOffset;
    ULONG   ulChunkLength;
} AVIINDEXENTRY;

The ckid, ulFlags, ulChunkOffset, and ulChunkLength entries are repeated in the AVI file for each data chunk indexed. The index will have entries for each 'rec' chunk. The 'rec' entries should have the AVIIF_LIST flag set and the list type in the ckid field.

The ckid field identifies the data chunk. This field uses four-character codes for the identifying chunk.

The ulFlags field specifies any flags for the data. The AVIIF_KEYFRAME flag indicates key frames in the video sequence. Key frames do not need previous video information to be decompressed. The AVIIF_NOTIME flag indicates a chunk does not affect the timing of a video stream. The AVIIF_LIST flag indicates the current chunk is a LIST chunk. Use the ckid field to identify the type of LIST chunk.

The ulChunkOffset and ulChunkLength fields specify the position of the chunk and the length of the chunk. The ulChunkOffset field specifies the position of the chunk in the file relative to the 'movi' list. The ulChunkLength field specifies the length of the chunk excluding the eight bytes for the RIFF header.

If you include an index in the RIFF file, set the AVIF_HASINDEX in the ulFlags field of the AVI header. (This header is identified by 'avih' chunk ID.) This flag indicates that the file has an index.


[Back: The LIST 'movi' Chunk]
[Next: Other Data Chunks]