/[cvs]/api/include/aviriff.h
ViewVC logotype

Annotation of /api/include/aviriff.h

Parent Directory Parent Directory | Revision Log Revision Log


Revision 1.1 - (hide annotations)
Sun Jul 1 20:47:59 2001 UTC (23 years, 5 months ago) by bearsoft
Branch point for: lazy, MAIN
File MIME type: text/plain
Initial revision

1 bearsoft 1.1 //------------------------------------------------------------------------------
2     // File: AVIRIFF.h
3     //
4     // Desc: Structures and defines for the RIFF AVI file format extended to
5     // handle very large/long files.
6     //
7     // Copyright (c) 1996 - 2000, Microsoft Corporation. All rights reserved.
8     //------------------------------------------------------------------------------
9    
10    
11     #pragma warning(disable: 4097 4511 4512 4514 4705)
12    
13    
14     #if !defined AVIRIFF_H
15     #define AVIRIFF_H
16    
17     #if !defined NUMELMS
18     #define NUMELMS(aa) (sizeof(aa)/sizeof((aa)[0]))
19     #endif
20    
21     // all structures in this file are packed on word boundaries
22     //
23     #include <pshpack2.h>
24    
25     /*
26     * heres the general layout of an AVI riff file (new format)
27     *
28     * RIFF (3F??????) AVI <- not more than 1 GB in size
29     * LIST (size) hdrl
30     * avih (0038)
31     * LIST (size) strl
32     * strh (0038)
33     * strf (????)
34     * indx (3ff8) <- size may vary, should be sector sized
35     * LIST (size) strl
36     * strh (0038)
37     * strf (????)
38     * indx (3ff8) <- size may vary, should be sector sized
39     * LIST (size) odml
40     * dmlh (????)
41     * JUNK (size) <- fill to align to sector - 12
42     * LIST (7f??????) movi <- aligned on sector - 12
43     * 00dc (size) <- sector aligned
44     * 01wb (size) <- sector aligned
45     * ix00 (size) <- sector aligned
46     * idx1 (00??????) <- sector aligned
47     * RIFF (7F??????) AVIX
48     * JUNK (size) <- fill to align to sector -12
49     * LIST (size) movi
50     * 00dc (size) <- sector aligned
51     * RIFF (7F??????) AVIX <- not more than 2GB in size
52     * JUNK (size) <- fill to align to sector - 12
53     * LIST (size) movi
54     * 00dc (size) <- sector aligned
55     *
56     *-===================================================================*/
57    
58     //
59     // structures for manipulating RIFF headers
60     //
61     #define FCC(ch4) ((((DWORD)(ch4) & 0xFF) << 24) | \
62     (((DWORD)(ch4) & 0xFF00) << 8) | \
63     (((DWORD)(ch4) & 0xFF0000) >> 8) | \
64     (((DWORD)(ch4) & 0xFF000000) >> 24))
65    
66     typedef struct _riffchunk {
67     FOURCC fcc;
68     DWORD cb;
69     } RIFFCHUNK, * LPRIFFCHUNK;
70     typedef struct _rifflist {
71     FOURCC fcc;
72     DWORD cb;
73     FOURCC fccListType;
74     } RIFFLIST, * LPRIFFLIST;
75    
76     #define RIFFROUND(cb) ((cb) + ((cb)&1))
77     #define RIFFNEXT(pChunk) (LPRIFFCHUNK)((LPBYTE)(pChunk) \
78     + sizeof(RIFFCHUNK) \
79     + RIFFROUND(((LPRIFFCHUNK)pChunk)->cb))
80    
81    
82     //
83     // ==================== avi header structures ===========================
84     //
85    
86     // main header for the avi file (compatibility header)
87     //
88     #define ckidMAINAVIHEADER FCC('avih')
89     typedef struct _avimainheader {
90     FOURCC fcc; // 'avih'
91     DWORD cb; // size of this structure -8
92     DWORD dwMicroSecPerFrame; // frame display rate (or 0L)
93     DWORD dwMaxBytesPerSec; // max. transfer rate
94     DWORD dwPaddingGranularity; // pad to multiples of this size; normally 2K.
95     DWORD dwFlags; // the ever-present flags
96     #define AVIF_HASINDEX 0x00000010 // Index at end of file?
97     #define AVIF_MUSTUSEINDEX 0x00000020
98     #define AVIF_ISINTERLEAVED 0x00000100
99     #define AVIF_TRUSTCKTYPE 0x00000800 // Use CKType to find key frames
100     #define AVIF_WASCAPTUREFILE 0x00010000
101     #define AVIF_COPYRIGHTED 0x00020000
102     DWORD dwTotalFrames; // # frames in first movi list
103     DWORD dwInitialFrames;
104     DWORD dwStreams;
105     DWORD dwSuggestedBufferSize;
106     DWORD dwWidth;
107     DWORD dwHeight;
108     DWORD dwReserved[4];
109     } AVIMAINHEADER;
110    
111     #define ckidODML FCC('odml')
112     #define ckidAVIEXTHEADER FCC('dmlh')
113     typedef struct _aviextheader {
114     FOURCC fcc; // 'dmlh'
115     DWORD cb; // size of this structure -8
116     DWORD dwGrandFrames; // total number of frames in the file
117     DWORD dwFuture[61]; // to be defined later
118     } AVIEXTHEADER;
119    
120     //
121     // structure of an AVI stream header riff chunk
122     //
123     #define ckidSTREAMLIST FCC('strl')
124    
125     #ifndef ckidSTREAMHEADER
126     #define ckidSTREAMHEADER FCC('strh')
127     #endif
128     typedef struct _avistreamheader {
129     FOURCC fcc; // 'strh'
130     DWORD cb; // size of this structure - 8
131    
132     FOURCC fccType; // stream type codes
133    
134     #ifndef streamtypeVIDEO
135     #define streamtypeVIDEO FCC('vids')
136     #define streamtypeAUDIO FCC('auds')
137     #define streamtypeMIDI FCC('mids')
138     #define streamtypeTEXT FCC('txts')
139     #endif
140    
141     FOURCC fccHandler;
142     DWORD dwFlags;
143     #define AVISF_DISABLED 0x00000001
144     #define AVISF_VIDEO_PALCHANGES 0x00010000
145    
146     WORD wPriority;
147     WORD wLanguage;
148     DWORD dwInitialFrames;
149     DWORD dwScale;
150     DWORD dwRate; // dwRate/dwScale is stream tick rate in ticks/sec
151     DWORD dwStart;
152     DWORD dwLength;
153     DWORD dwSuggestedBufferSize;
154     DWORD dwQuality;
155     DWORD dwSampleSize;
156     struct {
157     short int left;
158     short int top;
159     short int right;
160     short int bottom;
161     } rcFrame;
162     } AVISTREAMHEADER;
163    
164    
165     //
166     // structure of an AVI stream format chunk
167     //
168     #ifndef ckidSTREAMFORMAT
169     #define ckidSTREAMFORMAT FCC('strf')
170     #endif
171     //
172     // avi stream formats are different for each stream type
173     //
174     // BITMAPINFOHEADER for video streams
175     // WAVEFORMATEX or PCMWAVEFORMAT for audio streams
176     // nothing for text streams
177     // nothing for midi streams
178    
179    
180     #pragma warning(disable:4200)
181     //
182     // structure of old style AVI index
183     //
184     #define ckidAVIOLDINDEX FCC('idx1')
185     typedef struct _avioldindex {
186     FOURCC fcc; // 'idx1'
187     DWORD cb; // size of this structure -8
188     struct _avioldindex_entry {
189     DWORD dwChunkId;
190     DWORD dwFlags;
191    
192     #ifndef AVIIF_LIST
193     #define AVIIF_LIST 0x00000001
194     #define AVIIF_KEYFRAME 0x00000010
195     #endif
196    
197     #define AVIIF_NO_TIME 0x00000100
198     #define AVIIF_COMPRESSOR 0x0FFF0000 // unused?
199     DWORD dwOffset; // offset of riff chunk header for the data
200     DWORD dwSize; // size of the data (excluding riff header size)
201     } aIndex[]; // size of this array
202     } AVIOLDINDEX;
203    
204    
205     //
206     // ============ structures for timecode in an AVI file =================
207     //
208    
209     #ifndef TIMECODE_DEFINED
210     #define TIMECODE_DEFINED
211    
212     // defined
213     // timecode time structure
214     //
215     typedef union _timecode {
216     struct {
217     WORD wFrameRate;
218     WORD wFrameFract;
219     LONG cFrames;
220     };
221     DWORDLONG qw;
222     } TIMECODE;
223    
224     #endif // TIMECODE_DEFINED
225    
226     #define TIMECODE_RATE_30DROP 0 // this MUST be zero
227    
228     // struct for all the SMPTE timecode info
229     //
230     typedef struct _timecodedata {
231     TIMECODE time;
232     DWORD dwSMPTEflags;
233     DWORD dwUser;
234     } TIMECODEDATA;
235    
236     // dwSMPTEflags masks/values
237     //
238     #define TIMECODE_SMPTE_BINARY_GROUP 0x07
239     #define TIMECODE_SMPTE_COLOR_FRAME 0x08
240    
241     //
242     // ============ structures for new style AVI indexes =================
243     //
244    
245     // index type codes
246     //
247     #define AVI_INDEX_OF_INDEXES 0x00
248     #define AVI_INDEX_OF_CHUNKS 0x01
249     #define AVI_INDEX_OF_TIMED_CHUNKS 0x02
250     #define AVI_INDEX_OF_SUB_2FIELD 0x03
251     #define AVI_INDEX_IS_DATA 0x80
252    
253     // index subtype codes
254     //
255     #define AVI_INDEX_SUB_DEFAULT 0x00
256    
257     // INDEX_OF_CHUNKS subtype codes
258     //
259     #define AVI_INDEX_SUB_2FIELD 0x01
260    
261     // meta structure of all avi indexes
262     //
263     typedef struct _avimetaindex {
264     FOURCC fcc;
265     UINT cb;
266     WORD wLongsPerEntry;
267     BYTE bIndexSubType;
268     BYTE bIndexType;
269     DWORD nEntriesInUse;
270     DWORD dwChunkId;
271     DWORD dwReserved[3];
272     DWORD adwIndex[];
273     } AVIMETAINDEX;
274    
275     #define STDINDEXSIZE 0x4000
276     #define NUMINDEX(wLongsPerEntry) ((STDINDEXSIZE-32)/4/(wLongsPerEntry))
277     #define NUMINDEXFILL(wLongsPerEntry) ((STDINDEXSIZE/4) - NUMINDEX(wLongsPerEntry))
278    
279     // structure of a super index (INDEX_OF_INDEXES)
280     //
281     #define ckidAVISUPERINDEX FCC('indx')
282     typedef struct _avisuperindex {
283     FOURCC fcc; // 'indx'
284     UINT cb; // size of this structure
285     WORD wLongsPerEntry; // ==4
286     BYTE bIndexSubType; // ==0 (frame index) or AVI_INDEX_SUB_2FIELD
287     BYTE bIndexType; // ==AVI_INDEX_OF_INDEXES
288     DWORD nEntriesInUse; // offset of next unused entry in aIndex
289     DWORD dwChunkId; // chunk ID of chunks being indexed, (i.e. RGB8)
290     DWORD dwReserved[3]; // must be 0
291     struct _avisuperindex_entry {
292     DWORDLONG qwOffset; // 64 bit offset to sub index chunk
293     DWORD dwSize; // 32 bit size of sub index chunk
294     DWORD dwDuration; // time span of subindex chunk (in stream ticks)
295     } aIndex[NUMINDEX(4)];
296     } AVISUPERINDEX;
297     #define Valid_SUPERINDEX(pi) (*(DWORD *)(&((pi)->wLongsPerEntry)) == (4 | (AVI_INDEX_OF_INDEXES << 24)))
298    
299     // struct of a standard index (AVI_INDEX_OF_CHUNKS)
300     //
301     typedef struct _avistdindex_entry {
302     DWORD dwOffset; // 32 bit offset to data (points to data, not riff header)
303     DWORD dwSize; // 31 bit size of data (does not include size of riff header), bit 31 is deltaframe bit
304     } AVISTDINDEX_ENTRY;
305     #define AVISTDINDEX_DELTAFRAME ( 0x80000000) // Delta frames have the high bit set
306     #define AVISTDINDEX_SIZEMASK (~0x80000000)
307    
308     typedef struct _avistdindex {
309     FOURCC fcc; // 'indx' or '##ix'
310     UINT cb; // size of this structure
311     WORD wLongsPerEntry; // ==2
312     BYTE bIndexSubType; // ==0
313     BYTE bIndexType; // ==AVI_INDEX_OF_CHUNKS
314     DWORD nEntriesInUse; // offset of next unused entry in aIndex
315     DWORD dwChunkId; // chunk ID of chunks being indexed, (i.e. RGB8)
316     DWORDLONG qwBaseOffset; // base offset that all index intries are relative to
317     DWORD dwReserved_3; // must be 0
318     AVISTDINDEX_ENTRY aIndex[NUMINDEX(2)];
319     } AVISTDINDEX;
320    
321     // struct of a time variant standard index (AVI_INDEX_OF_TIMED_CHUNKS)
322     //
323     typedef struct _avitimedindex_entry {
324     DWORD dwOffset; // 32 bit offset to data (points to data, not riff header)
325     DWORD dwSize; // 31 bit size of data (does not include size of riff header) (high bit is deltaframe bit)
326     DWORD dwDuration; // how much time the chunk should be played (in stream ticks)
327     } AVITIMEDINDEX_ENTRY;
328    
329     typedef struct _avitimedindex {
330     FOURCC fcc; // 'indx' or '##ix'
331     UINT cb; // size of this structure
332     WORD wLongsPerEntry; // ==3
333     BYTE bIndexSubType; // ==0
334     BYTE bIndexType; // ==AVI_INDEX_OF_TIMED_CHUNKS
335     DWORD nEntriesInUse; // offset of next unused entry in aIndex
336     DWORD dwChunkId; // chunk ID of chunks being indexed, (i.e. RGB8)
337     DWORDLONG qwBaseOffset; // base offset that all index intries are relative to
338     DWORD dwReserved_3; // must be 0
339     AVITIMEDINDEX_ENTRY aIndex[NUMINDEX(3)];
340     DWORD adwTrailingFill[NUMINDEXFILL(3)]; // to align struct to correct size
341     } AVITIMEDINDEX;
342    
343     // structure of a timecode stream
344     //
345     typedef struct _avitimecodeindex {
346     FOURCC fcc; // 'indx' or '##ix'
347     UINT cb; // size of this structure
348     WORD wLongsPerEntry; // ==4
349     BYTE bIndexSubType; // ==0
350     BYTE bIndexType; // ==AVI_INDEX_IS_DATA
351     DWORD nEntriesInUse; // offset of next unused entry in aIndex
352     DWORD dwChunkId; // 'time'
353     DWORD dwReserved[3]; // must be 0
354     TIMECODEDATA aIndex[NUMINDEX(sizeof(TIMECODEDATA)/sizeof(LONG))];
355     } AVITIMECODEINDEX;
356    
357     // structure of a timecode discontinuity list (when wLongsPerEntry == 7)
358     //
359     typedef struct _avitcdlindex_entry {
360     DWORD dwTick; // stream tick time that maps to this timecode value
361     TIMECODE time;
362     DWORD dwSMPTEflags;
363     DWORD dwUser;
364     TCHAR szReelId[12];
365     } AVITCDLINDEX_ENTRY;
366    
367     typedef struct _avitcdlindex {
368     FOURCC fcc; // 'indx' or '##ix'
369     UINT cb; // size of this structure
370     WORD wLongsPerEntry; // ==7 (must be 4 or more all 'tcdl' indexes
371     BYTE bIndexSubType; // ==0
372     BYTE bIndexType; // ==AVI_INDEX_IS_DATA
373     DWORD nEntriesInUse; // offset of next unused entry in aIndex
374     DWORD dwChunkId; // 'tcdl'
375     DWORD dwReserved[3]; // must be 0
376     AVITCDLINDEX_ENTRY aIndex[NUMINDEX(7)];
377     DWORD adwTrailingFill[NUMINDEXFILL(7)]; // to align struct to correct size
378     } AVITCDLINDEX;
379    
380     typedef struct _avifieldindex_chunk {
381     FOURCC fcc; // 'ix##'
382     DWORD cb; // size of this structure
383     WORD wLongsPerEntry; // must be 3 (size of each entry in
384     // aIndex array)
385     BYTE bIndexSubType; // AVI_INDEX_2FIELD
386     BYTE bIndexType; // AVI_INDEX_OF_CHUNKS
387     DWORD nEntriesInUse; //
388     DWORD dwChunkId; // '##dc' or '##db'
389     DWORDLONG qwBaseOffset; // offsets in aIndex array are relative to this
390     DWORD dwReserved3; // must be 0
391     struct _avifieldindex_entry {
392     DWORD dwOffset;
393     DWORD dwSize; // size of all fields
394     // (bit 31 set for NON-keyframes)
395     DWORD dwOffsetField2; // offset to second field
396     } aIndex[ ];
397     } AVIFIELDINDEX, * PAVIFIELDINDEX;
398    
399    
400     #include <poppack.h>
401    
402     #endif

root@recompile.se
ViewVC Help
Powered by ViewVC 1.1.26