brotli 0.4.0 → 0.5.0
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/.github/workflows/main.yml +6 -3
- data/.github/workflows/publish.yml +7 -17
- data/.gitmodules +1 -1
- data/README.md +2 -2
- data/ext/brotli/brotli.c +1 -0
- data/ext/brotli/extconf.rb +6 -0
- data/lib/brotli/version.rb +1 -1
- data/test/brotli_test.rb +4 -1
- data/vendor/brotli/c/common/constants.c +1 -1
- data/vendor/brotli/c/common/constants.h +2 -1
- data/vendor/brotli/c/common/context.c +1 -1
- data/vendor/brotli/c/common/dictionary.c +5 -3
- data/vendor/brotli/c/common/platform.c +2 -1
- data/vendor/brotli/c/common/platform.h +60 -113
- data/vendor/brotli/c/common/shared_dictionary.c +521 -0
- data/vendor/brotli/c/common/shared_dictionary_internal.h +75 -0
- data/vendor/brotli/c/common/transform.c +1 -1
- data/vendor/brotli/c/common/version.h +31 -6
- data/vendor/brotli/c/dec/bit_reader.c +10 -8
- data/vendor/brotli/c/dec/bit_reader.h +172 -100
- data/vendor/brotli/c/dec/decode.c +467 -200
- data/vendor/brotli/c/dec/huffman.c +7 -4
- data/vendor/brotli/c/dec/huffman.h +2 -1
- data/vendor/brotli/c/dec/prefix.h +2 -1
- data/vendor/brotli/c/dec/state.c +33 -9
- data/vendor/brotli/c/dec/state.h +70 -35
- data/vendor/brotli/c/enc/backward_references.c +81 -19
- data/vendor/brotli/c/enc/backward_references.h +5 -4
- data/vendor/brotli/c/enc/backward_references_hq.c +148 -52
- data/vendor/brotli/c/enc/backward_references_hq.h +6 -5
- data/vendor/brotli/c/enc/backward_references_inc.h +31 -5
- data/vendor/brotli/c/enc/bit_cost.c +8 -7
- data/vendor/brotli/c/enc/bit_cost.h +5 -4
- data/vendor/brotli/c/enc/block_splitter.c +37 -14
- data/vendor/brotli/c/enc/block_splitter.h +5 -4
- data/vendor/brotli/c/enc/block_splitter_inc.h +86 -45
- data/vendor/brotli/c/enc/brotli_bit_stream.c +132 -110
- data/vendor/brotli/c/enc/brotli_bit_stream.h +11 -6
- data/vendor/brotli/c/enc/cluster.c +10 -9
- data/vendor/brotli/c/enc/cluster.h +7 -6
- data/vendor/brotli/c/enc/cluster_inc.h +25 -20
- data/vendor/brotli/c/enc/command.c +1 -1
- data/vendor/brotli/c/enc/command.h +5 -4
- data/vendor/brotli/c/enc/compound_dictionary.c +207 -0
- data/vendor/brotli/c/enc/compound_dictionary.h +74 -0
- data/vendor/brotli/c/enc/compress_fragment.c +93 -83
- data/vendor/brotli/c/enc/compress_fragment.h +32 -7
- data/vendor/brotli/c/enc/compress_fragment_two_pass.c +99 -87
- data/vendor/brotli/c/enc/compress_fragment_two_pass.h +21 -3
- data/vendor/brotli/c/enc/dictionary_hash.c +3 -1
- data/vendor/brotli/c/enc/encode.c +473 -404
- data/vendor/brotli/c/enc/encoder_dict.c +611 -4
- data/vendor/brotli/c/enc/encoder_dict.h +117 -3
- data/vendor/brotli/c/enc/entropy_encode.c +3 -2
- data/vendor/brotli/c/enc/entropy_encode.h +2 -1
- data/vendor/brotli/c/enc/entropy_encode_static.h +5 -2
- data/vendor/brotli/c/enc/fast_log.c +1 -1
- data/vendor/brotli/c/enc/fast_log.h +2 -1
- data/vendor/brotli/c/enc/find_match_length.h +15 -22
- data/vendor/brotli/c/enc/hash.h +285 -45
- data/vendor/brotli/c/enc/hash_composite_inc.h +26 -11
- data/vendor/brotli/c/enc/hash_forgetful_chain_inc.h +20 -18
- data/vendor/brotli/c/enc/hash_longest_match64_inc.h +34 -39
- data/vendor/brotli/c/enc/hash_longest_match_inc.h +6 -10
- data/vendor/brotli/c/enc/hash_longest_match_quickly_inc.h +4 -4
- data/vendor/brotli/c/enc/hash_rolling_inc.h +4 -4
- data/vendor/brotli/c/enc/hash_to_binary_tree_inc.h +6 -5
- data/vendor/brotli/c/enc/histogram.c +4 -4
- data/vendor/brotli/c/enc/histogram.h +7 -6
- data/vendor/brotli/c/enc/literal_cost.c +20 -15
- data/vendor/brotli/c/enc/literal_cost.h +4 -2
- data/vendor/brotli/c/enc/memory.c +29 -5
- data/vendor/brotli/c/enc/memory.h +19 -2
- data/vendor/brotli/c/enc/metablock.c +72 -58
- data/vendor/brotli/c/enc/metablock.h +9 -8
- data/vendor/brotli/c/enc/metablock_inc.h +8 -6
- data/vendor/brotli/c/enc/params.h +4 -3
- data/vendor/brotli/c/enc/prefix.h +3 -2
- data/vendor/brotli/c/enc/quality.h +40 -3
- data/vendor/brotli/c/enc/ringbuffer.h +4 -3
- data/vendor/brotli/c/enc/state.h +104 -0
- data/vendor/brotli/c/enc/static_dict.c +60 -4
- data/vendor/brotli/c/enc/static_dict.h +3 -2
- data/vendor/brotli/c/enc/static_dict_lut.h +2 -0
- data/vendor/brotli/c/enc/utf8_util.c +1 -1
- data/vendor/brotli/c/enc/utf8_util.h +2 -1
- data/vendor/brotli/c/enc/write_bits.h +2 -1
- data/vendor/brotli/c/include/brotli/decode.h +67 -2
- data/vendor/brotli/c/include/brotli/encode.h +55 -2
- data/vendor/brotli/c/include/brotli/port.h +28 -11
- data/vendor/brotli/c/include/brotli/shared_dictionary.h +100 -0
- metadata +9 -3
@@ -6,13 +6,14 @@
|
|
6
6
|
|
7
7
|
/* Utilities for building Huffman decoding tables. */
|
8
8
|
|
9
|
-
#include "
|
9
|
+
#include "huffman.h"
|
10
10
|
|
11
11
|
#include <string.h> /* memcpy, memset */
|
12
12
|
|
13
|
+
#include <brotli/types.h>
|
14
|
+
|
13
15
|
#include "../common/constants.h"
|
14
16
|
#include "../common/platform.h"
|
15
|
-
#include <brotli/types.h>
|
16
17
|
|
17
18
|
#if defined(__cplusplus) || defined(c_plusplus)
|
18
19
|
extern "C" {
|
@@ -117,11 +118,13 @@ void BrotliBuildCodeLengthsHuffmanTable(HuffmanCode* table,
|
|
117
118
|
int bits_count;
|
118
119
|
BROTLI_DCHECK(BROTLI_HUFFMAN_MAX_CODE_LENGTH_CODE_LENGTH <=
|
119
120
|
BROTLI_REVERSE_BITS_MAX);
|
121
|
+
BROTLI_DCHECK(BROTLI_HUFFMAN_MAX_CODE_LENGTH_CODE_LENGTH == 5);
|
120
122
|
|
121
123
|
/* Generate offsets into sorted symbol table by code length. */
|
122
124
|
symbol = -1;
|
123
125
|
bits = 1;
|
124
|
-
|
126
|
+
/* BROTLI_HUFFMAN_MAX_CODE_LENGTH_CODE_LENGTH == 5 */
|
127
|
+
BROTLI_REPEAT_5({
|
125
128
|
symbol += count[bits];
|
126
129
|
offset[bits] = symbol;
|
127
130
|
bits++;
|
@@ -132,7 +135,7 @@ void BrotliBuildCodeLengthsHuffmanTable(HuffmanCode* table,
|
|
132
135
|
/* Sort symbols by length, by symbol order within each length. */
|
133
136
|
symbol = BROTLI_CODE_LENGTH_CODES;
|
134
137
|
do {
|
135
|
-
|
138
|
+
BROTLI_REPEAT_6({
|
136
139
|
symbol--;
|
137
140
|
sorted[offset[code_lengths[symbol]]--] = symbol;
|
138
141
|
});
|
@@ -10,9 +10,10 @@
|
|
10
10
|
#ifndef BROTLI_DEC_PREFIX_H_
|
11
11
|
#define BROTLI_DEC_PREFIX_H_
|
12
12
|
|
13
|
-
#include "../common/constants.h"
|
14
13
|
#include <brotli/types.h>
|
15
14
|
|
15
|
+
#include "../common/constants.h"
|
16
|
+
|
16
17
|
typedef struct CmdLutElement {
|
17
18
|
uint8_t insert_len_extra_bits;
|
18
19
|
uint8_t copy_len_extra_bits;
|
data/vendor/brotli/c/dec/state.c
CHANGED
@@ -4,12 +4,14 @@
|
|
4
4
|
See file LICENSE for detail or copy at https://opensource.org/licenses/MIT
|
5
5
|
*/
|
6
6
|
|
7
|
-
#include "
|
7
|
+
#include "state.h"
|
8
8
|
|
9
9
|
#include <stdlib.h> /* free, malloc */
|
10
10
|
|
11
11
|
#include <brotli/types.h>
|
12
|
-
|
12
|
+
|
13
|
+
#include "../common/dictionary.h"
|
14
|
+
#include "huffman.h"
|
13
15
|
|
14
16
|
#if defined(__cplusplus) || defined(c_plusplus)
|
15
17
|
extern "C" {
|
@@ -42,6 +44,7 @@ BROTLI_BOOL BrotliDecoderStateInit(BrotliDecoderState* s,
|
|
42
44
|
s->pos = 0;
|
43
45
|
s->rb_roundtrips = 0;
|
44
46
|
s->partial_pos_out = 0;
|
47
|
+
s->used_input = 0;
|
45
48
|
|
46
49
|
s->block_type_trees = NULL;
|
47
50
|
s->block_len_trees = NULL;
|
@@ -81,17 +84,23 @@ BROTLI_BOOL BrotliDecoderStateInit(BrotliDecoderState* s,
|
|
81
84
|
|
82
85
|
s->mtf_upper_bound = 63;
|
83
86
|
|
84
|
-
s->
|
85
|
-
s->
|
87
|
+
s->compound_dictionary = NULL;
|
88
|
+
s->dictionary =
|
89
|
+
BrotliSharedDictionaryCreateInstance(alloc_func, free_func, opaque);
|
90
|
+
if (!s->dictionary) return BROTLI_FALSE;
|
91
|
+
|
92
|
+
s->metadata_start_func = NULL;
|
93
|
+
s->metadata_chunk_func = NULL;
|
94
|
+
s->metadata_callback_opaque = 0;
|
86
95
|
|
87
96
|
return BROTLI_TRUE;
|
88
97
|
}
|
89
98
|
|
90
99
|
void BrotliDecoderStateMetablockBegin(BrotliDecoderState* s) {
|
91
100
|
s->meta_block_remaining_len = 0;
|
92
|
-
s->block_length[0] =
|
93
|
-
s->block_length[1] =
|
94
|
-
s->block_length[2] =
|
101
|
+
s->block_length[0] = BROTLI_BLOCK_SIZE_CAP;
|
102
|
+
s->block_length[1] = BROTLI_BLOCK_SIZE_CAP;
|
103
|
+
s->block_length[2] = BROTLI_BLOCK_SIZE_CAP;
|
95
104
|
s->num_block_types[0] = 1;
|
96
105
|
s->num_block_types[1] = 1;
|
97
106
|
s->num_block_types[2] = 1;
|
@@ -126,16 +135,31 @@ void BrotliDecoderStateCleanupAfterMetablock(BrotliDecoderState* s) {
|
|
126
135
|
BROTLI_DECODER_FREE(s, s->distance_hgroup.htrees);
|
127
136
|
}
|
128
137
|
|
138
|
+
#ifdef BROTLI_REPORTING
|
139
|
+
/* When BROTLI_REPORTING is defined extra reporting module have to be linked. */
|
140
|
+
void BrotliDecoderOnFinish(const BrotliDecoderState* s);
|
141
|
+
#define BROTLI_DECODER_ON_FINISH(s) BrotliDecoderOnFinish(s);
|
142
|
+
#else
|
143
|
+
#if !defined(BROTLI_DECODER_ON_FINISH)
|
144
|
+
#define BROTLI_DECODER_ON_FINISH(s) (void)(s);
|
145
|
+
#endif
|
146
|
+
#endif
|
147
|
+
|
129
148
|
void BrotliDecoderStateCleanup(BrotliDecoderState* s) {
|
130
149
|
BrotliDecoderStateCleanupAfterMetablock(s);
|
131
150
|
|
151
|
+
BROTLI_DECODER_ON_FINISH(s);
|
152
|
+
|
153
|
+
BROTLI_DECODER_FREE(s, s->compound_dictionary);
|
154
|
+
BrotliSharedDictionaryDestroyInstance(s->dictionary);
|
155
|
+
s->dictionary = NULL;
|
132
156
|
BROTLI_DECODER_FREE(s, s->ringbuffer);
|
133
157
|
BROTLI_DECODER_FREE(s, s->block_type_trees);
|
134
158
|
}
|
135
159
|
|
136
160
|
BROTLI_BOOL BrotliDecoderHuffmanTreeGroupInit(BrotliDecoderState* s,
|
137
|
-
HuffmanTreeGroup* group,
|
138
|
-
|
161
|
+
HuffmanTreeGroup* group, brotli_reg_t alphabet_size_max,
|
162
|
+
brotli_reg_t alphabet_size_limit, brotli_reg_t ntrees) {
|
139
163
|
/* 376 = 256 (1-st level table) + 4 + 7 + 15 + 31 + 63 (2-nd level mix-tables)
|
140
164
|
This number is discovered "unlimited" "enough" calculator; it is actually
|
141
165
|
a wee bigger than required in several cases (especially for alphabets with
|
data/vendor/brotli/c/dec/state.h
CHANGED
@@ -9,13 +9,16 @@
|
|
9
9
|
#ifndef BROTLI_DEC_STATE_H_
|
10
10
|
#define BROTLI_DEC_STATE_H_
|
11
11
|
|
12
|
+
#include <brotli/decode.h>
|
13
|
+
#include <brotli/shared_dictionary.h>
|
14
|
+
#include <brotli/types.h>
|
15
|
+
|
12
16
|
#include "../common/constants.h"
|
13
17
|
#include "../common/dictionary.h"
|
14
18
|
#include "../common/platform.h"
|
15
19
|
#include "../common/transform.h"
|
16
|
-
#include
|
17
|
-
#include "
|
18
|
-
#include "./huffman.h"
|
20
|
+
#include "bit_reader.h"
|
21
|
+
#include "huffman.h"
|
19
22
|
|
20
23
|
#if defined(__cplusplus) || defined(c_plusplus)
|
21
24
|
extern "C" {
|
@@ -189,20 +192,34 @@ typedef enum {
|
|
189
192
|
BROTLI_STATE_READ_BLOCK_LENGTH_SUFFIX
|
190
193
|
} BrotliRunningReadBlockLengthState;
|
191
194
|
|
195
|
+
/* BrotliDecoderState addon, used for Compound Dictionary functionality. */
|
196
|
+
typedef struct BrotliDecoderCompoundDictionary {
|
197
|
+
int num_chunks;
|
198
|
+
int total_size;
|
199
|
+
int br_index;
|
200
|
+
int br_offset;
|
201
|
+
int br_length;
|
202
|
+
int br_copied;
|
203
|
+
const uint8_t* chunks[16];
|
204
|
+
int chunk_offsets[16];
|
205
|
+
int block_bits;
|
206
|
+
uint8_t block_map[256];
|
207
|
+
} BrotliDecoderCompoundDictionary;
|
208
|
+
|
192
209
|
typedef struct BrotliMetablockHeaderArena {
|
193
210
|
BrotliRunningTreeGroupState substate_tree_group;
|
194
211
|
BrotliRunningContextMapState substate_context_map;
|
195
212
|
BrotliRunningHuffmanState substate_huffman;
|
196
213
|
|
197
|
-
|
214
|
+
brotli_reg_t sub_loop_counter;
|
198
215
|
|
199
|
-
|
200
|
-
|
216
|
+
brotli_reg_t repeat_code_len;
|
217
|
+
brotli_reg_t prev_code_len;
|
201
218
|
|
202
219
|
/* For ReadHuffmanCode. */
|
203
|
-
|
204
|
-
|
205
|
-
|
220
|
+
brotli_reg_t symbol;
|
221
|
+
brotli_reg_t repeat;
|
222
|
+
brotli_reg_t space;
|
206
223
|
|
207
224
|
/* Huffman table for "histograms". */
|
208
225
|
HuffmanCode table[32];
|
@@ -216,21 +233,22 @@ typedef struct BrotliMetablockHeaderArena {
|
|
216
233
|
uint8_t code_length_code_lengths[BROTLI_CODE_LENGTH_CODES];
|
217
234
|
/* Population counts for the code lengths. */
|
218
235
|
uint16_t code_length_histo[16];
|
236
|
+
/* TODO(eustas): +2 bytes padding */
|
219
237
|
|
220
238
|
/* For HuffmanTreeGroupDecode. */
|
221
239
|
int htree_index;
|
222
240
|
HuffmanCode* next;
|
223
241
|
|
224
242
|
/* For DecodeContextMap. */
|
225
|
-
|
226
|
-
|
227
|
-
|
243
|
+
brotli_reg_t context_index;
|
244
|
+
brotli_reg_t max_run_length_prefix;
|
245
|
+
brotli_reg_t code;
|
228
246
|
HuffmanCode context_map_table[BROTLI_HUFFMAN_MAX_SIZE_272];
|
229
247
|
} BrotliMetablockHeaderArena;
|
230
248
|
|
231
249
|
typedef struct BrotliMetablockBodyArena {
|
232
250
|
uint8_t dist_extra_bits[544];
|
233
|
-
|
251
|
+
brotli_reg_t dist_offset[544];
|
234
252
|
} BrotliMetablockBodyArena;
|
235
253
|
|
236
254
|
struct BrotliDecoderStateStruct {
|
@@ -251,7 +269,7 @@ struct BrotliDecoderStateStruct {
|
|
251
269
|
uint64_t u64;
|
252
270
|
uint8_t u8[8];
|
253
271
|
} buffer;
|
254
|
-
|
272
|
+
brotli_reg_t buffer_length;
|
255
273
|
|
256
274
|
int pos;
|
257
275
|
int max_backward_distance;
|
@@ -261,6 +279,8 @@ struct BrotliDecoderStateStruct {
|
|
261
279
|
int dist_rb_idx;
|
262
280
|
int dist_rb[4];
|
263
281
|
int error_code;
|
282
|
+
int meta_block_remaining_len;
|
283
|
+
|
264
284
|
uint8_t* ringbuffer;
|
265
285
|
uint8_t* ringbuffer_end;
|
266
286
|
HuffmanCode* htree_command;
|
@@ -281,54 +301,64 @@ struct BrotliDecoderStateStruct {
|
|
281
301
|
/* Distance context is actual after command is decoded and before distance is
|
282
302
|
computed. After distance computation it is used as a temporary variable. */
|
283
303
|
int distance_context;
|
284
|
-
|
285
|
-
|
286
|
-
|
287
|
-
|
288
|
-
|
289
|
-
|
290
|
-
|
291
|
-
uint32_t num_dist_htrees;
|
304
|
+
brotli_reg_t block_length[3];
|
305
|
+
brotli_reg_t block_length_index;
|
306
|
+
brotli_reg_t num_block_types[3];
|
307
|
+
brotli_reg_t block_type_rb[6];
|
308
|
+
brotli_reg_t distance_postfix_bits;
|
309
|
+
brotli_reg_t num_direct_distance_codes;
|
310
|
+
brotli_reg_t num_dist_htrees;
|
292
311
|
uint8_t* dist_context_map;
|
293
312
|
HuffmanCode* literal_htree;
|
294
|
-
uint8_t dist_htree_index;
|
295
|
-
|
296
|
-
int copy_length;
|
297
|
-
int distance_code;
|
298
313
|
|
299
314
|
/* For partial write operations. */
|
300
315
|
size_t rb_roundtrips; /* how many times we went around the ring-buffer */
|
301
316
|
size_t partial_pos_out; /* how much output to the user in total */
|
302
317
|
|
303
318
|
/* For InverseMoveToFrontTransform. */
|
304
|
-
|
319
|
+
brotli_reg_t mtf_upper_bound;
|
305
320
|
uint32_t mtf[64 + 1];
|
306
321
|
|
322
|
+
int copy_length;
|
323
|
+
int distance_code;
|
324
|
+
|
325
|
+
uint8_t dist_htree_index;
|
326
|
+
/* TODO(eustas): +3 bytes padding */
|
327
|
+
|
307
328
|
/* Less used attributes are at the end of this struct. */
|
308
329
|
|
330
|
+
brotli_decoder_metadata_start_func metadata_start_func;
|
331
|
+
brotli_decoder_metadata_chunk_func metadata_chunk_func;
|
332
|
+
void* metadata_callback_opaque;
|
333
|
+
|
334
|
+
/* For reporting. */
|
335
|
+
uint64_t used_input; /* how many bytes of input are consumed */
|
336
|
+
|
309
337
|
/* States inside function calls. */
|
310
338
|
BrotliRunningMetablockHeaderState substate_metablock_header;
|
311
339
|
BrotliRunningUncompressedState substate_uncompressed;
|
312
340
|
BrotliRunningDecodeUint8State substate_decode_uint8;
|
313
341
|
BrotliRunningReadBlockLengthState substate_read_block_length;
|
314
342
|
|
343
|
+
int new_ringbuffer_size;
|
344
|
+
/* TODO(eustas): +4 bytes padding */
|
345
|
+
|
315
346
|
unsigned int is_last_metablock : 1;
|
316
347
|
unsigned int is_uncompressed : 1;
|
317
348
|
unsigned int is_metadata : 1;
|
318
349
|
unsigned int should_wrap_ringbuffer : 1;
|
319
350
|
unsigned int canny_ringbuffer_allocation : 1;
|
320
351
|
unsigned int large_window : 1;
|
352
|
+
unsigned int window_bits : 6;
|
321
353
|
unsigned int size_nibbles : 8;
|
322
|
-
|
354
|
+
/* TODO(eustas): +12 bits padding */
|
323
355
|
|
324
|
-
|
325
|
-
|
326
|
-
uint32_t num_literal_htrees;
|
356
|
+
brotli_reg_t num_literal_htrees;
|
327
357
|
uint8_t* context_map;
|
328
358
|
uint8_t* context_modes;
|
329
359
|
|
330
|
-
|
331
|
-
|
360
|
+
BrotliSharedDictionary* dictionary;
|
361
|
+
BrotliDecoderCompoundDictionary* compound_dictionary;
|
332
362
|
|
333
363
|
uint32_t trivial_literal_contexts[8]; /* 256 bits */
|
334
364
|
|
@@ -348,8 +378,9 @@ BROTLI_INTERNAL void BrotliDecoderStateMetablockBegin(BrotliDecoderState* s);
|
|
348
378
|
BROTLI_INTERNAL void BrotliDecoderStateCleanupAfterMetablock(
|
349
379
|
BrotliDecoderState* s);
|
350
380
|
BROTLI_INTERNAL BROTLI_BOOL BrotliDecoderHuffmanTreeGroupInit(
|
351
|
-
BrotliDecoderState* s, HuffmanTreeGroup* group,
|
352
|
-
|
381
|
+
BrotliDecoderState* s, HuffmanTreeGroup* group,
|
382
|
+
brotli_reg_t alphabet_size_max, brotli_reg_t alphabet_size_limit,
|
383
|
+
brotli_reg_t ntrees);
|
353
384
|
|
354
385
|
#define BROTLI_DECODER_ALLOC(S, L) S->alloc_func(S->memory_manager_opaque, L)
|
355
386
|
|
@@ -358,6 +389,10 @@ BROTLI_INTERNAL BROTLI_BOOL BrotliDecoderHuffmanTreeGroupInit(
|
|
358
389
|
X = NULL; \
|
359
390
|
}
|
360
391
|
|
392
|
+
/* Literal/Command/Distance block size maximum; same as maximum metablock size;
|
393
|
+
used as block size when there is no block switching. */
|
394
|
+
#define BROTLI_BLOCK_SIZE_CAP (1U << 24)
|
395
|
+
|
361
396
|
#if defined(__cplusplus) || defined(c_plusplus)
|
362
397
|
} /* extern "C" */
|
363
398
|
#endif
|
@@ -6,17 +6,19 @@
|
|
6
6
|
|
7
7
|
/* Function to find backward reference copies. */
|
8
8
|
|
9
|
-
#include "
|
9
|
+
#include "backward_references.h"
|
10
|
+
|
11
|
+
#include <brotli/types.h>
|
10
12
|
|
11
13
|
#include "../common/constants.h"
|
12
|
-
#include "../common/context.h"
|
13
14
|
#include "../common/dictionary.h"
|
14
15
|
#include "../common/platform.h"
|
15
|
-
#include
|
16
|
-
#include "
|
17
|
-
#include "
|
18
|
-
#include "
|
19
|
-
#include "
|
16
|
+
#include "command.h"
|
17
|
+
#include "compound_dictionary.h"
|
18
|
+
#include "dictionary_hash.h"
|
19
|
+
#include "encoder_dict.h"
|
20
|
+
#include "memory.h"
|
21
|
+
#include "quality.h"
|
20
22
|
|
21
23
|
#if defined(__cplusplus) || defined(c_plusplus)
|
22
24
|
extern "C" {
|
@@ -52,67 +54,103 @@ static BROTLI_INLINE size_t ComputeDistanceCode(size_t distance,
|
|
52
54
|
#define EXPORT_FN(X) EXPAND_CAT(X, EXPAND_CAT(PREFIX(), HASHER()))
|
53
55
|
|
54
56
|
#define PREFIX() N
|
57
|
+
#define ENABLE_COMPOUND_DICTIONARY 0
|
55
58
|
|
56
59
|
#define HASHER() H2
|
57
60
|
/* NOLINTNEXTLINE(build/include) */
|
58
|
-
#include "
|
61
|
+
#include "backward_references_inc.h"
|
59
62
|
#undef HASHER
|
60
63
|
|
61
64
|
#define HASHER() H3
|
62
65
|
/* NOLINTNEXTLINE(build/include) */
|
63
|
-
#include "
|
66
|
+
#include "backward_references_inc.h"
|
64
67
|
#undef HASHER
|
65
68
|
|
66
69
|
#define HASHER() H4
|
67
70
|
/* NOLINTNEXTLINE(build/include) */
|
68
|
-
#include "
|
71
|
+
#include "backward_references_inc.h"
|
69
72
|
#undef HASHER
|
70
73
|
|
71
74
|
#define HASHER() H5
|
72
75
|
/* NOLINTNEXTLINE(build/include) */
|
73
|
-
#include "
|
76
|
+
#include "backward_references_inc.h"
|
74
77
|
#undef HASHER
|
75
78
|
|
76
79
|
#define HASHER() H6
|
77
80
|
/* NOLINTNEXTLINE(build/include) */
|
78
|
-
#include "
|
81
|
+
#include "backward_references_inc.h"
|
79
82
|
#undef HASHER
|
80
83
|
|
81
84
|
#define HASHER() H40
|
82
85
|
/* NOLINTNEXTLINE(build/include) */
|
83
|
-
#include "
|
86
|
+
#include "backward_references_inc.h"
|
84
87
|
#undef HASHER
|
85
88
|
|
86
89
|
#define HASHER() H41
|
87
90
|
/* NOLINTNEXTLINE(build/include) */
|
88
|
-
#include "
|
91
|
+
#include "backward_references_inc.h"
|
89
92
|
#undef HASHER
|
90
93
|
|
91
94
|
#define HASHER() H42
|
92
95
|
/* NOLINTNEXTLINE(build/include) */
|
93
|
-
#include "
|
96
|
+
#include "backward_references_inc.h"
|
94
97
|
#undef HASHER
|
95
98
|
|
96
99
|
#define HASHER() H54
|
97
100
|
/* NOLINTNEXTLINE(build/include) */
|
98
|
-
#include "
|
101
|
+
#include "backward_references_inc.h"
|
99
102
|
#undef HASHER
|
100
103
|
|
101
104
|
#define HASHER() H35
|
102
105
|
/* NOLINTNEXTLINE(build/include) */
|
103
|
-
#include "
|
106
|
+
#include "backward_references_inc.h"
|
104
107
|
#undef HASHER
|
105
108
|
|
106
109
|
#define HASHER() H55
|
107
110
|
/* NOLINTNEXTLINE(build/include) */
|
108
|
-
#include "
|
111
|
+
#include "backward_references_inc.h"
|
109
112
|
#undef HASHER
|
110
113
|
|
111
114
|
#define HASHER() H65
|
112
115
|
/* NOLINTNEXTLINE(build/include) */
|
113
|
-
#include "
|
116
|
+
#include "backward_references_inc.h"
|
114
117
|
#undef HASHER
|
115
118
|
|
119
|
+
#undef ENABLE_COMPOUND_DICTIONARY
|
120
|
+
#undef PREFIX
|
121
|
+
#define PREFIX() D
|
122
|
+
#define ENABLE_COMPOUND_DICTIONARY 1
|
123
|
+
|
124
|
+
#define HASHER() H5
|
125
|
+
/* NOLINTNEXTLINE(build/include) */
|
126
|
+
#include "backward_references_inc.h"
|
127
|
+
#undef HASHER
|
128
|
+
#define HASHER() H6
|
129
|
+
/* NOLINTNEXTLINE(build/include) */
|
130
|
+
#include "backward_references_inc.h"
|
131
|
+
#undef HASHER
|
132
|
+
#define HASHER() H40
|
133
|
+
/* NOLINTNEXTLINE(build/include) */
|
134
|
+
#include "backward_references_inc.h"
|
135
|
+
#undef HASHER
|
136
|
+
#define HASHER() H41
|
137
|
+
/* NOLINTNEXTLINE(build/include) */
|
138
|
+
#include "backward_references_inc.h"
|
139
|
+
#undef HASHER
|
140
|
+
#define HASHER() H42
|
141
|
+
/* NOLINTNEXTLINE(build/include) */
|
142
|
+
#include "backward_references_inc.h"
|
143
|
+
#undef HASHER
|
144
|
+
#define HASHER() H55
|
145
|
+
/* NOLINTNEXTLINE(build/include) */
|
146
|
+
#include "backward_references_inc.h"
|
147
|
+
#undef HASHER
|
148
|
+
#define HASHER() H65
|
149
|
+
/* NOLINTNEXTLINE(build/include) */
|
150
|
+
#include "backward_references_inc.h"
|
151
|
+
#undef HASHER
|
152
|
+
|
153
|
+
#undef ENABLE_COMPOUND_DICTIONARY
|
116
154
|
#undef PREFIX
|
117
155
|
|
118
156
|
#undef EXPORT_FN
|
@@ -125,6 +163,29 @@ void BrotliCreateBackwardReferences(size_t num_bytes,
|
|
125
163
|
ContextLut literal_context_lut, const BrotliEncoderParams* params,
|
126
164
|
Hasher* hasher, int* dist_cache, size_t* last_insert_len,
|
127
165
|
Command* commands, size_t* num_commands, size_t* num_literals) {
|
166
|
+
if (params->dictionary.compound.num_chunks != 0) {
|
167
|
+
switch (params->hasher.type) {
|
168
|
+
#define CASE_(N) \
|
169
|
+
case N: \
|
170
|
+
CreateBackwardReferencesDH ## N(num_bytes, \
|
171
|
+
position, ringbuffer, ringbuffer_mask, \
|
172
|
+
literal_context_lut, params, hasher, dist_cache, \
|
173
|
+
last_insert_len, commands, num_commands, num_literals); \
|
174
|
+
return;
|
175
|
+
CASE_(5)
|
176
|
+
CASE_(6)
|
177
|
+
CASE_(40)
|
178
|
+
CASE_(41)
|
179
|
+
CASE_(42)
|
180
|
+
CASE_(55)
|
181
|
+
CASE_(65)
|
182
|
+
#undef CASE_
|
183
|
+
default:
|
184
|
+
BROTLI_DCHECK(false);
|
185
|
+
break;
|
186
|
+
}
|
187
|
+
}
|
188
|
+
|
128
189
|
switch (params->hasher.type) {
|
129
190
|
#define CASE_(N) \
|
130
191
|
case N: \
|
@@ -136,6 +197,7 @@ void BrotliCreateBackwardReferences(size_t num_bytes,
|
|
136
197
|
FOR_GENERIC_HASHERS(CASE_)
|
137
198
|
#undef CASE_
|
138
199
|
default:
|
200
|
+
BROTLI_DCHECK(false);
|
139
201
|
break;
|
140
202
|
}
|
141
203
|
}
|
@@ -9,14 +9,15 @@
|
|
9
9
|
#ifndef BROTLI_ENC_BACKWARD_REFERENCES_H_
|
10
10
|
#define BROTLI_ENC_BACKWARD_REFERENCES_H_
|
11
11
|
|
12
|
+
#include <brotli/types.h>
|
13
|
+
|
12
14
|
#include "../common/constants.h"
|
13
15
|
#include "../common/context.h"
|
14
16
|
#include "../common/dictionary.h"
|
15
17
|
#include "../common/platform.h"
|
16
|
-
#include
|
17
|
-
#include "
|
18
|
-
#include "
|
19
|
-
#include "./quality.h"
|
18
|
+
#include "command.h"
|
19
|
+
#include "hash.h"
|
20
|
+
#include "quality.h"
|
20
21
|
|
21
22
|
#if defined(__cplusplus) || defined(c_plusplus)
|
22
23
|
extern "C" {
|