brotli 0.2.0 → 0.2.1
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +5 -5
- data/Gemfile +1 -0
- data/Rakefile +6 -1
- data/brotli.gemspec +1 -1
- data/docs/Brotli.html +485 -0
- data/docs/Brotli/Error.html +124 -0
- data/docs/_index.html +122 -0
- data/docs/class_list.html +51 -0
- data/docs/css/common.css +1 -0
- data/docs/css/full_list.css +58 -0
- data/docs/css/style.css +496 -0
- data/docs/file.README.html +127 -0
- data/docs/file_list.html +56 -0
- data/docs/frames.html +17 -0
- data/docs/index.html +127 -0
- data/docs/js/app.js +292 -0
- data/docs/js/full_list.js +216 -0
- data/docs/js/jquery.js +4 -0
- data/docs/method_list.html +67 -0
- data/docs/top-level-namespace.html +110 -0
- data/ext/brotli/brotli.c +20 -0
- data/lib/brotli/version.rb +1 -1
- data/vendor/brotli/c/common/constants.h +13 -6
- data/vendor/brotli/c/{dec → common}/context.h +182 -172
- data/vendor/brotli/c/common/dictionary.bin +0 -0
- data/vendor/brotli/c/common/dictionary.bin.br +0 -0
- data/vendor/brotli/c/common/dictionary.c +1 -1
- data/vendor/brotli/c/common/dictionary.h +4 -4
- data/vendor/brotli/c/common/platform.h +509 -0
- data/vendor/brotli/c/common/transform.c +235 -0
- data/vendor/brotli/c/common/transform.h +80 -0
- data/vendor/brotli/c/common/version.h +8 -1
- data/vendor/brotli/c/dec/bit_reader.c +1 -1
- data/vendor/brotli/c/dec/bit_reader.h +35 -86
- data/vendor/brotli/c/dec/decode.c +322 -205
- data/vendor/brotli/c/dec/huffman.c +35 -37
- data/vendor/brotli/c/dec/huffman.h +13 -9
- data/vendor/brotli/c/dec/prefix.h +3 -4
- data/vendor/brotli/c/dec/state.c +26 -34
- data/vendor/brotli/c/dec/state.h +34 -23
- data/vendor/brotli/c/enc/backward_references.c +25 -15
- data/vendor/brotli/c/enc/backward_references.h +5 -6
- data/vendor/brotli/c/enc/backward_references_hq.c +94 -68
- data/vendor/brotli/c/enc/backward_references_hq.h +22 -25
- data/vendor/brotli/c/enc/backward_references_inc.h +10 -10
- data/vendor/brotli/c/enc/bit_cost.c +1 -1
- data/vendor/brotli/c/enc/bit_cost.h +5 -5
- data/vendor/brotli/c/enc/block_encoder_inc.h +7 -6
- data/vendor/brotli/c/enc/block_splitter.c +2 -3
- data/vendor/brotli/c/enc/block_splitter.h +1 -1
- data/vendor/brotli/c/enc/block_splitter_inc.h +11 -11
- data/vendor/brotli/c/enc/brotli_bit_stream.c +102 -101
- data/vendor/brotli/c/enc/brotli_bit_stream.h +19 -38
- data/vendor/brotli/c/enc/cluster.c +1 -1
- data/vendor/brotli/c/enc/cluster.h +1 -1
- data/vendor/brotli/c/enc/command.h +40 -30
- data/vendor/brotli/c/enc/compress_fragment.c +21 -22
- data/vendor/brotli/c/enc/compress_fragment.h +1 -1
- data/vendor/brotli/c/enc/compress_fragment_two_pass.c +101 -68
- data/vendor/brotli/c/enc/compress_fragment_two_pass.h +1 -1
- data/vendor/brotli/c/enc/dictionary_hash.c +1 -1
- data/vendor/brotli/c/enc/encode.c +262 -162
- data/vendor/brotli/c/enc/encoder_dict.c +32 -0
- data/vendor/brotli/c/enc/encoder_dict.h +41 -0
- data/vendor/brotli/c/enc/entropy_encode.c +14 -14
- data/vendor/brotli/c/enc/entropy_encode.h +5 -5
- data/vendor/brotli/c/enc/entropy_encode_static.h +3 -3
- data/vendor/brotli/c/enc/fast_log.h +4 -2
- data/vendor/brotli/c/enc/find_match_length.h +3 -3
- data/vendor/brotli/c/enc/hash.h +75 -24
- data/vendor/brotli/c/enc/hash_composite_inc.h +133 -0
- data/vendor/brotli/c/enc/hash_forgetful_chain_inc.h +9 -8
- data/vendor/brotli/c/enc/hash_longest_match64_inc.h +8 -8
- data/vendor/brotli/c/enc/hash_longest_match_inc.h +8 -8
- data/vendor/brotli/c/enc/hash_longest_match_quickly_inc.h +10 -9
- data/vendor/brotli/c/enc/hash_rolling_inc.h +215 -0
- data/vendor/brotli/c/enc/hash_to_binary_tree_inc.h +9 -8
- data/vendor/brotli/c/enc/histogram.c +9 -6
- data/vendor/brotli/c/enc/histogram.h +6 -3
- data/vendor/brotli/c/enc/histogram_inc.h +1 -1
- data/vendor/brotli/c/enc/literal_cost.c +5 -5
- data/vendor/brotli/c/enc/literal_cost.h +2 -2
- data/vendor/brotli/c/enc/memory.c +5 -16
- data/vendor/brotli/c/enc/memory.h +40 -1
- data/vendor/brotli/c/enc/metablock.c +163 -25
- data/vendor/brotli/c/enc/metablock.h +13 -8
- data/vendor/brotli/c/enc/metablock_inc.h +1 -1
- data/vendor/brotli/c/enc/params.h +44 -0
- data/vendor/brotli/c/enc/prefix.h +3 -4
- data/vendor/brotli/c/enc/quality.h +29 -24
- data/vendor/brotli/c/enc/ringbuffer.h +15 -11
- data/vendor/brotli/c/enc/static_dict.c +49 -45
- data/vendor/brotli/c/enc/static_dict.h +4 -3
- data/vendor/brotli/c/enc/static_dict_lut.h +1 -1
- data/vendor/brotli/c/enc/utf8_util.c +20 -20
- data/vendor/brotli/c/enc/utf8_util.h +1 -1
- data/vendor/brotli/c/enc/write_bits.h +16 -21
- data/vendor/brotli/c/include/brotli/decode.h +13 -8
- data/vendor/brotli/c/include/brotli/encode.h +33 -8
- data/vendor/brotli/c/include/brotli/port.h +211 -83
- data/vendor/brotli/c/include/brotli/types.h +0 -7
- metadata +33 -12
- data/vendor/brotli/c/dec/port.h +0 -168
- data/vendor/brotli/c/dec/transform.h +0 -300
- data/vendor/brotli/c/enc/context.h +0 -184
- data/vendor/brotli/c/enc/port.h +0 -184
@@ -80,11 +80,4 @@ typedef void* (*brotli_alloc_func)(void* opaque, size_t size);
|
|
80
80
|
*/
|
81
81
|
typedef void (*brotli_free_func)(void* opaque, void* address);
|
82
82
|
|
83
|
-
#if defined(__STDC_VERSION__) && (__STDC_VERSION__ >= 199901L) && \
|
84
|
-
!defined(__cplusplus) && !defined(__PGI)
|
85
|
-
#define BROTLI_ARRAY_PARAM(L) L
|
86
|
-
#else
|
87
|
-
#define BROTLI_ARRAY_PARAM(L)
|
88
|
-
#endif
|
89
|
-
|
90
83
|
#endif /* BROTLI_COMMON_TYPES_H_ */
|
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: brotli
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.2.
|
4
|
+
version: 0.2.1
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- miyucy
|
8
8
|
autorequire:
|
9
9
|
bindir: exe
|
10
10
|
cert_chain: []
|
11
|
-
date:
|
11
|
+
date: 2018-08-17 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: bundler
|
@@ -28,16 +28,16 @@ dependencies:
|
|
28
28
|
name: rake
|
29
29
|
requirement: !ruby/object:Gem::Requirement
|
30
30
|
requirements:
|
31
|
-
- - "
|
31
|
+
- - ">="
|
32
32
|
- !ruby/object:Gem::Version
|
33
|
-
version: '
|
33
|
+
version: '0'
|
34
34
|
type: :development
|
35
35
|
prerelease: false
|
36
36
|
version_requirements: !ruby/object:Gem::Requirement
|
37
37
|
requirements:
|
38
|
-
- - "
|
38
|
+
- - ">="
|
39
39
|
- !ruby/object:Gem::Version
|
40
|
-
version: '
|
40
|
+
version: '0'
|
41
41
|
- !ruby/object:Gem::Dependency
|
42
42
|
name: rake-compiler
|
43
43
|
requirement: !ruby/object:Gem::Requirement
|
@@ -99,6 +99,22 @@ files:
|
|
99
99
|
- bin/console
|
100
100
|
- bin/setup
|
101
101
|
- brotli.gemspec
|
102
|
+
- docs/Brotli.html
|
103
|
+
- docs/Brotli/Error.html
|
104
|
+
- docs/_index.html
|
105
|
+
- docs/class_list.html
|
106
|
+
- docs/css/common.css
|
107
|
+
- docs/css/full_list.css
|
108
|
+
- docs/css/style.css
|
109
|
+
- docs/file.README.html
|
110
|
+
- docs/file_list.html
|
111
|
+
- docs/frames.html
|
112
|
+
- docs/index.html
|
113
|
+
- docs/js/app.js
|
114
|
+
- docs/js/full_list.js
|
115
|
+
- docs/js/jquery.js
|
116
|
+
- docs/method_list.html
|
117
|
+
- docs/top-level-namespace.html
|
102
118
|
- ext/brotli/brotli.c
|
103
119
|
- ext/brotli/brotli.h
|
104
120
|
- ext/brotli/buffer.c
|
@@ -112,21 +128,23 @@ files:
|
|
112
128
|
- spec/spec_helper.rb
|
113
129
|
- vendor/brotli/LICENSE
|
114
130
|
- vendor/brotli/c/common/constants.h
|
131
|
+
- vendor/brotli/c/common/context.h
|
115
132
|
- vendor/brotli/c/common/dictionary.bin
|
133
|
+
- vendor/brotli/c/common/dictionary.bin.br
|
116
134
|
- vendor/brotli/c/common/dictionary.c
|
117
135
|
- vendor/brotli/c/common/dictionary.h
|
136
|
+
- vendor/brotli/c/common/platform.h
|
137
|
+
- vendor/brotli/c/common/transform.c
|
138
|
+
- vendor/brotli/c/common/transform.h
|
118
139
|
- vendor/brotli/c/common/version.h
|
119
140
|
- vendor/brotli/c/dec/bit_reader.c
|
120
141
|
- vendor/brotli/c/dec/bit_reader.h
|
121
|
-
- vendor/brotli/c/dec/context.h
|
122
142
|
- vendor/brotli/c/dec/decode.c
|
123
143
|
- vendor/brotli/c/dec/huffman.c
|
124
144
|
- vendor/brotli/c/dec/huffman.h
|
125
|
-
- vendor/brotli/c/dec/port.h
|
126
145
|
- vendor/brotli/c/dec/prefix.h
|
127
146
|
- vendor/brotli/c/dec/state.c
|
128
147
|
- vendor/brotli/c/dec/state.h
|
129
|
-
- vendor/brotli/c/dec/transform.h
|
130
148
|
- vendor/brotli/c/enc/backward_references.c
|
131
149
|
- vendor/brotli/c/enc/backward_references.h
|
132
150
|
- vendor/brotli/c/enc/backward_references_hq.c
|
@@ -149,20 +167,23 @@ files:
|
|
149
167
|
- vendor/brotli/c/enc/compress_fragment.h
|
150
168
|
- vendor/brotli/c/enc/compress_fragment_two_pass.c
|
151
169
|
- vendor/brotli/c/enc/compress_fragment_two_pass.h
|
152
|
-
- vendor/brotli/c/enc/context.h
|
153
170
|
- vendor/brotli/c/enc/dictionary_hash.c
|
154
171
|
- vendor/brotli/c/enc/dictionary_hash.h
|
155
172
|
- vendor/brotli/c/enc/encode.c
|
173
|
+
- vendor/brotli/c/enc/encoder_dict.c
|
174
|
+
- vendor/brotli/c/enc/encoder_dict.h
|
156
175
|
- vendor/brotli/c/enc/entropy_encode.c
|
157
176
|
- vendor/brotli/c/enc/entropy_encode.h
|
158
177
|
- vendor/brotli/c/enc/entropy_encode_static.h
|
159
178
|
- vendor/brotli/c/enc/fast_log.h
|
160
179
|
- vendor/brotli/c/enc/find_match_length.h
|
161
180
|
- vendor/brotli/c/enc/hash.h
|
181
|
+
- vendor/brotli/c/enc/hash_composite_inc.h
|
162
182
|
- vendor/brotli/c/enc/hash_forgetful_chain_inc.h
|
163
183
|
- vendor/brotli/c/enc/hash_longest_match64_inc.h
|
164
184
|
- vendor/brotli/c/enc/hash_longest_match_inc.h
|
165
185
|
- vendor/brotli/c/enc/hash_longest_match_quickly_inc.h
|
186
|
+
- vendor/brotli/c/enc/hash_rolling_inc.h
|
166
187
|
- vendor/brotli/c/enc/hash_to_binary_tree_inc.h
|
167
188
|
- vendor/brotli/c/enc/histogram.c
|
168
189
|
- vendor/brotli/c/enc/histogram.h
|
@@ -174,7 +195,7 @@ files:
|
|
174
195
|
- vendor/brotli/c/enc/metablock.c
|
175
196
|
- vendor/brotli/c/enc/metablock.h
|
176
197
|
- vendor/brotli/c/enc/metablock_inc.h
|
177
|
-
- vendor/brotli/c/enc/
|
198
|
+
- vendor/brotli/c/enc/params.h
|
178
199
|
- vendor/brotli/c/enc/prefix.h
|
179
200
|
- vendor/brotli/c/enc/quality.h
|
180
201
|
- vendor/brotli/c/enc/ringbuffer.h
|
@@ -208,7 +229,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
|
|
208
229
|
version: '0'
|
209
230
|
requirements: []
|
210
231
|
rubyforge_project:
|
211
|
-
rubygems_version: 2.6
|
232
|
+
rubygems_version: 2.7.6
|
212
233
|
signing_key:
|
213
234
|
specification_version: 4
|
214
235
|
summary: Brotli compressor/decompressor
|
data/vendor/brotli/c/dec/port.h
DELETED
@@ -1,168 +0,0 @@
|
|
1
|
-
/* Copyright 2015 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
|
-
/* Macros for compiler / platform specific features and build options.
|
8
|
-
|
9
|
-
Build options are:
|
10
|
-
* BROTLI_BUILD_32_BIT disables 64-bit optimizations
|
11
|
-
* BROTLI_BUILD_64_BIT forces to use 64-bit optimizations
|
12
|
-
* BROTLI_BUILD_BIG_ENDIAN forces to use big-endian optimizations
|
13
|
-
* BROTLI_BUILD_ENDIAN_NEUTRAL disables endian-aware optimizations
|
14
|
-
* BROTLI_BUILD_LITTLE_ENDIAN forces to use little-endian optimizations
|
15
|
-
* BROTLI_BUILD_MODERN_COMPILER forces to use modern compilers built-ins,
|
16
|
-
features and attributes
|
17
|
-
* BROTLI_BUILD_PORTABLE disables dangerous optimizations, like unaligned
|
18
|
-
read and overlapping memcpy; this reduces decompression speed by 5%
|
19
|
-
* BROTLI_BUILD_NO_RBIT disables "rbit" optimization for ARM CPUs
|
20
|
-
* BROTLI_DEBUG dumps file name and line number when decoder detects stream
|
21
|
-
or memory error
|
22
|
-
* BROTLI_ENABLE_LOG enables asserts and dumps various state information
|
23
|
-
*/
|
24
|
-
|
25
|
-
#ifndef BROTLI_DEC_PORT_H_
|
26
|
-
#define BROTLI_DEC_PORT_H_
|
27
|
-
|
28
|
-
#if defined(BROTLI_ENABLE_LOG) || defined(BROTLI_DEBUG)
|
29
|
-
#include <assert.h>
|
30
|
-
#include <stdio.h>
|
31
|
-
#endif
|
32
|
-
|
33
|
-
#include <brotli/port.h>
|
34
|
-
|
35
|
-
#if defined(__arm__) || defined(__thumb__) || \
|
36
|
-
defined(_M_ARM) || defined(_M_ARMT) || defined(__ARM64_ARCH_8__)
|
37
|
-
#define BROTLI_TARGET_ARM
|
38
|
-
#if (defined(__ARM_ARCH) && (__ARM_ARCH == 7)) || \
|
39
|
-
(defined(M_ARM) && (M_ARM == 7))
|
40
|
-
#define BROTLI_TARGET_ARMV7
|
41
|
-
#endif /* ARMv7 */
|
42
|
-
#if defined(__aarch64__) || defined(__ARM64_ARCH_8__)
|
43
|
-
#define BROTLI_TARGET_ARMV8
|
44
|
-
#endif /* ARMv8 */
|
45
|
-
#endif /* ARM */
|
46
|
-
|
47
|
-
#if defined(__i386) || defined(_M_IX86)
|
48
|
-
#define BROTLI_TARGET_X86
|
49
|
-
#endif
|
50
|
-
|
51
|
-
#if defined(__x86_64__) || defined(_M_X64)
|
52
|
-
#define BROTLI_TARGET_X64
|
53
|
-
#endif
|
54
|
-
|
55
|
-
#if defined(__PPC64__)
|
56
|
-
#define BROTLI_TARGET_POWERPC64
|
57
|
-
#endif
|
58
|
-
|
59
|
-
#ifdef BROTLI_BUILD_PORTABLE
|
60
|
-
#define BROTLI_ALIGNED_READ (!!1)
|
61
|
-
#elif defined(BROTLI_TARGET_X86) || defined(BROTLI_TARGET_X64) || \
|
62
|
-
defined(BROTLI_TARGET_ARMV7) || defined(BROTLI_TARGET_ARMV8)
|
63
|
-
/* Allow unaligned read only for white-listed CPUs. */
|
64
|
-
#define BROTLI_ALIGNED_READ (!!0)
|
65
|
-
#else
|
66
|
-
#define BROTLI_ALIGNED_READ (!!1)
|
67
|
-
#endif
|
68
|
-
|
69
|
-
/* IS_CONSTANT macros returns true for compile-time constant expressions. */
|
70
|
-
#if BROTLI_MODERN_COMPILER || __has_builtin(__builtin_constant_p)
|
71
|
-
#define IS_CONSTANT(x) (!!__builtin_constant_p(x))
|
72
|
-
#else
|
73
|
-
#define IS_CONSTANT(x) (!!0)
|
74
|
-
#endif
|
75
|
-
|
76
|
-
#ifdef BROTLI_ENABLE_LOG
|
77
|
-
#define BROTLI_DCHECK(x) assert(x)
|
78
|
-
#define BROTLI_LOG(x) printf x
|
79
|
-
#else
|
80
|
-
#define BROTLI_DCHECK(x)
|
81
|
-
#define BROTLI_LOG(x)
|
82
|
-
#endif
|
83
|
-
|
84
|
-
#if defined(BROTLI_DEBUG) || defined(BROTLI_ENABLE_LOG)
|
85
|
-
static BROTLI_INLINE void BrotliDump(const char* f, int l, const char* fn) {
|
86
|
-
fprintf(stderr, "%s:%d (%s)\n", f, l, fn);
|
87
|
-
fflush(stderr);
|
88
|
-
}
|
89
|
-
#define BROTLI_DUMP() BrotliDump(__FILE__, __LINE__, __FUNCTION__)
|
90
|
-
#else
|
91
|
-
#define BROTLI_DUMP() (void)(0)
|
92
|
-
#endif
|
93
|
-
|
94
|
-
#if defined(BROTLI_BUILD_64_BIT)
|
95
|
-
#define BROTLI_64_BITS 1
|
96
|
-
#elif defined(BROTLI_BUILD_32_BIT)
|
97
|
-
#define BROTLI_64_BITS 0
|
98
|
-
#elif defined(BROTLI_TARGET_X64) || defined(BROTLI_TARGET_ARMV8) || \
|
99
|
-
defined(BROTLI_TARGET_POWERPC64)
|
100
|
-
#define BROTLI_64_BITS 1
|
101
|
-
#else
|
102
|
-
#define BROTLI_64_BITS 0
|
103
|
-
#endif
|
104
|
-
|
105
|
-
#if (BROTLI_64_BITS)
|
106
|
-
#define reg_t uint64_t
|
107
|
-
#else
|
108
|
-
#define reg_t uint32_t
|
109
|
-
#endif
|
110
|
-
|
111
|
-
#if defined(BROTLI_BUILD_BIG_ENDIAN)
|
112
|
-
#define BROTLI_LITTLE_ENDIAN 0
|
113
|
-
#define BROTLI_BIG_ENDIAN 1
|
114
|
-
#elif defined(BROTLI_BUILD_LITTLE_ENDIAN)
|
115
|
-
#define BROTLI_LITTLE_ENDIAN 1
|
116
|
-
#define BROTLI_BIG_ENDIAN 0
|
117
|
-
#elif defined(BROTLI_BUILD_ENDIAN_NEUTRAL)
|
118
|
-
#define BROTLI_LITTLE_ENDIAN 0
|
119
|
-
#define BROTLI_BIG_ENDIAN 0
|
120
|
-
#elif defined(__BYTE_ORDER__) && (__BYTE_ORDER__ == __ORDER_LITTLE_ENDIAN__)
|
121
|
-
#define BROTLI_LITTLE_ENDIAN 1
|
122
|
-
#define BROTLI_BIG_ENDIAN 0
|
123
|
-
#elif defined(_WIN32)
|
124
|
-
/* Win32 can currently always be assumed to be little endian */
|
125
|
-
#define BROTLI_LITTLE_ENDIAN 1
|
126
|
-
#define BROTLI_BIG_ENDIAN 0
|
127
|
-
#else
|
128
|
-
#if (defined(__BYTE_ORDER__) && (__BYTE_ORDER__ == __ORDER_BIG_ENDIAN__))
|
129
|
-
#define BROTLI_BIG_ENDIAN 1
|
130
|
-
#else
|
131
|
-
#define BROTLI_BIG_ENDIAN 0
|
132
|
-
#endif
|
133
|
-
#define BROTLI_LITTLE_ENDIAN 0
|
134
|
-
#endif
|
135
|
-
|
136
|
-
#define BROTLI_REPEAT(N, X) { \
|
137
|
-
if ((N & 1) != 0) {X;} \
|
138
|
-
if ((N & 2) != 0) {X; X;} \
|
139
|
-
if ((N & 4) != 0) {X; X; X; X;} \
|
140
|
-
}
|
141
|
-
|
142
|
-
#if (BROTLI_MODERN_COMPILER || defined(__llvm__)) && \
|
143
|
-
!defined(BROTLI_BUILD_NO_RBIT)
|
144
|
-
#if defined(BROTLI_TARGET_ARMV7) || defined(BROTLI_TARGET_ARMV8)
|
145
|
-
/* TODO: detect ARMv6T2 and enable this code for it. */
|
146
|
-
static BROTLI_INLINE reg_t BrotliRBit(reg_t input) {
|
147
|
-
reg_t output;
|
148
|
-
__asm__("rbit %0, %1\n" : "=r"(output) : "r"(input));
|
149
|
-
return output;
|
150
|
-
}
|
151
|
-
#define BROTLI_RBIT(x) BrotliRBit(x)
|
152
|
-
#endif /* armv7 */
|
153
|
-
#endif /* gcc || clang */
|
154
|
-
|
155
|
-
#if defined(BROTLI_TARGET_ARM)
|
156
|
-
#define BROTLI_HAS_UBFX (!!1)
|
157
|
-
#else
|
158
|
-
#define BROTLI_HAS_UBFX (!!0)
|
159
|
-
#endif
|
160
|
-
|
161
|
-
#define BROTLI_ALLOC(S, L) S->alloc_func(S->memory_manager_opaque, L)
|
162
|
-
|
163
|
-
#define BROTLI_FREE(S, X) { \
|
164
|
-
S->free_func(S->memory_manager_opaque, X); \
|
165
|
-
X = NULL; \
|
166
|
-
}
|
167
|
-
|
168
|
-
#endif /* BROTLI_DEC_PORT_H_ */
|
@@ -1,300 +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
|
-
/* Transformations on dictionary words. */
|
8
|
-
|
9
|
-
#ifndef BROTLI_DEC_TRANSFORM_H_
|
10
|
-
#define BROTLI_DEC_TRANSFORM_H_
|
11
|
-
|
12
|
-
#include <brotli/types.h>
|
13
|
-
#include "./port.h"
|
14
|
-
|
15
|
-
#if defined(__cplusplus) || defined(c_plusplus)
|
16
|
-
extern "C" {
|
17
|
-
#endif
|
18
|
-
|
19
|
-
enum WordTransformType {
|
20
|
-
kIdentity = 0,
|
21
|
-
kOmitLast1 = 1,
|
22
|
-
kOmitLast2 = 2,
|
23
|
-
kOmitLast3 = 3,
|
24
|
-
kOmitLast4 = 4,
|
25
|
-
kOmitLast5 = 5,
|
26
|
-
kOmitLast6 = 6,
|
27
|
-
kOmitLast7 = 7,
|
28
|
-
kOmitLast8 = 8,
|
29
|
-
kOmitLast9 = 9,
|
30
|
-
kUppercaseFirst = 10,
|
31
|
-
kUppercaseAll = 11,
|
32
|
-
kOmitFirst1 = 12,
|
33
|
-
kOmitFirst2 = 13,
|
34
|
-
kOmitFirst3 = 14,
|
35
|
-
kOmitFirst4 = 15,
|
36
|
-
kOmitFirst5 = 16,
|
37
|
-
kOmitFirst6 = 17,
|
38
|
-
kOmitFirst7 = 18,
|
39
|
-
kOmitFirst8 = 19,
|
40
|
-
kOmitFirst9 = 20
|
41
|
-
};
|
42
|
-
|
43
|
-
typedef struct {
|
44
|
-
const uint8_t prefix_id;
|
45
|
-
const uint8_t transform;
|
46
|
-
const uint8_t suffix_id;
|
47
|
-
} Transform;
|
48
|
-
|
49
|
-
static const char kPrefixSuffix[208] =
|
50
|
-
"\0 \0, \0 of the \0 of \0s \0.\0 and \0 in \0\"\0 to \0\">\0\n\0. \0]\0"
|
51
|
-
" for \0 a \0 that \0\'\0 with \0 from \0 by \0(\0. The \0 on \0 as \0"
|
52
|
-
" is \0ing \0\n\t\0:\0ed \0=\"\0 at \0ly \0,\0=\'\0.com/\0. This \0"
|
53
|
-
" not \0er \0al \0ful \0ive \0less \0est \0ize \0\xc2\xa0\0ous ";
|
54
|
-
|
55
|
-
enum {
|
56
|
-
/* EMPTY = ""
|
57
|
-
SP = " "
|
58
|
-
DQUOT = "\""
|
59
|
-
SQUOT = "'"
|
60
|
-
CLOSEBR = "]"
|
61
|
-
OPEN = "("
|
62
|
-
SLASH = "/"
|
63
|
-
NBSP = non-breaking space "\0xc2\xa0"
|
64
|
-
*/
|
65
|
-
kPFix_EMPTY = 0,
|
66
|
-
kPFix_SP = 1,
|
67
|
-
kPFix_COMMASP = 3,
|
68
|
-
kPFix_SPofSPtheSP = 6,
|
69
|
-
kPFix_SPtheSP = 9,
|
70
|
-
kPFix_eSP = 12,
|
71
|
-
kPFix_SPofSP = 15,
|
72
|
-
kPFix_sSP = 20,
|
73
|
-
kPFix_DOT = 23,
|
74
|
-
kPFix_SPandSP = 25,
|
75
|
-
kPFix_SPinSP = 31,
|
76
|
-
kPFix_DQUOT = 36,
|
77
|
-
kPFix_SPtoSP = 38,
|
78
|
-
kPFix_DQUOTGT = 43,
|
79
|
-
kPFix_NEWLINE = 46,
|
80
|
-
kPFix_DOTSP = 48,
|
81
|
-
kPFix_CLOSEBR = 51,
|
82
|
-
kPFix_SPforSP = 53,
|
83
|
-
kPFix_SPaSP = 59,
|
84
|
-
kPFix_SPthatSP = 63,
|
85
|
-
kPFix_SQUOT = 70,
|
86
|
-
kPFix_SPwithSP = 72,
|
87
|
-
kPFix_SPfromSP = 79,
|
88
|
-
kPFix_SPbySP = 86,
|
89
|
-
kPFix_OPEN = 91,
|
90
|
-
kPFix_DOTSPTheSP = 93,
|
91
|
-
kPFix_SPonSP = 100,
|
92
|
-
kPFix_SPasSP = 105,
|
93
|
-
kPFix_SPisSP = 110,
|
94
|
-
kPFix_ingSP = 115,
|
95
|
-
kPFix_NEWLINETAB = 120,
|
96
|
-
kPFix_COLON = 123,
|
97
|
-
kPFix_edSP = 125,
|
98
|
-
kPFix_EQDQUOT = 129,
|
99
|
-
kPFix_SPatSP = 132,
|
100
|
-
kPFix_lySP = 137,
|
101
|
-
kPFix_COMMA = 141,
|
102
|
-
kPFix_EQSQUOT = 143,
|
103
|
-
kPFix_DOTcomSLASH = 146,
|
104
|
-
kPFix_DOTSPThisSP = 152,
|
105
|
-
kPFix_SPnotSP = 160,
|
106
|
-
kPFix_erSP = 166,
|
107
|
-
kPFix_alSP = 170,
|
108
|
-
kPFix_fulSP = 174,
|
109
|
-
kPFix_iveSP = 179,
|
110
|
-
kPFix_lessSP = 184,
|
111
|
-
kPFix_estSP = 190,
|
112
|
-
kPFix_izeSP = 195,
|
113
|
-
kPFix_NBSP = 200,
|
114
|
-
kPFix_ousSP = 203
|
115
|
-
};
|
116
|
-
|
117
|
-
static const Transform kTransforms[] = {
|
118
|
-
{ kPFix_EMPTY, kIdentity, kPFix_EMPTY },
|
119
|
-
{ kPFix_EMPTY, kIdentity, kPFix_SP },
|
120
|
-
{ kPFix_SP, kIdentity, kPFix_SP },
|
121
|
-
{ kPFix_EMPTY, kOmitFirst1, kPFix_EMPTY },
|
122
|
-
{ kPFix_EMPTY, kUppercaseFirst, kPFix_SP },
|
123
|
-
{ kPFix_EMPTY, kIdentity, kPFix_SPtheSP },
|
124
|
-
{ kPFix_SP, kIdentity, kPFix_EMPTY },
|
125
|
-
{ kPFix_sSP, kIdentity, kPFix_SP },
|
126
|
-
{ kPFix_EMPTY, kIdentity, kPFix_SPofSP },
|
127
|
-
{ kPFix_EMPTY, kUppercaseFirst, kPFix_EMPTY },
|
128
|
-
{ kPFix_EMPTY, kIdentity, kPFix_SPandSP },
|
129
|
-
{ kPFix_EMPTY, kOmitFirst2, kPFix_EMPTY },
|
130
|
-
{ kPFix_EMPTY, kOmitLast1, kPFix_EMPTY },
|
131
|
-
{ kPFix_COMMASP, kIdentity, kPFix_SP },
|
132
|
-
{ kPFix_EMPTY, kIdentity, kPFix_COMMASP },
|
133
|
-
{ kPFix_SP, kUppercaseFirst, kPFix_SP },
|
134
|
-
{ kPFix_EMPTY, kIdentity, kPFix_SPinSP },
|
135
|
-
{ kPFix_EMPTY, kIdentity, kPFix_SPtoSP },
|
136
|
-
{ kPFix_eSP, kIdentity, kPFix_SP },
|
137
|
-
{ kPFix_EMPTY, kIdentity, kPFix_DQUOT },
|
138
|
-
{ kPFix_EMPTY, kIdentity, kPFix_DOT },
|
139
|
-
{ kPFix_EMPTY, kIdentity, kPFix_DQUOTGT },
|
140
|
-
{ kPFix_EMPTY, kIdentity, kPFix_NEWLINE },
|
141
|
-
{ kPFix_EMPTY, kOmitLast3, kPFix_EMPTY },
|
142
|
-
{ kPFix_EMPTY, kIdentity, kPFix_CLOSEBR },
|
143
|
-
{ kPFix_EMPTY, kIdentity, kPFix_SPforSP },
|
144
|
-
{ kPFix_EMPTY, kOmitFirst3, kPFix_EMPTY },
|
145
|
-
{ kPFix_EMPTY, kOmitLast2, kPFix_EMPTY },
|
146
|
-
{ kPFix_EMPTY, kIdentity, kPFix_SPaSP },
|
147
|
-
{ kPFix_EMPTY, kIdentity, kPFix_SPthatSP },
|
148
|
-
{ kPFix_SP, kUppercaseFirst, kPFix_EMPTY },
|
149
|
-
{ kPFix_EMPTY, kIdentity, kPFix_DOTSP },
|
150
|
-
{ kPFix_DOT, kIdentity, kPFix_EMPTY },
|
151
|
-
{ kPFix_SP, kIdentity, kPFix_COMMASP },
|
152
|
-
{ kPFix_EMPTY, kOmitFirst4, kPFix_EMPTY },
|
153
|
-
{ kPFix_EMPTY, kIdentity, kPFix_SPwithSP },
|
154
|
-
{ kPFix_EMPTY, kIdentity, kPFix_SQUOT },
|
155
|
-
{ kPFix_EMPTY, kIdentity, kPFix_SPfromSP },
|
156
|
-
{ kPFix_EMPTY, kIdentity, kPFix_SPbySP },
|
157
|
-
{ kPFix_EMPTY, kOmitFirst5, kPFix_EMPTY },
|
158
|
-
{ kPFix_EMPTY, kOmitFirst6, kPFix_EMPTY },
|
159
|
-
{ kPFix_SPtheSP, kIdentity, kPFix_EMPTY },
|
160
|
-
{ kPFix_EMPTY, kOmitLast4, kPFix_EMPTY },
|
161
|
-
{ kPFix_EMPTY, kIdentity, kPFix_DOTSPTheSP },
|
162
|
-
{ kPFix_EMPTY, kUppercaseAll, kPFix_EMPTY },
|
163
|
-
{ kPFix_EMPTY, kIdentity, kPFix_SPonSP },
|
164
|
-
{ kPFix_EMPTY, kIdentity, kPFix_SPasSP },
|
165
|
-
{ kPFix_EMPTY, kIdentity, kPFix_SPisSP },
|
166
|
-
{ kPFix_EMPTY, kOmitLast7, kPFix_EMPTY },
|
167
|
-
{ kPFix_EMPTY, kOmitLast1, kPFix_ingSP },
|
168
|
-
{ kPFix_EMPTY, kIdentity, kPFix_NEWLINETAB },
|
169
|
-
{ kPFix_EMPTY, kIdentity, kPFix_COLON },
|
170
|
-
{ kPFix_SP, kIdentity, kPFix_DOTSP },
|
171
|
-
{ kPFix_EMPTY, kIdentity, kPFix_edSP },
|
172
|
-
{ kPFix_EMPTY, kOmitFirst9, kPFix_EMPTY },
|
173
|
-
{ kPFix_EMPTY, kOmitFirst7, kPFix_EMPTY },
|
174
|
-
{ kPFix_EMPTY, kOmitLast6, kPFix_EMPTY },
|
175
|
-
{ kPFix_EMPTY, kIdentity, kPFix_OPEN },
|
176
|
-
{ kPFix_EMPTY, kUppercaseFirst, kPFix_COMMASP },
|
177
|
-
{ kPFix_EMPTY, kOmitLast8, kPFix_EMPTY },
|
178
|
-
{ kPFix_EMPTY, kIdentity, kPFix_SPatSP },
|
179
|
-
{ kPFix_EMPTY, kIdentity, kPFix_lySP },
|
180
|
-
{ kPFix_SPtheSP, kIdentity, kPFix_SPofSP },
|
181
|
-
{ kPFix_EMPTY, kOmitLast5, kPFix_EMPTY },
|
182
|
-
{ kPFix_EMPTY, kOmitLast9, kPFix_EMPTY },
|
183
|
-
{ kPFix_SP, kUppercaseFirst, kPFix_COMMASP },
|
184
|
-
{ kPFix_EMPTY, kUppercaseFirst, kPFix_DQUOT },
|
185
|
-
{ kPFix_DOT, kIdentity, kPFix_OPEN },
|
186
|
-
{ kPFix_EMPTY, kUppercaseAll, kPFix_SP },
|
187
|
-
{ kPFix_EMPTY, kUppercaseFirst, kPFix_DQUOTGT },
|
188
|
-
{ kPFix_EMPTY, kIdentity, kPFix_EQDQUOT },
|
189
|
-
{ kPFix_SP, kIdentity, kPFix_DOT },
|
190
|
-
{ kPFix_DOTcomSLASH, kIdentity, kPFix_EMPTY },
|
191
|
-
{ kPFix_SPtheSP, kIdentity, kPFix_SPofSPtheSP },
|
192
|
-
{ kPFix_EMPTY, kUppercaseFirst, kPFix_SQUOT },
|
193
|
-
{ kPFix_EMPTY, kIdentity, kPFix_DOTSPThisSP },
|
194
|
-
{ kPFix_EMPTY, kIdentity, kPFix_COMMA },
|
195
|
-
{ kPFix_DOT, kIdentity, kPFix_SP },
|
196
|
-
{ kPFix_EMPTY, kUppercaseFirst, kPFix_OPEN },
|
197
|
-
{ kPFix_EMPTY, kUppercaseFirst, kPFix_DOT },
|
198
|
-
{ kPFix_EMPTY, kIdentity, kPFix_SPnotSP },
|
199
|
-
{ kPFix_SP, kIdentity, kPFix_EQDQUOT },
|
200
|
-
{ kPFix_EMPTY, kIdentity, kPFix_erSP },
|
201
|
-
{ kPFix_SP, kUppercaseAll, kPFix_SP },
|
202
|
-
{ kPFix_EMPTY, kIdentity, kPFix_alSP },
|
203
|
-
{ kPFix_SP, kUppercaseAll, kPFix_EMPTY },
|
204
|
-
{ kPFix_EMPTY, kIdentity, kPFix_EQSQUOT },
|
205
|
-
{ kPFix_EMPTY, kUppercaseAll, kPFix_DQUOT },
|
206
|
-
{ kPFix_EMPTY, kUppercaseFirst, kPFix_DOTSP },
|
207
|
-
{ kPFix_SP, kIdentity, kPFix_OPEN },
|
208
|
-
{ kPFix_EMPTY, kIdentity, kPFix_fulSP },
|
209
|
-
{ kPFix_SP, kUppercaseFirst, kPFix_DOTSP },
|
210
|
-
{ kPFix_EMPTY, kIdentity, kPFix_iveSP },
|
211
|
-
{ kPFix_EMPTY, kIdentity, kPFix_lessSP },
|
212
|
-
{ kPFix_EMPTY, kUppercaseAll, kPFix_SQUOT },
|
213
|
-
{ kPFix_EMPTY, kIdentity, kPFix_estSP },
|
214
|
-
{ kPFix_SP, kUppercaseFirst, kPFix_DOT },
|
215
|
-
{ kPFix_EMPTY, kUppercaseAll, kPFix_DQUOTGT },
|
216
|
-
{ kPFix_SP, kIdentity, kPFix_EQSQUOT },
|
217
|
-
{ kPFix_EMPTY, kUppercaseFirst, kPFix_COMMA },
|
218
|
-
{ kPFix_EMPTY, kIdentity, kPFix_izeSP },
|
219
|
-
{ kPFix_EMPTY, kUppercaseAll, kPFix_DOT },
|
220
|
-
{ kPFix_NBSP, kIdentity, kPFix_EMPTY },
|
221
|
-
{ kPFix_SP, kIdentity, kPFix_COMMA },
|
222
|
-
{ kPFix_EMPTY, kUppercaseFirst, kPFix_EQDQUOT },
|
223
|
-
{ kPFix_EMPTY, kUppercaseAll, kPFix_EQDQUOT },
|
224
|
-
{ kPFix_EMPTY, kIdentity, kPFix_ousSP },
|
225
|
-
{ kPFix_EMPTY, kUppercaseAll, kPFix_COMMASP },
|
226
|
-
{ kPFix_EMPTY, kUppercaseFirst, kPFix_EQSQUOT },
|
227
|
-
{ kPFix_SP, kUppercaseFirst, kPFix_COMMA },
|
228
|
-
{ kPFix_SP, kUppercaseAll, kPFix_EQDQUOT },
|
229
|
-
{ kPFix_SP, kUppercaseAll, kPFix_COMMASP },
|
230
|
-
{ kPFix_EMPTY, kUppercaseAll, kPFix_COMMA },
|
231
|
-
{ kPFix_EMPTY, kUppercaseAll, kPFix_OPEN },
|
232
|
-
{ kPFix_EMPTY, kUppercaseAll, kPFix_DOTSP },
|
233
|
-
{ kPFix_SP, kUppercaseAll, kPFix_DOT },
|
234
|
-
{ kPFix_EMPTY, kUppercaseAll, kPFix_EQSQUOT },
|
235
|
-
{ kPFix_SP, kUppercaseAll, kPFix_DOTSP },
|
236
|
-
{ kPFix_SP, kUppercaseFirst, kPFix_EQDQUOT },
|
237
|
-
{ kPFix_SP, kUppercaseAll, kPFix_EQSQUOT },
|
238
|
-
{ kPFix_SP, kUppercaseFirst, kPFix_EQSQUOT },
|
239
|
-
};
|
240
|
-
|
241
|
-
static const int kNumTransforms = sizeof(kTransforms) / sizeof(kTransforms[0]);
|
242
|
-
|
243
|
-
static int ToUpperCase(uint8_t* p) {
|
244
|
-
if (p[0] < 0xc0) {
|
245
|
-
if (p[0] >= 'a' && p[0] <= 'z') {
|
246
|
-
p[0] ^= 32;
|
247
|
-
}
|
248
|
-
return 1;
|
249
|
-
}
|
250
|
-
/* An overly simplified uppercasing model for UTF-8. */
|
251
|
-
if (p[0] < 0xe0) {
|
252
|
-
p[1] ^= 32;
|
253
|
-
return 2;
|
254
|
-
}
|
255
|
-
/* An arbitrary transform for three byte characters. */
|
256
|
-
p[2] ^= 5;
|
257
|
-
return 3;
|
258
|
-
}
|
259
|
-
|
260
|
-
static BROTLI_NOINLINE int TransformDictionaryWord(
|
261
|
-
uint8_t* dst, const uint8_t* word, int len, int transform) {
|
262
|
-
int idx = 0;
|
263
|
-
{
|
264
|
-
const char* prefix = &kPrefixSuffix[kTransforms[transform].prefix_id];
|
265
|
-
while (*prefix) { dst[idx++] = (uint8_t)*prefix++; }
|
266
|
-
}
|
267
|
-
{
|
268
|
-
const int t = kTransforms[transform].transform;
|
269
|
-
int i = 0;
|
270
|
-
int skip = t - (kOmitFirst1 - 1);
|
271
|
-
if (skip > 0) {
|
272
|
-
word += skip;
|
273
|
-
len -= skip;
|
274
|
-
} else if (t <= kOmitLast9) {
|
275
|
-
len -= t;
|
276
|
-
}
|
277
|
-
while (i < len) { dst[idx++] = word[i++]; }
|
278
|
-
if (t == kUppercaseFirst) {
|
279
|
-
ToUpperCase(&dst[idx - len]);
|
280
|
-
} else if (t == kUppercaseAll) {
|
281
|
-
uint8_t* uppercase = &dst[idx - len];
|
282
|
-
while (len > 0) {
|
283
|
-
int step = ToUpperCase(uppercase);
|
284
|
-
uppercase += step;
|
285
|
-
len -= step;
|
286
|
-
}
|
287
|
-
}
|
288
|
-
}
|
289
|
-
{
|
290
|
-
const char* suffix = &kPrefixSuffix[kTransforms[transform].suffix_id];
|
291
|
-
while (*suffix) { dst[idx++] = (uint8_t)*suffix++; }
|
292
|
-
return idx;
|
293
|
-
}
|
294
|
-
}
|
295
|
-
|
296
|
-
#if defined(__cplusplus) || defined(c_plusplus)
|
297
|
-
} /* extern "C" */
|
298
|
-
#endif
|
299
|
-
|
300
|
-
#endif /* BROTLI_DEC_TRANSFORM_H_ */
|