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.

233 lines
8.2 KiB

  1. /*--------------------------------------------------------------------------*\
  2. | |
  3. | MSRLE.H |
  4. \*--------------------------------------------------------------------------*/
  5. /**************************************************************************
  6. *
  7. * THIS CODE AND INFORMATION IS PROVIDED "AS IS" WITHOUT WARRANTY OF ANY
  8. * KIND, EITHER EXPRESSED OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE
  9. * IMPLIED WARRANTIES OF MERCHANTABILITY AND/OR FITNESS FOR A PARTICULAR
  10. * PURPOSE.
  11. *
  12. * Copyright (c) 1991 - 1995 Microsoft Corporation. All Rights Reserved.
  13. *
  14. **************************************************************************/
  15. #ifdef _WIN32
  16. #define huge
  17. // NT and WIN95 use different debug switches.
  18. // NT defines DBG to be 0 or 1
  19. // Win95 defines DEBUG, or does not define it
  20. // Map one methodology to the other
  21. #ifndef DBG
  22. #ifdef DEBUG
  23. #define DBG 1
  24. #else
  25. #define DBG 0
  26. #endif
  27. #endif
  28. #undef DEBUG
  29. #if DBG
  30. #define DEBUG
  31. #define STATICFN
  32. #define STATICDT
  33. #else
  34. #define STATICFN static
  35. #define STATICDT static
  36. #endif
  37. #endif
  38. //
  39. // compressor state info
  40. //
  41. typedef struct {
  42. long lMinFrameSize;
  43. long lMaxFrameSize;
  44. long tolTemporal;
  45. long tolSpatial;
  46. long tolMax;
  47. int iMaxRunLen;
  48. } RLESTATE, FAR *LPRLESTATE, *PRLESTATE;
  49. typedef struct {
  50. LPVOID lpbiPrev;
  51. int iStart;
  52. long lLastParm;
  53. long lFrames;
  54. RLESTATE RleState;
  55. BOOL fCompressBegin;
  56. BOOL fDecompressBegin;
  57. } RLEINST, *PRLEINST;
  58. #define BI_DIBX 0x78626964l // 'dibx'
  59. #define BI_DIBC 0x63626964l // 'dibc'
  60. #define QUALITY_DEFAULT 8500
  61. #define IDS_DESCRIPTION 42
  62. #define IDS_NAME 43
  63. extern HMODULE ghModule;
  64. /****************************************************************************
  65. ***************************************************************************/
  66. #ifdef _INC_COMPDDK
  67. void NEAR PASCAL RleLoad(void);
  68. void NEAR PASCAL RleFree(void);
  69. PRLEINST NEAR PASCAL RleOpen(void);
  70. DWORD NEAR PASCAL RleClose(PRLEINST pri);
  71. DWORD NEAR PASCAL RleGetState(PRLEINST pri, LPVOID pv, DWORD dwSize);
  72. DWORD NEAR PASCAL RleSetState(PRLEINST pri, LPVOID pv, DWORD dwSize);
  73. DWORD NEAR PASCAL RleGetInfo(PRLEINST pri, ICINFO FAR *icinfo, DWORD dwSize);
  74. DWORD NEAR PASCAL RleCompressBegin(PRLEINST pri, LPBITMAPINFOHEADER lpbiIn, LPBITMAPINFOHEADER lpbiOut);
  75. DWORD NEAR PASCAL RleCompressQuery(PRLEINST pri, LPBITMAPINFOHEADER lpbiIn,LPBITMAPINFOHEADER lpbiOut);
  76. DWORD NEAR PASCAL RleCompressGetFormat(PRLEINST pri, LPBITMAPINFOHEADER lpbiIn, LPBITMAPINFOHEADER lpbiOut);
  77. DWORD NEAR PASCAL RleCompress(PRLEINST pri,ICCOMPRESS FAR *icinfo, DWORD dwSize);
  78. DWORD NEAR PASCAL RleCompressGetSize(PRLEINST pri, LPBITMAPINFOHEADER lpbiIn, LPBITMAPINFOHEADER lpbiOut);
  79. DWORD NEAR PASCAL RleCompressEnd(PRLEINST lpri);
  80. DWORD NEAR PASCAL RleDecompressBegin(PRLEINST pri, LPBITMAPINFOHEADER lpbiIn, LPBITMAPINFOHEADER lpbiOut);
  81. DWORD NEAR PASCAL RleDecompressQuery(PRLEINST pri, LPBITMAPINFOHEADER lpbiIn,LPBITMAPINFOHEADER lpbiOut);
  82. DWORD NEAR PASCAL RleDecompressGetFormat(PRLEINST pri, LPBITMAPINFOHEADER lpbiIn, LPBITMAPINFOHEADER lpbiOut);
  83. DWORD NEAR PASCAL RleDecompress(PRLEINST pri,ICDECOMPRESS FAR *icinfo, DWORD dwSize);
  84. DWORD NEAR PASCAL RleDecompressEnd(PRLEINST pri);
  85. #endif
  86. /****************************************************************************
  87. ***************************************************************************/
  88. BOOL FAR PASCAL CrunchDib(PRLEINST pri,
  89. LPBITMAPINFOHEADER lpbiRle, LPVOID lpRle,
  90. LPBITMAPINFOHEADER lpbiPrev,LPVOID lpPrev,
  91. LPBITMAPINFOHEADER lpbiDib, LPVOID lpDib);
  92. BOOL FAR PASCAL SplitDib (PRLEINST pri,
  93. LPBITMAPINFOHEADER lpbiRle, LPVOID lpRle,
  94. LPBITMAPINFOHEADER lpbiPrev,LPVOID lpPrev,
  95. LPBITMAPINFOHEADER lpbiDib, LPVOID lpDib);
  96. //#define MAXSUMSQUARES 195075L
  97. #define MAXTOL 0x00FFFFFFL
  98. #define ADAPTIVE -1
  99. #define NO_LIMIT -1
  100. /****************************************************************************
  101. ***************************************************************************/
  102. /* RgbTol Table structure */
  103. typedef struct {
  104. int ClrUsed;
  105. RGBQUAD argbq[256];
  106. DWORD huge *hpTable;
  107. } RGBTOL;
  108. extern RGBTOL gRgbTol;
  109. /* Public functions anyone can call */
  110. BOOL FAR PASCAL RleDeltaFrame(
  111. LPBITMAPINFOHEADER lpbiRle, LPBYTE pbRle,
  112. LPBITMAPINFOHEADER lpbiPrev, LPBYTE pbPrev,
  113. LPBITMAPINFOHEADER lpbiDib, LPBYTE pbDib,
  114. int iStart,
  115. int iLen,
  116. long tolTemporal,
  117. long tolSpatial,
  118. int maxRun,
  119. int minJump);
  120. BOOL NEAR PASCAL MakeRgbTable(LPBITMAPINFOHEADER lpbi);
  121. void NEAR PASCAL DecodeRle(LPBITMAPINFOHEADER lpbi, LPVOID pb, LPVOID prle, DWORD dwSize);
  122. #ifndef _WIN32
  123. void NEAR PASCAL DecodeRle386(LPBITMAPINFOHEADER lpbi, LPVOID pb, LPVOID prle);
  124. void NEAR PASCAL DecodeRle286(LPBITMAPINFOHEADER lpbi, LPVOID pb, LPVOID prle);
  125. #endif
  126. // in DF.ASM
  127. #ifndef _WIN32
  128. extern void FAR PASCAL DeltaFrame386(
  129. LPBITMAPINFOHEADER lpbi,
  130. LPVOID pbPrev,
  131. LPVOID pbDib,
  132. LPVOID pbRle,
  133. WORD MaxRunLength,
  134. WORD MinJumpLength,
  135. LPVOID TolTable,
  136. DWORD tolTemporal,
  137. DWORD tolSpatial);
  138. #else
  139. extern void DeltaFrameC(
  140. LPBITMAPINFOHEADER lpbi,
  141. LPBYTE pbPrev,
  142. LPBYTE pbDib,
  143. LPBYTE pbRle,
  144. UINT MaxRunLength,
  145. UINT MinJumpLength,
  146. LPDWORD TolTable,
  147. DWORD tolTemporal,
  148. DWORD tolSpatial);
  149. #endif
  150. /****************************************************************************
  151. DIB macros.
  152. ***************************************************************************/
  153. #define WIDTHBYTES(i) ((unsigned)((i+31)&(~31))/8) /* ULONG aligned ! */
  154. #define DibWidthBytesN(lpbi, n) (UINT)WIDTHBYTES((UINT)(lpbi)->biWidth * (UINT)(n))
  155. #define DibWidthBytes(lpbi) DibWidthBytesN(lpbi, (lpbi)->biBitCount)
  156. #define DibSizeImage(lpbi) ((lpbi)->biSizeImage == 0 \
  157. ? ((DWORD)(UINT)DibWidthBytes(lpbi) * (DWORD)(UINT)(lpbi)->biHeight) \
  158. : (lpbi)->biSizeImage)
  159. // Use when biSizeImage is known to be correct (e.g. after FixBitmapInfo)
  160. #define DibSizeImageX(lpbi) ((lpbi)->biSizeImage)
  161. #define DibSize(lpbi) ((lpbi)->biSize + (lpbi)->biSizeImage + (int)(lpbi)->biClrUsed * sizeof(RGBQUAD))
  162. #define DibPaletteSize(lpbi) (DibNumColors(lpbi) * sizeof(RGBQUAD))
  163. #define DibPtr(lpbi) (LPVOID)(DibColors(lpbi) + (UINT)(lpbi)->biClrUsed)
  164. #define DibColors(lpbi) ((LPRGBQUAD)((LPBYTE)(lpbi) + (int)(lpbi)->biSize))
  165. #define DibNumColors(lpbi) ((lpbi)->biClrUsed == 0 && (lpbi)->biBitCount <= 8 \
  166. ? (int)(1 << (int)(lpbi)->biBitCount) \
  167. : (int)(lpbi)->biClrUsed)
  168. #define DibXYN(lpbi,pb,x,y,n) (LPVOID)( \
  169. (LPBYTE)(pb) + \
  170. (UINT)((UINT)(x) * (UINT)(n) / 8u) + \
  171. ((DWORD)DibWidthBytesN(lpbi,n) * (DWORD)(UINT)(y)))
  172. #define DibXY(lpbi,x,y) DibXYN(lpbi,DibPtr(lpbi),x,y,(lpbi)->biBitCount)
  173. #define FixBitmapInfo(lpbi) if ((lpbi)->biSizeImage == 0) \
  174. (lpbi)->biSizeImage = DibSizeImage(lpbi); \
  175. if ((lpbi)->biClrUsed == 0) \
  176. (lpbi)->biClrUsed = DibNumColors(lpbi);
  177. /****************************************************************************
  178. ***************************************************************************/
  179. #ifdef DEBUG
  180. extern void FAR CDECL dprintf(LPSTR, ...);
  181. #define DPF(_x_) dprintf _x_
  182. #else
  183. #define DPF ; / ## /
  184. #endif