extzstd 0.0.3.CONCEPT → 0.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/LICENSE +6 -6
- data/README.md +35 -22
- data/contrib/zstd/LICENSE +13 -9
- data/contrib/zstd/README.md +37 -44
- data/contrib/zstd/common/entropy_common.c +33 -39
- data/contrib/zstd/common/error_private.c +43 -0
- data/contrib/zstd/common/error_private.h +11 -60
- data/contrib/zstd/common/fse.h +11 -5
- data/contrib/zstd/common/fse_decompress.c +14 -16
- data/contrib/zstd/common/huf.h +1 -1
- data/contrib/zstd/common/mem.h +36 -43
- data/contrib/zstd/common/xxhash.c +31 -18
- data/contrib/zstd/common/xxhash.h +71 -35
- data/contrib/zstd/common/zbuff.h +29 -35
- data/contrib/zstd/common/zstd_common.c +24 -32
- data/contrib/zstd/common/zstd_errors.h +60 -0
- data/contrib/zstd/common/zstd_internal.h +109 -80
- data/contrib/zstd/compress/fse_compress.c +9 -6
- data/contrib/zstd/compress/huf_compress.c +30 -74
- data/contrib/zstd/compress/zbuff_compress.c +43 -51
- data/contrib/zstd/compress/zstd_compress.c +953 -763
- data/contrib/zstd/compress/zstd_opt.h +115 -261
- data/contrib/zstd/decompress/huf_decompress.c +29 -40
- data/contrib/zstd/decompress/zbuff_decompress.c +36 -78
- data/contrib/zstd/decompress/zstd_decompress.c +976 -496
- data/contrib/zstd/dictBuilder/divsufsort.h +5 -5
- data/contrib/zstd/dictBuilder/zdict.c +194 -229
- data/contrib/zstd/dictBuilder/zdict.h +66 -68
- data/contrib/zstd/legacy/zstd_legacy.h +168 -49
- data/contrib/zstd/legacy/zstd_v01.c +95 -178
- data/contrib/zstd/legacy/zstd_v01.h +12 -32
- data/contrib/zstd/legacy/zstd_v02.c +48 -274
- data/contrib/zstd/legacy/zstd_v02.h +12 -32
- data/contrib/zstd/legacy/zstd_v03.c +48 -274
- data/contrib/zstd/legacy/zstd_v03.h +12 -32
- data/contrib/zstd/legacy/zstd_v04.c +63 -320
- data/contrib/zstd/legacy/zstd_v04.h +13 -33
- data/contrib/zstd/legacy/zstd_v05.c +80 -345
- data/contrib/zstd/legacy/zstd_v05.h +9 -31
- data/contrib/zstd/legacy/zstd_v06.c +48 -458
- data/contrib/zstd/legacy/zstd_v06.h +41 -67
- data/contrib/zstd/legacy/zstd_v07.c +4544 -0
- data/contrib/zstd/legacy/zstd_v07.h +173 -0
- data/contrib/zstd/zstd.h +640 -0
- data/ext/extconf.rb +7 -3
- data/ext/extzstd.c +263 -106
- data/ext/extzstd.h +8 -6
- data/ext/extzstd_nogvls.h +0 -117
- data/ext/extzstd_stream.c +347 -0
- data/ext/zstd_common.c +8 -0
- data/ext/zstd_compress.c +6 -0
- data/ext/zstd_decompress.c +5 -0
- data/ext/zstd_dictbuilder.c +5 -0
- data/ext/zstd_legacy_v07.c +1 -0
- data/gemstub.rb +18 -16
- data/lib/extzstd/version.rb +1 -1
- data/lib/extzstd.rb +77 -43
- data/test/test_basic.rb +11 -6
- metadata +23 -10
- data/contrib/zstd/common/error_public.h +0 -77
- data/contrib/zstd/common/zstd.h +0 -475
- data/ext/extzstd_buffered.c +0 -265
- data/ext/zstd_amalgam.c +0 -18
@@ -0,0 +1,173 @@
|
|
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 ZSTDv07_H_235446
|
11
|
+
#define ZSTDv07_H_235446
|
12
|
+
|
13
|
+
#if defined (__cplusplus)
|
14
|
+
extern "C" {
|
15
|
+
#endif
|
16
|
+
|
17
|
+
/*====== Dependency ======*/
|
18
|
+
#include <stddef.h> /* size_t */
|
19
|
+
|
20
|
+
|
21
|
+
/*====== Export for Windows ======*/
|
22
|
+
/*!
|
23
|
+
* ZSTDv07_DLL_EXPORT :
|
24
|
+
* Enable exporting of functions when building a Windows DLL
|
25
|
+
*/
|
26
|
+
#if defined(_WIN32) && defined(ZSTDv07_DLL_EXPORT) && (ZSTDv07_DLL_EXPORT==1)
|
27
|
+
# define ZSTDLIBv07_API __declspec(dllexport)
|
28
|
+
#else
|
29
|
+
# define ZSTDLIBv07_API
|
30
|
+
#endif
|
31
|
+
|
32
|
+
|
33
|
+
/* *************************************
|
34
|
+
* Simple API
|
35
|
+
***************************************/
|
36
|
+
/*! ZSTDv07_getDecompressedSize() :
|
37
|
+
* @return : decompressed size if known, 0 otherwise.
|
38
|
+
note 1 : if `0`, follow up with ZSTDv07_getFrameParams() to know precise failure cause.
|
39
|
+
note 2 : decompressed size could be wrong or intentionally modified !
|
40
|
+
always ensure results fit within application's authorized limits */
|
41
|
+
unsigned long long ZSTDv07_getDecompressedSize(const void* src, size_t srcSize);
|
42
|
+
|
43
|
+
/*! ZSTDv07_decompress() :
|
44
|
+
`compressedSize` : must be _exact_ size of compressed input, otherwise decompression will fail.
|
45
|
+
`dstCapacity` must be equal or larger than originalSize.
|
46
|
+
@return : the number of bytes decompressed into `dst` (<= `dstCapacity`),
|
47
|
+
or an errorCode if it fails (which can be tested using ZSTDv07_isError()) */
|
48
|
+
ZSTDLIBv07_API size_t ZSTDv07_decompress( void* dst, size_t dstCapacity,
|
49
|
+
const void* src, size_t compressedSize);
|
50
|
+
|
51
|
+
/*====== Helper functions ======*/
|
52
|
+
ZSTDLIBv07_API unsigned ZSTDv07_isError(size_t code); /*!< tells if a `size_t` function result is an error code */
|
53
|
+
ZSTDLIBv07_API const char* ZSTDv07_getErrorName(size_t code); /*!< provides readable string from an error code */
|
54
|
+
|
55
|
+
|
56
|
+
/*-*************************************
|
57
|
+
* Explicit memory management
|
58
|
+
***************************************/
|
59
|
+
/** Decompression context */
|
60
|
+
typedef struct ZSTDv07_DCtx_s ZSTDv07_DCtx;
|
61
|
+
ZSTDLIBv07_API ZSTDv07_DCtx* ZSTDv07_createDCtx(void);
|
62
|
+
ZSTDLIBv07_API size_t ZSTDv07_freeDCtx(ZSTDv07_DCtx* dctx); /*!< @return : errorCode */
|
63
|
+
|
64
|
+
/** ZSTDv07_decompressDCtx() :
|
65
|
+
* Same as ZSTDv07_decompress(), requires an allocated ZSTDv07_DCtx (see ZSTDv07_createDCtx()) */
|
66
|
+
ZSTDLIBv07_API size_t ZSTDv07_decompressDCtx(ZSTDv07_DCtx* ctx, void* dst, size_t dstCapacity, const void* src, size_t srcSize);
|
67
|
+
|
68
|
+
|
69
|
+
/*-************************
|
70
|
+
* Simple dictionary API
|
71
|
+
***************************/
|
72
|
+
/*! ZSTDv07_decompress_usingDict() :
|
73
|
+
* Decompression using a pre-defined Dictionary content (see dictBuilder).
|
74
|
+
* Dictionary must be identical to the one used during compression.
|
75
|
+
* Note : This function load the dictionary, resulting in a significant startup time */
|
76
|
+
ZSTDLIBv07_API size_t ZSTDv07_decompress_usingDict(ZSTDv07_DCtx* dctx,
|
77
|
+
void* dst, size_t dstCapacity,
|
78
|
+
const void* src, size_t srcSize,
|
79
|
+
const void* dict,size_t dictSize);
|
80
|
+
|
81
|
+
|
82
|
+
/*-**************************
|
83
|
+
* Advanced Dictionary API
|
84
|
+
****************************/
|
85
|
+
/*! ZSTDv07_createDDict() :
|
86
|
+
* Create a digested dictionary, ready to start decompression operation without startup delay.
|
87
|
+
* `dict` can be released after creation */
|
88
|
+
typedef struct ZSTDv07_DDict_s ZSTDv07_DDict;
|
89
|
+
ZSTDLIBv07_API ZSTDv07_DDict* ZSTDv07_createDDict(const void* dict, size_t dictSize);
|
90
|
+
ZSTDLIBv07_API size_t ZSTDv07_freeDDict(ZSTDv07_DDict* ddict);
|
91
|
+
|
92
|
+
/*! ZSTDv07_decompress_usingDDict() :
|
93
|
+
* Decompression using a pre-digested Dictionary
|
94
|
+
* Faster startup than ZSTDv07_decompress_usingDict(), recommended when same dictionary is used multiple times. */
|
95
|
+
ZSTDLIBv07_API size_t ZSTDv07_decompress_usingDDict(ZSTDv07_DCtx* dctx,
|
96
|
+
void* dst, size_t dstCapacity,
|
97
|
+
const void* src, size_t srcSize,
|
98
|
+
const ZSTDv07_DDict* ddict);
|
99
|
+
|
100
|
+
typedef struct {
|
101
|
+
unsigned long long frameContentSize;
|
102
|
+
unsigned windowSize;
|
103
|
+
unsigned dictID;
|
104
|
+
unsigned checksumFlag;
|
105
|
+
} ZSTDv07_frameParams;
|
106
|
+
|
107
|
+
ZSTDLIBv07_API size_t ZSTDv07_getFrameParams(ZSTDv07_frameParams* fparamsPtr, const void* src, size_t srcSize); /**< doesn't consume input */
|
108
|
+
|
109
|
+
|
110
|
+
|
111
|
+
|
112
|
+
/* *************************************
|
113
|
+
* Streaming functions
|
114
|
+
***************************************/
|
115
|
+
typedef struct ZBUFFv07_DCtx_s ZBUFFv07_DCtx;
|
116
|
+
ZSTDLIBv07_API ZBUFFv07_DCtx* ZBUFFv07_createDCtx(void);
|
117
|
+
ZSTDLIBv07_API size_t ZBUFFv07_freeDCtx(ZBUFFv07_DCtx* dctx);
|
118
|
+
|
119
|
+
ZSTDLIBv07_API size_t ZBUFFv07_decompressInit(ZBUFFv07_DCtx* dctx);
|
120
|
+
ZSTDLIBv07_API size_t ZBUFFv07_decompressInitDictionary(ZBUFFv07_DCtx* dctx, const void* dict, size_t dictSize);
|
121
|
+
|
122
|
+
ZSTDLIBv07_API size_t ZBUFFv07_decompressContinue(ZBUFFv07_DCtx* dctx,
|
123
|
+
void* dst, size_t* dstCapacityPtr,
|
124
|
+
const void* src, size_t* srcSizePtr);
|
125
|
+
|
126
|
+
/*-***************************************************************************
|
127
|
+
* Streaming decompression howto
|
128
|
+
*
|
129
|
+
* A ZBUFFv07_DCtx object is required to track streaming operations.
|
130
|
+
* Use ZBUFFv07_createDCtx() and ZBUFFv07_freeDCtx() to create/release resources.
|
131
|
+
* Use ZBUFFv07_decompressInit() to start a new decompression operation,
|
132
|
+
* or ZBUFFv07_decompressInitDictionary() if decompression requires a dictionary.
|
133
|
+
* Note that ZBUFFv07_DCtx objects can be re-init multiple times.
|
134
|
+
*
|
135
|
+
* Use ZBUFFv07_decompressContinue() repetitively to consume your input.
|
136
|
+
* *srcSizePtr and *dstCapacityPtr can be any size.
|
137
|
+
* The function will report how many bytes were read or written by modifying *srcSizePtr and *dstCapacityPtr.
|
138
|
+
* Note that it may not consume the entire input, in which case it's up to the caller to present remaining input again.
|
139
|
+
* The content of `dst` will be overwritten (up to *dstCapacityPtr) at each function call, so save its content if it matters, or change `dst`.
|
140
|
+
* @return : a hint to preferred nb of bytes to use as input for next function call (it's only a hint, to help latency),
|
141
|
+
* or 0 when a frame is completely decoded,
|
142
|
+
* or an error code, which can be tested using ZBUFFv07_isError().
|
143
|
+
*
|
144
|
+
* Hint : recommended buffer sizes (not compulsory) : ZBUFFv07_recommendedDInSize() and ZBUFFv07_recommendedDOutSize()
|
145
|
+
* output : ZBUFFv07_recommendedDOutSize== 128 KB block size is the internal unit, it ensures it's always possible to write a full block when decoded.
|
146
|
+
* input : ZBUFFv07_recommendedDInSize == 128KB + 3;
|
147
|
+
* just follow indications from ZBUFFv07_decompressContinue() to minimize latency. It should always be <= 128 KB + 3 .
|
148
|
+
* *******************************************************************************/
|
149
|
+
|
150
|
+
|
151
|
+
/* *************************************
|
152
|
+
* Tool functions
|
153
|
+
***************************************/
|
154
|
+
ZSTDLIBv07_API unsigned ZBUFFv07_isError(size_t errorCode);
|
155
|
+
ZSTDLIBv07_API const char* ZBUFFv07_getErrorName(size_t errorCode);
|
156
|
+
|
157
|
+
/** Functions below provide recommended buffer sizes for Compression or Decompression operations.
|
158
|
+
* These sizes are just hints, they tend to offer better latency */
|
159
|
+
ZSTDLIBv07_API size_t ZBUFFv07_recommendedDInSize(void);
|
160
|
+
ZSTDLIBv07_API size_t ZBUFFv07_recommendedDOutSize(void);
|
161
|
+
|
162
|
+
|
163
|
+
/*-*************************************
|
164
|
+
* Constants
|
165
|
+
***************************************/
|
166
|
+
#define ZSTDv07_MAGICNUMBER 0xFD2FB527 /* v0.7 */
|
167
|
+
|
168
|
+
|
169
|
+
#if defined (__cplusplus)
|
170
|
+
}
|
171
|
+
#endif
|
172
|
+
|
173
|
+
#endif /* ZSTDv07_H_235446 */
|