brotli 0.2.3 → 0.4.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- checksums.yaml +4 -4
- data/.github/workflows/main.yml +34 -0
- data/.github/workflows/publish.yml +34 -0
- data/Gemfile +6 -3
- data/Rakefile +16 -9
- data/brotli.gemspec +7 -13
- data/ext/brotli/brotli.c +209 -31
- data/ext/brotli/buffer.c +1 -7
- data/ext/brotli/buffer.h +1 -1
- data/ext/brotli/extconf.rb +20 -18
- data/lib/brotli/version.rb +1 -1
- data/test/brotli_test.rb +104 -0
- data/test/brotli_writer_test.rb +36 -0
- data/test/test_helper.rb +8 -0
- data/vendor/brotli/c/common/constants.c +15 -0
- data/vendor/brotli/c/common/constants.h +136 -0
- data/vendor/brotli/c/common/context.c +156 -0
- data/vendor/brotli/c/common/context.h +4 -152
- data/vendor/brotli/c/common/dictionary.bin.br +0 -0
- data/vendor/brotli/c/common/dictionary.c +10 -1
- data/vendor/brotli/c/common/platform.c +22 -0
- data/vendor/brotli/c/common/platform.h +43 -17
- data/vendor/brotli/c/common/transform.c +59 -3
- data/vendor/brotli/c/common/transform.h +5 -0
- data/vendor/brotli/c/common/version.h +2 -2
- data/vendor/brotli/c/dec/bit_reader.c +28 -0
- data/vendor/brotli/c/dec/bit_reader.h +58 -16
- data/vendor/brotli/c/dec/decode.c +353 -251
- data/vendor/brotli/c/dec/huffman.h +6 -12
- data/vendor/brotli/c/dec/prefix.h +0 -18
- data/vendor/brotli/c/dec/state.c +9 -14
- data/vendor/brotli/c/dec/state.h +144 -37
- data/vendor/brotli/c/enc/backward_references.c +8 -7
- data/vendor/brotli/c/enc/backward_references.h +5 -4
- data/vendor/brotli/c/enc/backward_references_hq.c +51 -33
- data/vendor/brotli/c/enc/backward_references_hq.h +11 -8
- data/vendor/brotli/c/enc/backward_references_inc.h +24 -14
- data/vendor/brotli/c/enc/block_splitter.c +3 -3
- data/vendor/brotli/c/enc/block_splitter_inc.h +15 -6
- data/vendor/brotli/c/enc/brotli_bit_stream.c +13 -30
- data/vendor/brotli/c/enc/cluster_inc.h +6 -3
- data/vendor/brotli/c/enc/command.c +28 -0
- data/vendor/brotli/c/enc/command.h +12 -12
- data/vendor/brotli/c/enc/compress_fragment_two_pass.c +1 -1
- data/vendor/brotli/c/enc/dictionary_hash.c +1826 -1100
- data/vendor/brotli/c/enc/dictionary_hash.h +2 -1
- data/vendor/brotli/c/enc/encode.c +104 -39
- data/vendor/brotli/c/enc/encoder_dict.c +3 -2
- data/vendor/brotli/c/enc/encoder_dict.h +3 -1
- data/vendor/brotli/c/enc/entropy_encode.c +2 -0
- data/vendor/brotli/c/enc/entropy_encode.h +2 -2
- data/vendor/brotli/c/enc/fast_log.c +105 -0
- data/vendor/brotli/c/enc/fast_log.h +19 -100
- data/vendor/brotli/c/enc/find_match_length.h +2 -3
- data/vendor/brotli/c/enc/hash.h +80 -90
- data/vendor/brotli/c/enc/hash_composite_inc.h +52 -63
- data/vendor/brotli/c/enc/hash_forgetful_chain_inc.h +88 -49
- data/vendor/brotli/c/enc/hash_longest_match64_inc.h +50 -50
- data/vendor/brotli/c/enc/hash_longest_match_inc.h +53 -50
- data/vendor/brotli/c/enc/hash_longest_match_quickly_inc.h +91 -60
- data/vendor/brotli/c/enc/hash_rolling_inc.h +23 -27
- data/vendor/brotli/c/enc/hash_to_binary_tree_inc.h +39 -38
- data/vendor/brotli/c/enc/memory.h +24 -12
- data/vendor/brotli/c/enc/metablock.c +23 -27
- data/vendor/brotli/c/enc/metablock_inc.h +1 -1
- data/vendor/brotli/c/enc/params.h +3 -1
- data/vendor/brotli/c/enc/ringbuffer.h +4 -1
- data/vendor/brotli/c/enc/utf8_util.c +1 -1
- data/vendor/brotli/c/enc/write_bits.h +27 -25
- data/vendor/brotli/c/include/brotli/encode.h +22 -1
- data/vendor/brotli/c/include/brotli/port.h +14 -0
- metadata +17 -97
- data/.travis.yml +0 -31
- data/docs/Brotli.html +0 -485
- data/docs/Brotli/Error.html +0 -124
- data/docs/_index.html +0 -122
- data/docs/class_list.html +0 -51
- data/docs/css/common.css +0 -1
- data/docs/css/full_list.css +0 -58
- data/docs/css/style.css +0 -496
- data/docs/file.README.html +0 -127
- data/docs/file_list.html +0 -56
- data/docs/frames.html +0 -17
- data/docs/index.html +0 -127
- data/docs/js/app.js +0 -292
- data/docs/js/full_list.js +0 -216
- data/docs/js/jquery.js +0 -4
- data/docs/method_list.html +0 -67
- data/docs/top-level-namespace.html +0 -110
- data/spec/brotli_spec.rb +0 -88
- data/spec/inflate_spec.rb +0 -75
- data/spec/spec_helper.rb +0 -4
@@ -88,6 +88,7 @@
|
|
88
88
|
#ifndef BROTLI_COMMON_CONTEXT_H_
|
89
89
|
#define BROTLI_COMMON_CONTEXT_H_
|
90
90
|
|
91
|
+
#include <brotli/port.h>
|
91
92
|
#include <brotli/types.h>
|
92
93
|
|
93
94
|
typedef enum ContextType {
|
@@ -97,163 +98,14 @@ typedef enum ContextType {
|
|
97
98
|
CONTEXT_SIGNED = 3
|
98
99
|
} ContextType;
|
99
100
|
|
101
|
+
/* "Soft-private", it is exported, but not "advertised" as API. */
|
100
102
|
/* Common context lookup table for all context modes. */
|
101
|
-
|
102
|
-
/* CONTEXT_LSB6, last byte. */
|
103
|
-
0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15,
|
104
|
-
16, 17, 18, 19, 20, 21, 22, 23, 24, 25, 26, 27, 28, 29, 30, 31,
|
105
|
-
32, 33, 34, 35, 36, 37, 38, 39, 40, 41, 42, 43, 44, 45, 46, 47,
|
106
|
-
48, 49, 50, 51, 52, 53, 54, 55, 56, 57, 58, 59, 60, 61, 62, 63,
|
107
|
-
0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15,
|
108
|
-
16, 17, 18, 19, 20, 21, 22, 23, 24, 25, 26, 27, 28, 29, 30, 31,
|
109
|
-
32, 33, 34, 35, 36, 37, 38, 39, 40, 41, 42, 43, 44, 45, 46, 47,
|
110
|
-
48, 49, 50, 51, 52, 53, 54, 55, 56, 57, 58, 59, 60, 61, 62, 63,
|
111
|
-
0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15,
|
112
|
-
16, 17, 18, 19, 20, 21, 22, 23, 24, 25, 26, 27, 28, 29, 30, 31,
|
113
|
-
32, 33, 34, 35, 36, 37, 38, 39, 40, 41, 42, 43, 44, 45, 46, 47,
|
114
|
-
48, 49, 50, 51, 52, 53, 54, 55, 56, 57, 58, 59, 60, 61, 62, 63,
|
115
|
-
0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15,
|
116
|
-
16, 17, 18, 19, 20, 21, 22, 23, 24, 25, 26, 27, 28, 29, 30, 31,
|
117
|
-
32, 33, 34, 35, 36, 37, 38, 39, 40, 41, 42, 43, 44, 45, 46, 47,
|
118
|
-
48, 49, 50, 51, 52, 53, 54, 55, 56, 57, 58, 59, 60, 61, 62, 63,
|
119
|
-
|
120
|
-
/* CONTEXT_LSB6, second last byte, */
|
121
|
-
0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
|
122
|
-
0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
|
123
|
-
0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
|
124
|
-
0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
|
125
|
-
0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
|
126
|
-
0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
|
127
|
-
0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
|
128
|
-
0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
|
129
|
-
0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
|
130
|
-
0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
|
131
|
-
0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
|
132
|
-
0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
|
133
|
-
0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
|
134
|
-
0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
|
135
|
-
0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
|
136
|
-
0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
|
137
|
-
|
138
|
-
/* CONTEXT_MSB6, last byte. */
|
139
|
-
0, 0, 0, 0, 1, 1, 1, 1, 2, 2, 2, 2, 3, 3, 3, 3,
|
140
|
-
4, 4, 4, 4, 5, 5, 5, 5, 6, 6, 6, 6, 7, 7, 7, 7,
|
141
|
-
8, 8, 8, 8, 9, 9, 9, 9, 10, 10, 10, 10, 11, 11, 11, 11,
|
142
|
-
12, 12, 12, 12, 13, 13, 13, 13, 14, 14, 14, 14, 15, 15, 15, 15,
|
143
|
-
16, 16, 16, 16, 17, 17, 17, 17, 18, 18, 18, 18, 19, 19, 19, 19,
|
144
|
-
20, 20, 20, 20, 21, 21, 21, 21, 22, 22, 22, 22, 23, 23, 23, 23,
|
145
|
-
24, 24, 24, 24, 25, 25, 25, 25, 26, 26, 26, 26, 27, 27, 27, 27,
|
146
|
-
28, 28, 28, 28, 29, 29, 29, 29, 30, 30, 30, 30, 31, 31, 31, 31,
|
147
|
-
32, 32, 32, 32, 33, 33, 33, 33, 34, 34, 34, 34, 35, 35, 35, 35,
|
148
|
-
36, 36, 36, 36, 37, 37, 37, 37, 38, 38, 38, 38, 39, 39, 39, 39,
|
149
|
-
40, 40, 40, 40, 41, 41, 41, 41, 42, 42, 42, 42, 43, 43, 43, 43,
|
150
|
-
44, 44, 44, 44, 45, 45, 45, 45, 46, 46, 46, 46, 47, 47, 47, 47,
|
151
|
-
48, 48, 48, 48, 49, 49, 49, 49, 50, 50, 50, 50, 51, 51, 51, 51,
|
152
|
-
52, 52, 52, 52, 53, 53, 53, 53, 54, 54, 54, 54, 55, 55, 55, 55,
|
153
|
-
56, 56, 56, 56, 57, 57, 57, 57, 58, 58, 58, 58, 59, 59, 59, 59,
|
154
|
-
60, 60, 60, 60, 61, 61, 61, 61, 62, 62, 62, 62, 63, 63, 63, 63,
|
155
|
-
|
156
|
-
/* CONTEXT_MSB6, second last byte, */
|
157
|
-
0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
|
158
|
-
0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
|
159
|
-
0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
|
160
|
-
0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
|
161
|
-
0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
|
162
|
-
0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
|
163
|
-
0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
|
164
|
-
0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
|
165
|
-
0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
|
166
|
-
0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
|
167
|
-
0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
|
168
|
-
0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
|
169
|
-
0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
|
170
|
-
0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
|
171
|
-
0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
|
172
|
-
0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
|
173
|
-
|
174
|
-
/* CONTEXT_UTF8, last byte. */
|
175
|
-
/* ASCII range. */
|
176
|
-
0, 0, 0, 0, 0, 0, 0, 0, 0, 4, 4, 0, 0, 4, 0, 0,
|
177
|
-
0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
|
178
|
-
8, 12, 16, 12, 12, 20, 12, 16, 24, 28, 12, 12, 32, 12, 36, 12,
|
179
|
-
44, 44, 44, 44, 44, 44, 44, 44, 44, 44, 32, 32, 24, 40, 28, 12,
|
180
|
-
12, 48, 52, 52, 52, 48, 52, 52, 52, 48, 52, 52, 52, 52, 52, 48,
|
181
|
-
52, 52, 52, 52, 52, 48, 52, 52, 52, 52, 52, 24, 12, 28, 12, 12,
|
182
|
-
12, 56, 60, 60, 60, 56, 60, 60, 60, 56, 60, 60, 60, 60, 60, 56,
|
183
|
-
60, 60, 60, 60, 60, 56, 60, 60, 60, 60, 60, 24, 12, 28, 12, 0,
|
184
|
-
/* UTF8 continuation byte range. */
|
185
|
-
0, 1, 0, 1, 0, 1, 0, 1, 0, 1, 0, 1, 0, 1, 0, 1,
|
186
|
-
0, 1, 0, 1, 0, 1, 0, 1, 0, 1, 0, 1, 0, 1, 0, 1,
|
187
|
-
0, 1, 0, 1, 0, 1, 0, 1, 0, 1, 0, 1, 0, 1, 0, 1,
|
188
|
-
0, 1, 0, 1, 0, 1, 0, 1, 0, 1, 0, 1, 0, 1, 0, 1,
|
189
|
-
/* UTF8 lead byte range. */
|
190
|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,
|
211
|
-
/* UTF8 lead byte range. */
|
212
|
-
0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
|
213
|
-
2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2,
|
214
|
-
2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2,
|
215
|
-
|
216
|
-
/* CONTEXT_SIGNED, last byte, same as the above values shifted by 3 bits. */
|
217
|
-
0, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8,
|
218
|
-
16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16,
|
219
|
-
16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16,
|
220
|
-
16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16,
|
221
|
-
24, 24, 24, 24, 24, 24, 24, 24, 24, 24, 24, 24, 24, 24, 24, 24,
|
222
|
-
24, 24, 24, 24, 24, 24, 24, 24, 24, 24, 24, 24, 24, 24, 24, 24,
|
223
|
-
24, 24, 24, 24, 24, 24, 24, 24, 24, 24, 24, 24, 24, 24, 24, 24,
|
224
|
-
24, 24, 24, 24, 24, 24, 24, 24, 24, 24, 24, 24, 24, 24, 24, 24,
|
225
|
-
32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32,
|
226
|
-
32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32,
|
227
|
-
32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32,
|
228
|
-
32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32,
|
229
|
-
40, 40, 40, 40, 40, 40, 40, 40, 40, 40, 40, 40, 40, 40, 40, 40,
|
230
|
-
40, 40, 40, 40, 40, 40, 40, 40, 40, 40, 40, 40, 40, 40, 40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6, 6, 6, 6, 6, 6, 6, 6, 7,
|
251
|
-
};
|
103
|
+
BROTLI_COMMON_API extern const uint8_t _kBrotliContextLookupTable[2048];
|
252
104
|
|
253
105
|
typedef const uint8_t* ContextLut;
|
254
106
|
|
255
107
|
/* typeof(MODE) == ContextType; returns ContextLut */
|
256
|
-
#define BROTLI_CONTEXT_LUT(MODE) (&
|
108
|
+
#define BROTLI_CONTEXT_LUT(MODE) (&_kBrotliContextLookupTable[(MODE) << 9])
|
257
109
|
|
258
110
|
/* typeof(LUT) == ContextLut */
|
259
111
|
#define BROTLI_CONTEXT(P1, P2, LUT) ((LUT)[P1] | ((LUT) + 256)[P2])
|
File without changes
|
@@ -5,12 +5,13 @@
|
|
5
5
|
*/
|
6
6
|
|
7
7
|
#include "./dictionary.h"
|
8
|
+
#include "./platform.h"
|
8
9
|
|
9
10
|
#if defined(__cplusplus) || defined(c_plusplus)
|
10
11
|
extern "C" {
|
11
12
|
#endif
|
12
13
|
|
13
|
-
#
|
14
|
+
#if !defined(BROTLI_EXTERNAL_DICTIONARY_DATA)
|
14
15
|
static const uint8_t kBrotliDictionaryData[] =
|
15
16
|
{
|
16
17
|
116,105,109,101,100,111,119,110,108,105,102,101,108,101,102,116,98,97,99,107,99,
|
@@ -5862,7 +5863,11 @@ static const uint8_t kBrotliDictionaryData[] =
|
|
5862
5863
|
;
|
5863
5864
|
#endif /* !BROTLI_EXTERNAL_DICTIONARY_DATA */
|
5864
5865
|
|
5866
|
+
#if !defined(BROTLI_EXTERNAL_DICTIONARY_DATA)
|
5867
|
+
static const BrotliDictionary kBrotliDictionary = {
|
5868
|
+
#else
|
5865
5869
|
static BrotliDictionary kBrotliDictionary = {
|
5870
|
+
#endif
|
5866
5871
|
/* size_bits_by_length */
|
5867
5872
|
{
|
5868
5873
|
0, 0, 0, 0, 10, 10, 11, 11,
|
@@ -5895,9 +5900,13 @@ const BrotliDictionary* BrotliGetDictionary() {
|
|
5895
5900
|
}
|
5896
5901
|
|
5897
5902
|
void BrotliSetDictionaryData(const uint8_t* data) {
|
5903
|
+
#if defined(BROTLI_EXTERNAL_DICTIONARY_DATA)
|
5898
5904
|
if (!!data && !kBrotliDictionary.data) {
|
5899
5905
|
kBrotliDictionary.data = data;
|
5900
5906
|
}
|
5907
|
+
#else
|
5908
|
+
BROTLI_UNUSED(data); // Appease -Werror=unused-parameter
|
5909
|
+
#endif
|
5901
5910
|
}
|
5902
5911
|
|
5903
5912
|
#if defined(__cplusplus) || defined(c_plusplus)
|
@@ -0,0 +1,22 @@
|
|
1
|
+
/* Copyright 2016 Google Inc. All Rights Reserved.
|
2
|
+
|
3
|
+
Distributed under MIT license.
|
4
|
+
See file LICENSE for detail or copy at https://opensource.org/licenses/MIT
|
5
|
+
*/
|
6
|
+
|
7
|
+
#include <stdlib.h>
|
8
|
+
|
9
|
+
#include "./platform.h"
|
10
|
+
#include <brotli/types.h>
|
11
|
+
|
12
|
+
/* Default brotli_alloc_func */
|
13
|
+
void* BrotliDefaultAllocFunc(void* opaque, size_t size) {
|
14
|
+
BROTLI_UNUSED(opaque);
|
15
|
+
return malloc(size);
|
16
|
+
}
|
17
|
+
|
18
|
+
/* Default brotli_free_func */
|
19
|
+
void BrotliDefaultFreeFunc(void* opaque, void* address) {
|
20
|
+
BROTLI_UNUSED(opaque);
|
21
|
+
free(address);
|
22
|
+
}
|
@@ -24,12 +24,11 @@
|
|
24
24
|
#define BROTLI_COMMON_PLATFORM_H_
|
25
25
|
|
26
26
|
#include <string.h> /* memcpy */
|
27
|
-
#include <stdlib.h> /* malloc, free */
|
28
27
|
|
29
28
|
#include <brotli/port.h>
|
30
29
|
#include <brotli/types.h>
|
31
30
|
|
32
|
-
#if defined(OS_LINUX) || defined(OS_CYGWIN)
|
31
|
+
#if defined(OS_LINUX) || defined(OS_CYGWIN) || defined(__EMSCRIPTEN__)
|
33
32
|
#include <endian.h>
|
34
33
|
#elif defined(OS_FREEBSD)
|
35
34
|
#include <machine/endian.h>
|
@@ -41,6 +40,10 @@
|
|
41
40
|
#define BROTLI_X_BIG_ENDIAN BIG_ENDIAN
|
42
41
|
#endif
|
43
42
|
|
43
|
+
#if BROTLI_MSVC_VERSION_CHECK(12, 0, 0)
|
44
|
+
#include <intrin.h>
|
45
|
+
#endif
|
46
|
+
|
44
47
|
#if defined(BROTLI_ENABLE_LOG) || defined(BROTLI_DEBUG)
|
45
48
|
#include <assert.h>
|
46
49
|
#include <stdio.h>
|
@@ -308,8 +311,7 @@ static BROTLI_INLINE void BrotliUnalignedWrite64(void* p, uint64_t v) {
|
|
308
311
|
}
|
309
312
|
#else /* BROTLI_ALIGNED_READ */
|
310
313
|
/* Unaligned memory access is allowed: just cast pointer to requested type. */
|
311
|
-
#if
|
312
|
-
defined(MEMORY_SANITIZER)
|
314
|
+
#if BROTLI_SANITIZED
|
313
315
|
/* Consider we have an unaligned load/store of 4 bytes from address 0x...05.
|
314
316
|
AddressSanitizer will treat it as a 3-byte access to the range 05:07 and
|
315
317
|
will miss a bug if 08 is the first unaddressable byte.
|
@@ -334,7 +336,7 @@ extern "C" {
|
|
334
336
|
#define BrotliUnalignedRead32 __sanitizer_unaligned_load32
|
335
337
|
#define BrotliUnalignedRead64 __sanitizer_unaligned_load64
|
336
338
|
#define BrotliUnalignedWrite64 __sanitizer_unaligned_store64
|
337
|
-
#else
|
339
|
+
#else /* BROTLI_SANITIZED */
|
338
340
|
static BROTLI_INLINE uint16_t BrotliUnalignedRead16(const void* p) {
|
339
341
|
return *(const uint16_t*)p;
|
340
342
|
}
|
@@ -356,7 +358,7 @@ static BROTLI_INLINE void BrotliUnalignedWrite64(void* p, uint64_t v) {
|
|
356
358
|
typedef BROTLI_ALIGNED(1) uint64_t brotli_unaligned_uint64_t;
|
357
359
|
|
358
360
|
static BROTLI_INLINE uint64_t BrotliUnalignedRead64(const void* p) {
|
359
|
-
return (uint64_t) ((brotli_unaligned_uint64_t*) p)[0];
|
361
|
+
return (uint64_t) ((const brotli_unaligned_uint64_t*) p)[0];
|
360
362
|
}
|
361
363
|
static BROTLI_INLINE void BrotliUnalignedWrite64(void* p, uint64_t v) {
|
362
364
|
brotli_unaligned_uint64_t* dwords = (brotli_unaligned_uint64_t*) p;
|
@@ -374,7 +376,7 @@ static BROTLI_INLINE void BrotliUnalignedWrite64(void* p, uint64_t v) {
|
|
374
376
|
}
|
375
377
|
#endif /* BROTLI_GNUC_HAS_ATTRIBUTE(aligned, 2, 7, 0) */
|
376
378
|
#endif /* BROTLI_64_BITS */
|
377
|
-
#endif /*
|
379
|
+
#endif /* BROTLI_SANITIZED */
|
378
380
|
#endif /* BROTLI_ALIGNED_READ */
|
379
381
|
|
380
382
|
#if BROTLI_LITTLE_ENDIAN
|
@@ -466,20 +468,20 @@ static BROTLI_INLINE void BROTLI_UNALIGNED_STORE64LE(void* p, uint64_t v) {
|
|
466
468
|
#endif
|
467
469
|
|
468
470
|
#if defined(BROTLI_ENABLE_LOG)
|
469
|
-
#define BROTLI_DCHECK(x) assert(x)
|
470
471
|
#define BROTLI_LOG(x) printf x
|
471
472
|
#else
|
472
|
-
#define BROTLI_DCHECK(x)
|
473
473
|
#define BROTLI_LOG(x)
|
474
474
|
#endif
|
475
475
|
|
476
476
|
#if defined(BROTLI_DEBUG) || defined(BROTLI_ENABLE_LOG)
|
477
|
+
#define BROTLI_DCHECK(x) assert(x)
|
477
478
|
static BROTLI_INLINE void BrotliDump(const char* f, int l, const char* fn) {
|
478
479
|
fprintf(stderr, "%s:%d (%s)\n", f, l, fn);
|
479
480
|
fflush(stderr);
|
480
481
|
}
|
481
482
|
#define BROTLI_DUMP() BrotliDump(__FILE__, __LINE__, __FUNCTION__)
|
482
483
|
#else
|
484
|
+
#define BROTLI_DCHECK(x)
|
483
485
|
#define BROTLI_DUMP() (void)(0)
|
484
486
|
#endif
|
485
487
|
|
@@ -523,17 +525,41 @@ BROTLI_MIN_MAX(size_t) BROTLI_MIN_MAX(uint32_t) BROTLI_MIN_MAX(uint8_t)
|
|
523
525
|
(A)[(J)] = __brotli_swap_tmp; \
|
524
526
|
}
|
525
527
|
|
526
|
-
|
527
|
-
|
528
|
-
|
529
|
-
|
528
|
+
#if BROTLI_64_BITS
|
529
|
+
#if BROTLI_GNUC_HAS_BUILTIN(__builtin_ctzll, 3, 4, 0) || \
|
530
|
+
BROTLI_INTEL_VERSION_CHECK(16, 0, 0)
|
531
|
+
#define BROTLI_TZCNT64 __builtin_ctzll
|
532
|
+
#elif BROTLI_MSVC_VERSION_CHECK(12, 0, 0)
|
533
|
+
#if defined(BROTLI_TARGET_X64)
|
534
|
+
#define BROTLI_TZCNT64 _tzcnt_u64
|
535
|
+
#else /* BROTLI_TARGET_X64 */
|
536
|
+
static BROTLI_INLINE uint32_t BrotliBsf64Msvc(uint64_t x) {
|
537
|
+
uint32_t lsb;
|
538
|
+
_BitScanForward64(&lsb, x);
|
539
|
+
return lsb;
|
530
540
|
}
|
541
|
+
#define BROTLI_TZCNT64 BrotliBsf64Msvc
|
542
|
+
#endif /* BROTLI_TARGET_X64 */
|
543
|
+
#endif /* __builtin_ctzll */
|
544
|
+
#endif /* BROTLI_64_BITS */
|
531
545
|
|
532
|
-
|
533
|
-
|
534
|
-
|
535
|
-
|
546
|
+
#if BROTLI_GNUC_HAS_BUILTIN(__builtin_clz, 3, 4, 0) || \
|
547
|
+
BROTLI_INTEL_VERSION_CHECK(16, 0, 0)
|
548
|
+
#define BROTLI_BSR32(x) (31u ^ (uint32_t)__builtin_clz(x))
|
549
|
+
#elif BROTLI_MSVC_VERSION_CHECK(12, 0, 0)
|
550
|
+
static BROTLI_INLINE uint32_t BrotliBsr32Msvc(uint32_t x) {
|
551
|
+
unsigned long msb;
|
552
|
+
_BitScanReverse(&msb, x);
|
553
|
+
return (uint32_t)msb;
|
536
554
|
}
|
555
|
+
#define BROTLI_BSR32 BrotliBsr32Msvc
|
556
|
+
#endif /* __builtin_clz */
|
557
|
+
|
558
|
+
/* Default brotli_alloc_func */
|
559
|
+
BROTLI_COMMON_API void* BrotliDefaultAllocFunc(void* opaque, size_t size);
|
560
|
+
|
561
|
+
/* Default brotli_free_func */
|
562
|
+
BROTLI_COMMON_API void BrotliDefaultFreeFunc(void* opaque, void* address);
|
537
563
|
|
538
564
|
BROTLI_UNUSED_FUNCTION void BrotliSuppressUnusedFunctions(void) {
|
539
565
|
BROTLI_UNUSED(&BrotliSuppressUnusedFunctions);
|
@@ -24,8 +24,8 @@ static const char kPrefixSuffix[217] =
|
|
24
24
|
/* 8x _0 _ _3 _8 _C _E _ _1 _7 _F */
|
25
25
|
" not \3er \3al \4ful \4ive \5less \4es"
|
26
26
|
/* Ax _5 _9 _D _2 _7 _D */
|
27
|
-
"t \4ize \2\xc2\xa0\4ous \5 the \2e \0
|
28
|
-
/* Cx _2 _7___ ___ _A _F _5
|
27
|
+
"t \4ize \2\xc2\xa0\4ous \5 the \2e "; /* \0 - implicit trailing zero. */
|
28
|
+
/* Cx _2 _7___ ___ _A _F _5 _8 */
|
29
29
|
|
30
30
|
static const uint16_t kPrefixSuffixMap[50] = {
|
31
31
|
0x00, 0x02, 0x05, 0x0E, 0x13, 0x16, 0x18, 0x1E, 0x23, 0x25,
|
@@ -160,12 +160,13 @@ static const uint8_t kTransformsData[] = {
|
|
160
160
|
0, BROTLI_TRANSFORM_UPPERCASE_FIRST, 34,
|
161
161
|
};
|
162
162
|
|
163
|
-
static BrotliTransforms kBrotliTransforms = {
|
163
|
+
static const BrotliTransforms kBrotliTransforms = {
|
164
164
|
sizeof(kPrefixSuffix),
|
165
165
|
(const uint8_t*)kPrefixSuffix,
|
166
166
|
kPrefixSuffixMap,
|
167
167
|
sizeof(kTransformsData) / (3 * sizeof(kTransformsData[0])),
|
168
168
|
kTransformsData,
|
169
|
+
NULL, /* no extra parameters */
|
169
170
|
{0, 12, 27, 23, 42, 63, 56, 48, 59, 64}
|
170
171
|
};
|
171
172
|
|
@@ -190,6 +191,48 @@ static int ToUpperCase(uint8_t* p) {
|
|
190
191
|
return 3;
|
191
192
|
}
|
192
193
|
|
194
|
+
static int Shift(uint8_t* word, int word_len, uint16_t parameter) {
|
195
|
+
/* Limited sign extension: scalar < (1 << 24). */
|
196
|
+
uint32_t scalar =
|
197
|
+
(parameter & 0x7FFFu) + (0x1000000u - (parameter & 0x8000u));
|
198
|
+
if (word[0] < 0x80) {
|
199
|
+
/* 1-byte rune / 0sssssss / 7 bit scalar (ASCII). */
|
200
|
+
scalar += (uint32_t)word[0];
|
201
|
+
word[0] = (uint8_t)(scalar & 0x7Fu);
|
202
|
+
return 1;
|
203
|
+
} else if (word[0] < 0xC0) {
|
204
|
+
/* Continuation / 10AAAAAA. */
|
205
|
+
return 1;
|
206
|
+
} else if (word[0] < 0xE0) {
|
207
|
+
/* 2-byte rune / 110sssss AAssssss / 11 bit scalar. */
|
208
|
+
if (word_len < 2) return 1;
|
209
|
+
scalar += (uint32_t)((word[1] & 0x3Fu) | ((word[0] & 0x1Fu) << 6u));
|
210
|
+
word[0] = (uint8_t)(0xC0 | ((scalar >> 6u) & 0x1F));
|
211
|
+
word[1] = (uint8_t)((word[1] & 0xC0) | (scalar & 0x3F));
|
212
|
+
return 2;
|
213
|
+
} else if (word[0] < 0xF0) {
|
214
|
+
/* 3-byte rune / 1110ssss AAssssss BBssssss / 16 bit scalar. */
|
215
|
+
if (word_len < 3) return word_len;
|
216
|
+
scalar += (uint32_t)((word[2] & 0x3Fu) | ((word[1] & 0x3Fu) << 6u) |
|
217
|
+
((word[0] & 0x0Fu) << 12u));
|
218
|
+
word[0] = (uint8_t)(0xE0 | ((scalar >> 12u) & 0x0F));
|
219
|
+
word[1] = (uint8_t)((word[1] & 0xC0) | ((scalar >> 6u) & 0x3F));
|
220
|
+
word[2] = (uint8_t)((word[2] & 0xC0) | (scalar & 0x3F));
|
221
|
+
return 3;
|
222
|
+
} else if (word[0] < 0xF8) {
|
223
|
+
/* 4-byte rune / 11110sss AAssssss BBssssss CCssssss / 21 bit scalar. */
|
224
|
+
if (word_len < 4) return word_len;
|
225
|
+
scalar += (uint32_t)((word[3] & 0x3Fu) | ((word[2] & 0x3Fu) << 6u) |
|
226
|
+
((word[1] & 0x3Fu) << 12u) | ((word[0] & 0x07u) << 18u));
|
227
|
+
word[0] = (uint8_t)(0xF0 | ((scalar >> 18u) & 0x07));
|
228
|
+
word[1] = (uint8_t)((word[1] & 0xC0) | ((scalar >> 12u) & 0x3F));
|
229
|
+
word[2] = (uint8_t)((word[2] & 0xC0) | ((scalar >> 6u) & 0x3F));
|
230
|
+
word[3] = (uint8_t)((word[3] & 0xC0) | (scalar & 0x3F));
|
231
|
+
return 4;
|
232
|
+
}
|
233
|
+
return 1;
|
234
|
+
}
|
235
|
+
|
193
236
|
int BrotliTransformDictionaryWord(uint8_t* dst, const uint8_t* word, int len,
|
194
237
|
const BrotliTransforms* transforms, int transform_idx) {
|
195
238
|
int idx = 0;
|
@@ -221,6 +264,19 @@ int BrotliTransformDictionaryWord(uint8_t* dst, const uint8_t* word, int len,
|
|
221
264
|
uppercase += step;
|
222
265
|
len -= step;
|
223
266
|
}
|
267
|
+
} else if (t == BROTLI_TRANSFORM_SHIFT_FIRST) {
|
268
|
+
uint16_t param = (uint16_t)(transforms->params[transform_idx * 2]
|
269
|
+
+ (transforms->params[transform_idx * 2 + 1] << 8u));
|
270
|
+
Shift(&dst[idx - len], len, param);
|
271
|
+
} else if (t == BROTLI_TRANSFORM_SHIFT_ALL) {
|
272
|
+
uint16_t param = (uint16_t)(transforms->params[transform_idx * 2]
|
273
|
+
+ (transforms->params[transform_idx * 2 + 1] << 8u));
|
274
|
+
uint8_t* shift = &dst[idx - len];
|
275
|
+
while (len > 0) {
|
276
|
+
int step = Shift(shift, len, param);
|
277
|
+
shift += step;
|
278
|
+
len -= step;
|
279
|
+
}
|
224
280
|
}
|
225
281
|
}
|
226
282
|
{
|