From 19d3c36f1c730db0051491eb20d78a84503242e9 Mon Sep 17 00:00:00 2001 From: Yann Collet Date: Sat, 9 Aug 2014 23:14:26 +0200 Subject: Revert "Introduced "Continuous Block Mode" (CBM) naming" This reverts commit 53f1fbe062c6904b06d7181ccdb5a8fd6f883f15. --- lz4.c | 6 +++--- lz4.h | 18 +++++++++++------- lz4hc.c | 6 +++--- lz4hc.h | 45 ++++++++++++++++++++------------------------- 4 files changed, 37 insertions(+), 38 deletions(-) diff --git a/lz4.c b/lz4.c index 1c73e73..d58be27 100644 --- a/lz4.c +++ b/lz4.c @@ -683,7 +683,7 @@ int LZ4_compress_limitedOutput(const char* source, char* dest, int inputSize, in /***************************************** - Experimental Continuous Block Mode + Experimental : Streaming functions *****************************************/ /* @@ -1177,7 +1177,7 @@ int LZ4_uncompress (const char* source, char* dest, int outputSize) { return LZ4 int LZ4_uncompress_unknownOutputSize (const char* source, char* dest, int isize, int maxOutputSize) { return LZ4_decompress_safe(source, dest, isize, maxOutputSize); } -/* Obsolete CBM functions */ +/* Obsolete Streaming functions */ int LZ4_sizeofStreamState() { return LZ4_STREAMSIZE; } @@ -1236,7 +1236,7 @@ int LZ4_compress_limitedOutput_withState (void* state, const char* source, char* return LZ4_compress_generic(state, source, dest, inputSize, maxOutputSize, limitedOutput, LZ4_64BITS ? byU32 : byPtr, noDict, noDictIssue); } -/* Obsolete CBM decompression functions */ +/* Obsolete streaming decompression functions */ int LZ4_decompress_safe_withPrefix64k(const char* source, char* dest, int compressedSize, int maxOutputSize) { diff --git a/lz4.h b/lz4.h index 42c6ff9..f8327f0 100644 --- a/lz4.h +++ b/lz4.h @@ -170,11 +170,7 @@ int LZ4_decompress_safe_partial (const char* source, char* dest, int compressedS /*********************************************** - Experimental Continuous Block Mode - - These functions allow the compression of continuous blocks, - where each block benefits from prior 64 KB within preceding blocks to achieve better compression ratio. - A flow of multiple continuous blocks is called a "stream". + Experimental Streaming Compression Functions ***********************************************/ #define LZ4_STREAMSIZE_U32 ((1 << (LZ4_MEMORY_USAGE-2)) + 8) @@ -237,7 +233,7 @@ int LZ4_saveDict (LZ4_stream_t* LZ4_stream, char* safeBuffer, int dictSize); /************************************************ - Experimental CBM Decompression Functions + Experimental Streaming Decompression Functions ************************************************/ #define LZ4_STREAMDECODESIZE_U32 4 @@ -305,8 +301,16 @@ It is highly recommended to stop using these functions and migrated to newer one /* int LZ4_uncompress (const char* source, char* dest, int outputSize); */ /* int LZ4_uncompress_unknownOutputSize (const char* source, char* dest, int isize, int maxOutputSize); */ +/* + * If you prefer dynamic allocation methods, + * LZ4_createStreamDecode() + * provides a pointer (void*) towards an initialized LZ4_streamDecode_t structure. + * LZ4_free just frees it. + */ +/* void* LZ4_createStreamDecode(void); */ +/*int LZ4_free (void* LZ4_stream); yes, it's the same one as for compression */ -/* Obsolete CBM functions; use new CBM interface whenever possible */ +/* Obsolete streaming functions; use new streaming interface whenever possible */ void* LZ4_create (const char* inputBuffer); int LZ4_sizeofStreamState(void); int LZ4_resetStreamState(void* state, const char* inputBuffer); diff --git a/lz4hc.c b/lz4hc.c index cff5880..7de9811 100644 --- a/lz4hc.c +++ b/lz4hc.c @@ -870,9 +870,9 @@ int LZ4_compressHC_limitedOutput_withStateHC (void* state, const char* source, c { return LZ4_compressHC2_limitedOutput_withStateHC (state, source, dest, inputSize, maxOutputSize, 0); } -/************************************** - Experimental Continuous Block Mode -**************************************/ +/**************************** + Stream functions +****************************/ int LZ4_compressHC_continue (void* LZ4HC_Data, const char* source, char* dest, int inputSize) { diff --git a/lz4hc.h b/lz4hc.h index ed23f08..deb2394 100644 --- a/lz4hc.h +++ b/lz4hc.h @@ -101,13 +101,10 @@ They just use the externally allocated memory area instead of allocating their o */ -/*********************************************** - Experimental Continuous Block Mode - - These functions allow the compression of continuous blocks, - where each block benefits from prior 64 KB within preceding blocks to achieve better compression ratio. -***********************************************/ -/* Note : these CBM functions follow the older, more rigid, model */ +/************************************** + Streaming Functions +**************************************/ +/* Note : these streaming functions still follows the older model */ void* LZ4_createHC (const char* inputBuffer); int LZ4_compressHC_continue (void* LZ4HC_Data, const char* source, char* dest, int inputSize); int LZ4_compressHC_limitedOutput_continue (void* LZ4HC_Data, const char* source, char* dest, int inputSize, int maxOutputSize); @@ -118,33 +115,28 @@ int LZ4_compressHC2_continue (void* LZ4HC_Data, const char* source, char* dest int LZ4_compressHC2_limitedOutput_continue (void* LZ4HC_Data, const char* source, char* dest, int inputSize, int maxOutputSize, int compressionLevel); /* -Here is how it works : -First, start by creating the LZ4HC Data Structure, thanks to the function : +These functions allow the compression of dependent blocks, where each block benefits from prior 64 KB within preceding blocks. +In order to achieve this, it is necessary to start creating the LZ4HC Data Structure, thanks to the function : void* LZ4_createHC (const char* inputBuffer); - The result of the function is the (void*) pointer on the LZ4HC Data Structure. This pointer will be needed in all other functions. If the pointer returned is NULL, then the allocation has failed, and compression must be aborted. -The parameter 'const char* inputBuffer' must provide the beginning of input buffer. +The only parameter 'const char* inputBuffer' must, obviously, point at the beginning of input buffer. The input buffer must be already allocated, and size at least 192KB. -You will have to start your compression at this address. +'inputBuffer' will also be the 'const char* source' of the first block. All blocks are expected to lay next to each other within the input buffer, starting from 'inputBuffer'. To compress each block, use either LZ4_compressHC_continue() or LZ4_compressHC_limitedOutput_continue(). Their behavior are identical to LZ4_compressHC() or LZ4_compressHC_limitedOutput(), -but require the LZ4HC Data Structure as their first argument, -and check that each block starts right after the previous one. +but require the LZ4HC Data Structure as their first argument, and check that each block starts right after the previous one. If next block does not begin immediately after the previous one, the compression will fail (return 0). -When it's no longer possible to lay the next block after the previous one (no more space left into input buffer), -you can free some space by calling : - +When it's no longer possible to lay the next block after the previous one (not enough space left into input buffer), a call to : char* LZ4_slideInputBufferHC(void* LZ4HC_Data); - -It will typically copy the latest 64KB of input at the beginning of input buffer. -Note that, for this function to work properly, the minimum size of input buffer must be 192KB. -==> The function result provides the memory position where the next input data block must be copied. +must be performed. It will typically copy the latest 64KB of input at the beginning of input buffer. +Note that, for this function to work properly, minimum size of an input buffer must be 192KB. +==> The memory position where the next input data block must start is provided as the result of the function. Compression can then resume, using LZ4_compressHC_continue() or LZ4_compressHC_limitedOutput_continue(), as usual. @@ -156,7 +148,6 @@ int LZ4_resetStreamStateHC(void* state, const char* inputBuffer); /* These functions achieve the same result as : - void* LZ4_createHC (const char* inputBuffer); They are provided here to allow the user program to allocate memory using its own routines. @@ -164,11 +155,15 @@ They are provided here to allow the user program to allocate memory using its ow To know how much space must be allocated, use LZ4_sizeofStreamStateHC(); Note also that space must be aligned for pointers (32 or 64 bits). -Once space is allocated, you can reference it using a 'void*' pointer, which will be become the LZ4 HC Data Structure. -You can then follow previous instructions, using this pointer instead. +Once space is allocated, you must initialize it using : LZ4_resetStreamStateHC(void* state, const char* inputBuffer); +void* state is a pointer to the space allocated. +It must be aligned for pointers (32 or 64 bits), and be large enough. +The parameter 'const char* inputBuffer' must, obviously, point at the beginning of input buffer. +The input buffer must be already allocated, and size at least 192KB. +'inputBuffer' will also be the 'const char* source' of the first block. The same space can be re-used multiple times, just by initializing it each time with LZ4_resetStreamState(). -return value of LZ4_resetStreamStateHC() must be 0 if OK. +return value of LZ4_resetStreamStateHC() must be 0 is OK. Any other value means there was an error (typically, state is not aligned for pointers (32 or 64 bits)). */ -- cgit v0.12