The Stream Header Chunk

The Stream Header Chunk

Following the AVI header comes the stream header list, which is identified by the FOURCC value strl. The list is populated with stream header chunks, which are identified with strh. (FOURCC values are case sensitive.) The stream headers are used to define the specifics of each stream, as follows:

typedef struct _avistreamheader { FOURCC fcc; DWORD cb; FOURCC fccType; FOURCC fccHandler; DWORD dwFlags; WORD wPriority; WORD wLanguage; DWORD dwInitialFrames; DWORD dwScale; DWORD dwRate; DWORD dwStart; DWORD dwLength; DWORD dwSuggestedBufferSize; DWORD dwQuality; DWORD dwSampleSize; struct { short int left; short int top; short int right; short int bottom; } rcFrame; } AVISTREAMHEADER;

The fccType field is key to the AVI stream header. It has one of four possible FOURCC values, as described in Table 14-2.

Table 14-2. FOURCC Values of the fccType Field

FOURCC Value

Description

auds

Audio stream

mids

MIDI stream

txts

Text stream

vids

Video stream

The fccHandler field is another FOURCC code; it describes the preferred handler for the stream. In the case of audio or video streams, it specifies the codec for decoding the stream. If the stream is DV video, this field will usually be set to dvds. The dwFlags bit field indicates whether the stream is disabled (AVISF_DISABLED) or whether the video palette animates throughout the stream (AVISF_VIDEO_PALCHANGES). The dwPriority field specifies the priority of the stream. In a file with multiple audio or video streams, the stream with the highest priority might be the default stream, while the others could be alternate streams, for use at different times. In this way, a single AVI file could keep multiple paths of video and audio bundled together. The dwInitialFrames field has information necessary for working with interleaved streams. This field specifies how far ahead of the video data the audio data runs (that is, how many frames of audio must appear in the file before the first frame of video), just as the dwInitialFrames field does in the AVI header chunk.

The stream s playback speed is controlled with the next two fields, dw Scale and dwRate. Dividing dwRate by dwScale gives the number of samples per second, which is the frame rate if it s a video stream. Standard AVI files don t include any timestamps, so these values are needed to specify the playback rate per stream. The dwStart field specifies a start time (in units of dwRate divided by dwScale) for the stream. Usually, this time is zero meaning the start of the stream but it can be any value up to the value in the next field, dwLength, which is the entire stream length, given in the same units as dwStart. As in the AVI header, dwSuggestedBufferSize specifies how large a buffer a client reading the stream should allocate to read the stream.

The dwQuality field provides an indicator of the quality of the data in the stream. This value is in the range 0 to 10000, and in the case of compressed streams, this value represents a quality value passed to the compression software. The dwSampleSize field specifies the size of each sample in the stream in bytes. If this field is set to zero, the samples can vary in size, although each sample must reside in its own chunk. Finally, the rcFrame field defines a destination rectangle (four points) within the rectangle defined by the dwWidth and dwHeight of the AVI header. This field is used to coordinate multiple video streams, which can be combined and presented as a single video output.



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