]> git.sesse.net Git - vlc/blob - libs/loader/wine/avifmt.h
Removes trailing spaces. Removes tabs.
[vlc] / libs / loader / wine / avifmt.h
1 /****************************************************************************
2  *
3  *  AVIFMT - AVI file format definitions
4  *
5  ****************************************************************************/
6 #ifndef AVIFMT
7 #define AVIFMT
8
9 #ifndef NOAVIFMT
10
11 #ifndef  __WINE_WINDEF_H
12 #include "wine/windef.h"
13 #endif
14
15 #ifndef __WINE_MMSYSTEM_H
16 #ifndef __WINE_MSACM_H
17 typedef DWORD FOURCC;
18 #endif
19 #endif
20
21
22 #ifdef _MSC_VER
23 #pragma warning(disable:4200)
24 #endif
25  
26 /* The following is a short description of the AVI file format.  Please
27  * see the accompanying documentation for a full explanation.
28  *
29  * An AVI file is the following RIFF form:
30  *
31  *    RIFF('AVI'
32  *          LIST('hdrl'
33  *            avih(<MainAVIHeader>)
34  *                  LIST ('strl'
35  *                      strh(<Stream header>)
36  *                      strf(<Stream format>)
37  *                      ... additional header data
38  *            LIST('movi'    
39  *            { LIST('rec'
40  *                    SubChunk...
41  *                 )
42  *                | SubChunk } ....    
43  *            )
44  *            [ <AVIIndex> ]
45  *      )
46  *
47  *    The main file header specifies how many streams are present.  For
48  *    each one, there must be a stream header chunk and a stream format
49  *    chunk, enlosed in a 'strl' LIST chunk.  The 'strf' chunk contains
50  *    type-specific format information; for a video stream, this should
51  *    be a BITMAPINFO structure, including palette.  For an audio stream,
52  *    this should be a WAVEFORMAT (or PCMWAVEFORMAT) structure.
53  *
54  *    The actual data is contained in subchunks within the 'movi' LIST
55  *    chunk.  The first two characters of each data chunk are the
56  *    stream number with which that data is associated.
57  *
58  *    Some defined chunk types:
59  *           Video Streams:
60  *                  ##db:    RGB DIB bits
61  *                  ##dc:    RLE8 compressed DIB bits
62  *                  ##pc:    Palette Change
63  *
64  *           Audio Streams:
65  *                  ##wb:    waveform audio bytes
66  *
67  * The grouping into LIST 'rec' chunks implies only that the contents of
68  *   the chunk should be read into memory at the same time.  This
69  *   grouping is used for files specifically intended to be played from
70  *   CD-ROM.
71  *
72  * The index chunk at the end of the file should contain one entry for
73  *   each data chunk in the file.
74  *
75  * Limitations for the current software:
76  *    Only one video stream and one audio stream are allowed.
77  *    The streams must start at the beginning of the file.
78  *
79  *
80  * To register codec types please obtain a copy of the Multimedia
81  * Developer Registration Kit from:
82  *
83  *  Microsoft Corporation
84  *  Multimedia Systems Group
85  *  Product Marketing
86  *  One Microsoft Way
87  *  Redmond, WA 98052-6399
88  *
89  */
90
91 #ifndef mmioFOURCC
92 #define mmioFOURCC( ch0, ch1, ch2, ch3 )                \
93         ( (DWORD)(BYTE)(ch0) | ( (DWORD)(BYTE)(ch1) << 8 ) |    \
94         ( (DWORD)(BYTE)(ch2) << 16 ) | ( (DWORD)(BYTE)(ch3) << 24 ) )
95 #endif
96
97 /* Macro to make a TWOCC out of two characters */
98 #ifndef aviTWOCC
99 #define aviTWOCC(ch0, ch1) ((WORD)(BYTE)(ch0) | ((WORD)(BYTE)(ch1) << 8))
100 #endif
101
102 typedef WORD TWOCC;
103
104 /* form types, list types, and chunk types */
105 #define formtypeAVI             mmioFOURCC('A', 'V', 'I', ' ')
106 #define listtypeAVIHEADER       mmioFOURCC('h', 'd', 'r', 'l')
107 #define ckidAVIMAINHDR          mmioFOURCC('a', 'v', 'i', 'h')
108 #define listtypeSTREAMHEADER    mmioFOURCC('s', 't', 'r', 'l')
109 #define ckidSTREAMHEADER        mmioFOURCC('s', 't', 'r', 'h')
110 #define ckidSTREAMFORMAT        mmioFOURCC('s', 't', 'r', 'f')
111 #define ckidSTREAMHANDLERDATA   mmioFOURCC('s', 't', 'r', 'd')
112 #define ckidSTREAMNAME        mmioFOURCC('s', 't', 'r', 'n')
113
114 #define listtypeAVIMOVIE        mmioFOURCC('m', 'o', 'v', 'i')
115 #define listtypeAVIRECORD       mmioFOURCC('r', 'e', 'c', ' ')
116
117 #define ckidAVINEWINDEX         mmioFOURCC('i', 'd', 'x', '1')
118
119 /*
120 ** Stream types for the <fccType> field of the stream header.
121 */
122 #define streamtypeVIDEO         mmioFOURCC('v', 'i', 'd', 's')
123 #define streamtypeAUDIO         mmioFOURCC('a', 'u', 'd', 's')
124 #define streamtypeMIDI        mmioFOURCC('m', 'i', 'd', 's')
125 #define streamtypeTEXT          mmioFOURCC('t', 'x', 't', 's')
126
127 /* Basic chunk types */
128 #define cktypeDIBbits           aviTWOCC('d', 'b')
129 #define cktypeDIBcompressed     aviTWOCC('d', 'c')
130 #define cktypePALchange         aviTWOCC('p', 'c')
131 #define cktypeWAVEbytes         aviTWOCC('w', 'b')
132
133 /* Chunk id to use for extra chunks for padding. */
134 #define ckidAVIPADDING          mmioFOURCC('J', 'U', 'N', 'K')
135
136 /*
137 ** Useful macros
138 **
139 ** Warning: These are nasty macro, and MS C 6.0 compiles some of them
140 ** incorrectly if optimizations are on.  Ack.
141 */
142
143 /* Macro to get stream number out of a FOURCC ckid */
144 #define FromHex(n)    (((n) >= 'A') ? ((n) + 10 - 'A') : ((n) - '0'))
145 #define StreamFromFOURCC(fcc) ((WORD) ((FromHex(LOBYTE(LOWORD(fcc))) << 4) + \
146                                              (FromHex(HIBYTE(LOWORD(fcc))))))
147
148 /* Macro to get TWOCC chunk type out of a FOURCC ckid */
149 #define TWOCCFromFOURCC(fcc)    HIWORD(fcc)
150
151 /* Macro to make a ckid for a chunk out of a TWOCC and a stream number
152 ** from 0-255.
153 */
154 #define ToHex(n)    ((BYTE) (((n) > 9) ? ((n) - 10 + 'A') : ((n) + '0')))
155 #define MAKEAVICKID(tcc, stream) \
156         MAKELONG((ToHex((stream) & 0x0f) << 8) | \
157                 (ToHex(((stream) & 0xf0) >> 4)), tcc)
158
159 /*
160 ** Main AVI File Header
161 */    
162         
163 /* flags for use in <dwFlags> in AVIFileHdr */
164 #define AVIF_HASINDEX        0x00000010    // Index at end of file?
165 #define AVIF_MUSTUSEINDEX    0x00000020
166 #define AVIF_ISINTERLEAVED    0x00000100
167 #define AVIF_TRUSTCKTYPE    0x00000800    // Use CKType to find key frames?
168 #define AVIF_WASCAPTUREFILE    0x00010000
169 #define AVIF_COPYRIGHTED    0x00020000
170
171 /* The AVI File Header LIST chunk should be padded to this size */
172 #define AVI_HEADERSIZE  2048                    // size of AVI header list
173
174 typedef struct
175 {
176     DWORD        dwMicroSecPerFrame;    // frame display rate (or 0L)
177     DWORD        dwMaxBytesPerSec;    // max. transfer rate
178     DWORD        dwPaddingGranularity;    // pad to multiples of this
179                                                 // size; normally 2K.
180     DWORD        dwFlags;        // the ever-present flags
181     DWORD        dwTotalFrames;        // # frames in file
182     DWORD        dwInitialFrames;
183     DWORD        dwStreams;
184     DWORD        dwSuggestedBufferSize;
185  
186     DWORD        dwWidth;
187     DWORD        dwHeight;
188  
189     DWORD        dwReserved[4];
190 } MainAVIHeader;
191
192 /*
193 ** Stream header
194 */
195
196 #define AVISF_DISABLED            0x00000001
197
198 #define AVISF_VIDEO_PALCHANGES        0x00010000
199
200  
201 typedef struct {
202     FOURCC        fccType;
203     FOURCC        fccHandler;
204     DWORD        dwFlags;    /* Contains AVITF_* flags */
205     WORD        wPriority;
206     WORD        wLanguage;
207     DWORD        dwInitialFrames;
208     DWORD        dwScale;    
209     DWORD        dwRate;    /* dwRate / dwScale == samples/second */
210     DWORD        dwStart;
211     DWORD        dwLength; /* In units above... */
212     DWORD        dwSuggestedBufferSize;
213     DWORD        dwQuality;
214     DWORD        dwSampleSize;
215     RECT        rcFrame;
216 } AVIStreamHeader;
217
218 /* Flags for index */
219 #define AVIIF_LIST          0x00000001L // chunk is a 'LIST'
220 #define AVIIF_KEYFRAME      0x00000010L // this frame is a key frame.
221
222 #define AVIIF_NOTIME        0x00000100L // this frame doesn't take any time
223 #define AVIIF_COMPUSE       0x0FFF0000L // these bits are for compressor use
224
225 #define FOURCC_RIFF     mmioFOURCC('R', 'I', 'F', 'F')
226 #define FOURCC_LIST     mmioFOURCC('L', 'I', 'S', 'T')
227
228 typedef struct
229 {
230     DWORD        ckid;
231     DWORD        dwFlags;
232     DWORD        dwChunkOffset;        // Position of chunk
233     DWORD        dwChunkLength;        // Length of chunk
234 } AVIINDEXENTRY;
235
236 #define AVISTREAMREAD_CONVENIENT    (-1L)
237
238 /*
239 ** Palette change chunk
240 **
241 ** Used in video streams.
242 */
243 #endif /* NOAVIFMT */
244 #endif