diff --git a/include/freerdp/cache/brush.h b/include/freerdp/cache/brush.h index 2c116ecef..463e6a9a7 100644 --- a/include/freerdp/cache/brush.h +++ b/include/freerdp/cache/brush.h @@ -27,36 +27,10 @@ #include -typedef struct _BRUSH_ENTRY BRUSH_ENTRY; typedef struct rdp_brush_cache rdpBrushCache; #include -struct _BRUSH_ENTRY -{ - UINT32 bpp; - void* entry; -}; - -struct rdp_brush_cache -{ - pPatBlt PatBlt; /* 0 */ - pCacheBrush CacheBrush; /* 1 */ - pPolygonSC PolygonSC; /* 2 */ - pPolygonCB PolygonCB; /* 3 */ - UINT32 paddingA[16 - 4]; /* 4 */ - - UINT32 maxEntries; /* 16 */ - UINT32 maxMonoEntries; /* 17 */ - BRUSH_ENTRY* entries; /* 18 */ - BRUSH_ENTRY* monoEntries; /* 19 */ - UINT32 paddingB[32 - 20]; /* 20 */ - - /* internal */ - - rdpSettings* settings; -}; - #ifdef __cplusplus extern "C" { diff --git a/include/freerdp/cache/nine_grid.h b/include/freerdp/cache/nine_grid.h index 3b8e2b127..c10d571c0 100644 --- a/include/freerdp/cache/nine_grid.h +++ b/include/freerdp/cache/nine_grid.h @@ -27,32 +27,10 @@ #include -typedef struct _NINE_GRID_ENTRY NINE_GRID_ENTRY; typedef struct rdp_nine_grid_cache rdpNineGridCache; #include -struct _NINE_GRID_ENTRY -{ - void* entry; -}; - -struct rdp_nine_grid_cache -{ - pDrawNineGrid DrawNineGrid; /* 0 */ - pMultiDrawNineGrid MultiDrawNineGrid; /* 1 */ - UINT32 paddingA[16 - 2]; /* 2 */ - - UINT32 maxEntries; /* 16 */ - UINT32 maxSize; /* 17 */ - NINE_GRID_ENTRY* entries; /* 18 */ - UINT32 paddingB[32 - 19]; /* 19 */ - - /* internal */ - - rdpSettings* settings; -}; - #ifdef __cplusplus extern "C" { diff --git a/include/freerdp/cache/offscreen.h b/include/freerdp/cache/offscreen.h index 1af0dd725..202690f15 100644 --- a/include/freerdp/cache/offscreen.h +++ b/include/freerdp/cache/offscreen.h @@ -29,21 +29,6 @@ typedef struct rdp_offscreen_cache rdpOffscreenCache; -#include - -struct rdp_offscreen_cache -{ - UINT32 maxSize; /* 0 */ - UINT32 maxEntries; /* 1 */ - rdpBitmap** entries; /* 2 */ - UINT32 currentSurface; /* 3 */ - - /* internal */ - - rdpUpdate* update; - rdpSettings* settings; -}; - #ifdef __cplusplus extern "C" { diff --git a/include/freerdp/codec/mppc.h b/include/freerdp/codec/mppc.h index c754b7864..7295c28af 100644 --- a/include/freerdp/codec/mppc.h +++ b/include/freerdp/codec/mppc.h @@ -27,17 +27,6 @@ #include -struct _MPPC_CONTEXT -{ - wBitStream* bs; - BOOL Compressor; - BYTE* HistoryPtr; - UINT32 HistoryOffset; - UINT32 HistoryBufferSize; - BYTE HistoryBuffer[65536]; - UINT16 MatchBuffer[32768]; - UINT32 CompressionLevel; -}; typedef struct _MPPC_CONTEXT MPPC_CONTEXT; #ifdef __cplusplus diff --git a/include/freerdp/codec/ncrush.h b/include/freerdp/codec/ncrush.h index 999c8e7c8..7e89b9268 100644 --- a/include/freerdp/codec/ncrush.h +++ b/include/freerdp/codec/ncrush.h @@ -27,21 +27,6 @@ #include -struct _NCRUSH_CONTEXT -{ - BOOL Compressor; - BYTE* HistoryPtr; - UINT32 HistoryOffset; - UINT32 HistoryEndOffset; - UINT32 HistoryBufferSize; - BYTE HistoryBuffer[65536]; - UINT32 HistoryBufferFence; - UINT32 OffsetCache[4]; - UINT16 HashTable[65536]; - UINT16 MatchTable[65536]; - BYTE HuffTableCopyOffset[1024]; - BYTE HuffTableLOM[4096]; -}; typedef struct _NCRUSH_CONTEXT NCRUSH_CONTEXT; #ifdef __cplusplus diff --git a/include/freerdp/codec/xcrush.h b/include/freerdp/codec/xcrush.h index 62e9a2464..9a2be8a6e 100644 --- a/include/freerdp/codec/xcrush.h +++ b/include/freerdp/codec/xcrush.h @@ -25,75 +25,6 @@ #include -#pragma pack(push, 1) - -struct _XCRUSH_MATCH_INFO -{ - UINT32 MatchOffset; - UINT32 ChunkOffset; - UINT32 MatchLength; -}; -typedef struct _XCRUSH_MATCH_INFO XCRUSH_MATCH_INFO; - -struct _XCRUSH_CHUNK -{ - UINT32 offset; - UINT32 next; -}; -typedef struct _XCRUSH_CHUNK XCRUSH_CHUNK; - -struct _XCRUSH_SIGNATURE -{ - UINT16 seed; - UINT16 size; -}; -typedef struct _XCRUSH_SIGNATURE XCRUSH_SIGNATURE; - -struct _RDP61_MATCH_DETAILS -{ - UINT16 MatchLength; - UINT16 MatchOutputOffset; - UINT32 MatchHistoryOffset; -}; -typedef struct _RDP61_MATCH_DETAILS RDP61_MATCH_DETAILS; - -struct _RDP61_COMPRESSED_DATA -{ - BYTE Level1ComprFlags; - BYTE Level2ComprFlags; - UINT16 MatchCount; - RDP61_MATCH_DETAILS* MatchDetails; - BYTE* Literals; -}; -typedef struct _RDP61_COMPRESSED_DATA RDP61_COMPRESSED_DATA; - -#pragma pack(pop) - -struct _XCRUSH_CONTEXT -{ - BOOL Compressor; - MPPC_CONTEXT* mppc; - BYTE* HistoryPtr; - UINT32 HistoryOffset; - UINT32 HistoryBufferSize; - BYTE HistoryBuffer[2000000]; - BYTE BlockBuffer[16384]; - UINT32 CompressionFlags; - - UINT32 SignatureIndex; - UINT32 SignatureCount; - XCRUSH_SIGNATURE Signatures[1000]; - - UINT32 ChunkHead; - UINT32 ChunkTail; - XCRUSH_CHUNK Chunks[65534]; - UINT16 NextChunks[65536]; - - UINT32 OriginalMatchCount; - UINT32 OptimizedMatchCount; - XCRUSH_MATCH_INFO OriginalMatches[1000]; - XCRUSH_MATCH_INFO OptimizedMatches[1000]; -}; typedef struct _XCRUSH_CONTEXT XCRUSH_CONTEXT; #ifdef __cplusplus diff --git a/libfreerdp/cache/brush.c b/libfreerdp/cache/brush.c index 6a57e5753..0475b26a5 100644 --- a/libfreerdp/cache/brush.c +++ b/libfreerdp/cache/brush.c @@ -35,6 +35,32 @@ #define TAG FREERDP_TAG("cache.brush") +struct _BRUSH_ENTRY +{ + UINT32 bpp; + void* entry; +}; +typedef struct _BRUSH_ENTRY BRUSH_ENTRY; + +struct rdp_brush_cache +{ + pPatBlt PatBlt; /* 0 */ + pCacheBrush CacheBrush; /* 1 */ + pPolygonSC PolygonSC; /* 2 */ + pPolygonCB PolygonCB; /* 3 */ + UINT32 paddingA[16 - 4]; /* 4 */ + + UINT32 maxEntries; /* 16 */ + UINT32 maxMonoEntries; /* 17 */ + BRUSH_ENTRY* entries; /* 18 */ + BRUSH_ENTRY* monoEntries; /* 19 */ + UINT32 paddingB[32 - 20]; /* 20 */ + + /* internal */ + + rdpSettings* settings; +}; + static BOOL update_gdi_patblt(rdpContext* context, PATBLT_ORDER* patblt) { BYTE style; diff --git a/libfreerdp/cache/nine_grid.c b/libfreerdp/cache/nine_grid.c index e2953f4f3..33c16180e 100644 --- a/libfreerdp/cache/nine_grid.c +++ b/libfreerdp/cache/nine_grid.c @@ -34,6 +34,28 @@ #define TAG FREERDP_TAG("cache.nine_grid") +struct _NINE_GRID_ENTRY +{ + void* entry; +}; +typedef struct _NINE_GRID_ENTRY NINE_GRID_ENTRY; + +struct rdp_nine_grid_cache +{ + pDrawNineGrid DrawNineGrid; /* 0 */ + pMultiDrawNineGrid MultiDrawNineGrid; /* 1 */ + UINT32 paddingA[16 - 2]; /* 2 */ + + UINT32 maxEntries; /* 16 */ + UINT32 maxSize; /* 17 */ + NINE_GRID_ENTRY* entries; /* 18 */ + UINT32 paddingB[32 - 19]; /* 19 */ + + /* internal */ + + rdpSettings* settings; +}; + static void* nine_grid_cache_get(rdpNineGridCache* nine_grid, UINT32 index); static void nine_grid_cache_put(rdpNineGridCache* nine_grid, UINT32 index, void* entry); diff --git a/libfreerdp/cache/offscreen.c b/libfreerdp/cache/offscreen.c index a308acf22..cdad56b4d 100644 --- a/libfreerdp/cache/offscreen.c +++ b/libfreerdp/cache/offscreen.c @@ -29,11 +29,25 @@ #include #include +#include #include "../core/graphics.h" #define TAG FREERDP_TAG("cache.offscreen") +struct rdp_offscreen_cache +{ + UINT32 maxSize; /* 0 */ + UINT32 maxEntries; /* 1 */ + rdpBitmap** entries; /* 2 */ + UINT32 currentSurface; /* 3 */ + + /* internal */ + + rdpUpdate* update; + rdpSettings* settings; +}; + static void offscreen_cache_put(rdpOffscreenCache* offscreen_cache, UINT32 index, rdpBitmap* bitmap); static void offscreen_cache_delete(rdpOffscreenCache* offscreen, UINT32 index); diff --git a/libfreerdp/codec/mppc.c b/libfreerdp/codec/mppc.c index 7498eddb4..cdad24863 100644 --- a/libfreerdp/codec/mppc.c +++ b/libfreerdp/codec/mppc.c @@ -37,6 +37,18 @@ 0x07FFF000) >> \ 12) +struct _MPPC_CONTEXT +{ + wBitStream* bs; + BOOL Compressor; + BYTE* HistoryPtr; + UINT32 HistoryOffset; + UINT32 HistoryBufferSize; + BYTE HistoryBuffer[65536]; + UINT16 MatchBuffer[32768]; + UINT32 CompressionLevel; +}; + static const UINT32 MPPC_MATCH_TABLE[256] = { 0x00000000, 0x009CCF93, 0x01399F26, 0x01D66EB9, 0x02733E4C, 0x03100DDF, 0x03ACDD72, 0x0449AD05, 0x04E67C98, 0x05834C2B, 0x06201BBE, 0x06BCEB51, 0x0759BAE4, 0x07F68A77, 0x08935A0A, 0x0930299D, diff --git a/libfreerdp/codec/ncrush.c b/libfreerdp/codec/ncrush.c index 8b50b0b58..af503fc7c 100644 --- a/libfreerdp/codec/ncrush.c +++ b/libfreerdp/codec/ncrush.c @@ -32,6 +32,22 @@ #define TAG FREERDP_TAG("codec") +struct _NCRUSH_CONTEXT +{ + BOOL Compressor; + BYTE* HistoryPtr; + UINT32 HistoryOffset; + UINT32 HistoryEndOffset; + UINT32 HistoryBufferSize; + BYTE HistoryBuffer[65536]; + UINT32 HistoryBufferFence; + UINT32 OffsetCache[4]; + UINT16 HashTable[65536]; + UINT16 MatchTable[65536]; + BYTE HuffTableCopyOffset[1024]; + BYTE HuffTableLOM[4096]; +}; + static const UINT16 HuffTableLEC[8192] = { 0x510B, 0x611F, 0x610D, 0x9027, 0x6000, 0x7105, 0x6117, 0xA068, 0x5111, 0x7007, 0x6113, 0x90C0, 0x6108, 0x8018, 0x611B, 0xA0B3, 0x510F, 0x7003, 0x6110, 0x9042, 0x6002, 0x800B, 0x6119, 0xA091, diff --git a/libfreerdp/codec/xcrush.c b/libfreerdp/codec/xcrush.c index cadfcd820..87a74a2a4 100644 --- a/libfreerdp/codec/xcrush.c +++ b/libfreerdp/codec/xcrush.c @@ -32,6 +32,76 @@ #define TAG FREERDP_TAG("codec") +#pragma pack(push, 1) + +struct _XCRUSH_MATCH_INFO +{ + UINT32 MatchOffset; + UINT32 ChunkOffset; + UINT32 MatchLength; +}; +typedef struct _XCRUSH_MATCH_INFO XCRUSH_MATCH_INFO; + +struct _XCRUSH_CHUNK +{ + UINT32 offset; + UINT32 next; +}; +typedef struct _XCRUSH_CHUNK XCRUSH_CHUNK; + +struct _XCRUSH_SIGNATURE +{ + UINT16 seed; + UINT16 size; +}; +typedef struct _XCRUSH_SIGNATURE XCRUSH_SIGNATURE; + +struct _RDP61_MATCH_DETAILS +{ + UINT16 MatchLength; + UINT16 MatchOutputOffset; + UINT32 MatchHistoryOffset; +}; +typedef struct _RDP61_MATCH_DETAILS RDP61_MATCH_DETAILS; + +struct _RDP61_COMPRESSED_DATA +{ + BYTE Level1ComprFlags; + BYTE Level2ComprFlags; + UINT16 MatchCount; + RDP61_MATCH_DETAILS* MatchDetails; + BYTE* Literals; +}; +typedef struct _RDP61_COMPRESSED_DATA RDP61_COMPRESSED_DATA; + +#pragma pack(pop) + +struct _XCRUSH_CONTEXT +{ + BOOL Compressor; + MPPC_CONTEXT* mppc; + BYTE* HistoryPtr; + UINT32 HistoryOffset; + UINT32 HistoryBufferSize; + BYTE HistoryBuffer[2000000]; + BYTE BlockBuffer[16384]; + UINT32 CompressionFlags; + + UINT32 SignatureIndex; + UINT32 SignatureCount; + XCRUSH_SIGNATURE Signatures[1000]; + + UINT32 ChunkHead; + UINT32 ChunkTail; + XCRUSH_CHUNK Chunks[65534]; + UINT16 NextChunks[65536]; + + UINT32 OriginalMatchCount; + UINT32 OptimizedMatchCount; + XCRUSH_MATCH_INFO OriginalMatches[1000]; + XCRUSH_MATCH_INFO OptimizedMatches[1000]; +}; + #ifdef DEBUG_XCRUSH static const char* xcrush_get_level_2_compression_flags_string(UINT32 flags) { @@ -99,9 +169,9 @@ static const char* xcrush_get_level_1_compression_flags_string(UINT32 flags) } #endif -static UINT32 xcrush_update_hash(BYTE* data, UINT32 size) +static UINT32 xcrush_update_hash(const BYTE* data, UINT32 size) { - BYTE* end; + const BYTE* end; UINT32 seed = 5381; /* same value as in djb2 */ if (size > 32) @@ -121,7 +191,7 @@ static UINT32 xcrush_update_hash(BYTE* data, UINT32 size) return (UINT16)seed; } -static int xcrush_append_chunk(XCRUSH_CONTEXT* xcrush, BYTE* data, UINT32* beg, UINT32 end) +static int xcrush_append_chunk(XCRUSH_CONTEXT* xcrush, const BYTE* data, UINT32* beg, UINT32 end) { UINT16 seed; UINT32 size; @@ -146,7 +216,8 @@ static int xcrush_append_chunk(XCRUSH_CONTEXT* xcrush, BYTE* data, UINT32* beg, return 1; } -static int xcrush_compute_chunks(XCRUSH_CONTEXT* xcrush, BYTE* data, UINT32 size, UINT32* pIndex) +static int xcrush_compute_chunks(XCRUSH_CONTEXT* xcrush, const BYTE* data, UINT32 size, + UINT32* pIndex) { UINT32 i = 0; UINT32 offset = 0; @@ -215,7 +286,7 @@ static int xcrush_compute_chunks(XCRUSH_CONTEXT* xcrush, BYTE* data, UINT32 size return 0; } -static UINT32 xcrush_compute_signatures(XCRUSH_CONTEXT* xcrush, BYTE* data, UINT32 size) +static UINT32 xcrush_compute_signatures(XCRUSH_CONTEXT* xcrush, const BYTE* data, UINT32 size) { UINT32 index = 0; @@ -661,9 +732,9 @@ static int xcrush_generate_output(XCRUSH_CONTEXT* xcrush, BYTE* OutputBuffer, UI return 1; } -static int xcrush_copy_bytes(BYTE* dst, BYTE* src, int num) +static size_t xcrush_copy_bytes(BYTE* dst, const BYTE* src, size_t num) { - int index; + size_t index; for (index = 0; index < num; index++) { @@ -673,15 +744,15 @@ static int xcrush_copy_bytes(BYTE* dst, BYTE* src, int num) return num; } -static int xcrush_decompress_l1(XCRUSH_CONTEXT* xcrush, BYTE* pSrcData, UINT32 SrcSize, +static int xcrush_decompress_l1(XCRUSH_CONTEXT* xcrush, const BYTE* pSrcData, UINT32 SrcSize, BYTE** ppDstData, UINT32* pDstSize, UINT32 flags) { - BYTE* pSrcEnd = NULL; - BYTE* Literals = NULL; + const BYTE* pSrcEnd = NULL; + const BYTE* Literals = NULL; UINT16 MatchCount = 0; UINT16 MatchIndex = 0; BYTE* OutputPtr = NULL; - int OutputLength = 0; + size_t OutputLength = 0; UINT32 OutputOffset = 0; BYTE* HistoryPtr = NULL; BYTE* HistoryBuffer = NULL; @@ -813,10 +884,8 @@ int xcrush_decompress(XCRUSH_CONTEXT* xcrush, BYTE* pSrcData, UINT32 SrcSize, BY if (!(Level2ComprFlags & PACKET_COMPRESSED)) { - pDstData = pSrcData; - DstSize = SrcSize; status = - xcrush_decompress_l1(xcrush, pDstData, DstSize, ppDstData, pDstSize, Level1ComprFlags); + xcrush_decompress_l1(xcrush, pSrcData, SrcSize, ppDstData, pDstSize, Level1ComprFlags); return status; } @@ -830,7 +899,7 @@ int xcrush_decompress(XCRUSH_CONTEXT* xcrush, BYTE* pSrcData, UINT32 SrcSize, BY return status; } -static int xcrush_compress_l1(XCRUSH_CONTEXT* xcrush, BYTE* pSrcData, UINT32 SrcSize, +static int xcrush_compress_l1(XCRUSH_CONTEXT* xcrush, const BYTE* pSrcData, UINT32 SrcSize, BYTE** ppDstData, UINT32* pDstSize, UINT32* pFlags) { int status = 0;