libfreerdp-codec: cleanup context state flushing
This commit is contained in:
parent
830659fc5c
commit
18cac3d4dd
@ -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);
|
||||
|
@ -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);
|
||||
|
@ -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);
|
||||
|
@ -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;
|
||||
|
@ -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;
|
||||
|
@ -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;
|
||||
|
@ -80,7 +80,6 @@ set(${MODULE_PREFIX}_SRCS
|
||||
server.c
|
||||
server.h
|
||||
metrics.c
|
||||
metrics.h
|
||||
capabilities.c
|
||||
capabilities.h
|
||||
certificate.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)
|
||||
|
Loading…
Reference in New Issue
Block a user