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