Skip to content

Commit

Permalink
Merge pull request #86 from Cyan4973/dev
Browse files Browse the repository at this point in the history
0.4.2
  • Loading branch information
Cyan4973 committed Dec 2, 2015
2 parents a2e5f74 + 6a2f032 commit a174fb1
Show file tree
Hide file tree
Showing 8 changed files with 52 additions and 18 deletions.
2 changes: 1 addition & 1 deletion Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,7 @@
# ################################################################

# Version number
export VERSION := 0.4.0
export VERSION := 0.4.2

PRGDIR = programs
ZSTDDIR = lib
Expand Down
4 changes: 4 additions & 0 deletions NEWS
Original file line number Diff line number Diff line change
@@ -1,3 +1,7 @@
v0.4.2 :
Generic minor improvements for small blocks
Fixed : big-endian compatibility, by Peter Harris (#85)

v0.4.1
Fixed : ZSTD_LEGACY_SUPPORT=0 build mode (reported by Luben)
removed `zstd.c`
Expand Down
2 changes: 1 addition & 1 deletion lib/zstd.h
Original file line number Diff line number Diff line change
Expand Up @@ -48,7 +48,7 @@ extern "C" {
***************************************/
#define ZSTD_VERSION_MAJOR 0 /* for breaking interface changes */
#define ZSTD_VERSION_MINOR 4 /* for new (non-breaking) interface capabilities */
#define ZSTD_VERSION_RELEASE 0 /* for tweaks, bug-fixes, or development */
#define ZSTD_VERSION_RELEASE 2 /* for tweaks, bug-fixes, or development */
#define ZSTD_VERSION_NUMBER (ZSTD_VERSION_MAJOR *100*100 + ZSTD_VERSION_MINOR *100 + ZSTD_VERSION_RELEASE)
unsigned ZSTD_versionNumber (void);

Expand Down
25 changes: 14 additions & 11 deletions lib/zstd_compress.c
Original file line number Diff line number Diff line change
Expand Up @@ -100,8 +100,6 @@ static void ZSTD_resetSeqStore(seqStore_t* ssPtr)
/* *************************************
* Context memory management
***************************************/
#define WORKPLACESIZE (BLOCKSIZE*3)

struct ZSTD_CCtx_s
{
const BYTE* nextSrc; /* next block here to continue on current prefix */
Expand All @@ -113,6 +111,7 @@ struct ZSTD_CCtx_s
ZSTD_parameters params;
void* workSpace;
size_t workSpaceSize;
size_t blockSize;

seqStore_t seqStore; /* sequences storage ptrs */
U32* hashTable;
Expand Down Expand Up @@ -170,11 +169,14 @@ void ZSTD_validateParams(ZSTD_parameters* params)
static size_t ZSTD_resetCCtx_advanced (ZSTD_CCtx* zc,
ZSTD_parameters params)
{
/* note : params considered validated here */
const size_t blockSize = MIN(BLOCKSIZE, (size_t)1 << params.windowLog);

/* reserve table memory */
{
const U32 contentLog = (params.strategy == ZSTD_fast) ? 1 : params.contentLog;
const size_t tableSpace = ((1 << contentLog) + (1 << params.hashLog)) * sizeof(U32);
const size_t neededSpace = tableSpace + WORKPLACESIZE;
const size_t neededSpace = tableSpace + (3*blockSize);
if (zc->workSpaceSize < neededSpace)
{
free(zc->workSpace);
Expand All @@ -195,12 +197,13 @@ static size_t ZSTD_resetCCtx_advanced (ZSTD_CCtx* zc,
zc->dictLimit = 0;
zc->lowLimit = 0;
zc->params = params;
zc->blockSize = blockSize;
zc->seqStore.offsetStart = (U32*) (zc->seqStore.buffer);
zc->seqStore.offCodeStart = (BYTE*) (zc->seqStore.offsetStart + (BLOCKSIZE>>2));
zc->seqStore.litStart = zc->seqStore.offCodeStart + (BLOCKSIZE>>2);
zc->seqStore.litLengthStart = zc->seqStore.litStart + BLOCKSIZE;
zc->seqStore.matchLengthStart = zc->seqStore.litLengthStart + (BLOCKSIZE>>2);
zc->seqStore.dumpsStart = zc->seqStore.matchLengthStart + (BLOCKSIZE>>2);
zc->seqStore.offCodeStart = (BYTE*) (zc->seqStore.offsetStart + (blockSize>>2));
zc->seqStore.litStart = zc->seqStore.offCodeStart + (blockSize>>2);
zc->seqStore.litLengthStart = zc->seqStore.litStart + blockSize;
zc->seqStore.matchLengthStart = zc->seqStore.litLengthStart + (blockSize>>2);
zc->seqStore.dumpsStart = zc->seqStore.matchLengthStart + (blockSize>>2);

return 0;
}
Expand Down Expand Up @@ -620,7 +623,7 @@ static unsigned ZSTD_NbCommonBytes (register size_t val)
}
else /* Big Endian CPU */
{
if (MEM_32bits())
if (MEM_64bits())
{
# if defined(_MSC_VER) && defined(_WIN64)
unsigned long r = 0;
Expand Down Expand Up @@ -1919,7 +1922,7 @@ static size_t ZSTD_compress_generic (ZSTD_CCtx* ctxPtr,
void* dst, size_t maxDstSize,
const void* src, size_t srcSize)
{
size_t blockSize = BLOCKSIZE;
size_t blockSize = ctxPtr->blockSize;
size_t remaining = srcSize;
const BYTE* ip = (const BYTE*)src;
BYTE* const ostart = (BYTE*)dst;
Expand Down Expand Up @@ -2036,7 +2039,7 @@ size_t ZSTD_compressBegin_advanced(ZSTD_CCtx* ctx,
ZSTD_parameters ZSTD_getParams(int compressionLevel, U64 srcSizeHint)
{
ZSTD_parameters result;
int tableID = ((srcSizeHint-1) <= 128 KB); /* intentional underflow for srcSizeHint == 0 */
int tableID = ((srcSizeHint-1) <= 128 KB) + ((srcSizeHint-1) <= 16 KB); /* intentional underflow for srcSizeHint == 0 */
if (compressionLevel<=0) compressionLevel = 1;
if (compressionLevel > ZSTD_MAX_CLEVEL) compressionLevel = ZSTD_MAX_CLEVEL;
result = ZSTD_defaultParameters[tableID][compressionLevel];
Expand Down
30 changes: 27 additions & 3 deletions lib/zstd_static.h
Original file line number Diff line number Diff line change
Expand Up @@ -169,9 +169,9 @@ size_t ZSTD_decompressContinue(ZSTD_DCtx* dctx, void* dst, size_t maxDstSize, co
* Pre-defined compression levels
***************************************/
#define ZSTD_MAX_CLEVEL 20
static const ZSTD_parameters ZSTD_defaultParameters[2][ZSTD_MAX_CLEVEL+1] = {
static const ZSTD_parameters ZSTD_defaultParameters[3][ZSTD_MAX_CLEVEL+1] = {
{ /* "default" */
/* W, C, H, S, L, strat */
/* W, C, H, S, L, strat */
{ 0, 18, 12, 12, 1, 4, ZSTD_fast }, /* level 0 - never used */
{ 0, 19, 13, 14, 1, 7, ZSTD_fast }, /* level 1 */
{ 0, 19, 15, 16, 1, 6, ZSTD_fast }, /* level 2 */
Expand All @@ -195,7 +195,7 @@ static const ZSTD_parameters ZSTD_defaultParameters[2][ZSTD_MAX_CLEVEL+1] = {
{ 0, 26, 27, 25, 9, 5, ZSTD_btlazy2 }, /* level 20 */
},
{ /* for srcSize <= 128 KB */
/* W, C, H, S, L, strat */
/* W, C, H, S, L, strat */
{ 0, 17, 12, 12, 1, 4, ZSTD_fast }, /* level 0 - never used */
{ 0, 17, 12, 13, 1, 6, ZSTD_fast }, /* level 1 */
{ 0, 17, 15, 16, 1, 5, ZSTD_fast }, /* level 2 */
Expand All @@ -218,6 +218,30 @@ static const ZSTD_parameters ZSTD_defaultParameters[2][ZSTD_MAX_CLEVEL+1] = {
{ 0, 17, 18, 16, 10, 4, ZSTD_btlazy2 }, /* level 19 */
{ 0, 17, 18, 18, 12, 4, ZSTD_btlazy2 }, /* level 20 */
},
{ /* for srcSize <= 16 KB */
/* W, C, H, S, L, strat */
{ 0, 0, 0, 0, 0, 0, ZSTD_fast }, /* level 0 - never used */
{ 0, 14, 14, 14, 1, 4, ZSTD_fast }, /* level 1 */
{ 0, 14, 14, 16, 1, 4, ZSTD_fast }, /* level 1 */
{ 0, 14, 14, 14, 5, 4, ZSTD_greedy }, /* level 3 */
{ 0, 14, 14, 14, 8, 4, ZSTD_greedy }, /* level 4 */
{ 0, 14, 11, 14, 6, 4, ZSTD_lazy }, /* level 5 */
{ 0, 14, 14, 13, 6, 5, ZSTD_lazy }, /* level 6 */
{ 0, 14, 14, 14, 7, 6, ZSTD_lazy }, /* level 7 */
{ 0, 14, 14, 14, 8, 4, ZSTD_lazy }, /* level 8 */
{ 0, 14, 14, 15, 9, 4, ZSTD_lazy }, /* level 9 */
{ 0, 14, 14, 15, 10, 4, ZSTD_lazy }, /* level 10 */
{ 0, 14, 15, 15, 6, 4, ZSTD_btlazy2 }, /* level 11 */
{ 0, 14, 15, 15, 7, 4, ZSTD_btlazy2 }, /* level 12 */
{ 0, 14, 15, 15, 8, 4, ZSTD_btlazy2 }, /* level 13 */
{ 0, 14, 15, 15, 9, 4, ZSTD_btlazy2 }, /* level 14 */
{ 0, 14, 15, 15, 10, 4, ZSTD_btlazy2 }, /* level 15 */
{ 0, 14, 15, 15, 11, 4, ZSTD_btlazy2 }, /* level 16 */
{ 0, 14, 15, 15, 12, 4, ZSTD_btlazy2 }, /* level 17 */
{ 0, 14, 15, 15, 13, 4, ZSTD_btlazy2 }, /* level 18 */
{ 0, 14, 15, 15, 14, 4, ZSTD_btlazy2 }, /* level 19 */
{ 0, 14, 15, 15, 15, 4, ZSTD_btlazy2 }, /* level 20 */
},
};


Expand Down
2 changes: 1 addition & 1 deletion programs/Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,7 @@
# fullbench32: Same as fullbench, but forced to compile in 32-bits mode
# ##########################################################################

VERSION?= 0.4.0
VERSION?= 0.4.2

DESTDIR?=
PREFIX ?= /usr/local
Expand Down
3 changes: 3 additions & 0 deletions programs/paramgrill.c
Original file line number Diff line number Diff line change
Expand Up @@ -681,6 +681,8 @@ static void BMK_selectRandomStart(
/* totally random entry */
ZSTD_parameters p;
potentialRandomParams(&p, 1);
p.srcSize = srcSize;
ZSTD_validateParams(&p);
playAround(f, winners, p, srcBuffer, srcSize, ctx);
}
else
Expand Down Expand Up @@ -734,6 +736,7 @@ static void BMK_benchMem(void* srcBuffer, size_t srcSize)
for (i=1; i<=maxSeeds; i++)
{
params = ZSTD_getParams(i, blockSize);
ZSTD_validateParams(&params);
BMK_seed(winners, params, srcBuffer, srcSize, ctx);
}
}
Expand Down
2 changes: 1 addition & 1 deletion programs/zstdcli.c
Original file line number Diff line number Diff line change
Expand Up @@ -70,7 +70,7 @@
**************************************/
#define COMPRESSOR_NAME "zstd command line interface"
#ifndef ZSTD_VERSION
# define ZSTD_VERSION "v0.4.0"
# define ZSTD_VERSION "v0.4.2"
#endif
#define AUTHOR "Yann Collet"
#define WELCOME_MESSAGE "*** %s %i-bits %s, by %s (%s) ***\n", COMPRESSOR_NAME, (int)(sizeof(void*)*8), ZSTD_VERSION, AUTHOR, __DATE__
Expand Down

0 comments on commit a174fb1

Please sign in to comment.