Leaked source code of windows server 2003
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

402 lines
13 KiB

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