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.

216 lines
9.0 KiB

  1. DOC file for AVI Installable compressors
  2. ToddLa
  3. ----------------------------------------------------------------------------
  4. This document covers what happens (from the drivers point of
  5. view) when AVI loads, saves, edits, and plays a AVI file.
  6. FORMAT OF A AVI FILE -------------------------------------------------------
  7. AVI files are RIFF files with the following structure:
  8. RIFF('AVI'
  9. LIST('hdrl'
  10. avih(<MainAVIHeader>)
  11. LIST ('strl'
  12. strh(<Stream header>)
  13. strf(<Stream format>)
  14. strd(<Stream data>)
  15. )
  16. )
  17. LIST('movi'
  18. 00??(<driver Data>)
  19. .
  20. .
  21. .
  22. 00??(<driver Data>)
  23. )
  24. indx(<AVIIndex>)
  25. )
  26. OPENING a file for decompression -------------------------------------------
  27. this is what the driver see's when a AVI file is opened for playback
  28. or editing.
  29. 1. The AVI runtime driver gets the FOURCC driver name from the stream
  30. header and tries to open the named driver. drivers are
  31. listed in SYSTEM.INI
  32. [Installable Compressors]
  33. VIDC.SAMP = icsample.drv
  34. This example lists a video driver ('VIDC') with the name 'SAMP'.
  35. The first message a device driver receives is DRV_OPEN. Your
  36. device driver should allocate any instance data it uses when
  37. it processes this message. (Your driver will receive DRV_OPEN
  38. each time it is opened.)
  39. 2. If a 'strd' chunk exists for this stream, the AVI runtime driver
  40. will send your driver an ICM_SETSTATE message. The <MI>lParam1<D>
  41. parameter will contain a pointer to the data from
  42. the file.
  43. 3. Depending on how the AVI runtime driver will use the decompressed
  44. data, it will send either ICM_DECOMPRESS_GET_FORMAT
  45. or ICM_DECOMPRESS_QUERY to determine the decompression format.
  46. ICM_DECOMPRESS_GET_FORMAT:
  47. When your driver gets ICM_DECOMPRESS_GET_FORMAT,
  48. <MI>lParam1<D> points to the 'strf' data, and <MI>lParam2<D>
  49. points to a <B>BITMAPINFOHEADER<D> structure.
  50. Your driver should fill in the <B>BITMAPINFOHEADER<D> with
  51. information about the format it will use for decompressing
  52. the data.
  53. If your device driver cannot handle the input format, or
  54. the input format 'strf' is incorrect, your driver
  55. should return ICMERR_BADFORMAT to fail the message.
  56. ICM_DECOMPRESS_QUERY:
  57. When your driver gets ICM_DECOMPRESS_QUERY,
  58. <MI>lParam1<D> points to the 'strf' data, and <MI>lParam2<D>
  59. points to a <B>BITMAPINFOHEADER<D> structure. For this message,
  60. the AVI runtime driver filled the structure with a
  61. description of the output format it wants to use.
  62. The sugested format will be the native or best format
  63. for the decompressed data. For example,
  64. if playback is on an 8-bit device, the AVI runtime driver
  65. will suggest an 8-bit DIB.
  66. Your driver does not have to accept the suggested format.
  67. If you fail the message, the AVI runtime driver will
  68. suggest alternate formats until your driver accepts one.
  69. If your driver exhausts the list of formats normally used,
  70. the AVI runtime driver will request a format with
  71. ICM_DECOMPRESS_GET_FORMAT.
  72. 4. When the AVI runtime driver is ready, it sends the
  73. ICM_DECOMPRESS_BEGIN message to the device driver. The AVI runtime
  74. driver sets <MI>lParam1<D> to the input format ('strf' data)
  75. and <MI>lParam2<D> to the decompressed format of the DIB.
  76. If either of the formats is incorrect, your device driver
  77. should return ICERR_BADFORMAT.
  78. 5. The AVI runtime driver sends ICM_DECOMPRESS each time
  79. it has an image to decompress. The <B>ICDECOMPRESS<D>
  80. structure specified in <MI>lParam1<D> contains the
  81. decompression parameters. The AVI runtime driver
  82. uses the flags in the AVI index to ensure decompression
  83. will start on key frame boundries,
  84. 6. Your device driver receives ICM_DECOMPRESS_END when
  85. the AVI runtime driver no longer needs data decompressed.
  86. When the device driver is no longer needed the system will
  87. close it by sending DRV_CLOSE.
  88. COMPRESSING a file ------------------------------------------------------
  89. This is the sequence of messages that occur for compressing video data.
  90. NOTE: When an AVI file is recompressed, each frame is decompressed to
  91. a full frame and passed to the decompressor.
  92. 1. The first message a device driver receives is DRV_OPEN. Your
  93. device driver should allocate any instance data it uses when
  94. it processes this message. (Your driver will receive DRV_OPEN
  95. each time it is opened.)
  96. 2. The AVI runtime driver restores the device driver state
  97. by sending ICM_SET_STATE. (The state is recalled from the
  98. strd data chunk of the AVI file. The state information was
  99. obtained with the ICM_GET_STATE message.)
  100. 3. The AVI runtime driver determines the size of the buffer needed to
  101. hold the compressed data format by sending ICM_COMPRESS_GET_FORMAT.
  102. When requesting the buffer size, the AVI runtime driver uses
  103. <MI>lParam1<D> to point to a <B>BITMAPINFOHEADER<D> structure
  104. and sets <MI>lParam2<D> to NULL. Your device driver should
  105. return the size of the buffer in bytes.
  106. 4. The AVI runtime driver requests the output format by sending
  107. ICM_COMPRESS_GET_FORMAT with valid pointers in
  108. both <MI>lParam1<D> and <MI>lParam2<D>. For this case,
  109. your device driver should return the output format in
  110. the buffer pointed to by <MI>lParam2<D>.
  111. This data becomes the <B>strf<D> chunk in the AVI file.
  112. The data must start out like a <B>BITMAPINFOHEADER<D> data
  113. structure. A color table (if used) follows this information.
  114. The last part of the data is any additional information
  115. required to decompress the file.
  116. 5. When the AVI runtime driver is ready to start compressing data
  117. it sends the ICM_COMPRESS_BEGIN message.
  118. The AVI runtime driver uses <MI>lParam1<D> to point to the
  119. format of the data being compressed, and uses <MI>lParam2<D>
  120. to point to format for the compressed data. If your device
  121. driver cannot handle the formats, or if they are incorrect,
  122. your driver should return ICERR_BADFORMAT to fail the message.
  123. 6. Before the AVI runtime driver starts compressing data, it sends
  124. ICM_COMPRESS_GET_SIZE. For this message the AVI runtime driver
  125. uses <MI>lParam1<D> to point to the input format and uses
  126. <MI>lParam2<D> to point to the output format.
  127. Your driver should return the worst case size (in bytes) that any
  128. frame can compress to. The AVI runtime driver uses this size
  129. value when it allocates buffers for the compression.
  130. 7. The AVI runtime driver sends ICM_COMPRESS for each frame it
  131. wants compressed. It uses <MI>lParam1<D> to point
  132. to an <B>ICCOMPRESS<D> structure containing the parameters
  133. used for compression.
  134. Your driver uses the buffers pointed to by the fields of
  135. <B>ICCOMPRESS<D> for returning information
  136. about the compressed data.
  137. Your driver returns the actual size of the compressed data in the
  138. <B>biSizeImage<D> field in the <B>BITMAPINFO<D> data structure
  139. pointed to by the <B>lpbiOutput<D> field of <B>ICCOMPRESS<D>.
  140. Your driver returns the chunk ID
  141. in the buffer specified in the <B>lpckid<D> that it
  142. assigns to the data.
  143. Your driver also returns a DWORD of flags in the buffer pointed
  144. to by <B>lpdwFlags<D>. The flags will be placed in the AVI
  145. index for this chunk. The following flags are defined:
  146. AVIIF_TWOCC Specifies ckid is a TWOCC.
  147. AVIIF_KEYFRAME Specifies this frame is a key frame.
  148. Your driver can define its own flags but they must be set in the high
  149. word only.
  150. If your driver handles temporal compression (that is, the compression
  151. is based on the difference between two frames), it needs to save the
  152. previous frame(s) for temporal compresssion.
  153. 8. Your device driver receives ICM_DECOMPRESS_END when
  154. the AVI runtime driver no longer needs data compressed, or when
  155. the AVI runtime driver is changing the format or palette.
  156. If the AVI runtime driver will continue compressing data, it
  157. will start the sequence by sending ICM_COMPRESS_BEGIN.
  158. When the device driver is no longer needed the system will
  159. close it by sending DRV_CLOSE.
  160. The driver might also receive a ICM_COMPRESS_QUERY message
  161. to determine if it supports the input or output format.
  162. COMPRESSING A BUNCH OF FRAMES -------------------------------------------
  163. TBD