favorDecSpeed feature can be triggered from lz4frame
and lz4hc.
This commit is contained in:
parent
1148173c5d
commit
3792d00168
@ -612,6 +612,9 @@ size_t LZ4F_compressBegin_usingCDict(LZ4F_cctx* cctxPtr,
|
||||
/* frame init only for blockLinked : blockIndependent will be init at each block */
|
||||
LZ4F_applyCDict(cctxPtr->lz4CtxPtr, cdict, cctxPtr->prefs.compressionLevel);
|
||||
}
|
||||
if (preferencesPtr->compressionLevel >= LZ4HC_CLEVEL_MIN) {
|
||||
LZ4_favorDecompressionSpeed(cctxPtr->lz4CtxPtr, preferencesPtr->favorDecSpeed);
|
||||
}
|
||||
|
||||
/* Magic Number */
|
||||
LZ4F_writeLE32(dstPtr, LZ4F_MAGICNUMBER);
|
||||
|
@ -173,13 +173,14 @@ typedef struct {
|
||||
|
||||
/*! LZ4F_preferences_t :
|
||||
* makes it possible to supply detailed compression parameters to the stream interface.
|
||||
* It's not required to set all fields, as long as the structure was initially memset() to zero.
|
||||
* Structure is presumed initially memset() to zero, representing default settings.
|
||||
* All reserved fields must be set to zero. */
|
||||
typedef struct {
|
||||
LZ4F_frameInfo_t frameInfo;
|
||||
int compressionLevel; /* 0: default (fast mode); values > LZ4HC_CLEVEL_MAX count as LZ4HC_CLEVEL_MAX; values < 0 trigger "fast acceleration" */
|
||||
unsigned autoFlush; /* 1 == always flush, to reduce usage of internal buffers */
|
||||
unsigned reserved[4]; /* must be zero for forward compatibility */
|
||||
int compressionLevel; /* 0: default (fast mode); values > LZ4HC_CLEVEL_MAX count as LZ4HC_CLEVEL_MAX; values < 0 trigger "fast acceleration" */
|
||||
unsigned autoFlush; /* 1: always flush, to reduce usage of internal buffers */
|
||||
unsigned favorDecSpeed; /* 1: parser favors decompression speed vs compression ratio. Only works for high compression modes (>= LZ4LZ4HC_CLEVEL_OPT_MIN) */ /* >= v1.8.2 */
|
||||
unsigned reserved[3]; /* must be zero for forward compatibility */
|
||||
} LZ4F_preferences_t;
|
||||
|
||||
LZ4FLIB_API int LZ4F_compressionLevel_max(void);
|
||||
|
@ -876,6 +876,11 @@ void LZ4_setCompressionLevel(LZ4_streamHC_t* LZ4_streamHCPtr, int compressionLev
|
||||
LZ4_streamHCPtr->internal_donotuse.compressionLevel = compressionLevel;
|
||||
}
|
||||
|
||||
void LZ4_favorDecompressionSpeed(LZ4_streamHC_t* LZ4_streamHCPtr, int favor)
|
||||
{
|
||||
LZ4_streamHCPtr->internal_donotuse.favorDecSpeed = (favor!=0);
|
||||
}
|
||||
|
||||
int LZ4_loadDictHC (LZ4_streamHC_t* LZ4_streamHCPtr, const char* dictionary, int dictSize)
|
||||
{
|
||||
LZ4HC_CCtx_internal* const ctxPtr = &LZ4_streamHCPtr->internal_donotuse;
|
||||
@ -1120,7 +1125,7 @@ static int LZ4HC_compress_optimal (
|
||||
const limitedOutput_directive limit,
|
||||
int const fullUpdate,
|
||||
const dictCtx_directive dict,
|
||||
HCfavor_e favorDecSpeed
|
||||
const HCfavor_e favorDecSpeed
|
||||
)
|
||||
{
|
||||
#define TRAILING_LITERALS 3
|
||||
@ -1136,7 +1141,6 @@ static int LZ4HC_compress_optimal (
|
||||
BYTE* oend = op + dstCapacity;
|
||||
|
||||
/* init */
|
||||
favorDecSpeed = favorCompressionRatio;
|
||||
DEBUGLOG(5, "LZ4HC_compress_optimal");
|
||||
*srcSizePtr = 0;
|
||||
if (limit == limitedDestSize) oend -= LASTLITERALS; /* Hack for support LZ4 format restriction */
|
||||
|
18
lib/lz4hc.h
18
lib/lz4hc.h
@ -152,7 +152,8 @@ struct LZ4HC_CCtx_internal
|
||||
uint32_t dictLimit; /* below that point, need extDict */
|
||||
uint32_t lowLimit; /* below that point, no more dict */
|
||||
uint32_t nextToUpdate; /* index from which to continue dictionary update */
|
||||
int compressionLevel;
|
||||
short compressionLevel;
|
||||
short favorDecSpeed;
|
||||
const LZ4HC_CCtx_internal* dictCtx;
|
||||
};
|
||||
|
||||
@ -169,7 +170,8 @@ struct LZ4HC_CCtx_internal
|
||||
unsigned int dictLimit; /* below that point, need extDict */
|
||||
unsigned int lowLimit; /* below that point, no more dict */
|
||||
unsigned int nextToUpdate; /* index from which to continue dictionary update */
|
||||
int compressionLevel;
|
||||
short compressionLevel;
|
||||
short favorDecSpeed;
|
||||
const LZ4HC_CCtx_internal* dictCtx;
|
||||
};
|
||||
|
||||
@ -253,9 +255,9 @@ LZ4_DEPRECATED("use LZ4_resetStreamHC() instead") LZ4LIB_API int LZ4_resetStr
|
||||
* `srcSizePtr` : value will be updated to indicate how much bytes were read from `src`
|
||||
*/
|
||||
int LZ4_compress_HC_destSize(void* LZ4HC_Data,
|
||||
const char* src, char* dst,
|
||||
int* srcSizePtr, int targetDstSize,
|
||||
int compressionLevel);
|
||||
const char* src, char* dst,
|
||||
int* srcSizePtr, int targetDstSize,
|
||||
int compressionLevel);
|
||||
|
||||
/*! LZ4_compress_HC_continue_destSize() : v1.8.0 (experimental)
|
||||
* Similar as LZ4_compress_HC_continue(),
|
||||
@ -275,6 +277,12 @@ int LZ4_compress_HC_continue_destSize(LZ4_streamHC_t* LZ4_streamHCPtr,
|
||||
*/
|
||||
void LZ4_setCompressionLevel(LZ4_streamHC_t* LZ4_streamHCPtr, int compressionLevel);
|
||||
|
||||
/*! LZ4_favorDecompressionSpeed() : v1.8.2 (experimental)
|
||||
* Parser will select decisions favoring decompression over compression ratio.
|
||||
* Only work at highest compression settings (level >= LZ4HC_CLEVEL_OPT_MIN)
|
||||
*/
|
||||
void LZ4_favorDecompressionSpeed(LZ4_streamHC_t* LZ4_streamHCPtr, int favor);
|
||||
|
||||
/*! LZ4_resetStreamHC_fast() :
|
||||
* When an LZ4_streamHC_t is known to be in a internally coherent state,
|
||||
* it can often be prepared for a new compression with almost no work, only
|
||||
|
Loading…
Reference in New Issue
Block a user