diff --git a/include/freerdp/codec/ncrush.h b/include/freerdp/codec/ncrush.h new file mode 100644 index 000000000..db5a2542a --- /dev/null +++ b/include/freerdp/codec/ncrush.h @@ -0,0 +1,56 @@ +/** + * FreeRDP: A Remote Desktop Protocol Implementation + * NCrush (RDP6) Bulk Data Compression + * + * Copyright 2014 Marc-Andre Moreau + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +#ifndef FREERDP_CODEC_NCRUSH_H +#define FREERDP_CODEC_NCRUSH_H + +#include +#include + +#include + +#include + +struct _NCRUSH_CONTEXT +{ + wBitStream* bs; + BOOL Compressor; + BYTE* HistoryPtr; + UINT32 HistoryOffset; + UINT32 HistoryBufferSize; + BYTE HistoryBuffer[65536]; +}; +typedef struct _NCRUSH_CONTEXT NCRUSH_CONTEXT; + +#ifdef __cplusplus +extern "C" { +#endif + +FREERDP_API int ncrush_compress(NCRUSH_CONTEXT* ncrush, BYTE* pSrcData, UINT32 SrcSize, BYTE* pDstData, UINT32* pDstSize, UINT32* pFlags); +FREERDP_API int ncrush_decompress(NCRUSH_CONTEXT* ncrush, BYTE* pSrcData, UINT32 SrcSize, BYTE** ppDstData, UINT32* pDstSize, UINT32 flags); + +FREERDP_API NCRUSH_CONTEXT* ncrush_context_new(BOOL Compressor); +FREERDP_API void ncrush_context_free(NCRUSH_CONTEXT* ncrush); + +#ifdef __cplusplus +} +#endif + +#endif /* FREERDP_CODEC_NCRUSH_H */ + diff --git a/libfreerdp/codec/CMakeLists.txt b/libfreerdp/codec/CMakeLists.txt index 3d123bf10..49b15fb84 100644 --- a/libfreerdp/codec/CMakeLists.txt +++ b/libfreerdp/codec/CMakeLists.txt @@ -47,6 +47,7 @@ set(${MODULE_PREFIX}_SRCS nsc_encode.c nsc_encode.h nsc_types.h + ncrush.c mppc.c mppc_dec.c mppc_enc.c diff --git a/libfreerdp/codec/ncrush.c b/libfreerdp/codec/ncrush.c new file mode 100644 index 000000000..aed57c37d --- /dev/null +++ b/libfreerdp/codec/ncrush.c @@ -0,0 +1,70 @@ +/** + * FreeRDP: A Remote Desktop Protocol Implementation + * NCrush (RDP6) Bulk Data Compression + * + * Copyright 2014 Marc-Andre Moreau + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +#ifdef HAVE_CONFIG_H +#include "config.h" +#endif + +#include +#include +#include + +#include + +int ncrush_compress(NCRUSH_CONTEXT* ncrush, BYTE* pSrcData, UINT32 SrcSize, BYTE* pDstData, UINT32* pDstSize, UINT32* pFlags) +{ + return 1; +} + +int ncrush_decompress(NCRUSH_CONTEXT* ncrush, BYTE* pSrcData, UINT32 SrcSize, BYTE** ppDstData, UINT32* pDstSize, UINT32 flags) +{ + return 1; +} + +NCRUSH_CONTEXT* ncrush_context_new(BOOL Compressor) +{ + NCRUSH_CONTEXT* ncrush; + + ncrush = (NCRUSH_CONTEXT*) calloc(1, sizeof(NCRUSH_CONTEXT)); + + if (ncrush) + { + ncrush->Compressor = Compressor; + + ncrush->bs = BitStream_New(); + + ncrush->HistoryBufferSize = 65536; + ZeroMemory(&(ncrush->HistoryBuffer), sizeof(ncrush->HistoryBuffer)); + + ncrush->HistoryOffset = 0; + ncrush->HistoryPtr = &(ncrush->HistoryBuffer[ncrush->HistoryOffset]); + } + + return ncrush; +} + +void ncrush_context_free(NCRUSH_CONTEXT* ncrush) +{ + if (ncrush) + { + BitStream_Free(ncrush->bs); + + free(ncrush); + } +} diff --git a/libfreerdp/codec/test/CMakeLists.txt b/libfreerdp/codec/test/CMakeLists.txt index 62d358883..0eeb205a0 100644 --- a/libfreerdp/codec/test/CMakeLists.txt +++ b/libfreerdp/codec/test/CMakeLists.txt @@ -7,6 +7,7 @@ set(${MODULE_PREFIX}_DRIVER ${MODULE_NAME}.c) set(${MODULE_PREFIX}_TESTS TestFreeRDPRegion.c TestFreeRDPCodecMppc.c + TestFreeRDPCodecNCrush.c TestFreeRDPCodecPlanar.c TestFreeRDPCodecRemoteFX.c) diff --git a/libfreerdp/codec/test/TestFreeRDPCodecNCrush.c b/libfreerdp/codec/test/TestFreeRDPCodecNCrush.c new file mode 100644 index 000000000..c6ed54b7a --- /dev/null +++ b/libfreerdp/codec/test/TestFreeRDPCodecNCrush.c @@ -0,0 +1,9 @@ +#include +#include + +#include + +int TestFreeRDPCodecNCrush(int argc, char* argv[]) +{ + return 0; +}