Skip to content

Commit 9c57b42

Browse files
committed
Merge pull request #44 from Cyan4973/dev
Dev
2 parents 77dce3e + be50aaa commit 9c57b42

File tree

11 files changed

+186
-130
lines changed

11 files changed

+186
-130
lines changed

Makefile

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -32,7 +32,7 @@
3232
# ################################################################
3333

3434
# Version number
35-
export VERSION=0.1.1
35+
export VERSION := 0.1.2
3636

3737
PRGDIR = programs
3838
ZSTDDIR = lib

NEWS

Lines changed: 8 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,9 @@
1-
r0
2-
initial release
1+
v0.1.2
2+
3+
v0.1.1
4+
fix compression bug
5+
detects write-flush errors
6+
7+
v0.1.0
8+
first release
39

lib/Makefile

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -32,7 +32,7 @@
3232
# ################################################################
3333

3434
# Version numbers
35-
VERSION?= 0.1.1
35+
VERSION?= 0.1.2
3636
LIBVER_MAJOR=`sed -n '/define ZSTD_VERSION_MAJOR/s/.*[[:blank:]]\([0-9][0-9]*\).*/\1/p' < zstd.h`
3737
LIBVER_MINOR=`sed -n '/define ZSTD_VERSION_MINOR/s/.*[[:blank:]]\([0-9][0-9]*\).*/\1/p' < zstd.h`
3838
LIBVER_PATCH=`sed -n '/define ZSTD_VERSION_RELEASE/s/.*[[:blank:]]\([0-9][0-9]*\).*/\1/p' < zstd.h`
@@ -41,8 +41,7 @@ LIBVER = $(LIBVER_MAJOR).$(LIBVER_MINOR).$(LIBVER_PATCH)
4141
DESTDIR?=
4242
PREFIX ?= /usr/local
4343
CFLAGS ?= -O3
44-
CFLAGS += -std=c99 -Wall -Wextra -Wundef -Wshadow -Wcast-align -Wstrict-prototypes
45-
LDFLAGS = -I.
44+
CFLAGS += -I. -std=c99 -Wall -Wextra -Wundef -Wshadow -Wcast-align -Wstrict-prototypes
4645
FLAGS = $(CPPFLAGS) $(CFLAGS) $(LDFLAGS) $(MOREFLAGS)
4746

4847
LIBDIR ?= $(PREFIX)/lib

lib/fse.c

Lines changed: 30 additions & 30 deletions
Original file line numberDiff line numberDiff line change
@@ -914,8 +914,8 @@ size_t FSE_readNCount (short* normalizedCounter, unsigned* maxSVPtr, unsigned* t
914914
else
915915
{
916916
bitCount -= (int)(8 * (iend - 4 - ip));
917-
ip = iend - 4;
918-
}
917+
ip = iend - 4;
918+
}
919919
bitStream = FSE_readLE32(ip) >> (bitCount & 31);
920920
}
921921
}
@@ -967,20 +967,20 @@ void FSE_freeCTable (FSE_CTable* ct)
967967
/* provides the minimum logSize to safely represent a distribution */
968968
static unsigned FSE_minTableLog(size_t srcSize, unsigned maxSymbolValue)
969969
{
970-
U32 minBitsSrc = FSE_highbit32((U32)(srcSize - 1)) + 1;
971-
U32 minBitsSymbols = FSE_highbit32(maxSymbolValue) + 2;
972-
U32 minBits = minBitsSrc < minBitsSymbols ? minBitsSrc : minBitsSymbols;
973-
return minBits;
970+
U32 minBitsSrc = FSE_highbit32((U32)(srcSize - 1)) + 1;
971+
U32 minBitsSymbols = FSE_highbit32(maxSymbolValue) + 2;
972+
U32 minBits = minBitsSrc < minBitsSymbols ? minBitsSrc : minBitsSymbols;
973+
return minBits;
974974
}
975975

976976
unsigned FSE_optimalTableLog(unsigned maxTableLog, size_t srcSize, unsigned maxSymbolValue)
977977
{
978-
U32 maxBitsSrc = FSE_highbit32((U32)(srcSize - 1)) - 2;
978+
U32 maxBitsSrc = FSE_highbit32((U32)(srcSize - 1)) - 2;
979979
U32 tableLog = maxTableLog;
980-
U32 minBits = FSE_minTableLog(srcSize, maxSymbolValue);
980+
U32 minBits = FSE_minTableLog(srcSize, maxSymbolValue);
981981
if (tableLog==0) tableLog = FSE_DEFAULT_TABLELOG;
982-
if (maxBitsSrc < tableLog) tableLog = maxBitsSrc; /* Accuracy can be reduced */
983-
if (minBits > tableLog) tableLog = minBits; /* Need a minimum to safely represent all symbol values */
982+
if (maxBitsSrc < tableLog) tableLog = maxBitsSrc; /* Accuracy can be reduced */
983+
if (minBits > tableLog) tableLog = minBits; /* Need a minimum to safely represent all symbol values */
984984
if (tableLog < FSE_MIN_TABLELOG) tableLog = FSE_MIN_TABLELOG;
985985
if (tableLog > FSE_MAX_TABLELOG) tableLog = FSE_MAX_TABLELOG;
986986
return tableLog;
@@ -1569,8 +1569,8 @@ size_t FSE_readBitsFast(FSE_DStream_t* bitD, U32 nbBits) /* only if nbBits >=
15691569

15701570
unsigned FSE_reloadDStream(FSE_DStream_t* bitD)
15711571
{
1572-
if (bitD->bitsConsumed > (sizeof(bitD->bitContainer)*8)) /* should never happen */
1573-
return FSE_DStream_tooFar;
1572+
if (bitD->bitsConsumed > (sizeof(bitD->bitContainer)*8)) /* should never happen */
1573+
return FSE_DStream_tooFar;
15741574

15751575
if (bitD->ptr >= bitD->start + sizeof(bitD->bitContainer))
15761576
{
@@ -1834,7 +1834,7 @@ size_t HUF_writeCTable (void* dst, size_t maxDstSize, const HUF_CElt* tree, U32
18341834
if (maxSymbolValue > (241-128)) return (size_t)-FSE_ERROR_GENERIC; /* not implemented (not possible with current format) */
18351835
if (((maxSymbolValue+1)/2) + 1 > maxDstSize) return (size_t)-FSE_ERROR_dstSize_tooSmall; /* not enough space within dst buffer */
18361836
op[0] = (BYTE)(128 /*special case*/ + 0 /* Not Compressible */ + (maxSymbolValue-1));
1837-
huffWeight[maxSymbolValue] = 0; /* to be sure it doesn't cause issue in final combination */
1837+
huffWeight[maxSymbolValue] = 0; /* to be sure it doesn't cause issue in final combination */
18381838
for (n=0; n<maxSymbolValue; n+=2)
18391839
op[(n/2)+1] = (BYTE)((huffWeight[n] << 4) + huffWeight[n+1]);
18401840
return ((maxSymbolValue+1)/2) + 1;
@@ -1878,7 +1878,7 @@ static U32 HUF_setMaxHeight(nodeElt* huffNode, U32 lastNonNull, U32 maxNbBits)
18781878
U32 rankLast[HUF_MAX_TABLELOG];
18791879
U32 currentNbBits = maxNbBits;
18801880
int pos;
1881-
memset(rankLast, 0xF0, sizeof(rankLast));
1881+
memset(rankLast, 0xF0, sizeof(rankLast));
18821882
for (pos=n ; pos >= 0; pos--)
18831883
{
18841884
if (huffNode[pos].nbBits >= currentNbBits) continue;
@@ -1917,20 +1917,20 @@ static U32 HUF_setMaxHeight(nodeElt* huffNode, U32 lastNonNull, U32 maxNbBits)
19171917
}
19181918
}
19191919

1920-
while (totalCost < 0) /* Sometimes, cost correction overshoot */
1921-
{
1922-
if (rankLast[1] == noOne) /* special case, no weight 1, let's find it back at n */
1923-
{
1924-
while (huffNode[n].nbBits == maxNbBits) n--;
1925-
huffNode[n+1].nbBits--;
1926-
rankLast[1] = n+1;
1927-
totalCost++;
1928-
continue;
1929-
}
1930-
huffNode[ rankLast[1] + 1 ].nbBits--;
1931-
rankLast[1]++;
1932-
totalCost ++;
1933-
}
1920+
while (totalCost < 0) /* Sometimes, cost correction overshoot */
1921+
{
1922+
if (rankLast[1] == noOne) /* special case, no weight 1, let's find it back at n */
1923+
{
1924+
while (huffNode[n].nbBits == maxNbBits) n--;
1925+
huffNode[n+1].nbBits--;
1926+
rankLast[1] = n+1;
1927+
totalCost++;
1928+
continue;
1929+
}
1930+
huffNode[ rankLast[1] + 1 ].nbBits--;
1931+
rankLast[1]++;
1932+
totalCost ++;
1933+
}
19341934
}
19351935
}
19361936

@@ -1981,7 +1981,7 @@ size_t HUF_buildCTable (HUF_CElt* tree, const U32* count, U32 maxSymbolValue, U3
19811981
/* safety checks */
19821982
if (maxNbBits == 0) maxNbBits = HUF_DEFAULT_TABLELOG;
19831983
if (maxSymbolValue > HUF_MAX_SYMBOL_VALUE) return (size_t)-FSE_ERROR_GENERIC;
1984-
memset(huffNode0, 0, sizeof(huffNode0));
1984+
memset(huffNode0, 0, sizeof(huffNode0));
19851985

19861986
// sort, decreasing order
19871987
HUF_sort(huffNode, count, maxSymbolValue);
@@ -2066,7 +2066,7 @@ size_t HUF_compress_usingCTable(void* dst, size_t dstSize, const void* src, size
20662066
FSE_CStream_t bitC;
20672067

20682068
/* init */
2069-
if (dstSize < 8) return 0;
2069+
if (dstSize < 8) return 0;
20702070
op += 6; /* jump Table -- could be optimized by delta / deviation */
20712071
errorCode = FSE_initCStream(&bitC, op, oend-op);
20722072
if (FSE_isError(errorCode)) return 0;

0 commit comments

Comments
 (0)