brotli 0.1.3 → 0.1.4
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/.gitignore +3 -0
- data/.travis.yml +11 -3
- data/Gemfile +2 -0
- data/ext/brotli/brotli.c +279 -0
- data/ext/brotli/brotli.h +2 -0
- data/ext/brotli/buffer.c +95 -0
- data/ext/brotli/buffer.h +19 -0
- data/ext/brotli/extconf.rb +21 -81
- data/lib/brotli/version.rb +1 -1
- data/vendor/brotli/dec/bit_reader.c +5 -5
- data/vendor/brotli/dec/bit_reader.h +15 -15
- data/vendor/brotli/dec/context.h +1 -1
- data/vendor/brotli/dec/decode.c +433 -348
- data/vendor/brotli/dec/decode.h +74 -48
- data/vendor/brotli/dec/huffman.c +5 -4
- data/vendor/brotli/dec/huffman.h +4 -4
- data/vendor/brotli/dec/port.h +2 -95
- data/vendor/brotli/dec/prefix.h +5 -3
- data/vendor/brotli/dec/state.c +15 -27
- data/vendor/brotli/dec/state.h +21 -17
- data/vendor/brotli/dec/transform.h +1 -1
- data/vendor/brotli/enc/backward_references.c +892 -0
- data/vendor/brotli/enc/backward_references.h +85 -102
- data/vendor/brotli/enc/backward_references_inc.h +147 -0
- data/vendor/brotli/enc/bit_cost.c +35 -0
- data/vendor/brotli/enc/bit_cost.h +23 -121
- data/vendor/brotli/enc/bit_cost_inc.h +127 -0
- data/vendor/brotli/enc/block_encoder_inc.h +33 -0
- data/vendor/brotli/enc/block_splitter.c +197 -0
- data/vendor/brotli/enc/block_splitter.h +40 -50
- data/vendor/brotli/enc/block_splitter_inc.h +432 -0
- data/vendor/brotli/enc/brotli_bit_stream.c +1334 -0
- data/vendor/brotli/enc/brotli_bit_stream.h +95 -167
- data/vendor/brotli/enc/cluster.c +56 -0
- data/vendor/brotli/enc/cluster.h +23 -305
- data/vendor/brotli/enc/cluster_inc.h +315 -0
- data/vendor/brotli/enc/command.h +83 -76
- data/vendor/brotli/enc/compress_fragment.c +747 -0
- data/vendor/brotli/enc/compress_fragment.h +48 -37
- data/vendor/brotli/enc/compress_fragment_two_pass.c +557 -0
- data/vendor/brotli/enc/compress_fragment_two_pass.h +37 -26
- data/vendor/brotli/enc/compressor.cc +139 -0
- data/vendor/brotli/enc/compressor.h +146 -0
- data/vendor/brotli/enc/context.h +102 -96
- data/vendor/brotli/enc/dictionary_hash.h +9 -5
- data/vendor/brotli/enc/encode.c +1562 -0
- data/vendor/brotli/enc/encode.h +211 -199
- data/vendor/brotli/enc/encode_parallel.cc +161 -151
- data/vendor/brotli/enc/encode_parallel.h +7 -8
- data/vendor/brotli/enc/entropy_encode.c +501 -0
- data/vendor/brotli/enc/entropy_encode.h +107 -89
- data/vendor/brotli/enc/entropy_encode_static.h +29 -62
- data/vendor/brotli/enc/fast_log.h +26 -20
- data/vendor/brotli/enc/find_match_length.h +23 -20
- data/vendor/brotli/enc/hash.h +614 -871
- data/vendor/brotli/enc/hash_forgetful_chain_inc.h +249 -0
- data/vendor/brotli/enc/hash_longest_match_inc.h +241 -0
- data/vendor/brotli/enc/hash_longest_match_quickly_inc.h +230 -0
- data/vendor/brotli/enc/histogram.c +95 -0
- data/vendor/brotli/enc/histogram.h +49 -83
- data/vendor/brotli/enc/histogram_inc.h +51 -0
- data/vendor/brotli/enc/literal_cost.c +178 -0
- data/vendor/brotli/enc/literal_cost.h +16 -10
- data/vendor/brotli/enc/memory.c +181 -0
- data/vendor/brotli/enc/memory.h +62 -0
- data/vendor/brotli/enc/metablock.c +515 -0
- data/vendor/brotli/enc/metablock.h +87 -57
- data/vendor/brotli/enc/metablock_inc.h +183 -0
- data/vendor/brotli/enc/port.h +73 -47
- data/vendor/brotli/enc/prefix.h +34 -61
- data/vendor/brotli/enc/quality.h +130 -0
- data/vendor/brotli/enc/ringbuffer.h +137 -122
- data/vendor/brotli/enc/{static_dict.cc → static_dict.c} +162 -139
- data/vendor/brotli/enc/static_dict.h +23 -18
- data/vendor/brotli/enc/static_dict_lut.h +11223 -12037
- data/vendor/brotli/enc/streams.cc +7 -7
- data/vendor/brotli/enc/streams.h +32 -32
- data/vendor/brotli/enc/{utf8_util.cc → utf8_util.c} +22 -20
- data/vendor/brotli/enc/utf8_util.h +16 -9
- data/vendor/brotli/enc/write_bits.h +49 -43
- metadata +34 -25
- data/ext/brotli/brotli.cc +0 -181
- data/vendor/brotli/dec/Makefile +0 -12
- data/vendor/brotli/dec/dictionary.c +0 -9466
- data/vendor/brotli/dec/dictionary.h +0 -38
- data/vendor/brotli/dec/types.h +0 -38
- data/vendor/brotli/enc/Makefile +0 -14
- data/vendor/brotli/enc/backward_references.cc +0 -858
- data/vendor/brotli/enc/block_splitter.cc +0 -505
- data/vendor/brotli/enc/brotli_bit_stream.cc +0 -1181
- data/vendor/brotli/enc/compress_fragment.cc +0 -701
- data/vendor/brotli/enc/compress_fragment_two_pass.cc +0 -524
- data/vendor/brotli/enc/dictionary.cc +0 -9466
- data/vendor/brotli/enc/dictionary.h +0 -41
- data/vendor/brotli/enc/encode.cc +0 -1180
- data/vendor/brotli/enc/entropy_encode.cc +0 -480
- data/vendor/brotli/enc/histogram.cc +0 -67
- data/vendor/brotli/enc/literal_cost.cc +0 -165
- data/vendor/brotli/enc/metablock.cc +0 -539
- data/vendor/brotli/enc/transform.h +0 -248
- data/vendor/brotli/enc/types.h +0 -29
@@ -1,248 +0,0 @@
|
|
1
|
-
/* Copyright 2010 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
|
-
// Transformations on dictionary words.
|
8
|
-
|
9
|
-
#ifndef BROTLI_ENC_TRANSFORM_H_
|
10
|
-
#define BROTLI_ENC_TRANSFORM_H_
|
11
|
-
|
12
|
-
#include <string>
|
13
|
-
|
14
|
-
#include "./dictionary.h"
|
15
|
-
|
16
|
-
namespace brotli {
|
17
|
-
|
18
|
-
enum WordTransformType {
|
19
|
-
kIdentity = 0,
|
20
|
-
kOmitLast1 = 1,
|
21
|
-
kOmitLast2 = 2,
|
22
|
-
kOmitLast3 = 3,
|
23
|
-
kOmitLast4 = 4,
|
24
|
-
kOmitLast5 = 5,
|
25
|
-
kOmitLast6 = 6,
|
26
|
-
kOmitLast7 = 7,
|
27
|
-
kOmitLast8 = 8,
|
28
|
-
kOmitLast9 = 9,
|
29
|
-
kUppercaseFirst = 10,
|
30
|
-
kUppercaseAll = 11,
|
31
|
-
kOmitFirst1 = 12,
|
32
|
-
kOmitFirst2 = 13,
|
33
|
-
kOmitFirst3 = 14,
|
34
|
-
kOmitFirst4 = 15,
|
35
|
-
kOmitFirst5 = 16,
|
36
|
-
kOmitFirst6 = 17,
|
37
|
-
kOmitFirst7 = 18,
|
38
|
-
kOmitFirst8 = 19,
|
39
|
-
kOmitFirst9 = 20
|
40
|
-
};
|
41
|
-
|
42
|
-
struct Transform {
|
43
|
-
const char* prefix;
|
44
|
-
WordTransformType word_transform;
|
45
|
-
const char* suffix;
|
46
|
-
};
|
47
|
-
|
48
|
-
static const Transform kTransforms[] = {
|
49
|
-
{ "", kIdentity, "" },
|
50
|
-
{ "", kIdentity, " " },
|
51
|
-
{ " ", kIdentity, " " },
|
52
|
-
{ "", kOmitFirst1, "" },
|
53
|
-
{ "", kUppercaseFirst, " " },
|
54
|
-
{ "", kIdentity, " the " },
|
55
|
-
{ " ", kIdentity, "" },
|
56
|
-
{ "s ", kIdentity, " " },
|
57
|
-
{ "", kIdentity, " of " },
|
58
|
-
{ "", kUppercaseFirst, "" },
|
59
|
-
{ "", kIdentity, " and " },
|
60
|
-
{ "", kOmitFirst2, "" },
|
61
|
-
{ "", kOmitLast1, "" },
|
62
|
-
{ ", ", kIdentity, " " },
|
63
|
-
{ "", kIdentity, ", " },
|
64
|
-
{ " ", kUppercaseFirst, " " },
|
65
|
-
{ "", kIdentity, " in " },
|
66
|
-
{ "", kIdentity, " to " },
|
67
|
-
{ "e ", kIdentity, " " },
|
68
|
-
{ "", kIdentity, "\"" },
|
69
|
-
{ "", kIdentity, "." },
|
70
|
-
{ "", kIdentity, "\">" },
|
71
|
-
{ "", kIdentity, "\n" },
|
72
|
-
{ "", kOmitLast3, "" },
|
73
|
-
{ "", kIdentity, "]" },
|
74
|
-
{ "", kIdentity, " for " },
|
75
|
-
{ "", kOmitFirst3, "" },
|
76
|
-
{ "", kOmitLast2, "" },
|
77
|
-
{ "", kIdentity, " a " },
|
78
|
-
{ "", kIdentity, " that " },
|
79
|
-
{ " ", kUppercaseFirst, "" },
|
80
|
-
{ "", kIdentity, ". " },
|
81
|
-
{ ".", kIdentity, "" },
|
82
|
-
{ " ", kIdentity, ", " },
|
83
|
-
{ "", kOmitFirst4, "" },
|
84
|
-
{ "", kIdentity, " with " },
|
85
|
-
{ "", kIdentity, "'" },
|
86
|
-
{ "", kIdentity, " from " },
|
87
|
-
{ "", kIdentity, " by " },
|
88
|
-
{ "", kOmitFirst5, "" },
|
89
|
-
{ "", kOmitFirst6, "" },
|
90
|
-
{ " the ", kIdentity, "" },
|
91
|
-
{ "", kOmitLast4, "" },
|
92
|
-
{ "", kIdentity, ". The " },
|
93
|
-
{ "", kUppercaseAll, "" },
|
94
|
-
{ "", kIdentity, " on " },
|
95
|
-
{ "", kIdentity, " as " },
|
96
|
-
{ "", kIdentity, " is " },
|
97
|
-
{ "", kOmitLast7, "" },
|
98
|
-
{ "", kOmitLast1, "ing " },
|
99
|
-
{ "", kIdentity, "\n\t" },
|
100
|
-
{ "", kIdentity, ":" },
|
101
|
-
{ " ", kIdentity, ". " },
|
102
|
-
{ "", kIdentity, "ed " },
|
103
|
-
{ "", kOmitFirst9, "" },
|
104
|
-
{ "", kOmitFirst7, "" },
|
105
|
-
{ "", kOmitLast6, "" },
|
106
|
-
{ "", kIdentity, "(" },
|
107
|
-
{ "", kUppercaseFirst, ", " },
|
108
|
-
{ "", kOmitLast8, "" },
|
109
|
-
{ "", kIdentity, " at " },
|
110
|
-
{ "", kIdentity, "ly " },
|
111
|
-
{ " the ", kIdentity, " of " },
|
112
|
-
{ "", kOmitLast5, "" },
|
113
|
-
{ "", kOmitLast9, "" },
|
114
|
-
{ " ", kUppercaseFirst, ", " },
|
115
|
-
{ "", kUppercaseFirst, "\"" },
|
116
|
-
{ ".", kIdentity, "(" },
|
117
|
-
{ "", kUppercaseAll, " " },
|
118
|
-
{ "", kUppercaseFirst, "\">" },
|
119
|
-
{ "", kIdentity, "=\"" },
|
120
|
-
{ " ", kIdentity, "." },
|
121
|
-
{ ".com/", kIdentity, "" },
|
122
|
-
{ " the ", kIdentity, " of the " },
|
123
|
-
{ "", kUppercaseFirst, "'" },
|
124
|
-
{ "", kIdentity, ". This " },
|
125
|
-
{ "", kIdentity, "," },
|
126
|
-
{ ".", kIdentity, " " },
|
127
|
-
{ "", kUppercaseFirst, "(" },
|
128
|
-
{ "", kUppercaseFirst, "." },
|
129
|
-
{ "", kIdentity, " not " },
|
130
|
-
{ " ", kIdentity, "=\"" },
|
131
|
-
{ "", kIdentity, "er " },
|
132
|
-
{ " ", kUppercaseAll, " " },
|
133
|
-
{ "", kIdentity, "al " },
|
134
|
-
{ " ", kUppercaseAll, "" },
|
135
|
-
{ "", kIdentity, "='" },
|
136
|
-
{ "", kUppercaseAll, "\"" },
|
137
|
-
{ "", kUppercaseFirst, ". " },
|
138
|
-
{ " ", kIdentity, "(" },
|
139
|
-
{ "", kIdentity, "ful " },
|
140
|
-
{ " ", kUppercaseFirst, ". " },
|
141
|
-
{ "", kIdentity, "ive " },
|
142
|
-
{ "", kIdentity, "less " },
|
143
|
-
{ "", kUppercaseAll, "'" },
|
144
|
-
{ "", kIdentity, "est " },
|
145
|
-
{ " ", kUppercaseFirst, "." },
|
146
|
-
{ "", kUppercaseAll, "\">" },
|
147
|
-
{ " ", kIdentity, "='" },
|
148
|
-
{ "", kUppercaseFirst, "," },
|
149
|
-
{ "", kIdentity, "ize " },
|
150
|
-
{ "", kUppercaseAll, "." },
|
151
|
-
{ "\xc2\xa0", kIdentity, "" },
|
152
|
-
{ " ", kIdentity, "," },
|
153
|
-
{ "", kUppercaseFirst, "=\"" },
|
154
|
-
{ "", kUppercaseAll, "=\"" },
|
155
|
-
{ "", kIdentity, "ous " },
|
156
|
-
{ "", kUppercaseAll, ", " },
|
157
|
-
{ "", kUppercaseFirst, "='" },
|
158
|
-
{ " ", kUppercaseFirst, "," },
|
159
|
-
{ " ", kUppercaseAll, "=\"" },
|
160
|
-
{ " ", kUppercaseAll, ", " },
|
161
|
-
{ "", kUppercaseAll, "," },
|
162
|
-
{ "", kUppercaseAll, "(" },
|
163
|
-
{ "", kUppercaseAll, ". " },
|
164
|
-
{ " ", kUppercaseAll, "." },
|
165
|
-
{ "", kUppercaseAll, "='" },
|
166
|
-
{ " ", kUppercaseAll, ". " },
|
167
|
-
{ " ", kUppercaseFirst, "=\"" },
|
168
|
-
{ " ", kUppercaseAll, "='" },
|
169
|
-
{ " ", kUppercaseFirst, "='" },
|
170
|
-
};
|
171
|
-
|
172
|
-
static const size_t kNumTransforms =
|
173
|
-
sizeof(kTransforms) / sizeof(kTransforms[0]);
|
174
|
-
|
175
|
-
static const size_t kOmitLastNTransforms[10] = {
|
176
|
-
0, 12, 27, 23, 42, 63, 56, 48, 59, 64,
|
177
|
-
};
|
178
|
-
|
179
|
-
static size_t ToUpperCase(uint8_t *p, size_t len) {
|
180
|
-
if (len == 1 || p[0] < 0xc0) {
|
181
|
-
if (p[0] >= 'a' && p[0] <= 'z') {
|
182
|
-
p[0] ^= 32;
|
183
|
-
}
|
184
|
-
return 1;
|
185
|
-
}
|
186
|
-
if (p[0] < 0xe0) {
|
187
|
-
p[1] ^= 32;
|
188
|
-
return 2;
|
189
|
-
}
|
190
|
-
if (len == 2) {
|
191
|
-
return 2;
|
192
|
-
}
|
193
|
-
p[2] ^= 5;
|
194
|
-
return 3;
|
195
|
-
}
|
196
|
-
|
197
|
-
inline std::string TransformWord(
|
198
|
-
WordTransformType transform_type, const uint8_t* word, size_t len) {
|
199
|
-
if (transform_type <= kOmitLast9) {
|
200
|
-
if (len <= static_cast<size_t>(transform_type)) {
|
201
|
-
return std::string();
|
202
|
-
}
|
203
|
-
return std::string(word, word + len - transform_type);
|
204
|
-
}
|
205
|
-
|
206
|
-
if (transform_type >= kOmitFirst1) {
|
207
|
-
const size_t skip = transform_type - (kOmitFirst1 - 1);
|
208
|
-
if (len <= skip) {
|
209
|
-
return std::string();
|
210
|
-
}
|
211
|
-
return std::string(word + skip, word + len);
|
212
|
-
}
|
213
|
-
|
214
|
-
std::string ret = std::string(word, word + len);
|
215
|
-
uint8_t *uppercase = reinterpret_cast<uint8_t*>(&ret[0]);
|
216
|
-
if (transform_type == kUppercaseFirst) {
|
217
|
-
ToUpperCase(uppercase, len);
|
218
|
-
} else if (transform_type == kUppercaseAll) {
|
219
|
-
size_t position = 0;
|
220
|
-
while (position < len) {
|
221
|
-
size_t step = ToUpperCase(uppercase, len - position);
|
222
|
-
uppercase += step;
|
223
|
-
position += step;
|
224
|
-
}
|
225
|
-
}
|
226
|
-
return ret;
|
227
|
-
}
|
228
|
-
|
229
|
-
inline std::string ApplyTransform(
|
230
|
-
const Transform& t, const uint8_t* word, size_t len) {
|
231
|
-
return std::string(t.prefix) +
|
232
|
-
TransformWord(t.word_transform, word, len) + std::string(t.suffix);
|
233
|
-
}
|
234
|
-
|
235
|
-
inline std::string GetTransformedDictionaryWord(size_t len_code,
|
236
|
-
size_t word_id) {
|
237
|
-
size_t num_words = 1u << kBrotliDictionarySizeBitsByLength[len_code];
|
238
|
-
size_t offset = kBrotliDictionaryOffsetsByLength[len_code];
|
239
|
-
size_t t = word_id / num_words;
|
240
|
-
size_t word_idx = word_id % num_words;
|
241
|
-
offset += len_code * word_idx;
|
242
|
-
const uint8_t* word = &kBrotliDictionary[offset];
|
243
|
-
return ApplyTransform(kTransforms[t], word, len_code);
|
244
|
-
}
|
245
|
-
|
246
|
-
} // namespace brotli
|
247
|
-
|
248
|
-
#endif // BROTLI_ENC_TRANSFORM_H_
|
data/vendor/brotli/enc/types.h
DELETED
@@ -1,29 +0,0 @@
|
|
1
|
-
/* Copyright 2013 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
|
-
/* Common types */
|
8
|
-
|
9
|
-
#ifndef BROTLI_ENC_TYPES_H_
|
10
|
-
#define BROTLI_ENC_TYPES_H_
|
11
|
-
|
12
|
-
#include <stddef.h> /* for size_t */
|
13
|
-
|
14
|
-
#if defined(_MSC_VER) && (_MSC_VER < 1600)
|
15
|
-
typedef __int8 int8_t;
|
16
|
-
typedef unsigned __int8 uint8_t;
|
17
|
-
typedef __int16 int16_t;
|
18
|
-
typedef unsigned __int16 uint16_t;
|
19
|
-
typedef __int32 int32_t;
|
20
|
-
typedef unsigned __int32 uint32_t;
|
21
|
-
typedef unsigned __int64 uint64_t;
|
22
|
-
typedef __int64 int64_t;
|
23
|
-
#else
|
24
|
-
#include <stdint.h>
|
25
|
-
#endif /* defined(_MSC_VER) && (_MSC_VER < 1600) */
|
26
|
-
|
27
|
-
#define MAKE_UINT64_T(high, low) ((((uint64_t)(high)) << 32) | low)
|
28
|
-
|
29
|
-
#endif /* BROTLI_ENC_TYPES_H_ */
|