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.

170 lines
5.2 KiB

  1. #ifndef _XPRESS_H_
  2. #define _XPRESS_H_
  3. #ifdef _MSC_VER
  4. #pragma once
  5. #endif
  6. /* ------------------------------------------------------------------------ */
  7. /* */
  8. /* Copyright (c) Microsoft Corporation, 2000-2001. All rights reserved. */
  9. /* Copyright (c) Andrew Kadatch, 1991-2001. All rights reserved. */
  10. /* */
  11. /* Microsoft Confidential -- do not redistribute. */
  12. /* */
  13. /* ------------------------------------------------------------------------ */
  14. #ifdef __cplusplus
  15. extern "C" {
  16. #endif
  17. /* ---------------------- Common declarations ------------------------- */
  18. /* ------------------- */
  19. // max. size of input block
  20. #define XPRESS_MAX_BLOCK_LOG 16
  21. #define XPRESS_MAX_BLOCK (1 << XPRESS_MAX_BLOCK_LOG)
  22. // preferred data alignment to avoid misaligned accesses
  23. #define XPRESS_ALIGNMENT 8
  24. // declare default calling convention used in xpress
  25. #if !defined (UNIX) && !defined (XPRESS_CALL)
  26. #define XPRESS_CALL __stdcall
  27. #endif
  28. // user-supplied callback function that allocates memory
  29. // if there is no memory available it shall return NULL
  30. typedef
  31. void *
  32. XPRESS_CALL
  33. XpressAllocFn
  34. (
  35. void *context, // user-defined context (as passed to XpressEncodeCreate)
  36. int size // size of memory block to allocate
  37. );
  38. // user-supplied callback function that releases memory
  39. typedef
  40. void
  41. XPRESS_CALL
  42. XpressFreeFn
  43. (
  44. void *context, // user-defined context (as passed to XpressEncodeClose)
  45. void *address // pointer to the block to be freed
  46. );
  47. /* ----------------------------- Encoder ------------------------------ */
  48. /* ------- */
  49. // declare unique anonymous types for type safety
  50. typedef struct {int XpressEncodeDummy;} *XpressEncodeStream;
  51. // allocate and initialize encoder's data structures
  52. // returns NULL if callback returned NULL (not enough memory)
  53. XpressEncodeStream
  54. XPRESS_CALL
  55. XpressEncodeCreate
  56. (
  57. int MaxOrigSize, // max size of original data block
  58. void *context, // user-defined context info (will be passed to AllocFn)
  59. XpressAllocFn *AllocFn, // memory allocation callback
  60. int CompressionLevel // use 0 for speed, 9 for quality
  61. );
  62. // callback function called by XpressEncode to indicate compression progress
  63. typedef
  64. void
  65. XPRESS_CALL
  66. XpressProgressFn
  67. (
  68. void *context, // user-defined context
  69. int compressed // size of processed original data
  70. );
  71. // returns size of compressed data
  72. // if compression failed then compressed buffer is left as is, and
  73. // original data should be saved instead
  74. int
  75. XPRESS_CALL
  76. XpressEncode
  77. (
  78. XpressEncodeStream stream, // encoder's workspace
  79. void *CompAdr, int CompSize, // compressed data region
  80. const void *OrigAdr, int OrigSize, // input data block
  81. XpressProgressFn *ProgressFn, // NULL or progress callback
  82. void *ProgressContext, // user-defined context that will be passed to ProgressFn
  83. int ProgressSize // call ProgressFn each time ProgressSize bytes processed
  84. );
  85. // invalidate input stream and release workspace memory
  86. void
  87. XPRESS_CALL
  88. XpressEncodeClose
  89. (
  90. XpressEncodeStream stream, // encoder's workspace
  91. void *context, XpressFreeFn *FreeFn // memory releasing callback
  92. );
  93. /* ----------------------------- Decoder ------------------------------ */
  94. /* ------- */
  95. // declare unique anonymous types for type safety
  96. typedef struct {int XpressDecodeDummy;} *XpressDecodeStream;
  97. // allocate memory for decoder. Returns NULL if not enough memory.
  98. XpressDecodeStream
  99. XPRESS_CALL
  100. XpressDecodeCreate
  101. (
  102. void *context, // user-defined context info (will be passed to AllocFn)
  103. XpressAllocFn *AllocFn // memory allocation callback
  104. );
  105. // decode compressed block. Returns # of decoded bytes or -1 otherwise
  106. int
  107. XPRESS_CALL
  108. XpressDecode
  109. (
  110. XpressDecodeStream stream, // decoder's workspace
  111. void *OrigAdr, int OrigSize, // original data region
  112. int DecodeSize, // # of bytes to decode ( <= OrigSize)
  113. const void *CompAdr, int CompSize // compressed data block
  114. );
  115. void
  116. XPRESS_CALL
  117. XpressDecodeClose
  118. (
  119. XpressDecodeStream stream, // encoder's workspace
  120. void *context, // user-defined context info (will be passed to FreeFn)
  121. XpressFreeFn *FreeFn // callback that releases the memory
  122. );
  123. /* ------------------------------ CRC32 ------------------------------- */
  124. /* ----- */
  125. int
  126. XPRESS_CALL
  127. XpressCrc32
  128. (
  129. const void *data, // beginning of data block
  130. int bytes, // number of bytes
  131. int crc // initial value
  132. );
  133. #ifdef __cplusplus
  134. };
  135. #endif
  136. #endif /* _XPRESS_H_ */