mirror of
https://github.com/Xevion/easy7zip.git
synced 2025-12-14 02:11:40 -06:00
Update Lizard - use internal HUF and FSE entropy
- AdjustLiz.sh fixes some double defines with zstd of lizard - lizard uses it's own entropy lib again - this will fix #302 Signed-off-by: Tino Reichardt <milky-7zip@mcmilk.de>
This commit is contained in:
@@ -49,17 +49,8 @@
|
||||
#endif
|
||||
#endif
|
||||
#include "lizard_compress_lz4.h"
|
||||
#include "../zstd/huf.h"
|
||||
#include "huf.h"
|
||||
|
||||
#define HUF_WORKSPACE_SIZE_U32 (HUF_WORKSPACE_SIZE / 4)
|
||||
static inline size_t HUF_compress(void* dst, size_t dstSize, const void* src, size_t srcSize)
|
||||
{
|
||||
unsigned workSpace[HUF_WORKSPACE_SIZE_U32];
|
||||
return HUF_compress1X_repeat(dst, dstSize, src, srcSize,
|
||||
HUF_SYMBOLVALUE_MAX, HUF_TABLELOG_DEFAULT,
|
||||
workSpace, sizeof(workSpace),
|
||||
NULL, NULL, 0);
|
||||
}
|
||||
|
||||
/* *************************************
|
||||
* Local Macros
|
||||
@@ -154,7 +145,7 @@ FORCE_INLINE int Lizard_writeStream(int useHuff, Lizard_stream_t* ctx, BYTE* str
|
||||
int useHuffBuf;
|
||||
if (*op + 6 > oend) { LIZARD_LOG_COMPRESS("*op[%p] + 6 > oend[%p]\n", *op, oend); return -1; }
|
||||
|
||||
useHuffBuf = ((size_t)(oend - (*op + 6)) < HUF_compressBound(streamLen));
|
||||
useHuffBuf = ((size_t)(oend - (*op + 6)) < LIZ_HUF_compressBound(streamLen));
|
||||
if (useHuffBuf) {
|
||||
if (streamLen > LIZARD_BLOCK_SIZE) { LIZARD_LOG_COMPRESS("streamLen[%d] > LIZARD_BLOCK_SIZE\n", streamLen); return -1; }
|
||||
ctx->comprStreamLen = (U32)HUF_compress(ctx->huffBase, ctx->huffEnd - ctx->huffBase, streamPtr, streamLen);
|
||||
@@ -162,7 +153,7 @@ FORCE_INLINE int Lizard_writeStream(int useHuff, Lizard_stream_t* ctx, BYTE* str
|
||||
ctx->comprStreamLen = (U32)HUF_compress(*op + 6, oend - (*op + 6), streamPtr, streamLen);
|
||||
}
|
||||
|
||||
if (!HUF_isError(ctx->comprStreamLen)) {
|
||||
if (!LIZ_HUF_isError(ctx->comprStreamLen)) {
|
||||
if (ctx->comprStreamLen > 0 && (LIZARD_MINIMAL_HUFF_GAIN(ctx->comprStreamLen) < streamLen)) { /* compressible */
|
||||
MEM_writeLE24(*op, streamLen);
|
||||
MEM_writeLE24(*op+3, ctx->comprStreamLen);
|
||||
@@ -174,7 +165,7 @@ FORCE_INLINE int Lizard_writeStream(int useHuff, Lizard_stream_t* ctx, BYTE* str
|
||||
LIZARD_LOG_COMPRESS("HUF_compress streamLen=%d comprStreamLen=%d\n", (int)streamLen, (int)ctx->comprStreamLen);
|
||||
return 1;
|
||||
} else { LIZARD_LOG_COMPRESS("HUF_compress ERROR comprStreamLen=%d streamLen=%d\n", (int)ctx->comprStreamLen, (int)streamLen); }
|
||||
} else { LIZARD_LOG_COMPRESS("HUF_compress ERROR %d: %s\n", (int)ctx->comprStreamLen, HUF_getErrorName(ctx->comprStreamLen)); }
|
||||
} else { LIZARD_LOG_COMPRESS("HUF_compress ERROR %d: %s\n", (int)ctx->comprStreamLen, LIZ_HUF_getErrorName(ctx->comprStreamLen)); }
|
||||
#else
|
||||
LIZARD_LOG_COMPRESS("compiled with LIZARD_NO_HUFFMAN\n");
|
||||
(void)ctx;
|
||||
@@ -401,6 +392,7 @@ Lizard_stream_t* Lizard_initStream(Lizard_stream_t* ctx, int compressionLevel)
|
||||
Lizard_stream_t* Lizard_createStream(int compressionLevel)
|
||||
{
|
||||
Lizard_stream_t* ctx = Lizard_initStream(NULL, compressionLevel);
|
||||
if (ctx) ctx->base = NULL;
|
||||
return ctx;
|
||||
}
|
||||
|
||||
@@ -438,7 +430,7 @@ int Lizard_loadDict(Lizard_stream_t* Lizard_streamPtr, const char* dictionary, i
|
||||
dictionary += dictSize - LIZARD_DICT_SIZE;
|
||||
dictSize = LIZARD_DICT_SIZE;
|
||||
}
|
||||
Lizard_init (ctxPtr, (const BYTE*)dictionary);
|
||||
Lizard_init(ctxPtr, (const BYTE*)dictionary);
|
||||
if (dictSize >= HASH_UPDATE_LIMIT) Lizard_Insert (ctxPtr, (const BYTE*)dictionary + (dictSize - (HASH_UPDATE_LIMIT-1)));
|
||||
ctxPtr->end = (const BYTE*)dictionary + dictSize;
|
||||
return dictSize;
|
||||
@@ -559,8 +551,8 @@ int Lizard_compress_continue (Lizard_stream_t* ctxPtr,
|
||||
const char* source, char* dest,
|
||||
int inputSize, int maxOutputSize)
|
||||
{
|
||||
/* auto-init if forgotten */
|
||||
if (ctxPtr->base == NULL) Lizard_init (ctxPtr, (const BYTE*) source);
|
||||
/* auto-init if required */
|
||||
if (ctxPtr->base == NULL) Lizard_init(ctxPtr, (const BYTE*) source);
|
||||
|
||||
/* Check overflow */
|
||||
if ((size_t)(ctxPtr->end - ctxPtr->base) > 2 GB) {
|
||||
@@ -595,7 +587,7 @@ int Lizard_compress_extState (void* state, const char* src, char* dst, int srcSi
|
||||
|
||||
/* initialize stream */
|
||||
Lizard_initStream(ctx, compressionLevel);
|
||||
Lizard_init ((Lizard_stream_t*)state, (const BYTE*)src);
|
||||
Lizard_init((Lizard_stream_t*)state, (const BYTE*)src);
|
||||
|
||||
return Lizard_compress_generic (state, src, dst, srcSize, maxDstSize);
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user