The AVI Header Chunk

The AVI Header Chunk

The AVI file always opens with a header list, identified by the FOURCC value hdrl. The list type for AVI files is avih, or AVI header. The AVI header chunk has the following definition:

typedef struct _avimainheader { FOURCC fcc; DWORD cb; DWORD dwMicroSecPerFrame; DWORD dwMaxBytesPerSec; DWORD dwPaddingGranularity; DWORD dwFlags; DWORD dwTotalFrames; DWORD dwInitialFrames; DWORD dwStreams; DWORD dwSuggestedBufferSize; DWORD dwWidth; DWORD dwHeight; DWORD dwReserved[4]; } AVIMAINHEADER;

The AVIMAINHEADER structure (which includes the FOURCC and chunk length values as the first two fields in its definition) provides basic parameters needed for file playback. The dwMicroSecPerFrame field specifies the number of microseconds between frames. (For NTSC video, for example, this figure would be approximately 18000 because there are roughly 18 milliseconds between each field, assuming this is interleaved data.) The dwMaxBytesPerSec field specifies the maximum data rate of the file in other words, the number of bytes per second the system must be prepared to process when it presents the AVI movie. If the system can t guarantee that throughput, frames could be dropped. The byte-alignment of the data is given in dwPaddingGranularity; many AVI files are aligned on multiples of 4 bytes. The dwFlags field holds five bit values in a single field, as described in Table 14-1.

Table 14-1. AVI Header Flags

Value

Description

AVIF_HASINDEX

The AVI file has an index. (We ll cover the index later.)

AVIF_MUSTUSEINDEX

The application should use the index, rather than the physical ordering of the chunks in the file, to determine the presentation order of the data.

AVIF_ISINTERLEAVED

The AVI file contains interleaved data.

AVIF_WASCAPTUREFILE

The file is a specially allocated file used for capturing real-time video.

AVIF_COPYRIGHTED

The file contains copyrighted data and should not be duplicated.

The dwTotalFrames field specifies the total number of frames in the file, which can be used to calculate the running time of a movie. To do so, multiply the number of frames by the time per frame. The dwInitialFrames value contains zero, unless the data in the AVI file is interleaved. When the data is interleaved, the dwInitialFrames value specifies the number of frames by which the audio leads the video, which gives the audio some extra samples as a head start, typically around three-quarters of second.

The number of streams in the file is given in the dwStreams field. A file with both audio and video has two streams. (It s possible to have more than two streams in an AVI file. You could have one video stream and two separate audio streams, perhaps for different languages or for a director s cut. ) The dwSuggestedBufferSize field contains a suggested buffer size for any application reading the AVI file. This value is generally large enough to contain the largest chunk in the AVI file. If this value is set incorrectly (or to zero), an application might have to reallocate its buffers during operation, which would impair AVI playback performance. Finally, the width and height of the AVI movie, in pixels, are given in dwWidth and dwHeight.



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