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.

323 lines
18 KiB

  1. /****************************************************************************/
  2. /* abcapi.h */
  3. /* */
  4. /* Bitmap Compressor API Header File. */
  5. /* */
  6. /* Copyright(c) Microsoft, PictureTel 1992-1996 */
  7. /* (C) 1997-1999 Microsoft Corp. */
  8. /****************************************************************************/
  9. #ifndef _H_ABCAPI
  10. #define _H_ABCAPI
  11. /****************************************************************************/
  12. /* Define the maximum amount of uncompressed data that we can handle in */
  13. /* one go. */
  14. /****************************************************************************/
  15. #define MAX_UNCOMPRESSED_DATA_SIZE 32000L
  16. #ifdef DC_HICOLOR
  17. /****************************************************************************/
  18. // The following structure contains the results of our intermediate scan of
  19. // the buffer.
  20. /****************************************************************************/
  21. typedef struct {
  22. unsigned fgPel;
  23. unsigned length;
  24. BYTE type;
  25. } MATCH;
  26. #endif
  27. /****************************************************************************/
  28. // Shared memory data. Since BC is present in both the WD and DD, we should
  29. // only alloc this memory once. Note that it does not need to be zero-
  30. // initialized.
  31. /****************************************************************************/
  32. typedef struct {
  33. // noBitmapCompressionHdr: flag to indidate if the client supports
  34. // compressed bitmap without redundent BC header or not. The value
  35. // for this is TS_EXTRA_NO_BITMAP_COMPRESSION_HDR defined in REV2 bitmap
  36. // shm date needs to be aligned, so we need to add a pad.
  37. UINT16 noBitmapCompressionHdr;
  38. UINT16 pad1;
  39. // Work buffer. Note it is set to the max size we ever expect to see.
  40. // This has to include screen data buffers from SSI, and compressed
  41. // bitmaps from SBC.
  42. //erikma: Adjust normal and xor bufs to 65536 and change BC_CompressBitmap
  43. //to handle new size when we allow caches 4 and 5 to be activated.
  44. BYTE xor_buffer[MAX_UNCOMPRESSED_DATA_SIZE];
  45. #ifdef DC_HICOLOR
  46. MATCH match[8192];
  47. #ifdef DC_DEBUG
  48. BYTE decompBuffer[MAX_UNCOMPRESSED_DATA_SIZE];
  49. #endif
  50. #endif
  51. } BC_SHARED_DATA, *PBC_SHARED_DATA;
  52. /****************************************************************************/
  53. /* RLE codes */
  54. /****************************************************************************/
  55. /* The following codes fill a full single byte address space. The approach */
  56. /* is to use the high order bits to identify the code type and the low */
  57. /* order bits to encode the length of the associated run. There are two */
  58. /* forms of order */
  59. /* - regular orders which have a 5 bit length field (31 bytes of data) */
  60. /* - "lite" orders with a 4 bit length */
  61. /* */
  62. /* A value of 0 in the length field indicates an extended length, where */
  63. /* the following byte contains the length of the data. There is also a */
  64. /* "mega mega" form which has a two byte length field. (See end of */
  65. /* codespace of the codes that define the megamega form). */
  66. /* */
  67. /* A set of codes at the high end of the address space is used to encode */
  68. /* commonly occuring short sequences, in particular */
  69. /* - certain single byte FGBG codings */
  70. /* - single bytes of BLACK and WHITE */
  71. /* */
  72. /* */
  73. /* SUMMARY */
  74. /* ******* */
  75. /* 7 6 5 4 3 2 1 0 76543210 76543210 76543210 */
  76. /* */
  77. /* MEGA_BG_RUN 0 0 0 0 0 0 0 0 <length> */
  78. /* */
  79. /* BG_RUN 0 0 0 <length-> */
  80. /* */
  81. /* MEGA_FG_RUN 0 0 1 0 0 0 0 0 <length> */
  82. /* */
  83. /* FG_RUN 0 0 1 <length-> */
  84. /* */
  85. /* MEGA_FG_BG_IMAGE 0 1 0 0 0 0 0 0 <length> <-data-> ... */
  86. /* */
  87. /* FG_BG_IMAGE 0 1 0 <length-> <-data-> ... */
  88. /* */
  89. /* MEGA_COLOR_RUN 0 1 1 0 0 0 0 0 <length> <-color> */
  90. /* */
  91. /* COLOR_RUN 0 1 1 <length-> <color-> */
  92. /* */
  93. /* MEGA_COLOR_IMAGE 1 0 0 0 0 0 0 0 <length> <-data-> ... */
  94. /* */
  95. /* COLOR_IMAGE 1 0 0 <length-> <-data-> ... */
  96. /* */
  97. /* MEGA_PACKED_CLR_IMG 1 0 1 0 0 0 0 0 <length> <-data-> ... */
  98. /* */
  99. /* PACKED COLOR IMAGE 1 0 1 <length-> <-data-> ... */
  100. /* */
  101. /* SET_FG_MEGA_FG_RUN 1 1 0 0 0 0 0 0 <length> <-color> */
  102. /* */
  103. /* SET_FG_FG_RUN 1 1 0 0 <-len-> <color-> */
  104. /* */
  105. /* SET_FG_MEGA_FG_BG 1 1 0 1 0 0 0 0 <length> <-color> <-data-> ... */
  106. /* */
  107. /* SET_FG_FG_BG 1 1 0 1 <-len-> <color-> <-data-> ... */
  108. /* */
  109. /* MEGA_DITHERED_RUN 1 1 1 0 0 0 0 0 <length> <-data-> <-data-> */
  110. /* */
  111. /* DITHERED_RUN 1 1 1 0 <-len-> <-data-> <-data-> */
  112. /* */
  113. /* MEGA_MEGA_BG_RUN 1 1 1 1 0 0 0 0 */
  114. /* */
  115. /* MEGA_MEGA_FG_RUN 1 1 1 1 0 0 0 1 */
  116. /* */
  117. /* MEGA_MEGA_FGBG 1 1 1 1 0 0 1 0 */
  118. /* */
  119. /* MEGA_MEGA_COLOR_RUN 1 1 1 1 0 0 1 1 */
  120. /* */
  121. /* MEGA_MEGA_CLR_IMG 1 1 1 1 0 1 0 0 */
  122. /* */
  123. /* MEGA_MEGA_PACKED_CLR 1 1 1 1 0 1 0 1 */
  124. /* */
  125. /* MEGA_MEGA_SET_FG_RUN 1 1 1 1 0 1 1 0 */
  126. /* */
  127. /* MEGA_MEGA_SET_FGBG 1 1 1 1 0 1 1 1 */
  128. /* */
  129. /* MEGA_MEGA_DITHER 1 1 1 1 1 0 0 0 */
  130. /* */
  131. /* Special FGBG code 1 1 1 1 1 1 0 0 1 FGBG code 0x03 = 11000000 */
  132. /* (Note that 0x01 will generally handled by the single pel insertion code) */
  133. /* */
  134. /* Special FBBG code 2 1 1 1 1 1 0 1 0 FGBG code 0x05 = 10100000 */
  135. /* */
  136. #ifndef DC_HICOLOR
  137. /* Special FBBG code 3 1 1 1 1 1 0 1 1 FGBG code 0x07 = 11100000 */
  138. /* */
  139. /* Special FBBG code 4 1 1 1 1 1 1 0 0 FGBG code 0x0F = 11110000 */
  140. /* */
  141. #endif
  142. /* BLACK 1 1 1 1 1 1 0 1 */
  143. /* */
  144. /* WHITE 1 1 1 1 1 1 1 0 */
  145. /* */
  146. #ifndef DC_HICOLOR
  147. /* START_LOSSY 1 1 1 1 1 1 1 1 */
  148. /* */
  149. #endif
  150. /****************************************************************************/
  151. /* GENERAL NOTES */
  152. /****************************************************************************/
  153. /* - For MEGA runs the length encoded is the length of the run minus the */
  154. /* maximum length of the non-mega form. */
  155. /* In the mega-mega form we encode the plain 16 bit length, to keep */
  156. /* encoding/deconding simple. */
  157. /* */
  158. /* - The sequence BG_RUN,BG_RUN is not exactly what it appears. We */
  159. /* use the fact that this is not generated in normal encoding to */
  160. /* encode <n background><1 foreground><n background>. The same pel */
  161. /* insertion convention applies to any combination of MEGA_BG run and */
  162. /* BG_RUN */
  163. /* */
  164. /* - A packed image is encoded when we find that all the color fields in a */
  165. /* run have 0 in the high order nibble. We do not currently use this code */
  166. /* for 8 bit compression, but it is supported by the V2 decoder. */
  167. /* */
  168. /* - The set fg color code (Used to exist in V1) has been retired in favor */
  169. /* of separate commands for those codes that may embed a color. Generally*/
  170. /* This saves one byte for every foreground color transition for 8bpp. */
  171. /* */
  172. /* - The color run code is new for V2. It indicates a color run where the */
  173. /* XOR is not performed. This applies to, for example, the line of bits */
  174. /* immediately below a text line. (There is no special case for runs of */
  175. /* the bg color - these are treated as any other color run.) */
  176. /* */
  177. /* - Observation shows a high occurrence of BG runs split by single FGBG */
  178. /* codes. In decreasing probability these are 3,5,7,9,f,11,1f,3f (1 is */
  179. /* handled by the implicit BG run break). Save 1 byte by encoding as */
  180. /* single codes */
  181. /* */
  182. /* - There is a relatively high occurrence of single pel color codes ff and */
  183. /* 00. Save 1 byte by encoding as special characters */
  184. /* */
  185. /* - The length in a FGBG run is slightly strange. Because they generally */
  186. /* occur in multiples of 8 bytes we get a big saving if we encode the */
  187. /* length of a short run as length/8. However, for those special */
  188. /* cases where the length is not a multiple of 8 we encode a long run. */
  189. /* Therefore the long form can only cover the range 1-256 bytes. */
  190. /* beyond that we use the mega-mega form. */
  191. /* */
  192. /****************************************************************************/
  193. /* DETAILS OF COMPRESSION CODES */
  194. /****************************************************************************/
  195. // BG_RUN: Represents a background run (black:0) in the XOR buffer of the
  196. // specified length.
  197. //
  198. // FG_BG_IMAGE/SET_FG_FG_BG_IMAGE: Represents a binary image containing only
  199. // the current foreground(1) and background(0) colors from the XOR buffer.
  200. //
  201. // FG_RUN/SET_FG_FG_RUN: Represents a continuous foreground run of the
  202. // specified length, in the XOR buffer. The foreground color is white (0xFF)
  203. // by default, and is changed by the SET_FG_FG_RUN version of this code.
  204. //
  205. // DITHERED_RUN: Represents a run of alternating colors of the specified
  206. // length from the normal (non-XOR) buffer.
  207. //
  208. // COLOR_IMAGE: Represents a color image of the specified length, taken
  209. // from the normal (non-XOR) buffer. This data is uncompressed, so we hope
  210. // that we won't see many of these codes!
  211. //
  212. // COLOR_RUN: Represents a color run of the specified length, taken from
  213. // the normal (non-XOR) buffer. Since the color is not XORed, it is unlikely
  214. // to match the running foreground color information. Therefore this code
  215. // always carries a color byte and there is no SET_FG_COLOR_RUN form of the
  216. // code.
  217. //
  218. // PACKED_COLOR_IMAGE (unused): Represents a color image of the specified
  219. // length, with pairs of colors packed into a single byte. (This can only be
  220. // done when the color info is zero in the high order nibble.)
  221. //
  222. // START_LOSSY (unused): Informs the decoder that lossy mode has been
  223. // established and any of the following color runs will need pixel doubling
  224. // performed. RLE decoding will remain in this mode until the end of this
  225. // block.
  226. #define CODE_MASK 0xE0
  227. #define CODE_MASK_LITE 0xF0
  228. #define CODE_BG_RUN 0x00 /* 20 */
  229. #define CODE_FG_RUN 0x20 /* 20 */
  230. #define CODE_FG_BG_IMAGE 0x40 /* 20 */
  231. #define CODE_COLOR_RUN 0x60 /* 20 */
  232. #define CODE_COLOR_IMAGE 0x80 /* 20 */
  233. #ifndef DC_HICOLOR // not used
  234. #define CODE_PACKED_COLOR_IMAGE 0xA0 /* 20 */
  235. #endif
  236. #define CODE_SET_FG_FG_RUN 0xC0 /* 10 */
  237. #define CODE_SET_FG_FG_BG 0xD0 /* 10 */
  238. #define CODE_DITHERED_RUN 0xE0 /* 10 */
  239. #define CODE_MEGA_MEGA_BG_RUN 0xF0
  240. #define CODE_MEGA_MEGA_FG_RUN 0xF1
  241. #define CODE_MEGA_MEGA_FGBG 0xF2
  242. #define CODE_MEGA_MEGA_COLOR_RUN 0xF3
  243. #define CODE_MEGA_MEGA_CLR_IMG 0xF4
  244. #ifndef DC_HICOLOR // not used
  245. #define CODE_MEGA_MEGA_PACKED_CLR 0xF5
  246. #endif
  247. #define CODE_MEGA_MEGA_SET_FG_RUN 0xF6
  248. #define CODE_MEGA_MEGA_SET_FGBG 0xF7
  249. #define CODE_MEGA_MEGA_DITHER 0xF8
  250. #define CODE_SPECIAL_FGBG_1 0xF9
  251. #define CODE_SPECIAL_FGBG_2 0xFA
  252. #ifndef DC_HICOLOR // not used
  253. #define CODE_SPECIAL_FGBG_3 0xFB
  254. #define CODE_SPECIAL_FGBG_4 0xFC
  255. #endif
  256. #define CODE_WHITE 0xFD
  257. #define CODE_BLACK 0xFE
  258. #ifndef DC_HICOLOR // not used
  259. #define CODE_START_LOSSY 0xFF
  260. #endif
  261. #define MAX_LENGTH_ORDER 31
  262. #define MAX_LENGTH_LONG_ORDER 287
  263. #define MAX_LENGTH_ORDER_LITE 15
  264. #define MAX_LENGTH_LONG_ORDER_LITE 271
  265. #define MAX_LENGTH_FGBG_ORDER (31*8)
  266. #define MAX_LENGTH_FGBG_ORDER_LITE (15*8)
  267. #define MAX_LENGTH_LONG_FGBG_ORDER 255
  268. /****************************************************************************/
  269. /* The special FGBG codes that correspond to codes F0-F7 */
  270. /****************************************************************************/
  271. #define SPECIAL_FGBG_CODE_1 0x03
  272. #define SPECIAL_FGBG_CODE_2 0x05
  273. #define SPECIAL_FGBG_CODE_3 0x07
  274. #define SPECIAL_FGBG_CODE_4 0x0F
  275. /****************************************************************************/
  276. /* Run types as stored in the run index array */
  277. /****************************************************************************/
  278. #define RUN_BG 1
  279. #define RUN_BG_PEL 2
  280. #define RUN_FG 3
  281. #define RUN_COLOR 4
  282. #define RUN_DITHER 5
  283. #define IMAGE_FGBG 6
  284. #define IMAGE_COLOR 7
  285. #ifndef DC_HICOLOR
  286. #define IMAGE_LOSSY_ODD 8
  287. #endif
  288. // ShareClass includes the afn file directly, but in the DD we need these
  289. // defs.
  290. #ifdef DLL_DISP
  291. #include <abcafn.h>
  292. #endif
  293. #endif /* #ifndef _H_ABCAPI */