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.

79 lines
2.5 KiB

  1. /*++
  2. Copyright (C) 1994-2001 Microsoft Corporation
  3. Module Name:
  4. MRCICODE.H
  5. Abstract:
  6. MRCI 1 & MRCI 2 maxcompress and decompress functions
  7. History:
  8. --*/
  9. #include <setjmp.h>
  10. #include "corepol.h"
  11. #define LOGCHASH (13) /* Log of max. no. of hash buckets */
  12. #define CHASH (1U << LOGCHASH) /* Reasonably large table */
  13. #define LOGDISPSMALL (6) /* Number of bits in small disp */
  14. #define LOGDISPMED (8) /* Number of bits in medium disp */
  15. #define LOGDISPBIG (12) /* Number of bits in big displacement */
  16. #define MAXDISPSMALL ((1 << LOGDISPSMALL) - 1)
  17. /* Maximum small displacement */
  18. #define MAXDISPMED ((1 << LOGDISPMED) + MAXDISPSMALL)
  19. /* Maximum medium displacement */
  20. #define MAXDISPBIG ((1 << LOGDISPBIG) + MAXDISPMED)
  21. /* Maximum big displacement */
  22. class POLARITY CBaseMrciCompression
  23. {
  24. public:
  25. unsigned int Mrci1MaxCompress(unsigned char *pchbase, unsigned int cchunc,
  26. unsigned char *pchcmpBase, unsigned int cchcmpMax);
  27. unsigned Mrci1Decompress(unsigned char *pchin, unsigned cchin,
  28. unsigned char *pchdecBase, unsigned cchdecMax);
  29. unsigned Mrci2MaxCompress(unsigned char *pchbase, unsigned cchunc,
  30. unsigned char *pchcmpBase, unsigned cchcmpMax);
  31. unsigned Mrci2Decompress(unsigned char *pchin, unsigned cchin,
  32. unsigned char *pchdecBase, unsigned cchdecMax);
  33. private:
  34. /* compression internal functions */
  35. void inithash(void);
  36. void charbuf(unsigned c);
  37. void putbits(unsigned bits, unsigned cbits);
  38. void outlength(unsigned cb);
  39. void mrci1outsingle(unsigned ch);
  40. void mrci1outstring(unsigned disp, unsigned cb);
  41. void mrci2outsingle(unsigned ch);
  42. void mrci2outstring(unsigned disp, unsigned cb);
  43. /* decompression internal functions */
  44. unsigned getbit(void);
  45. unsigned getbits(unsigned cbits);
  46. void expandstring(unsigned char **ppchout, unsigned disp, unsigned cb);
  47. private:
  48. unsigned abits; /* Array of bits */
  49. unsigned cbitsleft; /* Number of bits in abits */
  50. unsigned char *pCompressed; /* pointer into compressed data */
  51. unsigned cCompressed; /* # bytes remaining @ pCompressed */
  52. unsigned ahash[CHASH]; /* Hash table */
  53. unsigned alink[MAXDISPBIG]; /* Links */
  54. };