zstdlib 0.9.0-arm64-darwin
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +7 -0
- data/.yardopts +6 -0
- data/CHANGES.md +78 -0
- data/Gemfile +3 -0
- data/README.md +107 -0
- data/Rakefile +59 -0
- data/ext/zstdlib_c/extconf.rb +54 -0
- data/ext/zstdlib_c/ruby/zlib-2.2/zstdlib.c +4675 -0
- data/ext/zstdlib_c/ruby/zlib-2.3/zstdlib.c +4702 -0
- data/ext/zstdlib_c/ruby/zlib-2.4/zstdlib.c +4859 -0
- data/ext/zstdlib_c/ruby/zlib-2.5/zstdlib.c +4864 -0
- data/ext/zstdlib_c/ruby/zlib-2.6/zstdlib.c +4906 -0
- data/ext/zstdlib_c/ruby/zlib-2.7/zstdlib.c +4895 -0
- data/ext/zstdlib_c/ruby/zlib-3.0/zstdlib.c +4994 -0
- data/ext/zstdlib_c/ruby/zlib-3.1/zstdlib.c +5076 -0
- data/ext/zstdlib_c/zlib-1.2.11/adler32.c +186 -0
- data/ext/zstdlib_c/zlib-1.2.11/compress.c +86 -0
- data/ext/zstdlib_c/zlib-1.2.11/crc32.c +442 -0
- data/ext/zstdlib_c/zlib-1.2.11/crc32.h +441 -0
- data/ext/zstdlib_c/zlib-1.2.11/deflate.c +2163 -0
- data/ext/zstdlib_c/zlib-1.2.11/deflate.h +349 -0
- data/ext/zstdlib_c/zlib-1.2.11/gzclose.c +25 -0
- data/ext/zstdlib_c/zlib-1.2.11/gzguts.h +218 -0
- data/ext/zstdlib_c/zlib-1.2.11/gzlib.c +637 -0
- data/ext/zstdlib_c/zlib-1.2.11/gzread.c +654 -0
- data/ext/zstdlib_c/zlib-1.2.11/gzwrite.c +665 -0
- data/ext/zstdlib_c/zlib-1.2.11/infback.c +640 -0
- data/ext/zstdlib_c/zlib-1.2.11/inffast.c +323 -0
- data/ext/zstdlib_c/zlib-1.2.11/inffast.h +11 -0
- data/ext/zstdlib_c/zlib-1.2.11/inffixed.h +94 -0
- data/ext/zstdlib_c/zlib-1.2.11/inflate.c +1561 -0
- data/ext/zstdlib_c/zlib-1.2.11/inflate.h +125 -0
- data/ext/zstdlib_c/zlib-1.2.11/inftrees.c +304 -0
- data/ext/zstdlib_c/zlib-1.2.11/inftrees.h +62 -0
- data/ext/zstdlib_c/zlib-1.2.11/trees.c +1203 -0
- data/ext/zstdlib_c/zlib-1.2.11/trees.h +128 -0
- data/ext/zstdlib_c/zlib-1.2.11/uncompr.c +93 -0
- data/ext/zstdlib_c/zlib-1.2.11/zconf.h +534 -0
- data/ext/zstdlib_c/zlib-1.2.11/zlib.h +1912 -0
- data/ext/zstdlib_c/zlib-1.2.11/zutil.c +325 -0
- data/ext/zstdlib_c/zlib-1.2.11/zutil.h +271 -0
- data/ext/zstdlib_c/zlib.mk +14 -0
- data/ext/zstdlib_c/zlibwrapper/zlibwrapper.c +10 -0
- data/ext/zstdlib_c/zlibwrapper.mk +14 -0
- data/ext/zstdlib_c/zstd-1.5.2/lib/common/bitstream.h +478 -0
- data/ext/zstdlib_c/zstd-1.5.2/lib/common/compiler.h +335 -0
- data/ext/zstdlib_c/zstd-1.5.2/lib/common/cpu.h +213 -0
- data/ext/zstdlib_c/zstd-1.5.2/lib/common/debug.c +24 -0
- data/ext/zstdlib_c/zstd-1.5.2/lib/common/debug.h +107 -0
- data/ext/zstdlib_c/zstd-1.5.2/lib/common/entropy_common.c +368 -0
- data/ext/zstdlib_c/zstd-1.5.2/lib/common/error_private.c +56 -0
- data/ext/zstdlib_c/zstd-1.5.2/lib/common/error_private.h +159 -0
- data/ext/zstdlib_c/zstd-1.5.2/lib/common/fse.h +717 -0
- data/ext/zstdlib_c/zstd-1.5.2/lib/common/fse_decompress.c +403 -0
- data/ext/zstdlib_c/zstd-1.5.2/lib/common/huf.h +364 -0
- data/ext/zstdlib_c/zstd-1.5.2/lib/common/mem.h +442 -0
- data/ext/zstdlib_c/zstd-1.5.2/lib/common/pool.c +355 -0
- data/ext/zstdlib_c/zstd-1.5.2/lib/common/pool.h +84 -0
- data/ext/zstdlib_c/zstd-1.5.2/lib/common/portability_macros.h +137 -0
- data/ext/zstdlib_c/zstd-1.5.2/lib/common/threading.c +122 -0
- data/ext/zstdlib_c/zstd-1.5.2/lib/common/threading.h +155 -0
- data/ext/zstdlib_c/zstd-1.5.2/lib/common/xxhash.c +24 -0
- data/ext/zstdlib_c/zstd-1.5.2/lib/common/xxhash.h +5686 -0
- data/ext/zstdlib_c/zstd-1.5.2/lib/common/zstd_common.c +83 -0
- data/ext/zstdlib_c/zstd-1.5.2/lib/common/zstd_deps.h +111 -0
- data/ext/zstdlib_c/zstd-1.5.2/lib/common/zstd_internal.h +493 -0
- data/ext/zstdlib_c/zstd-1.5.2/lib/common/zstd_trace.h +163 -0
- data/ext/zstdlib_c/zstd-1.5.2/lib/compress/clevels.h +134 -0
- data/ext/zstdlib_c/zstd-1.5.2/lib/compress/fse_compress.c +741 -0
- data/ext/zstdlib_c/zstd-1.5.2/lib/compress/hist.c +181 -0
- data/ext/zstdlib_c/zstd-1.5.2/lib/compress/hist.h +75 -0
- data/ext/zstdlib_c/zstd-1.5.2/lib/compress/huf_compress.c +1370 -0
- data/ext/zstdlib_c/zstd-1.5.2/lib/compress/zstd_compress.c +6327 -0
- data/ext/zstdlib_c/zstd-1.5.2/lib/compress/zstd_compress_internal.h +1458 -0
- data/ext/zstdlib_c/zstd-1.5.2/lib/compress/zstd_compress_literals.c +159 -0
- data/ext/zstdlib_c/zstd-1.5.2/lib/compress/zstd_compress_literals.h +31 -0
- data/ext/zstdlib_c/zstd-1.5.2/lib/compress/zstd_compress_sequences.c +442 -0
- data/ext/zstdlib_c/zstd-1.5.2/lib/compress/zstd_compress_sequences.h +54 -0
- data/ext/zstdlib_c/zstd-1.5.2/lib/compress/zstd_compress_superblock.c +573 -0
- data/ext/zstdlib_c/zstd-1.5.2/lib/compress/zstd_compress_superblock.h +32 -0
- data/ext/zstdlib_c/zstd-1.5.2/lib/compress/zstd_cwksp.h +676 -0
- data/ext/zstdlib_c/zstd-1.5.2/lib/compress/zstd_double_fast.c +696 -0
- data/ext/zstdlib_c/zstd-1.5.2/lib/compress/zstd_double_fast.h +38 -0
- data/ext/zstdlib_c/zstd-1.5.2/lib/compress/zstd_fast.c +675 -0
- data/ext/zstdlib_c/zstd-1.5.2/lib/compress/zstd_fast.h +37 -0
- data/ext/zstdlib_c/zstd-1.5.2/lib/compress/zstd_lazy.c +2104 -0
- data/ext/zstdlib_c/zstd-1.5.2/lib/compress/zstd_lazy.h +125 -0
- data/ext/zstdlib_c/zstd-1.5.2/lib/compress/zstd_ldm.c +724 -0
- data/ext/zstdlib_c/zstd-1.5.2/lib/compress/zstd_ldm.h +117 -0
- data/ext/zstdlib_c/zstd-1.5.2/lib/compress/zstd_ldm_geartab.h +106 -0
- data/ext/zstdlib_c/zstd-1.5.2/lib/compress/zstd_opt.c +1446 -0
- data/ext/zstdlib_c/zstd-1.5.2/lib/compress/zstd_opt.h +56 -0
- data/ext/zstdlib_c/zstd-1.5.2/lib/compress/zstdmt_compress.c +1859 -0
- data/ext/zstdlib_c/zstd-1.5.2/lib/compress/zstdmt_compress.h +113 -0
- data/ext/zstdlib_c/zstd-1.5.2/lib/decompress/huf_decompress.c +1889 -0
- data/ext/zstdlib_c/zstd-1.5.2/lib/decompress/huf_decompress_amd64.S +585 -0
- data/ext/zstdlib_c/zstd-1.5.2/lib/decompress/zstd_ddict.c +244 -0
- data/ext/zstdlib_c/zstd-1.5.2/lib/decompress/zstd_ddict.h +44 -0
- data/ext/zstdlib_c/zstd-1.5.2/lib/decompress/zstd_decompress.c +2230 -0
- data/ext/zstdlib_c/zstd-1.5.2/lib/decompress/zstd_decompress_block.c +2072 -0
- data/ext/zstdlib_c/zstd-1.5.2/lib/decompress/zstd_decompress_block.h +68 -0
- data/ext/zstdlib_c/zstd-1.5.2/lib/decompress/zstd_decompress_internal.h +236 -0
- data/ext/zstdlib_c/zstd-1.5.2/lib/zdict.h +452 -0
- data/ext/zstdlib_c/zstd-1.5.2/lib/zstd.h +2575 -0
- data/ext/zstdlib_c/zstd-1.5.2/lib/zstd_errors.h +95 -0
- data/ext/zstdlib_c/zstd-1.5.2/zlibWrapper/gzclose.c +28 -0
- data/ext/zstdlib_c/zstd-1.5.2/zlibWrapper/gzcompatibility.h +68 -0
- data/ext/zstdlib_c/zstd-1.5.2/zlibWrapper/gzguts.h +229 -0
- data/ext/zstdlib_c/zstd-1.5.2/zlibWrapper/gzlib.c +640 -0
- data/ext/zstdlib_c/zstd-1.5.2/zlibWrapper/gzread.c +678 -0
- data/ext/zstdlib_c/zstd-1.5.2/zlibWrapper/gzwrite.c +671 -0
- data/ext/zstdlib_c/zstd-1.5.2/zlibWrapper/zstd_zlibwrapper.c +1198 -0
- data/ext/zstdlib_c/zstd-1.5.2/zlibWrapper/zstd_zlibwrapper.h +88 -0
- data/ext/zstdlib_c/zstd.mk +15 -0
- data/lib/2.4/zstdlib_c.bundle +0 -0
- data/lib/2.5/zstdlib_c.bundle +0 -0
- data/lib/2.6/zstdlib_c.bundle +0 -0
- data/lib/2.7/zstdlib_c.bundle +0 -0
- data/lib/3.0/zstdlib_c.bundle +0 -0
- data/lib/3.1/zstdlib_c.bundle +0 -0
- data/lib/zstdlib.rb +6 -0
- data/test/zstdlib_test.rb +21 -0
- metadata +237 -0
@@ -0,0 +1,181 @@
|
|
1
|
+
/* ******************************************************************
|
2
|
+
* hist : Histogram functions
|
3
|
+
* part of Finite State Entropy project
|
4
|
+
* Copyright (c) Yann Collet, Facebook, Inc.
|
5
|
+
*
|
6
|
+
* You can contact the author at :
|
7
|
+
* - FSE source repository : https://github.com/Cyan4973/FiniteStateEntropy
|
8
|
+
* - Public forum : https://groups.google.com/forum/#!forum/lz4c
|
9
|
+
*
|
10
|
+
* This source code is licensed under both the BSD-style license (found in the
|
11
|
+
* LICENSE file in the root directory of this source tree) and the GPLv2 (found
|
12
|
+
* in the COPYING file in the root directory of this source tree).
|
13
|
+
* You may select, at your option, one of the above-listed licenses.
|
14
|
+
****************************************************************** */
|
15
|
+
|
16
|
+
/* --- dependencies --- */
|
17
|
+
#include "../common/mem.h" /* U32, BYTE, etc. */
|
18
|
+
#include "../common/debug.h" /* assert, DEBUGLOG */
|
19
|
+
#include "../common/error_private.h" /* ERROR */
|
20
|
+
#include "hist.h"
|
21
|
+
|
22
|
+
|
23
|
+
/* --- Error management --- */
|
24
|
+
unsigned HIST_isError(size_t code) { return ERR_isError(code); }
|
25
|
+
|
26
|
+
/*-**************************************************************
|
27
|
+
* Histogram functions
|
28
|
+
****************************************************************/
|
29
|
+
unsigned HIST_count_simple(unsigned* count, unsigned* maxSymbolValuePtr,
|
30
|
+
const void* src, size_t srcSize)
|
31
|
+
{
|
32
|
+
const BYTE* ip = (const BYTE*)src;
|
33
|
+
const BYTE* const end = ip + srcSize;
|
34
|
+
unsigned maxSymbolValue = *maxSymbolValuePtr;
|
35
|
+
unsigned largestCount=0;
|
36
|
+
|
37
|
+
ZSTD_memset(count, 0, (maxSymbolValue+1) * sizeof(*count));
|
38
|
+
if (srcSize==0) { *maxSymbolValuePtr = 0; return 0; }
|
39
|
+
|
40
|
+
while (ip<end) {
|
41
|
+
assert(*ip <= maxSymbolValue);
|
42
|
+
count[*ip++]++;
|
43
|
+
}
|
44
|
+
|
45
|
+
while (!count[maxSymbolValue]) maxSymbolValue--;
|
46
|
+
*maxSymbolValuePtr = maxSymbolValue;
|
47
|
+
|
48
|
+
{ U32 s;
|
49
|
+
for (s=0; s<=maxSymbolValue; s++)
|
50
|
+
if (count[s] > largestCount) largestCount = count[s];
|
51
|
+
}
|
52
|
+
|
53
|
+
return largestCount;
|
54
|
+
}
|
55
|
+
|
56
|
+
typedef enum { trustInput, checkMaxSymbolValue } HIST_checkInput_e;
|
57
|
+
|
58
|
+
/* HIST_count_parallel_wksp() :
|
59
|
+
* store histogram into 4 intermediate tables, recombined at the end.
|
60
|
+
* this design makes better use of OoO cpus,
|
61
|
+
* and is noticeably faster when some values are heavily repeated.
|
62
|
+
* But it needs some additional workspace for intermediate tables.
|
63
|
+
* `workSpace` must be a U32 table of size >= HIST_WKSP_SIZE_U32.
|
64
|
+
* @return : largest histogram frequency,
|
65
|
+
* or an error code (notably when histogram's alphabet is larger than *maxSymbolValuePtr) */
|
66
|
+
static size_t HIST_count_parallel_wksp(
|
67
|
+
unsigned* count, unsigned* maxSymbolValuePtr,
|
68
|
+
const void* source, size_t sourceSize,
|
69
|
+
HIST_checkInput_e check,
|
70
|
+
U32* const workSpace)
|
71
|
+
{
|
72
|
+
const BYTE* ip = (const BYTE*)source;
|
73
|
+
const BYTE* const iend = ip+sourceSize;
|
74
|
+
size_t const countSize = (*maxSymbolValuePtr + 1) * sizeof(*count);
|
75
|
+
unsigned max=0;
|
76
|
+
U32* const Counting1 = workSpace;
|
77
|
+
U32* const Counting2 = Counting1 + 256;
|
78
|
+
U32* const Counting3 = Counting2 + 256;
|
79
|
+
U32* const Counting4 = Counting3 + 256;
|
80
|
+
|
81
|
+
/* safety checks */
|
82
|
+
assert(*maxSymbolValuePtr <= 255);
|
83
|
+
if (!sourceSize) {
|
84
|
+
ZSTD_memset(count, 0, countSize);
|
85
|
+
*maxSymbolValuePtr = 0;
|
86
|
+
return 0;
|
87
|
+
}
|
88
|
+
ZSTD_memset(workSpace, 0, 4*256*sizeof(unsigned));
|
89
|
+
|
90
|
+
/* by stripes of 16 bytes */
|
91
|
+
{ U32 cached = MEM_read32(ip); ip += 4;
|
92
|
+
while (ip < iend-15) {
|
93
|
+
U32 c = cached; cached = MEM_read32(ip); ip += 4;
|
94
|
+
Counting1[(BYTE) c ]++;
|
95
|
+
Counting2[(BYTE)(c>>8) ]++;
|
96
|
+
Counting3[(BYTE)(c>>16)]++;
|
97
|
+
Counting4[ c>>24 ]++;
|
98
|
+
c = cached; cached = MEM_read32(ip); ip += 4;
|
99
|
+
Counting1[(BYTE) c ]++;
|
100
|
+
Counting2[(BYTE)(c>>8) ]++;
|
101
|
+
Counting3[(BYTE)(c>>16)]++;
|
102
|
+
Counting4[ c>>24 ]++;
|
103
|
+
c = cached; cached = MEM_read32(ip); ip += 4;
|
104
|
+
Counting1[(BYTE) c ]++;
|
105
|
+
Counting2[(BYTE)(c>>8) ]++;
|
106
|
+
Counting3[(BYTE)(c>>16)]++;
|
107
|
+
Counting4[ c>>24 ]++;
|
108
|
+
c = cached; cached = MEM_read32(ip); ip += 4;
|
109
|
+
Counting1[(BYTE) c ]++;
|
110
|
+
Counting2[(BYTE)(c>>8) ]++;
|
111
|
+
Counting3[(BYTE)(c>>16)]++;
|
112
|
+
Counting4[ c>>24 ]++;
|
113
|
+
}
|
114
|
+
ip-=4;
|
115
|
+
}
|
116
|
+
|
117
|
+
/* finish last symbols */
|
118
|
+
while (ip<iend) Counting1[*ip++]++;
|
119
|
+
|
120
|
+
{ U32 s;
|
121
|
+
for (s=0; s<256; s++) {
|
122
|
+
Counting1[s] += Counting2[s] + Counting3[s] + Counting4[s];
|
123
|
+
if (Counting1[s] > max) max = Counting1[s];
|
124
|
+
} }
|
125
|
+
|
126
|
+
{ unsigned maxSymbolValue = 255;
|
127
|
+
while (!Counting1[maxSymbolValue]) maxSymbolValue--;
|
128
|
+
if (check && maxSymbolValue > *maxSymbolValuePtr) return ERROR(maxSymbolValue_tooSmall);
|
129
|
+
*maxSymbolValuePtr = maxSymbolValue;
|
130
|
+
ZSTD_memmove(count, Counting1, countSize); /* in case count & Counting1 are overlapping */
|
131
|
+
}
|
132
|
+
return (size_t)max;
|
133
|
+
}
|
134
|
+
|
135
|
+
/* HIST_countFast_wksp() :
|
136
|
+
* Same as HIST_countFast(), but using an externally provided scratch buffer.
|
137
|
+
* `workSpace` is a writable buffer which must be 4-bytes aligned,
|
138
|
+
* `workSpaceSize` must be >= HIST_WKSP_SIZE
|
139
|
+
*/
|
140
|
+
size_t HIST_countFast_wksp(unsigned* count, unsigned* maxSymbolValuePtr,
|
141
|
+
const void* source, size_t sourceSize,
|
142
|
+
void* workSpace, size_t workSpaceSize)
|
143
|
+
{
|
144
|
+
if (sourceSize < 1500) /* heuristic threshold */
|
145
|
+
return HIST_count_simple(count, maxSymbolValuePtr, source, sourceSize);
|
146
|
+
if ((size_t)workSpace & 3) return ERROR(GENERIC); /* must be aligned on 4-bytes boundaries */
|
147
|
+
if (workSpaceSize < HIST_WKSP_SIZE) return ERROR(workSpace_tooSmall);
|
148
|
+
return HIST_count_parallel_wksp(count, maxSymbolValuePtr, source, sourceSize, trustInput, (U32*)workSpace);
|
149
|
+
}
|
150
|
+
|
151
|
+
/* HIST_count_wksp() :
|
152
|
+
* Same as HIST_count(), but using an externally provided scratch buffer.
|
153
|
+
* `workSpace` size must be table of >= HIST_WKSP_SIZE_U32 unsigned */
|
154
|
+
size_t HIST_count_wksp(unsigned* count, unsigned* maxSymbolValuePtr,
|
155
|
+
const void* source, size_t sourceSize,
|
156
|
+
void* workSpace, size_t workSpaceSize)
|
157
|
+
{
|
158
|
+
if ((size_t)workSpace & 3) return ERROR(GENERIC); /* must be aligned on 4-bytes boundaries */
|
159
|
+
if (workSpaceSize < HIST_WKSP_SIZE) return ERROR(workSpace_tooSmall);
|
160
|
+
if (*maxSymbolValuePtr < 255)
|
161
|
+
return HIST_count_parallel_wksp(count, maxSymbolValuePtr, source, sourceSize, checkMaxSymbolValue, (U32*)workSpace);
|
162
|
+
*maxSymbolValuePtr = 255;
|
163
|
+
return HIST_countFast_wksp(count, maxSymbolValuePtr, source, sourceSize, workSpace, workSpaceSize);
|
164
|
+
}
|
165
|
+
|
166
|
+
#ifndef ZSTD_NO_UNUSED_FUNCTIONS
|
167
|
+
/* fast variant (unsafe : won't check if src contains values beyond count[] limit) */
|
168
|
+
size_t HIST_countFast(unsigned* count, unsigned* maxSymbolValuePtr,
|
169
|
+
const void* source, size_t sourceSize)
|
170
|
+
{
|
171
|
+
unsigned tmpCounters[HIST_WKSP_SIZE_U32];
|
172
|
+
return HIST_countFast_wksp(count, maxSymbolValuePtr, source, sourceSize, tmpCounters, sizeof(tmpCounters));
|
173
|
+
}
|
174
|
+
|
175
|
+
size_t HIST_count(unsigned* count, unsigned* maxSymbolValuePtr,
|
176
|
+
const void* src, size_t srcSize)
|
177
|
+
{
|
178
|
+
unsigned tmpCounters[HIST_WKSP_SIZE_U32];
|
179
|
+
return HIST_count_wksp(count, maxSymbolValuePtr, src, srcSize, tmpCounters, sizeof(tmpCounters));
|
180
|
+
}
|
181
|
+
#endif
|
@@ -0,0 +1,75 @@
|
|
1
|
+
/* ******************************************************************
|
2
|
+
* hist : Histogram functions
|
3
|
+
* part of Finite State Entropy project
|
4
|
+
* Copyright (c) Yann Collet, Facebook, Inc.
|
5
|
+
*
|
6
|
+
* You can contact the author at :
|
7
|
+
* - FSE source repository : https://github.com/Cyan4973/FiniteStateEntropy
|
8
|
+
* - Public forum : https://groups.google.com/forum/#!forum/lz4c
|
9
|
+
*
|
10
|
+
* This source code is licensed under both the BSD-style license (found in the
|
11
|
+
* LICENSE file in the root directory of this source tree) and the GPLv2 (found
|
12
|
+
* in the COPYING file in the root directory of this source tree).
|
13
|
+
* You may select, at your option, one of the above-listed licenses.
|
14
|
+
****************************************************************** */
|
15
|
+
|
16
|
+
/* --- dependencies --- */
|
17
|
+
#include "../common/zstd_deps.h" /* size_t */
|
18
|
+
|
19
|
+
|
20
|
+
/* --- simple histogram functions --- */
|
21
|
+
|
22
|
+
/*! HIST_count():
|
23
|
+
* Provides the precise count of each byte within a table 'count'.
|
24
|
+
* 'count' is a table of unsigned int, of minimum size (*maxSymbolValuePtr+1).
|
25
|
+
* Updates *maxSymbolValuePtr with actual largest symbol value detected.
|
26
|
+
* @return : count of the most frequent symbol (which isn't identified).
|
27
|
+
* or an error code, which can be tested using HIST_isError().
|
28
|
+
* note : if return == srcSize, there is only one symbol.
|
29
|
+
*/
|
30
|
+
size_t HIST_count(unsigned* count, unsigned* maxSymbolValuePtr,
|
31
|
+
const void* src, size_t srcSize);
|
32
|
+
|
33
|
+
unsigned HIST_isError(size_t code); /**< tells if a return value is an error code */
|
34
|
+
|
35
|
+
|
36
|
+
/* --- advanced histogram functions --- */
|
37
|
+
|
38
|
+
#define HIST_WKSP_SIZE_U32 1024
|
39
|
+
#define HIST_WKSP_SIZE (HIST_WKSP_SIZE_U32 * sizeof(unsigned))
|
40
|
+
/** HIST_count_wksp() :
|
41
|
+
* Same as HIST_count(), but using an externally provided scratch buffer.
|
42
|
+
* Benefit is this function will use very little stack space.
|
43
|
+
* `workSpace` is a writable buffer which must be 4-bytes aligned,
|
44
|
+
* `workSpaceSize` must be >= HIST_WKSP_SIZE
|
45
|
+
*/
|
46
|
+
size_t HIST_count_wksp(unsigned* count, unsigned* maxSymbolValuePtr,
|
47
|
+
const void* src, size_t srcSize,
|
48
|
+
void* workSpace, size_t workSpaceSize);
|
49
|
+
|
50
|
+
/** HIST_countFast() :
|
51
|
+
* same as HIST_count(), but blindly trusts that all byte values within src are <= *maxSymbolValuePtr.
|
52
|
+
* This function is unsafe, and will segfault if any value within `src` is `> *maxSymbolValuePtr`
|
53
|
+
*/
|
54
|
+
size_t HIST_countFast(unsigned* count, unsigned* maxSymbolValuePtr,
|
55
|
+
const void* src, size_t srcSize);
|
56
|
+
|
57
|
+
/** HIST_countFast_wksp() :
|
58
|
+
* Same as HIST_countFast(), but using an externally provided scratch buffer.
|
59
|
+
* `workSpace` is a writable buffer which must be 4-bytes aligned,
|
60
|
+
* `workSpaceSize` must be >= HIST_WKSP_SIZE
|
61
|
+
*/
|
62
|
+
size_t HIST_countFast_wksp(unsigned* count, unsigned* maxSymbolValuePtr,
|
63
|
+
const void* src, size_t srcSize,
|
64
|
+
void* workSpace, size_t workSpaceSize);
|
65
|
+
|
66
|
+
/*! HIST_count_simple() :
|
67
|
+
* Same as HIST_countFast(), this function is unsafe,
|
68
|
+
* and will segfault if any value within `src` is `> *maxSymbolValuePtr`.
|
69
|
+
* It is also a bit slower for large inputs.
|
70
|
+
* However, it does not need any additional memory (not even on stack).
|
71
|
+
* @return : count of the most frequent symbol.
|
72
|
+
* Note this function doesn't produce any error (i.e. it must succeed).
|
73
|
+
*/
|
74
|
+
unsigned HIST_count_simple(unsigned* count, unsigned* maxSymbolValuePtr,
|
75
|
+
const void* src, size_t srcSize);
|