diff --git a/include/freerdp/codec/mppc.h b/include/freerdp/codec/mppc.h index ed167fdad..b61c30c6f 100644 --- a/include/freerdp/codec/mppc.h +++ b/include/freerdp/codec/mppc.h @@ -49,8 +49,7 @@ FREERDP_API int mppc_decompress(MPPC_CONTEXT* mppc, BYTE* pSrcData, UINT32 SrcSi FREERDP_API void mppc_set_compression_level(MPPC_CONTEXT* mppc, DWORD CompressionLevel); -FREERDP_API void mppc_context_reset(MPPC_CONTEXT* mppc); -FREERDP_API void mppc_context_flush(MPPC_CONTEXT* mppc); +FREERDP_API void mppc_context_reset(MPPC_CONTEXT* mppc, BOOL flush); FREERDP_API MPPC_CONTEXT* mppc_context_new(DWORD CompressionLevel, BOOL Compressor); FREERDP_API void mppc_context_free(MPPC_CONTEXT* mppc); diff --git a/include/freerdp/codec/ncrush.h b/include/freerdp/codec/ncrush.h index a50d48f0e..d472eb1f3 100644 --- a/include/freerdp/codec/ncrush.h +++ b/include/freerdp/codec/ncrush.h @@ -51,7 +51,7 @@ extern "C" { FREERDP_API int ncrush_compress(NCRUSH_CONTEXT* ncrush, BYTE* pSrcData, UINT32 SrcSize, BYTE** ppDstData, UINT32* pDstSize, UINT32* pFlags); FREERDP_API int ncrush_decompress(NCRUSH_CONTEXT* ncrush, BYTE* pSrcData, UINT32 SrcSize, BYTE** ppDstData, UINT32* pDstSize, UINT32 flags); -FREERDP_API void ncrush_context_reset(NCRUSH_CONTEXT* ncrush); +FREERDP_API void ncrush_context_reset(NCRUSH_CONTEXT* ncrush, BOOL flush); FREERDP_API NCRUSH_CONTEXT* ncrush_context_new(BOOL Compressor); FREERDP_API void ncrush_context_free(NCRUSH_CONTEXT* ncrush); diff --git a/include/freerdp/codec/xcrush.h b/include/freerdp/codec/xcrush.h index a9669bb3e..fe7ed226c 100644 --- a/include/freerdp/codec/xcrush.h +++ b/include/freerdp/codec/xcrush.h @@ -103,8 +103,7 @@ extern "C" { FREERDP_API int xcrush_compress(XCRUSH_CONTEXT* xcrush, BYTE* pSrcData, UINT32 SrcSize, BYTE** ppDstData, UINT32* pDstSize, UINT32* pFlags); FREERDP_API int xcrush_decompress(XCRUSH_CONTEXT* xcrush, BYTE* pSrcData, UINT32 SrcSize, BYTE** ppDstData, UINT32* pDstSize, UINT32 flags); -FREERDP_API void xcrush_context_reset(XCRUSH_CONTEXT* xcrush); -FREERDP_API void xcrush_context_flush(XCRUSH_CONTEXT* xcrush); +FREERDP_API void xcrush_context_reset(XCRUSH_CONTEXT* xcrush, BOOL flush); FREERDP_API XCRUSH_CONTEXT* xcrush_context_new(BOOL Compressor); FREERDP_API void xcrush_context_free(XCRUSH_CONTEXT* xcrush); diff --git a/libfreerdp/codec/mppc.c b/libfreerdp/codec/mppc.c index b7ea336b1..410277f0e 100644 --- a/libfreerdp/codec/mppc.c +++ b/libfreerdp/codec/mppc.c @@ -544,7 +544,7 @@ int mppc_compress(MPPC_CONTEXT* mppc, BYTE* pSrcData, UINT32 SrcSize, BYTE** ppD { if (((bs->position / 8) + 2) > (DstSize - 1)) { - mppc_context_flush(mppc); + mppc_context_reset(mppc, TRUE); *pFlags |= PACKET_FLUSHED; *pFlags |= CompressionLevel; *ppDstData = pSrcData; @@ -596,7 +596,7 @@ int mppc_compress(MPPC_CONTEXT* mppc, BYTE* pSrcData, UINT32 SrcSize, BYTE** ppD if (((bs->position / 8) + 7) > (DstSize - 1)) { - mppc_context_flush(mppc); + mppc_context_reset(mppc, TRUE); *pFlags |= PACKET_FLUSHED; *pFlags |= CompressionLevel; *ppDstData = pSrcData; @@ -753,7 +753,7 @@ int mppc_compress(MPPC_CONTEXT* mppc, BYTE* pSrcData, UINT32 SrcSize, BYTE** ppD { if (((bs->position / 8) + 2) > (DstSize - 1)) { - mppc_context_flush(mppc); + mppc_context_reset(mppc, TRUE); *pFlags |= PACKET_FLUSHED; *pFlags |= CompressionLevel; *ppDstData = pSrcData; @@ -819,19 +819,17 @@ void mppc_set_compression_level(MPPC_CONTEXT* mppc, DWORD CompressionLevel) } } -void mppc_context_reset(MPPC_CONTEXT* mppc) +void mppc_context_reset(MPPC_CONTEXT* mppc, BOOL flush) { ZeroMemory(&(mppc->HistoryBuffer), sizeof(mppc->HistoryBuffer)); ZeroMemory(&(mppc->MatchBuffer), sizeof(mppc->MatchBuffer)); - mppc->HistoryOffset = 0; - mppc->HistoryPtr = &(mppc->HistoryBuffer[mppc->HistoryOffset]); -} + if (flush) + mppc->HistoryOffset = mppc->HistoryBufferSize + 1; + else + mppc->HistoryOffset = 0; -void mppc_context_flush(MPPC_CONTEXT* mppc) -{ - mppc_context_reset(mppc); - mppc->HistoryOffset = mppc->HistoryBufferSize + 1; + mppc->HistoryPtr = &(mppc->HistoryBuffer[mppc->HistoryOffset]); } MPPC_CONTEXT* mppc_context_new(DWORD CompressionLevel, BOOL Compressor) @@ -857,7 +855,7 @@ MPPC_CONTEXT* mppc_context_new(DWORD CompressionLevel, BOOL Compressor) mppc->bs = BitStream_New(); - mppc_context_reset(mppc); + mppc_context_reset(mppc, FALSE); } return mppc; diff --git a/libfreerdp/codec/ncrush.c b/libfreerdp/codec/ncrush.c index ebb7f8568..cfb136e4d 100644 --- a/libfreerdp/codec/ncrush.c +++ b/libfreerdp/codec/ncrush.c @@ -2357,8 +2357,7 @@ int ncrush_compress(NCRUSH_CONTEXT* ncrush, BYTE* pSrcData, UINT32 SrcSize, BYTE if ((DstPtr + 2) > DstEndPtr) /* PACKET_FLUSH #1 */ { - ncrush_context_reset(ncrush); - ncrush->HistoryOffset = ncrush->HistoryBufferSize + 1; + ncrush_context_reset(ncrush, TRUE); *pFlags = PACKET_FLUSHED; *pFlags |= CompressionLevel; *ppDstData = pSrcData; @@ -2385,8 +2384,7 @@ int ncrush_compress(NCRUSH_CONTEXT* ncrush, BYTE* pSrcData, UINT32 SrcSize, BYTE if ((DstPtr + 8) > DstEndPtr) /* PACKET_FLUSH #2 */ { - ncrush_context_reset(ncrush); - ncrush->HistoryOffset = ncrush->HistoryBufferSize + 1; + ncrush_context_reset(ncrush, TRUE); *pFlags = PACKET_FLUSHED; *pFlags |= CompressionLevel; *ppDstData = pSrcData; @@ -2530,8 +2528,7 @@ int ncrush_compress(NCRUSH_CONTEXT* ncrush, BYTE* pSrcData, UINT32 SrcSize, BYTE { if ((DstPtr + 2) > DstEndPtr) /* PACKET_FLUSH #3 */ { - ncrush_context_reset(ncrush); - ncrush->HistoryOffset = ncrush->HistoryBufferSize + 1; + ncrush_context_reset(ncrush, TRUE); *pFlags = PACKET_FLUSHED; *pFlags |= CompressionLevel; *ppDstData = pSrcData; @@ -2554,8 +2551,7 @@ int ncrush_compress(NCRUSH_CONTEXT* ncrush, BYTE* pSrcData, UINT32 SrcSize, BYTE if ((DstPtr + 4) >= DstEndPtr) /* PACKET_FLUSH #4 */ { - ncrush_context_reset(ncrush); - ncrush->HistoryOffset = ncrush->HistoryBufferSize + 1; + ncrush_context_reset(ncrush, TRUE); *pFlags = PACKET_FLUSHED; *pFlags |= CompressionLevel; *ppDstData = pSrcData; @@ -2648,7 +2644,7 @@ int ncrush_generate_tables(NCRUSH_CONTEXT *context) return 1; } -void ncrush_context_reset(NCRUSH_CONTEXT* ncrush) +void ncrush_context_reset(NCRUSH_CONTEXT* ncrush, BOOL flush) { ZeroMemory(&(ncrush->HistoryBuffer), sizeof(ncrush->HistoryBuffer)); ZeroMemory(&(ncrush->OffsetCache), sizeof(ncrush->OffsetCache)); @@ -2656,7 +2652,11 @@ void ncrush_context_reset(NCRUSH_CONTEXT* ncrush) ZeroMemory(&(ncrush->MatchTable), sizeof(ncrush->MatchTable)); ZeroMemory(&(ncrush->HashTable), sizeof(ncrush->HashTable)); - ncrush->HistoryOffset = 0; + if (flush) + ncrush->HistoryOffset = ncrush->HistoryBufferSize + 1; + else + ncrush->HistoryOffset = 0; + ncrush->HistoryPtr = &(ncrush->HistoryBuffer[ncrush->HistoryOffset]); } @@ -2672,9 +2672,9 @@ NCRUSH_CONTEXT* ncrush_context_new(BOOL Compressor) ZeroMemory(&(ncrush->OffsetCache), sizeof(ncrush->OffsetCache)); - ncrush->HistoryEndOffset = 65535; - ncrush->HistoryBufferSize = 65536; + ncrush->HistoryEndOffset = ncrush->HistoryBufferSize - 1; + ZeroMemory(&(ncrush->HistoryBuffer), sizeof(ncrush->HistoryBuffer)); ncrush->HistoryBufferFence = 0xABABABAB; @@ -2684,7 +2684,7 @@ NCRUSH_CONTEXT* ncrush_context_new(BOOL Compressor) if (ncrush_generate_tables(ncrush) < 0) printf("ncrush_context_new: failed to initialize tables\n"); - ncrush_context_reset(ncrush); + ncrush_context_reset(ncrush, FALSE); } return ncrush; diff --git a/libfreerdp/codec/xcrush.c b/libfreerdp/codec/xcrush.c index 39ca7da8d..e32285d71 100644 --- a/libfreerdp/codec/xcrush.c +++ b/libfreerdp/codec/xcrush.c @@ -963,7 +963,7 @@ int xcrush_compress(XCRUSH_CONTEXT* xcrush, BYTE* pSrcData, UINT32 SrcSize, BYTE { if (CompressedDataSize > DstSize) { - xcrush_context_flush(xcrush); + xcrush_context_reset(xcrush, TRUE); *ppDstData = pSrcData; *pDstSize = SrcSize; *pFlags = 0; @@ -1004,7 +1004,7 @@ int xcrush_compress(XCRUSH_CONTEXT* xcrush, BYTE* pSrcData, UINT32 SrcSize, BYTE return 1; } -void xcrush_context_reset(XCRUSH_CONTEXT* xcrush) +void xcrush_context_reset(XCRUSH_CONTEXT* xcrush, BOOL flush) { xcrush->SignatureIndex = 0; xcrush->SignatureCount = 1000; @@ -1019,15 +1019,12 @@ void xcrush_context_reset(XCRUSH_CONTEXT* xcrush) ZeroMemory(&(xcrush->OriginalMatches), sizeof(xcrush->OriginalMatches)); ZeroMemory(&(xcrush->OptimizedMatches), sizeof(xcrush->OptimizedMatches)); - mppc_context_reset(xcrush->mppc); -} + if (flush) + xcrush->HistoryOffset = xcrush->HistoryBufferSize + 1; + else + xcrush->HistoryOffset = 0; -void xcrush_context_flush(XCRUSH_CONTEXT* xcrush) -{ - xcrush_context_reset(xcrush); - xcrush->HistoryOffset = xcrush->HistoryBufferSize + 1; - - mppc_context_flush(xcrush->mppc); + mppc_context_reset(xcrush->mppc, flush); } XCRUSH_CONTEXT* xcrush_context_new(BOOL Compressor) @@ -1044,7 +1041,7 @@ XCRUSH_CONTEXT* xcrush_context_new(BOOL Compressor) xcrush->HistoryOffset = 0; xcrush->HistoryBufferSize = 2000000; - xcrush_context_reset(xcrush); + xcrush_context_reset(xcrush, FALSE); } return xcrush; diff --git a/libfreerdp/core/CMakeLists.txt b/libfreerdp/core/CMakeLists.txt index 33e311534..856dc767d 100644 --- a/libfreerdp/core/CMakeLists.txt +++ b/libfreerdp/core/CMakeLists.txt @@ -80,7 +80,6 @@ set(${MODULE_PREFIX}_SRCS server.c server.h metrics.c - metrics.h capabilities.c capabilities.h certificate.c diff --git a/libfreerdp/core/bulk.c b/libfreerdp/core/bulk.c index 5a833ec88..c79fbc4d9 100644 --- a/libfreerdp/core/bulk.c +++ b/libfreerdp/core/bulk.c @@ -256,14 +256,14 @@ int bulk_compress(rdpBulk* bulk, BYTE* pSrcData, UINT32 SrcSize, BYTE** ppDstDat void bulk_reset(rdpBulk* bulk) { - mppc_context_reset(bulk->mppcSend); - mppc_context_reset(bulk->mppcRecv); + mppc_context_reset(bulk->mppcSend, FALSE); + mppc_context_reset(bulk->mppcRecv, FALSE); - ncrush_context_reset(bulk->ncrushRecv); - ncrush_context_reset(bulk->ncrushSend); + ncrush_context_reset(bulk->ncrushRecv, FALSE); + ncrush_context_reset(bulk->ncrushSend, FALSE); - xcrush_context_reset(bulk->xcrushRecv); - xcrush_context_reset(bulk->xcrushSend); + xcrush_context_reset(bulk->xcrushRecv, FALSE); + xcrush_context_reset(bulk->xcrushSend, FALSE); } rdpBulk* bulk_new(rdpContext* context)