brotli 0.1.1 → 0.1.2
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/ext/brotli/brotli.cc +114 -24
- data/ext/brotli/brotli.h +0 -1
- data/ext/brotli/extconf.rb +30 -23
- data/lib/brotli/version.rb +1 -1
- data/vendor/brotli/LICENSE +1 -1
- data/vendor/brotli/dec/Makefile +1 -1
- data/vendor/brotli/dec/bit_reader.c +3 -3
- data/vendor/brotli/dec/bit_reader.h +25 -27
- data/vendor/brotli/dec/context.h +4 -4
- data/vendor/brotli/dec/decode.c +410 -486
- data/vendor/brotli/dec/decode.h +101 -105
- data/vendor/brotli/dec/dictionary.c +1 -1
- data/vendor/brotli/dec/dictionary.h +7 -8
- data/vendor/brotli/dec/huffman.c +103 -105
- data/vendor/brotli/dec/huffman.h +18 -18
- data/vendor/brotli/dec/port.h +52 -40
- data/vendor/brotli/dec/prefix.h +2 -0
- data/vendor/brotli/dec/state.c +13 -19
- data/vendor/brotli/dec/state.h +25 -39
- data/vendor/brotli/dec/transform.h +38 -44
- data/vendor/brotli/dec/types.h +2 -2
- data/vendor/brotli/enc/Makefile +1 -1
- data/vendor/brotli/enc/backward_references.cc +455 -359
- data/vendor/brotli/enc/backward_references.h +79 -3
- data/vendor/brotli/enc/bit_cost.h +54 -32
- data/vendor/brotli/enc/block_splitter.cc +285 -193
- data/vendor/brotli/enc/block_splitter.h +4 -12
- data/vendor/brotli/enc/brotli_bit_stream.cc +623 -324
- data/vendor/brotli/enc/brotli_bit_stream.h +76 -37
- data/vendor/brotli/enc/cluster.h +161 -120
- data/vendor/brotli/enc/command.h +60 -37
- data/vendor/brotli/enc/compress_fragment.cc +701 -0
- data/vendor/brotli/enc/compress_fragment.h +47 -0
- data/vendor/brotli/enc/compress_fragment_two_pass.cc +524 -0
- data/vendor/brotli/enc/compress_fragment_two_pass.h +40 -0
- data/vendor/brotli/enc/compressor.h +15 -0
- data/vendor/brotli/enc/context.h +1 -1
- data/vendor/brotli/enc/dictionary.h +2 -2
- data/vendor/brotli/enc/encode.cc +819 -286
- data/vendor/brotli/enc/encode.h +38 -15
- data/vendor/brotli/enc/encode_parallel.cc +40 -42
- data/vendor/brotli/enc/entropy_encode.cc +144 -147
- data/vendor/brotli/enc/entropy_encode.h +32 -8
- data/vendor/brotli/enc/entropy_encode_static.h +572 -0
- data/vendor/brotli/enc/fast_log.h +7 -40
- data/vendor/brotli/enc/find_match_length.h +9 -9
- data/vendor/brotli/enc/hash.h +462 -154
- data/vendor/brotli/enc/histogram.cc +6 -6
- data/vendor/brotli/enc/histogram.h +13 -13
- data/vendor/brotli/enc/literal_cost.cc +45 -45
- data/vendor/brotli/enc/metablock.cc +92 -89
- data/vendor/brotli/enc/metablock.h +12 -12
- data/vendor/brotli/enc/port.h +7 -16
- data/vendor/brotli/enc/prefix.h +23 -22
- data/vendor/brotli/enc/ringbuffer.h +75 -29
- data/vendor/brotli/enc/static_dict.cc +56 -48
- data/vendor/brotli/enc/static_dict.h +5 -5
- data/vendor/brotli/enc/streams.cc +1 -1
- data/vendor/brotli/enc/streams.h +5 -5
- data/vendor/brotli/enc/transform.h +40 -35
- data/vendor/brotli/enc/types.h +2 -0
- data/vendor/brotli/enc/utf8_util.cc +3 -2
- data/vendor/brotli/enc/write_bits.h +6 -6
- metadata +9 -5
- data/vendor/brotli/dec/streams.c +0 -102
- data/vendor/brotli/dec/streams.h +0 -95
data/vendor/brotli/dec/port.h
CHANGED
@@ -18,13 +18,16 @@
|
|
18
18
|
read and overlapping memcpy; this reduces decompression speed by 5%
|
19
19
|
* BROTLI_DEBUG dumps file name and line number when decoder detects stream
|
20
20
|
or memory error
|
21
|
-
*
|
21
|
+
* BROTLI_ENABLE_LOG enables asserts and dumps various state information
|
22
22
|
*/
|
23
23
|
|
24
24
|
#ifndef BROTLI_DEC_PORT_H_
|
25
25
|
#define BROTLI_DEC_PORT_H_
|
26
26
|
|
27
|
-
#
|
27
|
+
#if defined(BROTLI_ENABLE_LOG) || defined(BROTLI_DEBUG)
|
28
|
+
#include <assert.h>
|
29
|
+
#include <stdio.h>
|
30
|
+
#endif
|
28
31
|
|
29
32
|
/* Compatibility with non-clang compilers. */
|
30
33
|
#ifndef __has_builtin
|
@@ -39,10 +42,6 @@
|
|
39
42
|
#define __has_feature(x) 0
|
40
43
|
#endif
|
41
44
|
|
42
|
-
#if defined(__sparc)
|
43
|
-
#define BROTLI_TARGET_SPARC
|
44
|
-
#endif
|
45
|
-
|
46
45
|
#if defined(__arm__) || defined(__thumb__) || \
|
47
46
|
defined(_M_ARM) || defined(_M_ARMT)
|
48
47
|
#define BROTLI_TARGET_ARM
|
@@ -55,6 +54,10 @@
|
|
55
54
|
#endif /* ARMv8 */
|
56
55
|
#endif /* ARM */
|
57
56
|
|
57
|
+
#if defined(__i386) || defined(_M_IX86)
|
58
|
+
#define BROTLI_TARGET_X86
|
59
|
+
#endif
|
60
|
+
|
58
61
|
#if defined(__x86_64__) || defined(_M_X64)
|
59
62
|
#define BROTLI_TARGET_X64
|
60
63
|
#endif
|
@@ -83,25 +86,16 @@
|
|
83
86
|
#define BROTLI_MODERN_COMPILER 0
|
84
87
|
#endif
|
85
88
|
|
86
|
-
/* SPARC and ARMv6 don't support unaligned read.
|
87
|
-
Choose portable build for them. */
|
88
|
-
#if !defined(BROTLI_BUILD_PORTABLE)
|
89
|
-
#if defined(BROTLI_TARGET_SPARC) || \
|
90
|
-
(defined(BROTLI_TARGET_ARM) && !defined(BROTLI_TARGET_ARMV7))
|
91
|
-
#define BROTLI_BUILD_PORTABLE
|
92
|
-
#endif /* SPARK or ARMv6 */
|
93
|
-
#endif /* portable build */
|
94
|
-
|
95
89
|
#ifdef BROTLI_BUILD_PORTABLE
|
96
|
-
#define BROTLI_ALIGNED_READ 1
|
97
|
-
#
|
90
|
+
#define BROTLI_ALIGNED_READ (!!1)
|
91
|
+
#elif defined(BROTLI_TARGET_X86) || defined(BROTLI_TARGET_X64) || \
|
92
|
+
defined(BROTLI_TARGET_ARMV7) || defined(BROTLI_TARGET_ARMV8)
|
93
|
+
/* Allow unaligned read only for whitelisted CPUs. */
|
94
|
+
#define BROTLI_ALIGNED_READ (!!0)
|
98
95
|
#else
|
99
|
-
#define BROTLI_ALIGNED_READ
|
100
|
-
#define BROTLI_SAFE_MEMMOVE 0
|
96
|
+
#define BROTLI_ALIGNED_READ (!!1)
|
101
97
|
#endif
|
102
98
|
|
103
|
-
#define BROTLI_ASAN_BUILD __has_feature(address_sanitizer)
|
104
|
-
|
105
99
|
/* Define "PREDICT_TRUE" and "PREDICT_FALSE" macros for capable compilers.
|
106
100
|
|
107
101
|
To apply compiler hint, enclose the branching condition into macros, like this:
|
@@ -129,9 +123,9 @@ OR:
|
|
129
123
|
|
130
124
|
/* IS_CONSTANT macros returns true for compile-time constant expressions. */
|
131
125
|
#if BROTLI_MODERN_COMPILER || __has_builtin(__builtin_constant_p)
|
132
|
-
#define IS_CONSTANT(x) __builtin_constant_p(x)
|
126
|
+
#define IS_CONSTANT(x) (!!__builtin_constant_p(x))
|
133
127
|
#else
|
134
|
-
#define IS_CONSTANT(x) 0
|
128
|
+
#define IS_CONSTANT(x) (!!0)
|
135
129
|
#endif
|
136
130
|
|
137
131
|
#if BROTLI_MODERN_COMPILER || __has_attribute(always_inline)
|
@@ -140,9 +134,21 @@ OR:
|
|
140
134
|
#define ATTRIBUTE_ALWAYS_INLINE
|
141
135
|
#endif
|
142
136
|
|
137
|
+
#if defined(_WIN32) || defined(__CYGWIN__)
|
138
|
+
#define ATTRIBUTE_VISIBILITY_HIDDEN
|
139
|
+
#elif BROTLI_MODERN_COMPILER || __has_attribute(visibility)
|
140
|
+
#define ATTRIBUTE_VISIBILITY_HIDDEN __attribute__ ((visibility ("hidden")))
|
141
|
+
#else
|
142
|
+
#define ATTRIBUTE_VISIBILITY_HIDDEN
|
143
|
+
#endif
|
144
|
+
|
145
|
+
#ifndef BROTLI_INTERNAL
|
146
|
+
#define BROTLI_INTERNAL ATTRIBUTE_VISIBILITY_HIDDEN
|
147
|
+
#endif
|
148
|
+
|
143
149
|
#ifndef _MSC_VER
|
144
|
-
#if defined(__cplusplus) || !defined(__STRICT_ANSI__) \
|
145
|
-
|
150
|
+
#if defined(__cplusplus) || !defined(__STRICT_ANSI__) || \
|
151
|
+
__STDC_VERSION__ >= 199901L
|
146
152
|
#define BROTLI_INLINE inline ATTRIBUTE_ALWAYS_INLINE
|
147
153
|
#else
|
148
154
|
#define BROTLI_INLINE
|
@@ -151,10 +157,22 @@ OR:
|
|
151
157
|
#define BROTLI_INLINE __forceinline
|
152
158
|
#endif /* _MSC_VER */
|
153
159
|
|
154
|
-
#ifdef
|
160
|
+
#ifdef BROTLI_ENABLE_LOG
|
155
161
|
#define BROTLI_DCHECK(x) assert(x)
|
162
|
+
#define BROTLI_LOG(x) printf x
|
156
163
|
#else
|
157
164
|
#define BROTLI_DCHECK(x)
|
165
|
+
#define BROTLI_LOG(x)
|
166
|
+
#endif
|
167
|
+
|
168
|
+
#if defined(BROTLI_DEBUG) || defined(BROTLI_ENABLE_LOG)
|
169
|
+
static inline void BrotliDump(const char* f, int l, const char* fn) {
|
170
|
+
fprintf(stderr, "%s:%d (%s)\n", f, l, fn);
|
171
|
+
fflush(stderr);
|
172
|
+
}
|
173
|
+
#define BROTLI_DUMP() BrotliDump(__FILE__, __LINE__, __FUNCTION__)
|
174
|
+
#else
|
175
|
+
#define BROTLI_DUMP() (void)(0)
|
158
176
|
#endif
|
159
177
|
|
160
178
|
#if defined(BROTLI_BUILD_64_BIT)
|
@@ -194,20 +212,14 @@ OR:
|
|
194
212
|
#endif
|
195
213
|
|
196
214
|
#if BROTLI_MODERN_COMPILER || __has_attribute(noinline)
|
197
|
-
#define BROTLI_NOINLINE __attribute__
|
215
|
+
#define BROTLI_NOINLINE __attribute__((noinline))
|
198
216
|
#else
|
199
217
|
#define BROTLI_NOINLINE
|
200
218
|
#endif
|
201
219
|
|
202
|
-
#
|
203
|
-
|
204
|
-
|
205
|
-
#define BROTLI_NO_ASAN
|
206
|
-
#endif
|
207
|
-
|
208
|
-
#define BROTLI_REPEAT(N, X) { \
|
209
|
-
if ((N & 1) != 0) {X;} \
|
210
|
-
if ((N & 2) != 0) {X; X;} \
|
220
|
+
#define BROTLI_REPEAT(N, X) { \
|
221
|
+
if ((N & 1) != 0) {X;} \
|
222
|
+
if ((N & 2) != 0) {X; X;} \
|
211
223
|
if ((N & 4) != 0) {X; X; X; X;} \
|
212
224
|
}
|
213
225
|
|
@@ -223,16 +235,16 @@ static BROTLI_INLINE unsigned BrotliRBit(unsigned input) {
|
|
223
235
|
#endif /* gcc || clang */
|
224
236
|
|
225
237
|
#if defined(BROTLI_TARGET_ARM)
|
226
|
-
#define BROTLI_HAS_UBFX 1
|
238
|
+
#define BROTLI_HAS_UBFX (!!1)
|
227
239
|
#else
|
228
|
-
#define BROTLI_HAS_UBFX 0
|
240
|
+
#define BROTLI_HAS_UBFX (!!0)
|
229
241
|
#endif
|
230
242
|
|
231
243
|
#define BROTLI_ALLOC(S, L) S->alloc_func(S->memory_manager_opaque, L)
|
232
244
|
|
233
|
-
#define BROTLI_FREE(S, X) {
|
245
|
+
#define BROTLI_FREE(S, X) { \
|
234
246
|
S->free_func(S->memory_manager_opaque, X); \
|
235
|
-
X = NULL;
|
247
|
+
X = NULL; \
|
236
248
|
}
|
237
249
|
|
238
250
|
#define BROTLI_UNUSED(X) (void)(X)
|
data/vendor/brotli/dec/prefix.h
CHANGED
data/vendor/brotli/dec/state.c
CHANGED
@@ -4,16 +4,21 @@
|
|
4
4
|
See file LICENSE for detail or copy at https://opensource.org/licenses/MIT
|
5
5
|
*/
|
6
6
|
|
7
|
-
#include "./huffman.h"
|
8
7
|
#include "./state.h"
|
9
8
|
|
10
|
-
#include <stdlib.h>
|
11
|
-
|
9
|
+
#include <stdlib.h> /* free, malloc */
|
10
|
+
|
11
|
+
#include "./huffman.h"
|
12
|
+
#include "./types.h"
|
12
13
|
|
13
14
|
#if defined(__cplusplus) || defined(c_plusplus)
|
14
15
|
extern "C" {
|
15
16
|
#endif
|
16
17
|
|
18
|
+
/* Declared in decode.h */
|
19
|
+
int BrotliStateIsStreamStart(const BrotliState* s);
|
20
|
+
int BrotliStateIsStreamEnd(const BrotliState* s);
|
21
|
+
|
17
22
|
static void* DefaultAllocFunc(void* opaque, size_t size) {
|
18
23
|
BROTLI_UNUSED(opaque);
|
19
24
|
return malloc(size);
|
@@ -75,7 +80,6 @@ void BrotliStateInitWithCustomAllocators(BrotliState* s,
|
|
75
80
|
s->distance_hgroup.codes = NULL;
|
76
81
|
s->distance_hgroup.htrees = NULL;
|
77
82
|
|
78
|
-
|
79
83
|
s->custom_dict = NULL;
|
80
84
|
s->custom_dict_size = 0;
|
81
85
|
|
@@ -94,13 +98,6 @@ void BrotliStateInitWithCustomAllocators(BrotliState* s,
|
|
94
98
|
s->symbol_lists = &s->symbols_lists_array[BROTLI_HUFFMAN_MAX_CODE_LENGTH + 1];
|
95
99
|
|
96
100
|
s->mtf_upper_bound = 255;
|
97
|
-
|
98
|
-
s->legacy_input_buffer = 0;
|
99
|
-
s->legacy_output_buffer = 0;
|
100
|
-
s->legacy_input_len = 0;
|
101
|
-
s->legacy_output_len = 0;
|
102
|
-
s->legacy_input_pos = 0;
|
103
|
-
s->legacy_output_pos = 0;
|
104
101
|
}
|
105
102
|
|
106
103
|
void BrotliStateMetablockBegin(BrotliState* s) {
|
@@ -121,7 +118,6 @@ void BrotliStateMetablockBegin(BrotliState* s) {
|
|
121
118
|
s->context_modes = NULL;
|
122
119
|
s->dist_context_map = NULL;
|
123
120
|
s->context_map_slice = NULL;
|
124
|
-
s->literal_htree_index = 0;
|
125
121
|
s->literal_htree = NULL;
|
126
122
|
s->dist_context_map_slice = NULL;
|
127
123
|
s->dist_htree_index = 0;
|
@@ -150,8 +146,6 @@ void BrotliStateCleanup(BrotliState* s) {
|
|
150
146
|
|
151
147
|
BROTLI_FREE(s, s->ringbuffer);
|
152
148
|
BROTLI_FREE(s, s->block_type_trees);
|
153
|
-
BROTLI_FREE(s, s->legacy_input_buffer);
|
154
|
-
BROTLI_FREE(s, s->legacy_output_buffer);
|
155
149
|
}
|
156
150
|
|
157
151
|
int BrotliStateIsStreamStart(const BrotliState* s) {
|
@@ -166,10 +160,10 @@ int BrotliStateIsStreamEnd(const BrotliState* s) {
|
|
166
160
|
void BrotliHuffmanTreeGroupInit(BrotliState* s, HuffmanTreeGroup* group,
|
167
161
|
uint32_t alphabet_size, uint32_t ntrees) {
|
168
162
|
/* Pack two allocations into one */
|
169
|
-
const size_t
|
170
|
-
|
171
|
-
const size_t htree_size = sizeof(HuffmanCode*) *
|
172
|
-
char
|
163
|
+
const size_t max_table_size = kMaxHuffmanTableSize[(alphabet_size + 31) >> 5];
|
164
|
+
const size_t code_size = sizeof(HuffmanCode) * ntrees * max_table_size;
|
165
|
+
const size_t htree_size = sizeof(HuffmanCode*) * ntrees;
|
166
|
+
char* p = (char*)BROTLI_ALLOC(s, code_size + htree_size);
|
173
167
|
group->alphabet_size = (uint16_t)alphabet_size;
|
174
168
|
group->num_htrees = (uint16_t)ntrees;
|
175
169
|
group->codes = (HuffmanCode*)p;
|
@@ -182,5 +176,5 @@ void BrotliHuffmanTreeGroupRelease(BrotliState* s, HuffmanTreeGroup* group) {
|
|
182
176
|
}
|
183
177
|
|
184
178
|
#if defined(__cplusplus) || defined(c_plusplus)
|
185
|
-
}
|
179
|
+
} /* extern "C" */
|
186
180
|
#endif
|
data/vendor/brotli/dec/state.h
CHANGED
@@ -9,10 +9,10 @@
|
|
9
9
|
#ifndef BROTLI_DEC_STATE_H_
|
10
10
|
#define BROTLI_DEC_STATE_H_
|
11
11
|
|
12
|
-
#include <stdio.h>
|
13
12
|
#include "./bit_reader.h"
|
14
13
|
#include "./huffman.h"
|
15
14
|
#include "./types.h"
|
15
|
+
#include "./port.h"
|
16
16
|
|
17
17
|
#if defined(__cplusplus) || defined(c_plusplus)
|
18
18
|
extern "C" {
|
@@ -95,6 +95,10 @@ typedef enum {
|
|
95
95
|
|
96
96
|
struct BrotliStateStruct {
|
97
97
|
BrotliRunningState state;
|
98
|
+
|
99
|
+
/* This counter is reused for several disjoint loops. */
|
100
|
+
int loop_counter;
|
101
|
+
|
98
102
|
BrotliBitReader br;
|
99
103
|
|
100
104
|
brotli_alloc_func alloc_func;
|
@@ -108,8 +112,6 @@ struct BrotliStateStruct {
|
|
108
112
|
} buffer;
|
109
113
|
uint32_t buffer_length;
|
110
114
|
|
111
|
-
/* This counter is reused for several disjoint loops. */
|
112
|
-
int loop_counter;
|
113
115
|
int pos;
|
114
116
|
int max_backward_distance;
|
115
117
|
int max_backward_distance_minus_custom_dict_size;
|
@@ -118,6 +120,8 @@ struct BrotliStateStruct {
|
|
118
120
|
int ringbuffer_mask;
|
119
121
|
int dist_rb_idx;
|
120
122
|
int dist_rb[4];
|
123
|
+
int error_code;
|
124
|
+
uint32_t sub_loop_counter;
|
121
125
|
uint8_t* ringbuffer;
|
122
126
|
uint8_t* ringbuffer_end;
|
123
127
|
HuffmanCode* htree_command;
|
@@ -126,8 +130,6 @@ struct BrotliStateStruct {
|
|
126
130
|
uint8_t* context_map_slice;
|
127
131
|
uint8_t* dist_context_map_slice;
|
128
132
|
|
129
|
-
uint32_t sub_loop_counter;
|
130
|
-
|
131
133
|
/* This ring buffer holds a few past copy distances that will be used by */
|
132
134
|
/* some special distance codes. */
|
133
135
|
HuffmanTreeGroup literal_hgroup;
|
@@ -149,13 +151,11 @@ struct BrotliStateStruct {
|
|
149
151
|
int distance_postfix_mask;
|
150
152
|
uint32_t num_dist_htrees;
|
151
153
|
uint8_t* dist_context_map;
|
152
|
-
HuffmanCode
|
153
|
-
uint8_t literal_htree_index;
|
154
|
+
HuffmanCode* literal_htree;
|
154
155
|
uint8_t dist_htree_index;
|
155
156
|
uint32_t repeat_code_len;
|
156
157
|
uint32_t prev_code_len;
|
157
158
|
|
158
|
-
|
159
159
|
int copy_length;
|
160
160
|
int distance_code;
|
161
161
|
|
@@ -173,7 +173,7 @@ struct BrotliStateStruct {
|
|
173
173
|
uint16_t* symbol_lists;
|
174
174
|
/* Storage from symbol_lists. */
|
175
175
|
uint16_t symbols_lists_array[BROTLI_HUFFMAN_MAX_CODE_LENGTH + 1 +
|
176
|
-
|
176
|
+
BROTLI_HUFFMAN_MAX_CODE_LENGTHS_SIZE];
|
177
177
|
/* Tails of symbol chains. */
|
178
178
|
int next_symbol[32];
|
179
179
|
uint8_t code_length_code_lengths[18];
|
@@ -188,11 +188,11 @@ struct BrotliStateStruct {
|
|
188
188
|
uint32_t context_index;
|
189
189
|
uint32_t max_run_length_prefix;
|
190
190
|
uint32_t code;
|
191
|
-
HuffmanCode context_map_table[
|
191
|
+
HuffmanCode context_map_table[BROTLI_HUFFMAN_MAX_SIZE_272];
|
192
192
|
|
193
193
|
/* For InverseMoveToFrontTransform */
|
194
194
|
uint32_t mtf_upper_bound;
|
195
|
-
uint8_t mtf[256];
|
195
|
+
uint8_t mtf[256 + 4];
|
196
196
|
|
197
197
|
/* For custom dictionaries */
|
198
198
|
const uint8_t* custom_dict;
|
@@ -218,39 +218,25 @@ struct BrotliStateStruct {
|
|
218
218
|
uint8_t* context_map;
|
219
219
|
uint8_t* context_modes;
|
220
220
|
|
221
|
-
|
222
|
-
uint8_t* legacy_output_buffer;
|
223
|
-
size_t legacy_input_len;
|
224
|
-
size_t legacy_output_len;
|
225
|
-
size_t legacy_input_pos;
|
226
|
-
size_t legacy_output_pos;
|
221
|
+
uint32_t trivial_literal_contexts[8]; /* 256 bits */
|
227
222
|
};
|
228
223
|
|
229
|
-
typedef struct BrotliStateStruct
|
230
|
-
|
231
|
-
void BrotliStateInit(BrotliState* s);
|
232
|
-
void BrotliStateInitWithCustomAllocators(BrotliState* s,
|
233
|
-
brotli_alloc_func alloc_func,
|
234
|
-
brotli_free_func free_func,
|
235
|
-
void* opaque);
|
236
|
-
void BrotliStateCleanup(BrotliState* s);
|
237
|
-
void BrotliStateMetablockBegin(BrotliState* s);
|
238
|
-
void BrotliStateCleanupAfterMetablock(BrotliState* s);
|
239
|
-
void BrotliHuffmanTreeGroupInit(BrotliState* s, HuffmanTreeGroup* group,
|
240
|
-
uint32_t alphabet_size, uint32_t ntrees);
|
241
|
-
void BrotliHuffmanTreeGroupRelease(BrotliState* s, HuffmanTreeGroup* group);
|
242
|
-
|
243
|
-
/* Returns 1, if s is in a state where we have not read any input bytes yet,
|
244
|
-
and 0 otherwise */
|
245
|
-
int BrotliStateIsStreamStart(const BrotliState* s);
|
246
|
-
|
247
|
-
/* Returns 1, if s is in a state where we reached the end of the input and
|
248
|
-
produced all of the output, and 0 otherwise. */
|
249
|
-
int BrotliStateIsStreamEnd(const BrotliState* s);
|
224
|
+
typedef struct BrotliStateStruct BrotliStateInternal;
|
225
|
+
#define BrotliState BrotliStateInternal
|
250
226
|
|
227
|
+
BROTLI_INTERNAL void BrotliStateInit(BrotliState* s);
|
228
|
+
BROTLI_INTERNAL void BrotliStateInitWithCustomAllocators(BrotliState* s,
|
229
|
+
brotli_alloc_func alloc_func, brotli_free_func free_func, void* opaque);
|
230
|
+
BROTLI_INTERNAL void BrotliStateCleanup(BrotliState* s);
|
231
|
+
BROTLI_INTERNAL void BrotliStateMetablockBegin(BrotliState* s);
|
232
|
+
BROTLI_INTERNAL void BrotliStateCleanupAfterMetablock(BrotliState* s);
|
233
|
+
BROTLI_INTERNAL void BrotliHuffmanTreeGroupInit(BrotliState* s,
|
234
|
+
HuffmanTreeGroup* group, uint32_t alphabet_size, uint32_t ntrees);
|
235
|
+
BROTLI_INTERNAL void BrotliHuffmanTreeGroupRelease(BrotliState* s,
|
236
|
+
HuffmanTreeGroup* group);
|
251
237
|
|
252
238
|
#if defined(__cplusplus) || defined(c_plusplus)
|
253
|
-
}
|
239
|
+
} /* extern "C" */
|
254
240
|
#endif
|
255
241
|
|
256
242
|
#endif /* BROTLI_DEC_STATE_H_ */
|
@@ -9,8 +9,6 @@
|
|
9
9
|
#ifndef BROTLI_DEC_TRANSFORM_H_
|
10
10
|
#define BROTLI_DEC_TRANSFORM_H_
|
11
11
|
|
12
|
-
#include <stdio.h>
|
13
|
-
#include <ctype.h>
|
14
12
|
#include "./port.h"
|
15
13
|
#include "./types.h"
|
16
14
|
|
@@ -19,27 +17,27 @@ extern "C" {
|
|
19
17
|
#endif
|
20
18
|
|
21
19
|
enum WordTransformType {
|
22
|
-
kIdentity
|
23
|
-
kOmitLast1
|
24
|
-
kOmitLast2
|
25
|
-
kOmitLast3
|
26
|
-
kOmitLast4
|
27
|
-
kOmitLast5
|
28
|
-
kOmitLast6
|
29
|
-
kOmitLast7
|
30
|
-
kOmitLast8
|
31
|
-
kOmitLast9
|
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,
|
32
30
|
kUppercaseFirst = 10,
|
33
|
-
kUppercaseAll
|
34
|
-
kOmitFirst1
|
35
|
-
kOmitFirst2
|
36
|
-
kOmitFirst3
|
37
|
-
kOmitFirst4
|
38
|
-
kOmitFirst5
|
39
|
-
kOmitFirst6
|
40
|
-
kOmitFirst7
|
41
|
-
kOmitFirst8
|
42
|
-
kOmitFirst9
|
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
|
43
41
|
};
|
44
42
|
|
45
43
|
typedef struct {
|
@@ -68,15 +66,15 @@ enum {
|
|
68
66
|
kPFix_SP = 1,
|
69
67
|
kPFix_COMMASP = 3,
|
70
68
|
kPFix_SPofSPtheSP = 6,
|
71
|
-
kPFix_SPtheSP
|
69
|
+
kPFix_SPtheSP = 9,
|
72
70
|
kPFix_eSP = 12,
|
73
|
-
kPFix_SPofSP
|
71
|
+
kPFix_SPofSP = 15,
|
74
72
|
kPFix_sSP = 20,
|
75
73
|
kPFix_DOT = 23,
|
76
74
|
kPFix_SPandSP = 25,
|
77
75
|
kPFix_SPinSP = 31,
|
78
76
|
kPFix_DQUOT = 36,
|
79
|
-
kPFix_SPtoSP
|
77
|
+
kPFix_SPtoSP = 38,
|
80
78
|
kPFix_DQUOTGT = 43,
|
81
79
|
kPFix_NEWLINE = 46,
|
82
80
|
kPFix_DOTSP = 48,
|
@@ -86,20 +84,20 @@ enum {
|
|
86
84
|
kPFix_SPthatSP = 63,
|
87
85
|
kPFix_SQUOT = 70,
|
88
86
|
kPFix_SPwithSP = 72,
|
89
|
-
kPFix_SPfromSP
|
90
|
-
kPFix_SPbySP
|
87
|
+
kPFix_SPfromSP = 79,
|
88
|
+
kPFix_SPbySP = 86,
|
91
89
|
kPFix_OPEN = 91,
|
92
90
|
kPFix_DOTSPTheSP = 93,
|
93
|
-
kPFix_SPonSP
|
94
|
-
kPFix_SPasSP
|
95
|
-
kPFix_SPisSP
|
91
|
+
kPFix_SPonSP = 100,
|
92
|
+
kPFix_SPasSP = 105,
|
93
|
+
kPFix_SPisSP = 110,
|
96
94
|
kPFix_ingSP = 115,
|
97
95
|
kPFix_NEWLINETAB = 120,
|
98
96
|
kPFix_COLON = 123,
|
99
97
|
kPFix_edSP = 125,
|
100
98
|
kPFix_EQDQUOT = 129,
|
101
99
|
kPFix_SPatSP = 132,
|
102
|
-
kPFix_lySP
|
100
|
+
kPFix_lySP = 137,
|
103
101
|
kPFix_COMMA = 141,
|
104
102
|
kPFix_EQSQUOT = 143,
|
105
103
|
kPFix_DOTcomSLASH = 146,
|
@@ -116,7 +114,6 @@ enum {
|
|
116
114
|
kPFix_ousSP = 203
|
117
115
|
};
|
118
116
|
|
119
|
-
|
120
117
|
static const Transform kTransforms[] = {
|
121
118
|
{ kPFix_EMPTY, kIdentity, kPFix_EMPTY },
|
122
119
|
{ kPFix_EMPTY, kIdentity, kPFix_SP },
|
@@ -243,7 +240,7 @@ static const Transform kTransforms[] = {
|
|
243
240
|
|
244
241
|
static const int kNumTransforms = sizeof(kTransforms) / sizeof(kTransforms[0]);
|
245
242
|
|
246
|
-
static int ToUpperCase(uint8_t
|
243
|
+
static int ToUpperCase(uint8_t* p) {
|
247
244
|
if (p[0] < 0xc0) {
|
248
245
|
if (p[0] >= 'a' && p[0] <= 'z') {
|
249
246
|
p[0] ^= 32;
|
@@ -269,22 +266,19 @@ static BROTLI_NOINLINE int TransformDictionaryWord(
|
|
269
266
|
}
|
270
267
|
{
|
271
268
|
const int t = kTransforms[transform].transform;
|
272
|
-
int skip = t < kOmitFirst1 ? 0 : t - (kOmitFirst1 - 1);
|
273
269
|
int i = 0;
|
274
|
-
|
275
|
-
if (skip >
|
276
|
-
|
277
|
-
|
278
|
-
|
279
|
-
len -= skip;
|
280
|
-
if (t <= kOmitLast9) {
|
270
|
+
int skip = t - (kOmitFirst1 - 1);
|
271
|
+
if (skip > 0) {
|
272
|
+
word += skip;
|
273
|
+
len -= skip;
|
274
|
+
} else if (t <= kOmitLast9) {
|
281
275
|
len -= t;
|
282
276
|
}
|
283
277
|
while (i < len) { dst[idx++] = word[i++]; }
|
284
|
-
uppercase = &dst[idx - len];
|
285
278
|
if (t == kUppercaseFirst) {
|
286
|
-
ToUpperCase(
|
279
|
+
ToUpperCase(&dst[idx - len]);
|
287
280
|
} else if (t == kUppercaseAll) {
|
281
|
+
uint8_t* uppercase = &dst[idx - len];
|
288
282
|
while (len > 0) {
|
289
283
|
int step = ToUpperCase(uppercase);
|
290
284
|
uppercase += step;
|
@@ -300,7 +294,7 @@ static BROTLI_NOINLINE int TransformDictionaryWord(
|
|
300
294
|
}
|
301
295
|
|
302
296
|
#if defined(__cplusplus) || defined(c_plusplus)
|
303
|
-
}
|
297
|
+
} /* extern "C" */
|
304
298
|
#endif
|
305
299
|
|
306
300
|
#endif /* BROTLI_DEC_TRANSFORM_H_ */
|
data/vendor/brotli/dec/types.h
CHANGED
@@ -29,10 +29,10 @@ typedef __int64 int64_t;
|
|
29
29
|
size length. Neither items nor size are allowed to be 0.
|
30
30
|
opaque argument is a pointer provided by client and could be used to bind
|
31
31
|
function to specific object (memory pool). */
|
32
|
-
typedef void* (*brotli_alloc_func)
|
32
|
+
typedef void* (*brotli_alloc_func)(void* opaque, size_t size);
|
33
33
|
|
34
34
|
/* Deallocating function pointer. Function SHOULD be no-op in the case the
|
35
35
|
address is 0. */
|
36
|
-
typedef void
|
36
|
+
typedef void (*brotli_free_func)(void* opaque, void* address);
|
37
37
|
|
38
38
|
#endif /* BROTLI_DEC_TYPES_H_ */
|
data/vendor/brotli/enc/Makefile
CHANGED
@@ -2,7 +2,7 @@
|
|
2
2
|
|
3
3
|
include ../shared.mk
|
4
4
|
|
5
|
-
OBJS_NODICT = backward_references.o block_splitter.o brotli_bit_stream.o encode.o encode_parallel.o entropy_encode.o histogram.o literal_cost.o metablock.o static_dict.o streams.o utf8_util.o
|
5
|
+
OBJS_NODICT = backward_references.o block_splitter.o brotli_bit_stream.o compress_fragment.o compress_fragment_two_pass.o encode.o encode_parallel.o entropy_encode.o histogram.o literal_cost.o metablock.o static_dict.o streams.o utf8_util.o
|
6
6
|
OBJS = $(OBJS_NODICT) dictionary.o
|
7
7
|
|
8
8
|
nodict : $(OBJS_NODICT)
|