extzstd 0.0.3.CONCEPT-x86-mingw32 → 0.1-x86-mingw32
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/2.1/extzstd.so +0 -0
- data/lib/2.2/extzstd.so +0 -0
- data/lib/2.3/extzstd.so +0 -0
- data/lib/extzstd/version.rb +1 -1
- data/lib/extzstd.rb +77 -43
- data/test/test_basic.rb +11 -6
- metadata +23 -11
- 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
- data/lib/2.0/extzstd.so +0 -0
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 304f17cd776244a146f3d2b6077de16b0a028b6c
|
4
|
+
data.tar.gz: 557b07fb1ce871790ad3bf0c50e63baaf9ff7595
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 8bb9a1dcbb8b9670514b28cdd8ea9a6727a41bed4de21249cfd9cb812ba0fbf8b65191b3c0a8bf3d0b4374bad6bb6b7fa16c2a230fc69a77d3771063f431c855
|
7
|
+
data.tar.gz: f63c68baa0d78f01be21c5ad6ec82a74dabeecdde3ca9d6684e4f00b30f7116c3954d2715ea0df2a000f1196b6fefd6bcb5c6250d9b5839baeb3f094b45d177a
|
data/HISTORY.ja
ADDED
data/LICENSE
CHANGED
@@ -4,12 +4,12 @@ Redistribution and use in source and binary forms, with or
|
|
4
4
|
without modification, are permitted provided that the following
|
5
5
|
conditions are met:
|
6
6
|
|
7
|
-
|
8
|
-
|
9
|
-
|
10
|
-
|
11
|
-
|
12
|
-
|
7
|
+
1. Redistributions of source code must retain the above copyright
|
8
|
+
notice, this list of conditions and the following disclaimer.
|
9
|
+
2. Redistributions in binary form must reproduce the above copyright
|
10
|
+
notice, this list of conditions and the following disclaimer in
|
11
|
+
the documentation and/or other materials provided with the
|
12
|
+
distribution.
|
13
13
|
|
14
14
|
THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
|
15
15
|
"AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
|
data/README.md
CHANGED
@@ -1,48 +1,61 @@
|
|
1
1
|
# extzstd - ruby bindings for Zstd (Zstandard)
|
2
2
|
|
3
3
|
This is unofficial ruby bindings for compression library
|
4
|
-
[Zstd (
|
4
|
+
[Zstd (Zstandard)](https://github.com/facebook/zstd).
|
5
5
|
|
6
6
|
* package name: extzstd
|
7
|
-
* version: 0.
|
7
|
+
* version: 0.1
|
8
8
|
* software quality: EXPERIMENTAL
|
9
|
-
* license: 2-clause
|
9
|
+
* license: BSD-2-clause License
|
10
10
|
* author: dearblue <mailto:dearblue@users.osdn.me>
|
11
11
|
* report issue to: <https://osdn.jp/projects/rutsubo/ticket/>
|
12
|
-
* dependency ruby: ruby-2.
|
12
|
+
* dependency ruby: ruby-2.1+
|
13
13
|
* dependency ruby gems: (none)
|
14
14
|
* dependency library: (none)
|
15
15
|
* bundled external C library:
|
16
|
-
* zstd-
|
16
|
+
* zstd-1.1.1 <https://github.com/facebook/zstd/tree/v1.1.1>
|
17
17
|
|
18
|
-
|
18
|
+
under BSD-3-clause License <https://github.com/facebook/zstd/blob/v1.1.1/LICENSE>
|
19
|
+
|
20
|
+
by facebook <https://github.com/facebook>
|
21
|
+
|
22
|
+
"extzstd" is supported decompression with the legacy formats (zstd-0.1 - 0.7).
|
19
23
|
|
20
24
|
|
21
25
|
## Quick API Reference
|
22
26
|
|
23
|
-
*
|
24
|
-
* ``Zstd.encode(buf, params = nil, dict
|
25
|
-
* ``Zstd.encode(outport, params = nil, dict
|
26
|
-
* ``Zstd.encode(outport, params = nil, dict
|
27
|
+
* encoder (compression)
|
28
|
+
* ``Zstd.encode(buf, params = nil, dict: nil) -> encoded string``
|
29
|
+
* ``Zstd.encode(outport, params = nil, dict: nil) -> an instance of Zstd::Encoder``
|
30
|
+
* ``Zstd.encode(outport, params = nil, dict: nil) { |encoder| ... } -> block returned value``
|
27
31
|
* ``Zstd::Encoder#write(buf) -> this instance``
|
28
32
|
* ``Zstd::Encoder#close -> nil``
|
29
33
|
|
30
|
-
*
|
31
|
-
* ``Zstd.decode(zstd_buf, dict
|
32
|
-
* ``Zstd.decode(inport, dict
|
33
|
-
* ``Zstd.decode(inport, dict
|
34
|
+
* decoder (decompression)
|
35
|
+
* ``Zstd.decode(zstd_buf, dict: nil) -> decoded string``
|
36
|
+
* ``Zstd.decode(inport, dict: nil) -> an intance of Zstd::Decoder``
|
37
|
+
* ``Zstd.decode(inport, dict: nil) { |decoder| ... } -> block returned value``
|
34
38
|
* ``Zstd::Decoder#read(size = nil, buf = nil) -> buf``
|
35
39
|
* ``Zstd::Decoder#close -> nil``
|
36
40
|
|
37
|
-
*
|
38
|
-
* ``Zstd::
|
39
|
-
* ``Zstd::
|
40
|
-
* ``Zstd::
|
41
|
-
* ``Zstd::
|
41
|
+
* stream encoder
|
42
|
+
* ``Zstd::StreamEncoder.new(params, dict)`` (``ZSTD_createCStream``, ``ZSTD_initCStream_advanced``)
|
43
|
+
* ``Zstd::StreamEncoder#update(src, srcoff, dest, maxdest) -> integer as new src offset`` (``ZSTD_compressStream``)
|
44
|
+
* ``Zstd::StreamEncoder#flush(dest, maxdest) -> dest`` (``ZSTD_flushStream``)
|
45
|
+
* ``Zstd::StreamEncoder#end(dest, maxdest) -> dest`` (``ZSTD_endStream``)
|
46
|
+
|
47
|
+
* stream decoder
|
48
|
+
* ``Zstd::StreamDecoder.new(dict)`` (``ZSTD_createDStream``, ``ZSTD_initDStream_usingDict``)
|
49
|
+
* ``Zstd::StreamDecoder#update(src, srcoff, dest, maxdest) -> integer as new src offset`` (``ZSTD_decompressStream``)
|
50
|
+
|
51
|
+
* instant (context less) encoder/decoder
|
52
|
+
* ``Zstd::ContextLess.encode(src, dest, maxdest, predict, params) -> dest`` (``ZSTD_compress_usingDict``, ``ZSTD_compress_advanced``)
|
53
|
+
* ``Zstd::ContextLess.decode(src, dest, maxdest, predict) -> dest`` (``ZSTD_decompress_usingDict``)
|
42
54
|
|
43
|
-
*
|
44
|
-
* ``Zstd.
|
45
|
-
* ``Zstd.
|
55
|
+
* dictionary (*EXPEREMENTAL*)
|
56
|
+
* ``Zstd::Dictionary.train_from_buffer(buf, dict_capacity) -> dictionary'ed string`` (``ZDICT_trainFromBuffer``)
|
57
|
+
* ``Zstd::Dictionary.add_entropy_tables_from_buffer(dict, dict_capacity, sample) -> dict`` (``ZDICT_addEntropyTablesFromBuffer``)
|
58
|
+
* ``Zstd::Dictionary.getid(dict) -> dict id as integer`` (``ZDICT_getDictID``)
|
46
59
|
|
47
60
|
|
48
61
|
## HOW TO USE
|
data/contrib/zstd/LICENSE
CHANGED
@@ -1,18 +1,22 @@
|
|
1
|
-
ZSTD Library
|
2
|
-
Copyright (c) 2014-2015, Yann Collet
|
3
|
-
All rights reserved.
|
4
|
-
|
5
1
|
BSD License
|
6
2
|
|
3
|
+
For Zstandard software
|
4
|
+
|
5
|
+
Copyright (c) 2016-present, Facebook, Inc. All rights reserved.
|
6
|
+
|
7
7
|
Redistribution and use in source and binary forms, with or without modification,
|
8
8
|
are permitted provided that the following conditions are met:
|
9
9
|
|
10
|
-
* Redistributions of source code must retain the above copyright notice, this
|
11
|
-
|
10
|
+
* Redistributions of source code must retain the above copyright notice, this
|
11
|
+
list of conditions and the following disclaimer.
|
12
|
+
|
13
|
+
* Redistributions in binary form must reproduce the above copyright notice,
|
14
|
+
this list of conditions and the following disclaimer in the documentation
|
15
|
+
and/or other materials provided with the distribution.
|
12
16
|
|
13
|
-
*
|
14
|
-
|
15
|
-
|
17
|
+
* Neither the name Facebook nor the names of its contributors may be used to
|
18
|
+
endorse or promote products derived from this software without specific
|
19
|
+
prior written permission.
|
16
20
|
|
17
21
|
THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND
|
18
22
|
ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
|
data/contrib/zstd/README.md
CHANGED
@@ -1,62 +1,54 @@
|
|
1
|
-
|
1
|
+
Zstandard library files
|
2
2
|
================================
|
3
3
|
|
4
|
-
The __lib__ directory contains several
|
4
|
+
The __lib__ directory contains several directories.
|
5
|
+
Depending on target use case, it's enough to include only files from relevant directories.
|
5
6
|
|
6
|
-
#### Minimal library files
|
7
7
|
|
8
|
-
|
8
|
+
#### API
|
9
9
|
|
10
|
-
|
11
|
-
|
12
|
-
- [common/error_public.h](common/error_public.h)
|
13
|
-
- common/fse.h
|
14
|
-
- common/fse_decompress.c
|
15
|
-
- common/huf.h
|
16
|
-
- [common/mem.h](common/mem.h)
|
17
|
-
- [common/zstd.h]
|
18
|
-
- common/zstd_internal.h
|
19
|
-
- compress/fse_compress.c
|
20
|
-
- compress/huf_compress.c
|
21
|
-
- compress/zstd_compress.c
|
22
|
-
- compress/zstd_opt.h
|
23
|
-
- decompress/huf_decompress.c
|
24
|
-
- decompress/zstd_decompress.c
|
10
|
+
Zstandard's stable API is exposed within [zstd.h](zstd.h),
|
11
|
+
at the root of `lib` directory.
|
25
12
|
|
26
|
-
Stable API is exposed in [common/zstd.h].
|
27
|
-
Advanced and experimental API can be enabled by defining `ZSTD_STATIC_LINKING_ONLY`.
|
28
|
-
Never use them with a dynamic library, as their definition may change in future versions.
|
29
13
|
|
30
|
-
|
14
|
+
#### Advanced API
|
31
15
|
|
16
|
+
Some additional API may be useful if you're looking into advanced features :
|
17
|
+
- common/error_public.h : transforms `size_t` function results into an `enum`,
|
18
|
+
for precise error handling.
|
19
|
+
- ZSTD_STATIC_LINKING_ONLY : if you define this macro _before_ including `zstd.h`,
|
20
|
+
it will give access to advanced and experimental API.
|
21
|
+
These APIs shall ___never be used with dynamic library___ !
|
22
|
+
They are not "stable", their definition may change in the future.
|
23
|
+
Only static linking is allowed.
|
32
24
|
|
33
|
-
#### Separate compressor and decompressor
|
34
25
|
|
35
|
-
|
36
|
-
In a similar way to build a separate zstd decompressor all files from `common/` and `decompressor/` directories are needed.
|
26
|
+
#### Modular build
|
37
27
|
|
28
|
+
Directory `common/` is required in all circumstances.
|
29
|
+
You can select to support compression only, by just adding files from the `compress/` directory,
|
30
|
+
In a similar way, you can build a decompressor-only library with the `decompress/` directory.
|
38
31
|
|
39
|
-
|
32
|
+
Other optional functionalities provided are :
|
40
33
|
|
41
|
-
|
42
|
-
|
34
|
+
- `dictBuilder/` : source files to create dictionaries.
|
35
|
+
The API can be consulted in `dictBuilder/zdict.h`.
|
36
|
+
This module also depends on `common/` and `compress/` .
|
43
37
|
|
44
|
-
-
|
45
|
-
|
46
|
-
|
38
|
+
- `legacy/` : source code to decompress previous versions of zstd, starting from `v0.1`.
|
39
|
+
This module also depends on `common/` and `decompress/` .
|
40
|
+
Library compilation must include directive `ZSTD_LEGACY_SUPPORT = 1` .
|
41
|
+
The main API can be consulted in `legacy/zstd_legacy.h`.
|
42
|
+
Advanced API from each version can be found in their relevant header file.
|
43
|
+
For example, advanced API for version `v0.4` is in `legacy/zstd_v04.h` .
|
47
44
|
|
48
45
|
|
49
|
-
####
|
46
|
+
#### Obsolete streaming API
|
50
47
|
|
51
|
-
|
52
|
-
|
53
|
-
|
54
|
-
|
55
|
-
#### Legacy support
|
56
|
-
|
57
|
-
Zstandard can decode previous formats, starting from v0.1.
|
58
|
-
Support for these format is provided in [folder legacy](legacy/).
|
59
|
-
It's also required to compile the library with `ZSTD_LEGACY_SUPPORT = 1`.
|
48
|
+
Streaming is now provided within `zstd.h`.
|
49
|
+
Older streaming API is still provided within `common/zbuff.h`.
|
50
|
+
It is considered obsolete, and will be removed in a future version.
|
51
|
+
Consider migrating towards newer streaming API.
|
60
52
|
|
61
53
|
|
62
54
|
#### Miscellaneous
|
@@ -64,5 +56,6 @@ It's also required to compile the library with `ZSTD_LEGACY_SUPPORT = 1`.
|
|
64
56
|
The other files are not source code. There are :
|
65
57
|
|
66
58
|
- LICENSE : contains the BSD license text
|
67
|
-
- Makefile : script to compile or install zstd library (static
|
68
|
-
- libzstd.pc.in : for pkg-config (make install)
|
59
|
+
- Makefile : script to compile or install zstd library (static and dynamic)
|
60
|
+
- libzstd.pc.in : for pkg-config (`make install`)
|
61
|
+
- README.md : this file
|
@@ -38,10 +38,9 @@
|
|
38
38
|
#include "mem.h"
|
39
39
|
#include "error_private.h" /* ERR_*, ERROR */
|
40
40
|
#define FSE_STATIC_LINKING_ONLY /* FSE_MIN_TABLELOG */
|
41
|
-
#include "fse.h"
|
41
|
+
#include "fse.h"
|
42
42
|
#define HUF_STATIC_LINKING_ONLY /* HUF_TABLELOG_ABSOLUTEMAX */
|
43
|
-
#include "huf.h"
|
44
|
-
|
43
|
+
#include "huf.h"
|
45
44
|
|
46
45
|
|
47
46
|
/*-****************************************
|
@@ -63,7 +62,7 @@ const char* HUF_getErrorName(size_t code) { return ERR_getErrorName(code); }
|
|
63
62
|
/*-**************************************************************
|
64
63
|
* FSE NCount encoding-decoding
|
65
64
|
****************************************************************/
|
66
|
-
static short FSE_abs(short a) { return a<0 ? -a : a; }
|
65
|
+
static short FSE_abs(short a) { return (short)(a<0 ? -a : a); }
|
67
66
|
|
68
67
|
size_t FSE_readNCount (short* normalizedCounter, unsigned* maxSVPtr, unsigned* tableLogPtr,
|
69
68
|
const void* headerBuffer, size_t hbSize)
|
@@ -90,22 +89,22 @@ size_t FSE_readNCount (short* normalizedCounter, unsigned* maxSVPtr, unsigned* t
|
|
90
89
|
threshold = 1<<nbBits;
|
91
90
|
nbBits++;
|
92
91
|
|
93
|
-
while ((remaining>1)
|
92
|
+
while ((remaining>1) & (charnum<=*maxSVPtr)) {
|
94
93
|
if (previous0) {
|
95
94
|
unsigned n0 = charnum;
|
96
95
|
while ((bitStream & 0xFFFF) == 0xFFFF) {
|
97
|
-
n0+=24;
|
96
|
+
n0 += 24;
|
98
97
|
if (ip < iend-5) {
|
99
|
-
ip+=2;
|
98
|
+
ip += 2;
|
100
99
|
bitStream = MEM_readLE32(ip) >> bitCount;
|
101
100
|
} else {
|
102
101
|
bitStream >>= 16;
|
103
|
-
bitCount+=16;
|
102
|
+
bitCount += 16;
|
104
103
|
} }
|
105
104
|
while ((bitStream & 3) == 3) {
|
106
|
-
n0+=3;
|
107
|
-
bitStream>>=2;
|
108
|
-
bitCount+=2;
|
105
|
+
n0 += 3;
|
106
|
+
bitStream >>= 2;
|
107
|
+
bitCount += 2;
|
109
108
|
}
|
110
109
|
n0 += bitStream & 3;
|
111
110
|
bitCount += 2;
|
@@ -115,10 +114,9 @@ size_t FSE_readNCount (short* normalizedCounter, unsigned* maxSVPtr, unsigned* t
|
|
115
114
|
ip += bitCount>>3;
|
116
115
|
bitCount &= 7;
|
117
116
|
bitStream = MEM_readLE32(ip) >> bitCount;
|
118
|
-
}
|
119
|
-
else
|
117
|
+
} else {
|
120
118
|
bitStream >>= 2;
|
121
|
-
}
|
119
|
+
} }
|
122
120
|
{ short const max = (short)((2*threshold-1)-remaining);
|
123
121
|
short count;
|
124
122
|
|
@@ -148,12 +146,12 @@ size_t FSE_readNCount (short* normalizedCounter, unsigned* maxSVPtr, unsigned* t
|
|
148
146
|
ip = iend - 4;
|
149
147
|
}
|
150
148
|
bitStream = MEM_readLE32(ip) >> (bitCount & 31);
|
151
|
-
} } /* while ((remaining>1)
|
152
|
-
if (remaining != 1) return ERROR(
|
149
|
+
} } /* while ((remaining>1) & (charnum<=*maxSVPtr)) */
|
150
|
+
if (remaining != 1) return ERROR(corruption_detected);
|
151
|
+
if (bitCount > 32) return ERROR(corruption_detected);
|
153
152
|
*maxSVPtr = charnum-1;
|
154
153
|
|
155
154
|
ip += (bitCount+7)>>3;
|
156
|
-
if ((size_t)(ip-istart) > hbSize) return ERROR(srcSize_wrong);
|
157
155
|
return ip-istart;
|
158
156
|
}
|
159
157
|
|
@@ -162,7 +160,7 @@ size_t FSE_readNCount (short* normalizedCounter, unsigned* maxSVPtr, unsigned* t
|
|
162
160
|
Read compact Huffman tree, saved by HUF_writeCTable().
|
163
161
|
`huffWeight` is destination buffer.
|
164
162
|
@return : size read from `src` , or an error Code .
|
165
|
-
Note : Needed by HUF_readCTable() and
|
163
|
+
Note : Needed by HUF_readCTable() and HUF_readDTableX?() .
|
166
164
|
*/
|
167
165
|
size_t HUF_readStats(BYTE* huffWeight, size_t hwSize, U32* rankStats,
|
168
166
|
U32* nbSymbolsPtr, U32* tableLogPtr,
|
@@ -170,29 +168,24 @@ size_t HUF_readStats(BYTE* huffWeight, size_t hwSize, U32* rankStats,
|
|
170
168
|
{
|
171
169
|
U32 weightTotal;
|
172
170
|
const BYTE* ip = (const BYTE*) src;
|
173
|
-
size_t iSize
|
171
|
+
size_t iSize;
|
174
172
|
size_t oSize;
|
175
173
|
|
176
|
-
|
177
|
-
|
178
|
-
|
179
|
-
|
180
|
-
|
181
|
-
|
182
|
-
|
183
|
-
|
184
|
-
|
185
|
-
|
186
|
-
|
187
|
-
|
188
|
-
|
189
|
-
|
190
|
-
|
191
|
-
{ U32 n;
|
192
|
-
for (n=0; n<oSize; n+=2) {
|
193
|
-
huffWeight[n] = ip[n/2] >> 4;
|
194
|
-
huffWeight[n+1] = ip[n/2] & 15;
|
195
|
-
} } } }
|
174
|
+
if (!srcSize) return ERROR(srcSize_wrong);
|
175
|
+
iSize = ip[0];
|
176
|
+
/* memset(huffWeight, 0, hwSize); *//* is not necessary, even though some analyzer complain ... */
|
177
|
+
|
178
|
+
if (iSize >= 128) { /* special header */
|
179
|
+
oSize = iSize - 127;
|
180
|
+
iSize = ((oSize+1)/2);
|
181
|
+
if (iSize+1 > srcSize) return ERROR(srcSize_wrong);
|
182
|
+
if (oSize >= hwSize) return ERROR(corruption_detected);
|
183
|
+
ip += 1;
|
184
|
+
{ U32 n;
|
185
|
+
for (n=0; n<oSize; n+=2) {
|
186
|
+
huffWeight[n] = ip[n/2] >> 4;
|
187
|
+
huffWeight[n+1] = ip[n/2] & 15;
|
188
|
+
} } }
|
196
189
|
else { /* header compressed with FSE (normal case) */
|
197
190
|
if (iSize+1 > srcSize) return ERROR(srcSize_wrong);
|
198
191
|
oSize = FSE_decompress(huffWeight, hwSize-1, ip+1, iSize); /* max (hwSize-1) values decoded, as last one is implied */
|
@@ -207,6 +200,7 @@ size_t HUF_readStats(BYTE* huffWeight, size_t hwSize, U32* rankStats,
|
|
207
200
|
rankStats[huffWeight[n]]++;
|
208
201
|
weightTotal += (1 << huffWeight[n]) >> 1;
|
209
202
|
} }
|
203
|
+
if (weightTotal == 0) return ERROR(corruption_detected);
|
210
204
|
|
211
205
|
/* get last non-null symbol weight (implied, total must be 2^n) */
|
212
206
|
{ U32 const tableLog = BIT_highbit32(weightTotal) + 1;
|
@@ -0,0 +1,43 @@
|
|
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
|
+
/* The purpose of this file is to have a single list of error strings embedded in binary */
|
11
|
+
|
12
|
+
#include "error_private.h"
|
13
|
+
|
14
|
+
const char* ERR_getErrorString(ERR_enum code)
|
15
|
+
{
|
16
|
+
static const char* const notErrorCode = "Unspecified error code";
|
17
|
+
switch( code )
|
18
|
+
{
|
19
|
+
case PREFIX(no_error): return "No error detected";
|
20
|
+
case PREFIX(GENERIC): return "Error (generic)";
|
21
|
+
case PREFIX(prefix_unknown): return "Unknown frame descriptor";
|
22
|
+
case PREFIX(version_unsupported): return "Version not supported";
|
23
|
+
case PREFIX(parameter_unknown): return "Unknown parameter type";
|
24
|
+
case PREFIX(frameParameter_unsupported): return "Unsupported frame parameter";
|
25
|
+
case PREFIX(frameParameter_unsupportedBy32bits): return "Frame parameter unsupported in 32-bits mode";
|
26
|
+
case PREFIX(frameParameter_windowTooLarge): return "Frame requires too much memory for decoding";
|
27
|
+
case PREFIX(compressionParameter_unsupported): return "Compression parameter is out of bound";
|
28
|
+
case PREFIX(init_missing): return "Context should be init first";
|
29
|
+
case PREFIX(memory_allocation): return "Allocation error : not enough memory";
|
30
|
+
case PREFIX(stage_wrong): return "Operation not authorized at current processing stage";
|
31
|
+
case PREFIX(dstSize_tooSmall): return "Destination buffer is too small";
|
32
|
+
case PREFIX(srcSize_wrong): return "Src size incorrect";
|
33
|
+
case PREFIX(corruption_detected): return "Corrupted block detected";
|
34
|
+
case PREFIX(checksum_wrong): return "Restored data doesn't match checksum";
|
35
|
+
case PREFIX(tableLog_tooLarge): return "tableLog requires too much memory : unsupported";
|
36
|
+
case PREFIX(maxSymbolValue_tooLarge): return "Unsupported max Symbol Value : too large";
|
37
|
+
case PREFIX(maxSymbolValue_tooSmall): return "Specified maxSymbolValue is too small";
|
38
|
+
case PREFIX(dictionary_corrupted): return "Dictionary is corrupted";
|
39
|
+
case PREFIX(dictionary_wrong): return "Dictionary mismatch";
|
40
|
+
case PREFIX(maxCode):
|
41
|
+
default: return notErrorCode;
|
42
|
+
}
|
43
|
+
}
|
@@ -1,35 +1,12 @@
|
|
1
|
-
|
2
|
-
|
3
|
-
|
4
|
-
|
5
|
-
|
6
|
-
|
7
|
-
|
8
|
-
|
9
|
-
|
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
|
-
- Homepage : http://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
|
+
*/
|
9
|
+
|
33
10
|
/* Note : this module is expected to remain private, do not expose it */
|
34
11
|
|
35
12
|
#ifndef ERROR_H_MODULE
|
@@ -44,7 +21,7 @@ extern "C" {
|
|
44
21
|
* Dependencies
|
45
22
|
******************************************/
|
46
23
|
#include <stddef.h> /* size_t */
|
47
|
-
#include "
|
24
|
+
#include "zstd_errors.h" /* enum list */
|
48
25
|
|
49
26
|
|
50
27
|
/* ****************************************
|
@@ -85,33 +62,7 @@ ERR_STATIC ERR_enum ERR_getErrorCode(size_t code) { if (!ERR_isError(code)) retu
|
|
85
62
|
* Error Strings
|
86
63
|
******************************************/
|
87
64
|
|
88
|
-
|
89
|
-
{
|
90
|
-
static const char* notErrorCode = "Unspecified error code";
|
91
|
-
switch( code )
|
92
|
-
{
|
93
|
-
case PREFIX(no_error): return "No error detected";
|
94
|
-
case PREFIX(GENERIC): return "Error (generic)";
|
95
|
-
case PREFIX(prefix_unknown): return "Unknown frame descriptor";
|
96
|
-
case PREFIX(frameParameter_unsupported): return "Unsupported frame parameter";
|
97
|
-
case PREFIX(frameParameter_unsupportedBy32bits): return "Frame parameter unsupported in 32-bits mode";
|
98
|
-
case PREFIX(compressionParameter_unsupported): return "Compression parameter is out of bound";
|
99
|
-
case PREFIX(init_missing): return "Context should be init first";
|
100
|
-
case PREFIX(memory_allocation): return "Allocation error : not enough memory";
|
101
|
-
case PREFIX(stage_wrong): return "Operation not authorized at current processing stage";
|
102
|
-
case PREFIX(dstSize_tooSmall): return "Destination buffer is too small";
|
103
|
-
case PREFIX(srcSize_wrong): return "Src size incorrect";
|
104
|
-
case PREFIX(corruption_detected): return "Corrupted block detected";
|
105
|
-
case PREFIX(checksum_wrong): return "Restored data doesn't match checksum";
|
106
|
-
case PREFIX(tableLog_tooLarge): return "tableLog requires too much memory : unsupported";
|
107
|
-
case PREFIX(maxSymbolValue_tooLarge): return "Unsupported max Symbol Value : too large";
|
108
|
-
case PREFIX(maxSymbolValue_tooSmall): return "Specified maxSymbolValue is too small";
|
109
|
-
case PREFIX(dictionary_corrupted): return "Dictionary is corrupted";
|
110
|
-
case PREFIX(dictionary_wrong): return "Dictionary mismatch";
|
111
|
-
case PREFIX(maxCode):
|
112
|
-
default: return notErrorCode;
|
113
|
-
}
|
114
|
-
}
|
65
|
+
const char* ERR_getErrorString(ERR_enum code); /* error_private.c */
|
115
66
|
|
116
67
|
ERR_STATIC const char* ERR_getErrorName(size_t code)
|
117
68
|
{
|
data/contrib/zstd/common/fse.h
CHANGED
@@ -503,7 +503,8 @@ MEM_STATIC void FSE_flushCState(BIT_CStream_t* bitC, const FSE_CState_t* statePt
|
|
503
503
|
BIT_flushBits(bitC);
|
504
504
|
}
|
505
505
|
|
506
|
-
|
506
|
+
|
507
|
+
/* ====== Decompression ====== */
|
507
508
|
|
508
509
|
typedef struct {
|
509
510
|
U16 tableLog;
|
@@ -581,14 +582,19 @@ MEM_STATIC unsigned FSE_endOfDState(const FSE_DState_t* DStatePtr)
|
|
581
582
|
* Increasing memory usage improves compression ratio
|
582
583
|
* Reduced memory usage can improve speed, due to cache effect
|
583
584
|
* Recommended max value is 14, for 16KB, which nicely fits into Intel x86 L1 cache */
|
584
|
-
#
|
585
|
-
#define
|
585
|
+
#ifndef FSE_MAX_MEMORY_USAGE
|
586
|
+
# define FSE_MAX_MEMORY_USAGE 14
|
587
|
+
#endif
|
588
|
+
#ifndef FSE_DEFAULT_MEMORY_USAGE
|
589
|
+
# define FSE_DEFAULT_MEMORY_USAGE 13
|
590
|
+
#endif
|
586
591
|
|
587
592
|
/*!FSE_MAX_SYMBOL_VALUE :
|
588
593
|
* Maximum symbol value authorized.
|
589
594
|
* Required for proper stack allocation */
|
590
|
-
#
|
591
|
-
|
595
|
+
#ifndef FSE_MAX_SYMBOL_VALUE
|
596
|
+
# define FSE_MAX_SYMBOL_VALUE 255
|
597
|
+
#endif
|
592
598
|
|
593
599
|
/* **************************************************************
|
594
600
|
* template functions type & suffix
|