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
@@ -1,35 +1,11 @@
|
|
1
|
-
|
2
|
-
|
3
|
-
|
4
|
-
|
5
|
-
|
6
|
-
|
7
|
-
|
8
|
-
|
9
|
-
met:
|
10
|
-
|
11
|
-
* Redistributions of source code must retain the above copyright
|
12
|
-
notice, this list of conditions and the following disclaimer.
|
13
|
-
* Redistributions in binary form must reproduce the above
|
14
|
-
copyright notice, this list of conditions and the following disclaimer
|
15
|
-
in the documentation and/or other materials provided with the
|
16
|
-
distribution.
|
17
|
-
|
18
|
-
THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
|
19
|
-
"AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
|
20
|
-
LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
|
21
|
-
A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
|
22
|
-
OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
|
23
|
-
SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
|
24
|
-
LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
|
25
|
-
DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
|
26
|
-
THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
|
27
|
-
(INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
|
28
|
-
OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
29
|
-
|
30
|
-
You can contact the author at :
|
31
|
-
- Zstd source repository : https://www.zstd.net
|
32
|
-
*/
|
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
|
+
*/
|
33
9
|
|
34
10
|
#ifndef DICTBUILDER_H_001
|
35
11
|
#define DICTBUILDER_H_001
|
@@ -38,41 +14,44 @@
|
|
38
14
|
extern "C" {
|
39
15
|
#endif
|
40
16
|
|
41
|
-
/*-*************************************
|
42
|
-
* Public functions
|
43
|
-
***************************************/
|
44
|
-
/*! ZDICT_trainFromBuffer() :
|
45
|
-
Train a dictionary from a memory buffer `samplesBuffer`,
|
46
|
-
where `nbSamples` samples have been stored concatenated.
|
47
|
-
Each sample size is provided into an orderly table `samplesSizes`.
|
48
|
-
Resulting dictionary will be saved into `dictBuffer`.
|
49
|
-
@return : size of dictionary stored into `dictBuffer` (<= `dictBufferCapacity`)
|
50
|
-
or an error code, which can be tested by ZDICT_isError().
|
51
|
-
*/
|
52
|
-
size_t ZDICT_trainFromBuffer(void* dictBuffer, size_t dictBufferCapacity,
|
53
|
-
const void* samplesBuffer, const size_t* samplesSizes, unsigned nbSamples);
|
54
17
|
|
55
|
-
|
18
|
+
/*====== Dependencies ======*/
|
19
|
+
#include <stddef.h> /* size_t */
|
56
20
|
|
57
|
-
Given a content-only dictionary (built for example from common strings in
|
58
|
-
the input), add entropy tables computed from the memory buffer
|
59
|
-
`samplesBuffer`, where `nbSamples` samples have been stored concatenated.
|
60
|
-
Each sample size is provided into an orderly table `samplesSizes`.
|
61
21
|
|
62
|
-
|
63
|
-
|
64
|
-
|
65
|
-
|
22
|
+
/*====== Export for Windows ======*/
|
23
|
+
/*!
|
24
|
+
* ZSTD_DLL_EXPORT :
|
25
|
+
* Enable exporting of functions when building a Windows DLL
|
66
26
|
*/
|
67
|
-
|
68
|
-
|
27
|
+
#if defined(_WIN32) && defined(ZSTD_DLL_EXPORT) && (ZSTD_DLL_EXPORT==1)
|
28
|
+
# define ZDICTLIB_API __declspec(dllexport)
|
29
|
+
#else
|
30
|
+
# define ZDICTLIB_API
|
31
|
+
#endif
|
32
|
+
|
69
33
|
|
34
|
+
/*! ZDICT_trainFromBuffer() :
|
35
|
+
Train a dictionary from an array of samples.
|
36
|
+
Samples must be stored concatenated in a single flat buffer `samplesBuffer`,
|
37
|
+
supplied with an array of sizes `samplesSizes`, providing the size of each sample, in order.
|
38
|
+
The resulting dictionary will be saved into `dictBuffer`.
|
39
|
+
@return : size of dictionary stored into `dictBuffer` (<= `dictBufferCapacity`)
|
40
|
+
or an error code, which can be tested with ZDICT_isError().
|
41
|
+
Tips : In general, a reasonable dictionary has a size of ~ 100 KB.
|
42
|
+
It's obviously possible to target smaller or larger ones, just by specifying different `dictBufferCapacity`.
|
43
|
+
In general, it's recommended to provide a few thousands samples, but this can vary a lot.
|
44
|
+
It's recommended that total size of all samples be about ~x100 times the target size of dictionary.
|
45
|
+
*/
|
46
|
+
ZDICTLIB_API size_t ZDICT_trainFromBuffer(void* dictBuffer, size_t dictBufferCapacity,
|
47
|
+
const void* samplesBuffer, const size_t* samplesSizes, unsigned nbSamples);
|
48
|
+
|
49
|
+
|
50
|
+
/*====== Helper functions ======*/
|
51
|
+
ZDICTLIB_API unsigned ZDICT_getDictID(const void* dictBuffer, size_t dictSize); /**< extracts dictID; @return zero if error (not a valid dictionary) */
|
52
|
+
ZDICTLIB_API unsigned ZDICT_isError(size_t errorCode);
|
53
|
+
ZDICTLIB_API const char* ZDICT_getErrorName(size_t errorCode);
|
70
54
|
|
71
|
-
/*-*************************************
|
72
|
-
* Helper functions
|
73
|
-
***************************************/
|
74
|
-
unsigned ZDICT_isError(size_t errorCode);
|
75
|
-
const char* ZDICT_getErrorName(size_t errorCode);
|
76
55
|
|
77
56
|
|
78
57
|
#ifdef ZDICT_STATIC_LINKING_ONLY
|
@@ -85,24 +64,43 @@ const char* ZDICT_getErrorName(size_t errorCode);
|
|
85
64
|
* ==================================================================================== */
|
86
65
|
|
87
66
|
typedef struct {
|
88
|
-
unsigned selectivityLevel; /* 0 means default; larger =>
|
89
|
-
|
67
|
+
unsigned selectivityLevel; /* 0 means default; larger => select more => larger dictionary */
|
68
|
+
int compressionLevel; /* 0 means default; target a specific zstd compression level */
|
90
69
|
unsigned notificationLevel; /* Write to stderr; 0 = none (default); 1 = errors; 2 = progression; 3 = details; 4 = debug; */
|
91
70
|
unsigned dictID; /* 0 means auto mode (32-bits random value); other : force dictID value */
|
92
|
-
unsigned reserved[2]; /* space for future parameters */
|
71
|
+
unsigned reserved[2]; /* reserved space for future parameters */
|
93
72
|
} ZDICT_params_t;
|
94
73
|
|
95
74
|
|
96
75
|
/*! ZDICT_trainFromBuffer_advanced() :
|
97
76
|
Same as ZDICT_trainFromBuffer() with control over more parameters.
|
98
77
|
`parameters` is optional and can be provided with values set to 0 to mean "default".
|
99
|
-
@return : size of dictionary stored into `dictBuffer` (<= `dictBufferSize`)
|
78
|
+
@return : size of dictionary stored into `dictBuffer` (<= `dictBufferSize`),
|
100
79
|
or an error code, which can be tested by ZDICT_isError().
|
101
|
-
note : ZDICT_trainFromBuffer_advanced() will send notifications into stderr if instructed to, using
|
80
|
+
note : ZDICT_trainFromBuffer_advanced() will send notifications into stderr if instructed to, using notificationLevel>0.
|
102
81
|
*/
|
103
82
|
size_t ZDICT_trainFromBuffer_advanced(void* dictBuffer, size_t dictBufferCapacity,
|
104
|
-
|
105
|
-
|
83
|
+
const void* samplesBuffer, const size_t* samplesSizes, unsigned nbSamples,
|
84
|
+
ZDICT_params_t parameters);
|
85
|
+
|
86
|
+
|
87
|
+
/*! ZDICT_addEntropyTablesFromBuffer() :
|
88
|
+
|
89
|
+
Given a content-only dictionary (built using any 3rd party algorithm),
|
90
|
+
add entropy tables computed from an array of samples.
|
91
|
+
Samples must be stored concatenated in a flat buffer `samplesBuffer`,
|
92
|
+
supplied with an array of sizes `samplesSizes`, providing the size of each sample in order.
|
93
|
+
|
94
|
+
The input dictionary content must be stored *at the end* of `dictBuffer`.
|
95
|
+
Its size is `dictContentSize`.
|
96
|
+
The resulting dictionary with added entropy tables will be *written back to `dictBuffer`*,
|
97
|
+
starting from its beginning.
|
98
|
+
@return : size of dictionary stored into `dictBuffer` (<= `dictBufferCapacity`).
|
99
|
+
*/
|
100
|
+
size_t ZDICT_addEntropyTablesFromBuffer(void* dictBuffer, size_t dictContentSize, size_t dictBufferCapacity,
|
101
|
+
const void* samplesBuffer, const size_t* samplesSizes, unsigned nbSamples);
|
102
|
+
|
103
|
+
|
106
104
|
|
107
105
|
#endif /* ZDICT_STATIC_LINKING_ONLY */
|
108
106
|
|
@@ -1,35 +1,12 @@
|
|
1
|
-
|
2
|
-
|
3
|
-
|
4
|
-
|
5
|
-
|
6
|
-
|
7
|
-
|
8
|
-
|
9
|
-
|
10
|
-
met:
|
11
|
-
* Redistributions of source code must retain the above copyright
|
12
|
-
notice, this list of conditions and the following disclaimer.
|
13
|
-
* Redistributions in binary form must reproduce the above
|
14
|
-
copyright notice, this list of conditions and the following disclaimer
|
15
|
-
in the documentation and/or other materials provided with the
|
16
|
-
distribution.
|
17
|
-
THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
|
18
|
-
"AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
|
19
|
-
LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
|
20
|
-
A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
|
21
|
-
OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
|
22
|
-
SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
|
23
|
-
LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
|
24
|
-
DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
|
25
|
-
THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
|
26
|
-
(INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
|
27
|
-
OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
28
|
-
|
29
|
-
You can contact the author at :
|
30
|
-
- zstd source repository : https://github.com/Cyan4973/zstd
|
31
|
-
- ztsd public forum : https://groups.google.com/forum/#!forum/lz4c
|
32
|
-
*/
|
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
|
+
|
33
10
|
#ifndef ZSTD_LEGACY_H
|
34
11
|
#define ZSTD_LEGACY_H
|
35
12
|
|
@@ -42,12 +19,14 @@ extern "C" {
|
|
42
19
|
***************************************/
|
43
20
|
#include "mem.h" /* MEM_STATIC */
|
44
21
|
#include "error_private.h" /* ERROR */
|
22
|
+
#include "zstd.h" /* ZSTD_inBuffer, ZSTD_outBuffer */
|
45
23
|
#include "zstd_v01.h"
|
46
24
|
#include "zstd_v02.h"
|
47
25
|
#include "zstd_v03.h"
|
48
26
|
#include "zstd_v04.h"
|
49
27
|
#include "zstd_v05.h"
|
50
28
|
#include "zstd_v06.h"
|
29
|
+
#include "zstd_v07.h"
|
51
30
|
|
52
31
|
|
53
32
|
/** ZSTD_isLegacy() :
|
@@ -67,6 +46,7 @@ MEM_STATIC unsigned ZSTD_isLegacy(const void* src, size_t srcSize)
|
|
67
46
|
case ZSTDv04_magicNumber : return 4;
|
68
47
|
case ZSTDv05_MAGICNUMBER : return 5;
|
69
48
|
case ZSTDv06_MAGICNUMBER : return 6;
|
49
|
+
case ZSTDv07_MAGICNUMBER : return 7;
|
70
50
|
default : return 0;
|
71
51
|
}
|
72
52
|
}
|
@@ -74,26 +54,30 @@ MEM_STATIC unsigned ZSTD_isLegacy(const void* src, size_t srcSize)
|
|
74
54
|
|
75
55
|
MEM_STATIC unsigned long long ZSTD_getDecompressedSize_legacy(const void* src, size_t srcSize)
|
76
56
|
{
|
77
|
-
|
78
|
-
|
79
|
-
|
80
|
-
|
81
|
-
|
82
|
-
|
83
|
-
|
84
|
-
if (frResult != 0) return 0;
|
85
|
-
return fParams.srcSize;
|
86
|
-
}
|
87
|
-
if (version==6) {
|
88
|
-
ZSTDv06_frameParams fParams;
|
89
|
-
size_t const frResult = ZSTDv06_getFrameParams(&fParams, src, srcSize);
|
90
|
-
if (frResult != 0) return 0;
|
91
|
-
return fParams.frameContentSize;
|
92
|
-
}
|
93
|
-
return 0; /* should not be possible */
|
57
|
+
U32 const version = ZSTD_isLegacy(src, srcSize);
|
58
|
+
if (version < 5) return 0; /* no decompressed size in frame header, or not a legacy format */
|
59
|
+
if (version==5) {
|
60
|
+
ZSTDv05_parameters fParams;
|
61
|
+
size_t const frResult = ZSTDv05_getFrameParams(&fParams, src, srcSize);
|
62
|
+
if (frResult != 0) return 0;
|
63
|
+
return fParams.srcSize;
|
94
64
|
}
|
65
|
+
if (version==6) {
|
66
|
+
ZSTDv06_frameParams fParams;
|
67
|
+
size_t const frResult = ZSTDv06_getFrameParams(&fParams, src, srcSize);
|
68
|
+
if (frResult != 0) return 0;
|
69
|
+
return fParams.frameContentSize;
|
70
|
+
}
|
71
|
+
if (version==7) {
|
72
|
+
ZSTDv07_frameParams fParams;
|
73
|
+
size_t const frResult = ZSTDv07_getFrameParams(&fParams, src, srcSize);
|
74
|
+
if (frResult != 0) return 0;
|
75
|
+
return fParams.frameContentSize;
|
76
|
+
}
|
77
|
+
return 0; /* should not be possible */
|
95
78
|
}
|
96
79
|
|
80
|
+
|
97
81
|
MEM_STATIC size_t ZSTD_decompressLegacy(
|
98
82
|
void* dst, size_t dstCapacity,
|
99
83
|
const void* src, size_t compressedSize,
|
@@ -126,12 +110,147 @@ MEM_STATIC size_t ZSTD_decompressLegacy(
|
|
126
110
|
ZSTDv06_freeDCtx(zd);
|
127
111
|
return result;
|
128
112
|
}
|
113
|
+
case 7 :
|
114
|
+
{ size_t result;
|
115
|
+
ZSTDv07_DCtx* const zd = ZSTDv07_createDCtx();
|
116
|
+
if (zd==NULL) return ERROR(memory_allocation);
|
117
|
+
result = ZSTDv07_decompress_usingDict(zd, dst, dstCapacity, src, compressedSize, dict, dictSize);
|
118
|
+
ZSTDv07_freeDCtx(zd);
|
119
|
+
return result;
|
120
|
+
}
|
129
121
|
default :
|
130
122
|
return ERROR(prefix_unknown);
|
131
123
|
}
|
132
124
|
}
|
133
125
|
|
134
126
|
|
127
|
+
MEM_STATIC size_t ZSTD_freeLegacyStreamContext(void* legacyContext, U32 version)
|
128
|
+
{
|
129
|
+
switch(version)
|
130
|
+
{
|
131
|
+
default :
|
132
|
+
case 1 :
|
133
|
+
case 2 :
|
134
|
+
case 3 :
|
135
|
+
return ERROR(version_unsupported);
|
136
|
+
case 4 : return ZBUFFv04_freeDCtx((ZBUFFv04_DCtx*)legacyContext);
|
137
|
+
case 5 : return ZBUFFv05_freeDCtx((ZBUFFv05_DCtx*)legacyContext);
|
138
|
+
case 6 : return ZBUFFv06_freeDCtx((ZBUFFv06_DCtx*)legacyContext);
|
139
|
+
case 7 : return ZBUFFv07_freeDCtx((ZBUFFv07_DCtx*)legacyContext);
|
140
|
+
}
|
141
|
+
}
|
142
|
+
|
143
|
+
|
144
|
+
MEM_STATIC size_t ZSTD_initLegacyStream(void** legacyContext, U32 prevVersion, U32 newVersion,
|
145
|
+
const void* dict, size_t dictSize)
|
146
|
+
{
|
147
|
+
if (prevVersion != newVersion) ZSTD_freeLegacyStreamContext(*legacyContext, prevVersion);
|
148
|
+
switch(newVersion)
|
149
|
+
{
|
150
|
+
default :
|
151
|
+
case 1 :
|
152
|
+
case 2 :
|
153
|
+
case 3 :
|
154
|
+
return 0;
|
155
|
+
case 4 :
|
156
|
+
{
|
157
|
+
ZBUFFv04_DCtx* dctx = (prevVersion != newVersion) ? ZBUFFv04_createDCtx() : (ZBUFFv04_DCtx*)*legacyContext;
|
158
|
+
if (dctx==NULL) return ERROR(memory_allocation);
|
159
|
+
ZBUFFv04_decompressInit(dctx);
|
160
|
+
ZBUFFv04_decompressWithDictionary(dctx, dict, dictSize);
|
161
|
+
*legacyContext = dctx;
|
162
|
+
return 0;
|
163
|
+
}
|
164
|
+
case 5 :
|
165
|
+
{
|
166
|
+
ZBUFFv05_DCtx* dctx = (prevVersion != newVersion) ? ZBUFFv05_createDCtx() : (ZBUFFv05_DCtx*)*legacyContext;
|
167
|
+
if (dctx==NULL) return ERROR(memory_allocation);
|
168
|
+
ZBUFFv05_decompressInitDictionary(dctx, dict, dictSize);
|
169
|
+
*legacyContext = dctx;
|
170
|
+
return 0;
|
171
|
+
}
|
172
|
+
case 6 :
|
173
|
+
{
|
174
|
+
ZBUFFv06_DCtx* dctx = (prevVersion != newVersion) ? ZBUFFv06_createDCtx() : (ZBUFFv06_DCtx*)*legacyContext;
|
175
|
+
if (dctx==NULL) return ERROR(memory_allocation);
|
176
|
+
ZBUFFv06_decompressInitDictionary(dctx, dict, dictSize);
|
177
|
+
*legacyContext = dctx;
|
178
|
+
return 0;
|
179
|
+
}
|
180
|
+
case 7 :
|
181
|
+
{
|
182
|
+
ZBUFFv07_DCtx* dctx = (prevVersion != newVersion) ? ZBUFFv07_createDCtx() : (ZBUFFv07_DCtx*)*legacyContext;
|
183
|
+
if (dctx==NULL) return ERROR(memory_allocation);
|
184
|
+
ZBUFFv07_decompressInitDictionary(dctx, dict, dictSize);
|
185
|
+
*legacyContext = dctx;
|
186
|
+
return 0;
|
187
|
+
}
|
188
|
+
}
|
189
|
+
}
|
190
|
+
|
191
|
+
|
192
|
+
|
193
|
+
MEM_STATIC size_t ZSTD_decompressLegacyStream(void* legacyContext, U32 version,
|
194
|
+
ZSTD_outBuffer* output, ZSTD_inBuffer* input)
|
195
|
+
{
|
196
|
+
switch(version)
|
197
|
+
{
|
198
|
+
default :
|
199
|
+
case 1 :
|
200
|
+
case 2 :
|
201
|
+
case 3 :
|
202
|
+
return ERROR(version_unsupported);
|
203
|
+
case 4 :
|
204
|
+
{
|
205
|
+
ZBUFFv04_DCtx* dctx = (ZBUFFv04_DCtx*) legacyContext;
|
206
|
+
const void* src = (const char*)input->src + input->pos;
|
207
|
+
size_t readSize = input->size - input->pos;
|
208
|
+
void* dst = (char*)output->dst + output->pos;
|
209
|
+
size_t decodedSize = output->size - output->pos;
|
210
|
+
size_t const hintSize = ZBUFFv04_decompressContinue(dctx, dst, &decodedSize, src, &readSize);
|
211
|
+
output->pos += decodedSize;
|
212
|
+
input->pos += readSize;
|
213
|
+
return hintSize;
|
214
|
+
}
|
215
|
+
case 5 :
|
216
|
+
{
|
217
|
+
ZBUFFv05_DCtx* dctx = (ZBUFFv05_DCtx*) legacyContext;
|
218
|
+
const void* src = (const char*)input->src + input->pos;
|
219
|
+
size_t readSize = input->size - input->pos;
|
220
|
+
void* dst = (char*)output->dst + output->pos;
|
221
|
+
size_t decodedSize = output->size - output->pos;
|
222
|
+
size_t const hintSize = ZBUFFv05_decompressContinue(dctx, dst, &decodedSize, src, &readSize);
|
223
|
+
output->pos += decodedSize;
|
224
|
+
input->pos += readSize;
|
225
|
+
return hintSize;
|
226
|
+
}
|
227
|
+
case 6 :
|
228
|
+
{
|
229
|
+
ZBUFFv06_DCtx* dctx = (ZBUFFv06_DCtx*) legacyContext;
|
230
|
+
const void* src = (const char*)input->src + input->pos;
|
231
|
+
size_t readSize = input->size - input->pos;
|
232
|
+
void* dst = (char*)output->dst + output->pos;
|
233
|
+
size_t decodedSize = output->size - output->pos;
|
234
|
+
size_t const hintSize = ZBUFFv06_decompressContinue(dctx, dst, &decodedSize, src, &readSize);
|
235
|
+
output->pos += decodedSize;
|
236
|
+
input->pos += readSize;
|
237
|
+
return hintSize;
|
238
|
+
}
|
239
|
+
case 7 :
|
240
|
+
{
|
241
|
+
ZBUFFv07_DCtx* dctx = (ZBUFFv07_DCtx*) legacyContext;
|
242
|
+
const void* src = (const char*)input->src + input->pos;
|
243
|
+
size_t readSize = input->size - input->pos;
|
244
|
+
void* dst = (char*)output->dst + output->pos;
|
245
|
+
size_t decodedSize = output->size - output->pos;
|
246
|
+
size_t const hintSize = ZBUFFv07_decompressContinue(dctx, dst, &decodedSize, src, &readSize);
|
247
|
+
output->pos += decodedSize;
|
248
|
+
input->pos += readSize;
|
249
|
+
return hintSize;
|
250
|
+
}
|
251
|
+
}
|
252
|
+
}
|
253
|
+
|
135
254
|
|
136
255
|
#if defined (__cplusplus)
|
137
256
|
}
|