1 /****************************************************************************
3 * AVIFMT - AVI file format definitions
5 ****************************************************************************/
6 #ifndef MPLAYER_AVIFMT_H
7 #define MPLAYER_AVIFMT_H
9 #ifndef MPLAYER_NOAVIFMT_H
13 #ifndef MPLAYER_MSACM_H
19 #pragma warning(disable:4200)
22 /* The following is a short description of the AVI file format. Please
23 * see the accompanying documentation for a full explanation.
25 * An AVI file is the following RIFF form:
29 * avih(<MainAVIHeader>)
31 * strh(<Stream header>)
32 * strf(<Stream format>)
33 * ... additional header data
43 * The main file header specifies how many streams are present. For
44 * each one, there must be a stream header chunk and a stream format
45 * chunk, enlosed in a 'strl' LIST chunk. The 'strf' chunk contains
46 * type-specific format information; for a video stream, this should
47 * be a BITMAPINFO structure, including palette. For an audio stream,
48 * this should be a WAVEFORMAT (or PCMWAVEFORMAT) structure.
50 * The actual data is contained in subchunks within the 'movi' LIST
51 * chunk. The first two characters of each data chunk are the
52 * stream number with which that data is associated.
54 * Some defined chunk types:
57 * ##dc: RLE8 compressed DIB bits
58 * ##pc: Palette Change
61 * ##wb: waveform audio bytes
63 * The grouping into LIST 'rec' chunks implies only that the contents of
64 * the chunk should be read into memory at the same time. This
65 * grouping is used for files specifically intended to be played from
68 * The index chunk at the end of the file should contain one entry for
69 * each data chunk in the file.
71 * Limitations for the current software:
72 * Only one video stream and one audio stream are allowed.
73 * The streams must start at the beginning of the file.
76 * To register codec types please obtain a copy of the Multimedia
77 * Developer Registration Kit from:
79 * Microsoft Corporation
80 * Multimedia Systems Group
83 * Redmond, WA 98052-6399
88 #define mmioFOURCC( ch0, ch1, ch2, ch3 ) \
89 ( (DWORD)(BYTE)(ch0) | ( (DWORD)(BYTE)(ch1) << 8 ) | \
90 ( (DWORD)(BYTE)(ch2) << 16 ) | ( (DWORD)(BYTE)(ch3) << 24 ) )
93 /* Macro to make a TWOCC out of two characters */
95 #define aviTWOCC(ch0, ch1) ((WORD)(BYTE)(ch0) | ((WORD)(BYTE)(ch1) << 8))
100 /* form types, list types, and chunk types */
101 #define formtypeAVI mmioFOURCC('A', 'V', 'I', ' ')
102 #define listtypeAVIHEADER mmioFOURCC('h', 'd', 'r', 'l')
103 #define ckidAVIMAINHDR mmioFOURCC('a', 'v', 'i', 'h')
104 #define listtypeSTREAMHEADER mmioFOURCC('s', 't', 'r', 'l')
105 #define ckidSTREAMHEADER mmioFOURCC('s', 't', 'r', 'h')
106 #define ckidSTREAMFORMAT mmioFOURCC('s', 't', 'r', 'f')
107 #define ckidSTREAMHANDLERDATA mmioFOURCC('s', 't', 'r', 'd')
108 #define ckidSTREAMNAME mmioFOURCC('s', 't', 'r', 'n')
110 #define listtypeAVIMOVIE mmioFOURCC('m', 'o', 'v', 'i')
111 #define listtypeAVIRECORD mmioFOURCC('r', 'e', 'c', ' ')
113 #define ckidAVINEWINDEX mmioFOURCC('i', 'd', 'x', '1')
116 ** Stream types for the <fccType> field of the stream header.
118 #define streamtypeVIDEO mmioFOURCC('v', 'i', 'd', 's')
119 #define streamtypeAUDIO mmioFOURCC('a', 'u', 'd', 's')
120 #define streamtypeMIDI mmioFOURCC('m', 'i', 'd', 's')
121 #define streamtypeTEXT mmioFOURCC('t', 'x', 't', 's')
123 /* Basic chunk types */
124 #define cktypeDIBbits aviTWOCC('d', 'b')
125 #define cktypeDIBcompressed aviTWOCC('d', 'c')
126 #define cktypePALchange aviTWOCC('p', 'c')
127 #define cktypeWAVEbytes aviTWOCC('w', 'b')
129 /* Chunk id to use for extra chunks for padding. */
130 #define ckidAVIPADDING mmioFOURCC('J', 'U', 'N', 'K')
135 ** Warning: These are nasty macro, and MS C 6.0 compiles some of them
136 ** incorrectly if optimizations are on. Ack.
139 /* Macro to get stream number out of a FOURCC ckid */
140 #define FromHex(n) (((n) >= 'A') ? ((n) + 10 - 'A') : ((n) - '0'))
141 #define StreamFromFOURCC(fcc) ((WORD) ((FromHex(LOBYTE(LOWORD(fcc))) << 4) + \
142 (FromHex(HIBYTE(LOWORD(fcc))))))
144 /* Macro to get TWOCC chunk type out of a FOURCC ckid */
145 #define TWOCCFromFOURCC(fcc) HIWORD(fcc)
147 /* Macro to make a ckid for a chunk out of a TWOCC and a stream number
150 #define ToHex(n) ((BYTE) (((n) > 9) ? ((n) - 10 + 'A') : ((n) + '0')))
151 #define MAKEAVICKID(tcc, stream) \
152 MAKELONG((ToHex((stream) & 0x0f) << 8) | \
153 (ToHex(((stream) & 0xf0) >> 4)), tcc)
156 ** Main AVI File Header
159 /* flags for use in <dwFlags> in AVIFileHdr */
160 #define AVIF_HASINDEX 0x00000010 // Index at end of file?
161 #define AVIF_MUSTUSEINDEX 0x00000020
162 #define AVIF_ISINTERLEAVED 0x00000100
163 #define AVIF_TRUSTCKTYPE 0x00000800 // Use CKType to find key frames?
164 #define AVIF_WASCAPTUREFILE 0x00010000
165 #define AVIF_COPYRIGHTED 0x00020000
167 /* The AVI File Header LIST chunk should be padded to this size */
168 #define AVI_HEADERSIZE 2048 // size of AVI header list
172 DWORD dwMicroSecPerFrame
; // frame display rate (or 0L)
173 DWORD dwMaxBytesPerSec
; // max. transfer rate
174 DWORD dwPaddingGranularity
; // pad to multiples of this
175 // size; normally 2K.
176 DWORD dwFlags
; // the ever-present flags
177 DWORD dwTotalFrames
; // # frames in file
178 DWORD dwInitialFrames
;
180 DWORD dwSuggestedBufferSize
;
192 #define AVISF_DISABLED 0x00000001
194 #define AVISF_VIDEO_PALCHANGES 0x00010000
200 DWORD dwFlags
; /* Contains AVITF_* flags */
203 DWORD dwInitialFrames
;
205 DWORD dwRate
; /* dwRate / dwScale == samples/second */
207 DWORD dwLength
; /* In units above... */
208 DWORD dwSuggestedBufferSize
;
214 /* Flags for index */
215 #define AVIIF_LIST 0x00000001L // chunk is a 'LIST'
216 #define AVIIF_KEYFRAME 0x00000010L // this frame is a key frame.
218 #define AVIIF_NOTIME 0x00000100L // this frame doesn't take any time
219 #define AVIIF_COMPUSE 0x0FFF0000L // these bits are for compressor use
221 #define FOURCC_RIFF mmioFOURCC('R', 'I', 'F', 'F')
222 #define FOURCC_LIST mmioFOURCC('L', 'I', 'S', 'T')
228 DWORD dwChunkOffset
; // Position of chunk
229 DWORD dwChunkLength
; // Length of chunk
232 #define AVISTREAMREAD_CONVENIENT (-1L)
235 ** Palette change chunk
237 ** Used in video streams.
239 #endif /* MPLAYER_NOAVIFMT_H */
240 #endif /* MPLAYER_AVIFMT_H */