AVI Index Entries

AVI Index Entries

Following the stream data list, there can be an additional chunk, the index chunk, idx1. This chunk is an index that points to the stream data chunks within the AVI file. This feature is very useful because it allows you to locate any stream data chunk at random, rather than have to search from the beginning of the stream data list for a particular chunk.

It s also possible that the index chunk has the FOURCC value indx, as defined in the OpenDML AVI File Format specification. The indx index is preferable to the older idx1 index because it includes support for files bigger than 4 GB. It s also broken into smaller subindexes, which makes it more efficient to work with than the monolithic idx1 index. By default, the AVI Mux filter writes AVI files with the indx chunk. It will also write an idx1 index for backward compatibility with older software. This functionality can be disabled with a call to IConfigAviMux::SetOutputCompatibilityIndex. The structure of the idx1 chunk is as follows:

typedef struct _avioldindex { FOURCC fcc; DWORD cb; struct _avioldindex_entry { DWORD dwChunkId; DWORD dwFlags; DWORD dwOffset; DWORD dwSize; } aIndex[]; } AVIOLDINDEX;

The fcc field is always idx1, and the cb field gives the length of the entire index, minus the fcc and cb fields. An arbitrary number of index entries follows. (You should be able to calculate the total number by dividing the total length of the index by the size of each entry.) Each entry has a dwChunkId, which refers to the stream number plus the two-character code used by the stream data list. Next is dwFlags, a bit field that signals the presence of key-frame and other information. The dwOffset field specifies the start of the chunk as an offset, either from the beginning of the file or from the beginning of the movi list. (It should be from the beginning of the movi list, but some AVI files don t observe this convention. You ll have to test the value in your code and decide.) Finally, the dwSize field specifies the size of the stream data chunk in bytes.

For an AVI movie three frames in length, with sound, the index chunk might appear like Figure 14-5.

figure 14-5 the avi index, which points to all the samples in the avi stream

Figure 14-5. The AVI index, which points to all the samples in the AVI stream

When all these lists and chunks are combined into a single unit, you get the structure of a complete AVI file, as shown in Figure 14-6. This figure is just a sample AVI file structure, with one video and one audio stream, which is typical of the structure you d see for DV-encoded AVI files.

figure 14-6 the complete avi file, with an avi header, chunks of data, and an index

Figure 14-6. The complete AVI file, with an AVI header, chunks of data, and an index



Programming Microsoft DirectShow for Digital Video and Television
Programming Microsoft DirectShow for Digital Video and Television (Pro-Developer)
ISBN: 0735618216
EAN: 2147483647
Year: 2002
Pages: 108
Authors: Mark D. Pesce

flylib.com © 2008-2017.
If you may any questions please contact us: flylib@qtcs.net