Source code of Windows XP (NT5)
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.

251 lines
8.2 KiB

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