extzstd 0.1 → 0.1.1
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/HISTORY.ja +5 -0
- data/README.md +5 -5
- data/contrib/zstd/CONTRIBUTING.md +42 -0
- data/contrib/zstd/LICENSE-examples +11 -0
- data/contrib/zstd/Makefile +315 -0
- data/contrib/zstd/NEWS +261 -0
- data/contrib/zstd/PATENTS +33 -0
- data/contrib/zstd/README.md +121 -41
- data/contrib/zstd/TESTING.md +44 -0
- data/contrib/zstd/appveyor.yml +178 -0
- data/contrib/zstd/circle.yml +75 -0
- data/contrib/zstd/lib/BUCK +186 -0
- data/contrib/zstd/lib/Makefile +163 -0
- data/contrib/zstd/lib/README.md +77 -0
- data/contrib/zstd/{common → lib/common}/bitstream.h +7 -4
- data/contrib/zstd/{common → lib/common}/entropy_common.c +19 -23
- data/contrib/zstd/{common → lib/common}/error_private.c +0 -0
- data/contrib/zstd/{common → lib/common}/error_private.h +0 -0
- data/contrib/zstd/{common → lib/common}/fse.h +94 -34
- data/contrib/zstd/{common → lib/common}/fse_decompress.c +18 -19
- data/contrib/zstd/{common → lib/common}/huf.h +52 -20
- data/contrib/zstd/{common → lib/common}/mem.h +17 -13
- data/contrib/zstd/lib/common/pool.c +194 -0
- data/contrib/zstd/lib/common/pool.h +56 -0
- data/contrib/zstd/lib/common/threading.c +80 -0
- data/contrib/zstd/lib/common/threading.h +104 -0
- data/contrib/zstd/{common → lib/common}/xxhash.c +3 -1
- data/contrib/zstd/{common → lib/common}/xxhash.h +11 -15
- data/contrib/zstd/{common → lib/common}/zstd_common.c +1 -11
- data/contrib/zstd/{common → lib/common}/zstd_errors.h +16 -2
- data/contrib/zstd/{common → lib/common}/zstd_internal.h +17 -1
- data/contrib/zstd/{compress → lib/compress}/fse_compress.c +138 -91
- data/contrib/zstd/{compress → lib/compress}/huf_compress.c +218 -67
- data/contrib/zstd/{compress → lib/compress}/zstd_compress.c +231 -108
- data/contrib/zstd/{compress → lib/compress}/zstd_opt.h +44 -25
- data/contrib/zstd/lib/compress/zstdmt_compress.c +739 -0
- data/contrib/zstd/lib/compress/zstdmt_compress.h +78 -0
- data/contrib/zstd/{decompress → lib/decompress}/huf_decompress.c +28 -23
- data/contrib/zstd/{decompress → lib/decompress}/zstd_decompress.c +814 -176
- data/contrib/zstd/{common → lib/deprecated}/zbuff.h +60 -39
- data/contrib/zstd/lib/deprecated/zbuff_common.c +26 -0
- data/contrib/zstd/lib/deprecated/zbuff_compress.c +145 -0
- data/contrib/zstd/lib/deprecated/zbuff_decompress.c +74 -0
- data/contrib/zstd/lib/dictBuilder/cover.c +1029 -0
- data/contrib/zstd/{dictBuilder → lib/dictBuilder}/divsufsort.c +0 -0
- data/contrib/zstd/{dictBuilder → lib/dictBuilder}/divsufsort.h +0 -0
- data/contrib/zstd/{dictBuilder → lib/dictBuilder}/zdict.c +68 -18
- data/contrib/zstd/lib/dictBuilder/zdict.h +201 -0
- data/contrib/zstd/{legacy → lib/legacy}/zstd_legacy.h +122 -7
- data/contrib/zstd/{legacy → lib/legacy}/zstd_v01.c +34 -3
- data/contrib/zstd/{legacy → lib/legacy}/zstd_v01.h +8 -0
- data/contrib/zstd/{legacy → lib/legacy}/zstd_v02.c +45 -12
- data/contrib/zstd/{legacy → lib/legacy}/zstd_v02.h +8 -0
- data/contrib/zstd/{legacy → lib/legacy}/zstd_v03.c +45 -12
- data/contrib/zstd/{legacy → lib/legacy}/zstd_v03.h +8 -0
- data/contrib/zstd/{legacy → lib/legacy}/zstd_v04.c +56 -33
- data/contrib/zstd/{legacy → lib/legacy}/zstd_v04.h +8 -0
- data/contrib/zstd/{legacy → lib/legacy}/zstd_v05.c +45 -18
- data/contrib/zstd/{legacy → lib/legacy}/zstd_v05.h +7 -0
- data/contrib/zstd/{legacy → lib/legacy}/zstd_v06.c +43 -16
- data/contrib/zstd/{legacy → lib/legacy}/zstd_v06.h +7 -0
- data/contrib/zstd/{legacy → lib/legacy}/zstd_v07.c +57 -23
- data/contrib/zstd/{legacy → lib/legacy}/zstd_v07.h +8 -0
- data/contrib/zstd/lib/libzstd.pc.in +14 -0
- data/contrib/zstd/{zstd.h → lib/zstd.h} +206 -71
- data/ext/depend +2 -0
- data/ext/extconf.rb +4 -4
- data/ext/extzstd.c +1 -1
- data/ext/zstd_common.c +5 -5
- data/ext/zstd_compress.c +3 -3
- data/ext/zstd_decompress.c +2 -2
- data/ext/zstd_dictbuilder.c +2 -2
- data/ext/zstd_legacy_v01.c +1 -1
- data/ext/zstd_legacy_v02.c +1 -1
- data/ext/zstd_legacy_v03.c +1 -1
- data/ext/zstd_legacy_v04.c +1 -1
- data/ext/zstd_legacy_v05.c +1 -1
- data/ext/zstd_legacy_v06.c +1 -1
- data/ext/zstd_legacy_v07.c +1 -1
- data/gemstub.rb +9 -5
- data/lib/extzstd/version.rb +1 -1
- metadata +73 -51
- data/contrib/zstd/compress/zbuff_compress.c +0 -319
- data/contrib/zstd/decompress/zbuff_decompress.c +0 -252
- data/contrib/zstd/dictBuilder/zdict.h +0 -111
@@ -0,0 +1,78 @@
|
|
1
|
+
/**
|
2
|
+
* Copyright (c) 2016-present, Yann Collet, Facebook, Inc.
|
3
|
+
* All rights reserved.
|
4
|
+
*
|
5
|
+
* This source code is licensed under the BSD-style license found in the
|
6
|
+
* LICENSE file in the root directory of this source tree. An additional grant
|
7
|
+
* of patent rights can be found in the PATENTS file in the same directory.
|
8
|
+
*/
|
9
|
+
|
10
|
+
#ifndef ZSTDMT_COMPRESS_H
|
11
|
+
#define ZSTDMT_COMPRESS_H
|
12
|
+
|
13
|
+
#if defined (__cplusplus)
|
14
|
+
extern "C" {
|
15
|
+
#endif
|
16
|
+
|
17
|
+
|
18
|
+
/* Note : All prototypes defined in this file shall be considered experimental.
|
19
|
+
* There is no guarantee of API continuity (yet) on any of these prototypes */
|
20
|
+
|
21
|
+
/* === Dependencies === */
|
22
|
+
#include <stddef.h> /* size_t */
|
23
|
+
#define ZSTD_STATIC_LINKING_ONLY /* ZSTD_parameters */
|
24
|
+
#include "zstd.h" /* ZSTD_inBuffer, ZSTD_outBuffer, ZSTDLIB_API */
|
25
|
+
|
26
|
+
|
27
|
+
/* === Simple one-pass functions === */
|
28
|
+
|
29
|
+
typedef struct ZSTDMT_CCtx_s ZSTDMT_CCtx;
|
30
|
+
ZSTDLIB_API ZSTDMT_CCtx* ZSTDMT_createCCtx(unsigned nbThreads);
|
31
|
+
ZSTDLIB_API size_t ZSTDMT_freeCCtx(ZSTDMT_CCtx* cctx);
|
32
|
+
|
33
|
+
ZSTDLIB_API size_t ZSTDMT_compressCCtx(ZSTDMT_CCtx* cctx,
|
34
|
+
void* dst, size_t dstCapacity,
|
35
|
+
const void* src, size_t srcSize,
|
36
|
+
int compressionLevel);
|
37
|
+
|
38
|
+
|
39
|
+
/* === Streaming functions === */
|
40
|
+
|
41
|
+
ZSTDLIB_API size_t ZSTDMT_initCStream(ZSTDMT_CCtx* mtctx, int compressionLevel);
|
42
|
+
ZSTDLIB_API size_t ZSTDMT_resetCStream(ZSTDMT_CCtx* mtctx, unsigned long long pledgedSrcSize); /**< pledgedSrcSize is optional and can be zero == unknown */
|
43
|
+
|
44
|
+
ZSTDLIB_API size_t ZSTDMT_compressStream(ZSTDMT_CCtx* mtctx, ZSTD_outBuffer* output, ZSTD_inBuffer* input);
|
45
|
+
|
46
|
+
ZSTDLIB_API size_t ZSTDMT_flushStream(ZSTDMT_CCtx* mtctx, ZSTD_outBuffer* output); /**< @return : 0 == all flushed; >0 : still some data to be flushed; or an error code (ZSTD_isError()) */
|
47
|
+
ZSTDLIB_API size_t ZSTDMT_endStream(ZSTDMT_CCtx* mtctx, ZSTD_outBuffer* output); /**< @return : 0 == all flushed; >0 : still some data to be flushed; or an error code (ZSTD_isError()) */
|
48
|
+
|
49
|
+
|
50
|
+
/* === Advanced functions and parameters === */
|
51
|
+
|
52
|
+
#ifndef ZSTDMT_SECTION_SIZE_MIN
|
53
|
+
# define ZSTDMT_SECTION_SIZE_MIN (1U << 20) /* 1 MB - Minimum size of each compression job */
|
54
|
+
#endif
|
55
|
+
|
56
|
+
ZSTDLIB_API size_t ZSTDMT_initCStream_advanced(ZSTDMT_CCtx* mtctx, const void* dict, size_t dictSize, /**< dict can be released after init, a local copy is preserved within zcs */
|
57
|
+
ZSTD_parameters params, unsigned long long pledgedSrcSize); /**< pledgedSrcSize is optional and can be zero == unknown */
|
58
|
+
|
59
|
+
/* ZSDTMT_parameter :
|
60
|
+
* List of parameters that can be set using ZSTDMT_setMTCtxParameter() */
|
61
|
+
typedef enum {
|
62
|
+
ZSTDMT_p_sectionSize, /* size of input "section". Each section is compressed in parallel. 0 means default, which is dynamically determined within compression functions */
|
63
|
+
ZSTDMT_p_overlapSectionLog /* Log of overlapped section; 0 == no overlap, 6(default) == use 1/8th of window, >=9 == use full window */
|
64
|
+
} ZSDTMT_parameter;
|
65
|
+
|
66
|
+
/* ZSTDMT_setMTCtxParameter() :
|
67
|
+
* allow setting individual parameters, one at a time, among a list of enums defined in ZSTDMT_parameter.
|
68
|
+
* The function must be called typically after ZSTD_createCCtx().
|
69
|
+
* Parameters not explicitly reset by ZSTDMT_init*() remain the same in consecutive compression sessions.
|
70
|
+
* @return : 0, or an error code (which can be tested using ZSTD_isError()) */
|
71
|
+
ZSTDLIB_API size_t ZSTDMT_setMTCtxParameter(ZSTDMT_CCtx* mtctx, ZSDTMT_parameter parameter, unsigned value);
|
72
|
+
|
73
|
+
|
74
|
+
#if defined (__cplusplus)
|
75
|
+
}
|
76
|
+
#endif
|
77
|
+
|
78
|
+
#endif /* ZSTDMT_COMPRESS_H */
|
@@ -35,16 +35,19 @@
|
|
35
35
|
/* **************************************************************
|
36
36
|
* Compiler specifics
|
37
37
|
****************************************************************/
|
38
|
-
#if defined (__cplusplus) || (defined (__STDC_VERSION__) && (__STDC_VERSION__ >= 199901L) /* C99 */)
|
39
|
-
/* inline is defined */
|
40
|
-
#elif defined(_MSC_VER) || defined(__GNUC__)
|
41
|
-
# define inline __inline
|
42
|
-
#else
|
43
|
-
# define inline /* disable inline */
|
44
|
-
#endif
|
45
|
-
|
46
38
|
#ifdef _MSC_VER /* Visual Studio */
|
39
|
+
# define FORCE_INLINE static __forceinline
|
47
40
|
# pragma warning(disable : 4127) /* disable: C4127: conditional expression is constant */
|
41
|
+
#else
|
42
|
+
# if defined (__cplusplus) || defined (__STDC_VERSION__) && __STDC_VERSION__ >= 199901L /* C99 */
|
43
|
+
# ifdef __GNUC__
|
44
|
+
# define FORCE_INLINE static inline __attribute__((always_inline))
|
45
|
+
# else
|
46
|
+
# define FORCE_INLINE static inline
|
47
|
+
# endif
|
48
|
+
# else
|
49
|
+
# define FORCE_INLINE static
|
50
|
+
# endif /* __STDC_VERSION__ */
|
48
51
|
#endif
|
49
52
|
|
50
53
|
|
@@ -102,16 +105,16 @@ size_t HUF_readDTableX2 (HUF_DTable* DTable, const void* src, size_t srcSize)
|
|
102
105
|
|
103
106
|
/* Table header */
|
104
107
|
{ DTableDesc dtd = HUF_getDTableDesc(DTable);
|
105
|
-
if (tableLog > (U32)(dtd.maxTableLog+1)) return ERROR(tableLog_tooLarge); /* DTable too small,
|
108
|
+
if (tableLog > (U32)(dtd.maxTableLog+1)) return ERROR(tableLog_tooLarge); /* DTable too small, Huffman tree cannot fit in */
|
106
109
|
dtd.tableType = 0;
|
107
110
|
dtd.tableLog = (BYTE)tableLog;
|
108
111
|
memcpy(DTable, &dtd, sizeof(dtd));
|
109
112
|
}
|
110
113
|
|
111
|
-
/*
|
114
|
+
/* Calculate starting value for each rank */
|
112
115
|
{ U32 n, nextRankStart = 0;
|
113
116
|
for (n=1; n<tableLog+1; n++) {
|
114
|
-
U32 current = nextRankStart;
|
117
|
+
U32 const current = nextRankStart;
|
115
118
|
nextRankStart += (rankVal[n] << (n-1));
|
116
119
|
rankVal[n] = current;
|
117
120
|
} }
|
@@ -121,11 +124,11 @@ size_t HUF_readDTableX2 (HUF_DTable* DTable, const void* src, size_t srcSize)
|
|
121
124
|
for (n=0; n<nbSymbols; n++) {
|
122
125
|
U32 const w = huffWeight[n];
|
123
126
|
U32 const length = (1 << w) >> 1;
|
124
|
-
U32
|
127
|
+
U32 u;
|
125
128
|
HUF_DEltX2 D;
|
126
129
|
D.byte = (BYTE)n; D.nbBits = (BYTE)(tableLog + 1 - w);
|
127
|
-
for (
|
128
|
-
dt[
|
130
|
+
for (u = rankVal[w]; u < rankVal[w] + length; u++)
|
131
|
+
dt[u] = D;
|
129
132
|
rankVal[w] += length;
|
130
133
|
} }
|
131
134
|
|
@@ -152,7 +155,7 @@ static BYTE HUF_decodeSymbolX2(BIT_DStream_t* Dstream, const HUF_DEltX2* dt, con
|
|
152
155
|
if (MEM_64bits()) \
|
153
156
|
HUF_DECODE_SYMBOLX2_0(ptr, DStreamPtr)
|
154
157
|
|
155
|
-
|
158
|
+
FORCE_INLINE size_t HUF_decodeStreamX2(BYTE* p, BIT_DStream_t* const bitDPtr, BYTE* const pEnd, const HUF_DEltX2* const dt, const U32 dtLog)
|
156
159
|
{
|
157
160
|
BYTE* const pStart = p;
|
158
161
|
|
@@ -358,13 +361,15 @@ typedef struct { U16 sequence; BYTE nbBits; BYTE length; } HUF_DEltX4; /* doubl
|
|
358
361
|
|
359
362
|
typedef struct { BYTE symbol; BYTE weight; } sortedSymbol_t;
|
360
363
|
|
364
|
+
/* HUF_fillDTableX4Level2() :
|
365
|
+
* `rankValOrigin` must be a table of at least (HUF_TABLELOG_MAX + 1) U32 */
|
361
366
|
static void HUF_fillDTableX4Level2(HUF_DEltX4* DTable, U32 sizeLog, const U32 consumed,
|
362
367
|
const U32* rankValOrigin, const int minWeight,
|
363
368
|
const sortedSymbol_t* sortedSymbols, const U32 sortedListSize,
|
364
369
|
U32 nbBitsBaseline, U16 baseSeq)
|
365
370
|
{
|
366
371
|
HUF_DEltX4 DElt;
|
367
|
-
U32 rankVal[
|
372
|
+
U32 rankVal[HUF_TABLELOG_MAX + 1];
|
368
373
|
|
369
374
|
/* get pre-calculated rankVal */
|
370
375
|
memcpy(rankVal, rankValOrigin, sizeof(rankVal));
|
@@ -398,14 +403,14 @@ static void HUF_fillDTableX4Level2(HUF_DEltX4* DTable, U32 sizeLog, const U32 co
|
|
398
403
|
} }
|
399
404
|
}
|
400
405
|
|
401
|
-
typedef U32 rankVal_t[
|
406
|
+
typedef U32 rankVal_t[HUF_TABLELOG_MAX][HUF_TABLELOG_MAX + 1];
|
402
407
|
|
403
408
|
static void HUF_fillDTableX4(HUF_DEltX4* DTable, const U32 targetLog,
|
404
409
|
const sortedSymbol_t* sortedList, const U32 sortedListSize,
|
405
410
|
const U32* rankStart, rankVal_t rankValOrigin, const U32 maxWeight,
|
406
411
|
const U32 nbBitsBaseline)
|
407
412
|
{
|
408
|
-
U32 rankVal[
|
413
|
+
U32 rankVal[HUF_TABLELOG_MAX + 1];
|
409
414
|
const int scaleLog = nbBitsBaseline - targetLog; /* note : targetLog >= srcLog, hence scaleLog <= 1 */
|
410
415
|
const U32 minBits = nbBitsBaseline - maxWeight;
|
411
416
|
U32 s;
|
@@ -446,8 +451,8 @@ size_t HUF_readDTableX4 (HUF_DTable* DTable, const void* src, size_t srcSize)
|
|
446
451
|
{
|
447
452
|
BYTE weightList[HUF_SYMBOLVALUE_MAX + 1];
|
448
453
|
sortedSymbol_t sortedSymbol[HUF_SYMBOLVALUE_MAX + 1];
|
449
|
-
U32 rankStats[
|
450
|
-
U32 rankStart0[
|
454
|
+
U32 rankStats[HUF_TABLELOG_MAX + 1] = { 0 };
|
455
|
+
U32 rankStart0[HUF_TABLELOG_MAX + 2] = { 0 };
|
451
456
|
U32* const rankStart = rankStart0+1;
|
452
457
|
rankVal_t rankVal;
|
453
458
|
U32 tableLog, maxW, sizeOfSort, nbSymbols;
|
@@ -457,8 +462,8 @@ size_t HUF_readDTableX4 (HUF_DTable* DTable, const void* src, size_t srcSize)
|
|
457
462
|
void* dtPtr = DTable+1; /* force compiler to avoid strict-aliasing */
|
458
463
|
HUF_DEltX4* const dt = (HUF_DEltX4*)dtPtr;
|
459
464
|
|
460
|
-
HUF_STATIC_ASSERT(sizeof(HUF_DEltX4) == sizeof(HUF_DTable)); /* if
|
461
|
-
if (maxTableLog >
|
465
|
+
HUF_STATIC_ASSERT(sizeof(HUF_DEltX4) == sizeof(HUF_DTable)); /* if compiler fails here, assertion is wrong */
|
466
|
+
if (maxTableLog > HUF_TABLELOG_MAX) return ERROR(tableLog_tooLarge);
|
462
467
|
/* memset(weightList, 0, sizeof(weightList)); */ /* is not necessary, even though some analyzer complain ... */
|
463
468
|
|
464
469
|
iSize = HUF_readStats(weightList, HUF_SYMBOLVALUE_MAX + 1, rankStats, &nbSymbols, &tableLog, src, srcSize);
|
@@ -557,7 +562,7 @@ static U32 HUF_decodeLastSymbolX4(void* op, BIT_DStream_t* DStream, const HUF_DE
|
|
557
562
|
if (MEM_64bits()) \
|
558
563
|
ptr += HUF_decodeSymbolX4(ptr, DStreamPtr, dt, dtLog)
|
559
564
|
|
560
|
-
|
565
|
+
FORCE_INLINE size_t HUF_decodeStreamX4(BYTE* p, BIT_DStream_t* bitDPtr, BYTE* const pEnd, const HUF_DEltX4* const dt, const U32 dtLog)
|
561
566
|
{
|
562
567
|
BYTE* const pStart = p;
|
563
568
|
|