multi_compress 0.3.2 → 0.3.4
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/CHANGELOG.md +17 -3
- data/GET_STARTED.md +3 -3
- data/README.md +75 -66
- data/THIRD_PARTY_NOTICES.md +24 -0
- data/ext/multi_compress/brotli_dec_static_init.c +3 -0
- data/ext/multi_compress/brotli_enc_static_init.c +3 -0
- data/ext/multi_compress/extconf.rb +79 -3
- data/ext/multi_compress/multi_compress.c +199 -120
- data/ext/multi_compress/vendor/.vendored +2 -2
- data/ext/multi_compress/vendor/brotli/LICENSE +19 -0
- data/ext/multi_compress/vendor/brotli/c/common/constants.c +7 -7
- data/ext/multi_compress/vendor/brotli/c/common/constants.h +2 -5
- data/ext/multi_compress/vendor/brotli/c/common/context.c +2 -2
- data/ext/multi_compress/vendor/brotli/c/common/context.h +1 -2
- data/ext/multi_compress/vendor/brotli/c/common/dictionary.c +4 -5856
- data/ext/multi_compress/vendor/brotli/c/common/dictionary.h +1 -2
- data/ext/multi_compress/vendor/brotli/c/common/dictionary_inc.h +5847 -0
- data/ext/multi_compress/vendor/brotli/c/common/platform.c +0 -4
- data/ext/multi_compress/vendor/brotli/c/common/platform.h +182 -43
- data/ext/multi_compress/vendor/brotli/c/common/shared_dictionary.c +3 -7
- data/ext/multi_compress/vendor/brotli/c/common/shared_dictionary_internal.h +1 -1
- data/ext/multi_compress/vendor/brotli/c/common/static_init.h +56 -0
- data/ext/multi_compress/vendor/brotli/c/common/transform.c +6 -4
- data/ext/multi_compress/vendor/brotli/c/common/transform.h +1 -2
- data/ext/multi_compress/vendor/brotli/c/common/version.h +3 -3
- data/ext/multi_compress/vendor/brotli/c/dec/bit_reader.c +2 -3
- data/ext/multi_compress/vendor/brotli/c/dec/bit_reader.h +0 -4
- data/ext/multi_compress/vendor/brotli/c/dec/decode.c +128 -39
- data/ext/multi_compress/vendor/brotli/c/dec/huffman.c +2 -5
- data/ext/multi_compress/vendor/brotli/c/dec/huffman.h +0 -2
- data/ext/multi_compress/vendor/brotli/c/dec/prefix.c +67 -0
- data/ext/multi_compress/vendor/brotli/c/dec/prefix.h +18 -708
- data/ext/multi_compress/vendor/brotli/c/dec/prefix_inc.h +707 -0
- data/ext/multi_compress/vendor/brotli/c/dec/state.c +18 -15
- data/ext/multi_compress/vendor/brotli/c/dec/state.h +2 -6
- data/ext/multi_compress/vendor/brotli/c/dec/static_init.c +53 -0
- data/ext/multi_compress/vendor/brotli/c/dec/static_init.h +30 -0
- data/ext/multi_compress/vendor/brotli/c/enc/backward_references.c +32 -8
- data/ext/multi_compress/vendor/brotli/c/enc/backward_references.h +1 -5
- data/ext/multi_compress/vendor/brotli/c/enc/backward_references_hq.c +15 -15
- data/ext/multi_compress/vendor/brotli/c/enc/backward_references_hq.h +1 -5
- data/ext/multi_compress/vendor/brotli/c/enc/bit_cost.c +28 -4
- data/ext/multi_compress/vendor/brotli/c/enc/bit_cost.h +8 -40
- data/ext/multi_compress/vendor/brotli/c/enc/bit_cost_inc.h +1 -1
- data/ext/multi_compress/vendor/brotli/c/enc/block_splitter.c +9 -12
- data/ext/multi_compress/vendor/brotli/c/enc/block_splitter.h +0 -3
- data/ext/multi_compress/vendor/brotli/c/enc/block_splitter_inc.h +14 -8
- data/ext/multi_compress/vendor/brotli/c/enc/brotli_bit_stream.c +10 -9
- data/ext/multi_compress/vendor/brotli/c/enc/brotli_bit_stream.h +0 -6
- data/ext/multi_compress/vendor/brotli/c/enc/cluster.c +0 -2
- data/ext/multi_compress/vendor/brotli/c/enc/cluster.h +0 -2
- data/ext/multi_compress/vendor/brotli/c/enc/command.c +1 -1
- data/ext/multi_compress/vendor/brotli/c/enc/command.h +8 -10
- data/ext/multi_compress/vendor/brotli/c/enc/compound_dictionary.c +3 -5
- data/ext/multi_compress/vendor/brotli/c/enc/compound_dictionary.h +1 -4
- data/ext/multi_compress/vendor/brotli/c/enc/compress_fragment.c +3 -13
- data/ext/multi_compress/vendor/brotli/c/enc/compress_fragment.h +0 -2
- data/ext/multi_compress/vendor/brotli/c/enc/compress_fragment_two_pass.c +5 -15
- data/ext/multi_compress/vendor/brotli/c/enc/compress_fragment_two_pass.h +0 -2
- data/ext/multi_compress/vendor/brotli/c/enc/dictionary_hash.c +127 -1830
- data/ext/multi_compress/vendor/brotli/c/enc/dictionary_hash.h +23 -3
- data/ext/multi_compress/vendor/brotli/c/enc/dictionary_hash_inc.h +1829 -0
- data/ext/multi_compress/vendor/brotli/c/enc/encode.c +77 -52
- data/ext/multi_compress/vendor/brotli/c/enc/encoder_dict.c +9 -7
- data/ext/multi_compress/vendor/brotli/c/enc/encoder_dict.h +2 -4
- data/ext/multi_compress/vendor/brotli/c/enc/entropy_encode.c +3 -6
- data/ext/multi_compress/vendor/brotli/c/enc/entropy_encode.h +2 -4
- data/ext/multi_compress/vendor/brotli/c/enc/entropy_encode_static.h +18 -12
- data/ext/multi_compress/vendor/brotli/c/enc/fast_log.c +1 -1
- data/ext/multi_compress/vendor/brotli/c/enc/fast_log.h +2 -3
- data/ext/multi_compress/vendor/brotli/c/enc/find_match_length.h +0 -2
- data/ext/multi_compress/vendor/brotli/c/enc/hash.h +38 -31
- data/ext/multi_compress/vendor/brotli/c/enc/hash_base.h +38 -0
- data/ext/multi_compress/vendor/brotli/c/enc/hash_forgetful_chain_inc.h +11 -1
- data/ext/multi_compress/vendor/brotli/c/enc/hash_longest_match64_inc.h +24 -7
- data/ext/multi_compress/vendor/brotli/c/enc/hash_longest_match64_simd_inc.h +304 -0
- data/ext/multi_compress/vendor/brotli/c/enc/hash_longest_match_inc.h +30 -11
- data/ext/multi_compress/vendor/brotli/c/enc/hash_longest_match_quickly_inc.h +4 -0
- data/ext/multi_compress/vendor/brotli/c/enc/hash_longest_match_simd_inc.h +278 -0
- data/ext/multi_compress/vendor/brotli/c/enc/histogram.c +1 -0
- data/ext/multi_compress/vendor/brotli/c/enc/histogram.h +0 -4
- data/ext/multi_compress/vendor/brotli/c/enc/literal_cost.c +4 -6
- data/ext/multi_compress/vendor/brotli/c/enc/literal_cost.h +0 -2
- data/ext/multi_compress/vendor/brotli/c/enc/matching_tag_mask.h +69 -0
- data/ext/multi_compress/vendor/brotli/c/enc/memory.c +0 -5
- data/ext/multi_compress/vendor/brotli/c/enc/memory.h +0 -4
- data/ext/multi_compress/vendor/brotli/c/enc/metablock.c +7 -9
- data/ext/multi_compress/vendor/brotli/c/enc/metablock.h +3 -3
- data/ext/multi_compress/vendor/brotli/c/enc/metablock_inc.h +4 -4
- data/ext/multi_compress/vendor/brotli/c/enc/params.h +0 -1
- data/ext/multi_compress/vendor/brotli/c/enc/prefix.h +0 -2
- data/ext/multi_compress/vendor/brotli/c/enc/quality.h +17 -10
- data/ext/multi_compress/vendor/brotli/c/enc/ringbuffer.h +1 -4
- data/ext/multi_compress/vendor/brotli/c/enc/state.h +2 -2
- data/ext/multi_compress/vendor/brotli/c/enc/static_dict.c +5 -11
- data/ext/multi_compress/vendor/brotli/c/enc/static_dict.h +1 -3
- data/ext/multi_compress/vendor/brotli/c/enc/static_dict_lut.c +224 -0
- data/ext/multi_compress/vendor/brotli/c/enc/static_dict_lut.h +20 -5837
- data/ext/multi_compress/vendor/brotli/c/enc/static_dict_lut_inc.h +5830 -0
- data/ext/multi_compress/vendor/brotli/c/enc/static_init.c +59 -0
- data/ext/multi_compress/vendor/brotli/c/enc/static_init.h +30 -0
- data/ext/multi_compress/vendor/brotli/c/enc/static_init_lazy.cc +26 -0
- data/ext/multi_compress/vendor/brotli/c/enc/utf8_util.c +1 -1
- data/ext/multi_compress/vendor/brotli/c/enc/utf8_util.h +0 -2
- data/ext/multi_compress/vendor/brotli/c/enc/write_bits.h +0 -2
- data/ext/multi_compress/vendor/brotli/c/include/brotli/decode.h +1 -1
- data/ext/multi_compress/vendor/brotli/c/include/brotli/encode.h +5 -1
- data/ext/multi_compress/vendor/brotli/c/include/brotli/port.h +4 -7
- data/ext/multi_compress/vendor/brotli/c/include/brotli/types.h +2 -2
- data/ext/multi_compress/vendor/lz4/LICENSE +12 -0
- data/ext/multi_compress/vendor/zstd/COPYING +339 -0
- data/ext/multi_compress/vendor/zstd/LICENSE +30 -0
- data/ext/multi_compress/vendor/zstd/lib/Makefile +67 -35
- data/ext/multi_compress/vendor/zstd/lib/README.md +33 -2
- data/ext/multi_compress/vendor/zstd/lib/common/allocations.h +55 -0
- data/ext/multi_compress/vendor/zstd/lib/common/bits.h +205 -0
- data/ext/multi_compress/vendor/zstd/lib/common/bitstream.h +84 -108
- data/ext/multi_compress/vendor/zstd/lib/common/compiler.h +170 -41
- data/ext/multi_compress/vendor/zstd/lib/common/cpu.h +37 -1
- data/ext/multi_compress/vendor/zstd/lib/common/debug.c +7 -1
- data/ext/multi_compress/vendor/zstd/lib/common/debug.h +21 -21
- data/ext/multi_compress/vendor/zstd/lib/common/entropy_common.c +12 -40
- data/ext/multi_compress/vendor/zstd/lib/common/error_private.c +10 -2
- data/ext/multi_compress/vendor/zstd/lib/common/error_private.h +46 -47
- data/ext/multi_compress/vendor/zstd/lib/common/fse.h +8 -100
- data/ext/multi_compress/vendor/zstd/lib/common/fse_decompress.c +28 -116
- data/ext/multi_compress/vendor/zstd/lib/common/huf.h +79 -166
- data/ext/multi_compress/vendor/zstd/lib/common/mem.h +46 -66
- data/ext/multi_compress/vendor/zstd/lib/common/pool.c +27 -11
- data/ext/multi_compress/vendor/zstd/lib/common/pool.h +8 -11
- data/ext/multi_compress/vendor/zstd/lib/common/portability_macros.h +45 -11
- data/ext/multi_compress/vendor/zstd/lib/common/threading.c +74 -14
- data/ext/multi_compress/vendor/zstd/lib/common/threading.h +5 -18
- data/ext/multi_compress/vendor/zstd/lib/common/xxhash.c +5 -11
- data/ext/multi_compress/vendor/zstd/lib/common/xxhash.h +2411 -1003
- data/ext/multi_compress/vendor/zstd/lib/common/zstd_common.c +1 -36
- data/ext/multi_compress/vendor/zstd/lib/common/zstd_deps.h +13 -1
- data/ext/multi_compress/vendor/zstd/lib/common/zstd_internal.h +13 -182
- data/ext/multi_compress/vendor/zstd/lib/common/zstd_trace.h +6 -13
- data/ext/multi_compress/vendor/zstd/lib/compress/clevels.h +1 -1
- data/ext/multi_compress/vendor/zstd/lib/compress/fse_compress.c +15 -131
- data/ext/multi_compress/vendor/zstd/lib/compress/hist.c +11 -1
- data/ext/multi_compress/vendor/zstd/lib/compress/hist.h +8 -1
- data/ext/multi_compress/vendor/zstd/lib/compress/huf_compress.c +283 -189
- data/ext/multi_compress/vendor/zstd/lib/compress/zstd_compress.c +2419 -903
- data/ext/multi_compress/vendor/zstd/lib/compress/zstd_compress_internal.h +423 -245
- data/ext/multi_compress/vendor/zstd/lib/compress/zstd_compress_literals.c +116 -40
- data/ext/multi_compress/vendor/zstd/lib/compress/zstd_compress_literals.h +16 -8
- data/ext/multi_compress/vendor/zstd/lib/compress/zstd_compress_sequences.c +10 -10
- data/ext/multi_compress/vendor/zstd/lib/compress/zstd_compress_sequences.h +8 -7
- data/ext/multi_compress/vendor/zstd/lib/compress/zstd_compress_superblock.c +254 -139
- data/ext/multi_compress/vendor/zstd/lib/compress/zstd_compress_superblock.h +1 -1
- data/ext/multi_compress/vendor/zstd/lib/compress/zstd_cwksp.h +184 -95
- data/ext/multi_compress/vendor/zstd/lib/compress/zstd_double_fast.c +163 -81
- data/ext/multi_compress/vendor/zstd/lib/compress/zstd_double_fast.h +18 -14
- data/ext/multi_compress/vendor/zstd/lib/compress/zstd_fast.c +507 -197
- data/ext/multi_compress/vendor/zstd/lib/compress/zstd_fast.h +7 -14
- data/ext/multi_compress/vendor/zstd/lib/compress/zstd_lazy.c +579 -484
- data/ext/multi_compress/vendor/zstd/lib/compress/zstd_lazy.h +133 -65
- data/ext/multi_compress/vendor/zstd/lib/compress/zstd_ldm.c +61 -40
- data/ext/multi_compress/vendor/zstd/lib/compress/zstd_ldm.h +7 -15
- data/ext/multi_compress/vendor/zstd/lib/compress/zstd_ldm_geartab.h +1 -1
- data/ext/multi_compress/vendor/zstd/lib/compress/zstd_opt.c +352 -218
- data/ext/multi_compress/vendor/zstd/lib/compress/zstd_opt.h +37 -21
- data/ext/multi_compress/vendor/zstd/lib/compress/zstd_preSplit.c +238 -0
- data/ext/multi_compress/vendor/zstd/lib/compress/zstd_preSplit.h +33 -0
- data/ext/multi_compress/vendor/zstd/lib/compress/zstdmt_compress.c +239 -175
- data/ext/multi_compress/vendor/zstd/lib/compress/zstdmt_compress.h +5 -16
- data/ext/multi_compress/vendor/zstd/lib/decompress/huf_decompress.c +543 -488
- data/ext/multi_compress/vendor/zstd/lib/decompress/huf_decompress_amd64.S +78 -61
- data/ext/multi_compress/vendor/zstd/lib/decompress/zstd_ddict.c +4 -4
- data/ext/multi_compress/vendor/zstd/lib/decompress/zstd_ddict.h +1 -1
- data/ext/multi_compress/vendor/zstd/lib/decompress/zstd_decompress.c +295 -115
- data/ext/multi_compress/vendor/zstd/lib/decompress/zstd_decompress_block.c +430 -293
- data/ext/multi_compress/vendor/zstd/lib/decompress/zstd_decompress_block.h +7 -2
- data/ext/multi_compress/vendor/zstd/lib/decompress/zstd_decompress_internal.h +11 -7
- data/ext/multi_compress/vendor/zstd/lib/deprecated/zbuff.h +1 -1
- data/ext/multi_compress/vendor/zstd/lib/deprecated/zbuff_common.c +1 -1
- data/ext/multi_compress/vendor/zstd/lib/deprecated/zbuff_compress.c +1 -1
- data/ext/multi_compress/vendor/zstd/lib/deprecated/zbuff_decompress.c +3 -1
- data/ext/multi_compress/vendor/zstd/lib/dictBuilder/cover.c +95 -46
- data/ext/multi_compress/vendor/zstd/lib/dictBuilder/cover.h +3 -9
- data/ext/multi_compress/vendor/zstd/lib/dictBuilder/divsufsort.h +0 -10
- data/ext/multi_compress/vendor/zstd/lib/dictBuilder/fastcover.c +4 -4
- data/ext/multi_compress/vendor/zstd/lib/dictBuilder/zdict.c +25 -97
- data/ext/multi_compress/vendor/zstd/lib/dll/example/Makefile +1 -1
- data/ext/multi_compress/vendor/zstd/lib/dll/example/README.md +1 -1
- data/ext/multi_compress/vendor/zstd/lib/legacy/zstd_legacy.h +38 -1
- data/ext/multi_compress/vendor/zstd/lib/legacy/zstd_v01.c +19 -50
- data/ext/multi_compress/vendor/zstd/lib/legacy/zstd_v01.h +1 -1
- data/ext/multi_compress/vendor/zstd/lib/legacy/zstd_v02.c +27 -80
- data/ext/multi_compress/vendor/zstd/lib/legacy/zstd_v02.h +1 -1
- data/ext/multi_compress/vendor/zstd/lib/legacy/zstd_v03.c +28 -83
- data/ext/multi_compress/vendor/zstd/lib/legacy/zstd_v03.h +1 -1
- data/ext/multi_compress/vendor/zstd/lib/legacy/zstd_v04.c +25 -74
- data/ext/multi_compress/vendor/zstd/lib/legacy/zstd_v04.h +1 -1
- data/ext/multi_compress/vendor/zstd/lib/legacy/zstd_v05.c +31 -76
- data/ext/multi_compress/vendor/zstd/lib/legacy/zstd_v05.h +1 -1
- data/ext/multi_compress/vendor/zstd/lib/legacy/zstd_v06.c +44 -88
- data/ext/multi_compress/vendor/zstd/lib/legacy/zstd_v06.h +1 -1
- data/ext/multi_compress/vendor/zstd/lib/legacy/zstd_v07.c +33 -84
- data/ext/multi_compress/vendor/zstd/lib/legacy/zstd_v07.h +1 -1
- data/ext/multi_compress/vendor/zstd/lib/libzstd.mk +65 -33
- data/ext/multi_compress/vendor/zstd/lib/libzstd.pc.in +5 -5
- data/ext/multi_compress/vendor/zstd/lib/module.modulemap +13 -3
- data/ext/multi_compress/vendor/zstd/lib/zdict.h +65 -36
- data/ext/multi_compress/vendor/zstd/lib/zstd.h +890 -267
- data/ext/multi_compress/vendor/zstd/lib/zstd_errors.h +28 -16
- data/lib/multi_compress/version.rb +1 -1
- data/lib/multi_compress.rb +80 -41
- metadata +29 -2
|
@@ -7,34 +7,32 @@
|
|
|
7
7
|
/* Implementation of Brotli compressor. */
|
|
8
8
|
|
|
9
9
|
#include <brotli/encode.h>
|
|
10
|
-
#include <brotli/shared_dictionary.h>
|
|
11
|
-
#include <brotli/types.h>
|
|
12
|
-
|
|
13
|
-
#include <stdlib.h> /* free, malloc */
|
|
14
|
-
#include <string.h> /* memcpy, memset */
|
|
15
10
|
|
|
16
11
|
#include "../common/constants.h"
|
|
17
12
|
#include "../common/context.h"
|
|
18
13
|
#include "../common/platform.h"
|
|
14
|
+
#include <brotli/shared_dictionary.h>
|
|
19
15
|
#include "../common/version.h"
|
|
20
|
-
#include "backward_references.h"
|
|
21
16
|
#include "backward_references_hq.h"
|
|
17
|
+
#include "backward_references.h"
|
|
22
18
|
#include "bit_cost.h"
|
|
23
19
|
#include "brotli_bit_stream.h"
|
|
24
|
-
#include "
|
|
20
|
+
#include "command.h"
|
|
21
|
+
#include "compound_dictionary.h"
|
|
25
22
|
#include "compress_fragment_two_pass.h"
|
|
23
|
+
#include "compress_fragment.h"
|
|
26
24
|
#include "dictionary_hash.h"
|
|
27
25
|
#include "encoder_dict.h"
|
|
28
|
-
#include "entropy_encode.h"
|
|
29
26
|
#include "fast_log.h"
|
|
30
27
|
#include "hash.h"
|
|
31
28
|
#include "histogram.h"
|
|
32
29
|
#include "memory.h"
|
|
33
30
|
#include "metablock.h"
|
|
34
|
-
#include "
|
|
35
|
-
#include "state.h"
|
|
31
|
+
#include "params.h"
|
|
36
32
|
#include "quality.h"
|
|
37
33
|
#include "ringbuffer.h"
|
|
34
|
+
#include "state.h"
|
|
35
|
+
#include "static_init.h"
|
|
38
36
|
#include "utf8_util.h"
|
|
39
37
|
#include "write_bits.h"
|
|
40
38
|
|
|
@@ -202,7 +200,7 @@ static void EncodeWindowBits(int lgwin, BROTLI_BOOL large_window,
|
|
|
202
200
|
/* TODO(eustas): move to compress_fragment.c? */
|
|
203
201
|
/* Initializes the command and distance prefix codes for the first block. */
|
|
204
202
|
static void InitCommandPrefixCodes(BrotliOnePassArena* s) {
|
|
205
|
-
static const uint8_t kDefaultCommandDepths[128] = {
|
|
203
|
+
static const BROTLI_MODEL("small") uint8_t kDefaultCommandDepths[128] = {
|
|
206
204
|
0, 4, 4, 5, 6, 6, 7, 7, 7, 7, 7, 8, 8, 8, 8, 8,
|
|
207
205
|
0, 0, 0, 4, 4, 4, 4, 4, 5, 5, 6, 6, 6, 6, 7, 7,
|
|
208
206
|
7, 7, 10, 10, 10, 10, 10, 10, 0, 4, 4, 5, 5, 5, 6, 6,
|
|
@@ -212,7 +210,7 @@ static void InitCommandPrefixCodes(BrotliOnePassArena* s) {
|
|
|
212
210
|
4, 4, 4, 5, 5, 5, 5, 5, 5, 6, 6, 7, 7, 7, 8, 10,
|
|
213
211
|
12, 12, 12, 12, 12, 12, 12, 12, 12, 12, 12, 12,
|
|
214
212
|
};
|
|
215
|
-
static const uint16_t kDefaultCommandBits[128] = {
|
|
213
|
+
static const BROTLI_MODEL("small") uint16_t kDefaultCommandBits[128] = {
|
|
216
214
|
0, 0, 8, 9, 3, 35, 7, 71,
|
|
217
215
|
39, 103, 23, 47, 175, 111, 239, 31,
|
|
218
216
|
0, 0, 0, 4, 12, 2, 10, 6,
|
|
@@ -226,7 +224,7 @@ static void InitCommandPrefixCodes(BrotliOnePassArena* s) {
|
|
|
226
224
|
2, 10, 6, 21, 13, 29, 3, 19, 11, 15, 47, 31, 95, 63, 127, 255,
|
|
227
225
|
767, 2815, 1791, 3839, 511, 2559, 1535, 3583, 1023, 3071, 2047, 4095,
|
|
228
226
|
};
|
|
229
|
-
static const uint8_t kDefaultCommandCode[] = {
|
|
227
|
+
static const BROTLI_MODEL("small") uint8_t kDefaultCommandCode[] = {
|
|
230
228
|
0xff, 0x77, 0xd5, 0xbf, 0xe7, 0xde, 0xea, 0x9e, 0x51, 0x5d, 0xde, 0xc6,
|
|
231
229
|
0x70, 0x57, 0xbc, 0x58, 0x58, 0x58, 0xd8, 0xd8, 0x58, 0xd5, 0xcb, 0x8c,
|
|
232
230
|
0xea, 0xe0, 0xc3, 0x87, 0x1f, 0x83, 0xc1, 0x60, 0x1c, 0x67, 0xb2, 0xaa,
|
|
@@ -243,24 +241,39 @@ static void InitCommandPrefixCodes(BrotliOnePassArena* s) {
|
|
|
243
241
|
s->cmd_code_numbits = kDefaultCommandCodeNumBits;
|
|
244
242
|
}
|
|
245
243
|
|
|
244
|
+
/* TODO(eustas): avoid FP calculations. */
|
|
245
|
+
static double EstimateEntropy(const uint32_t* population, size_t size) {
|
|
246
|
+
size_t total = 0;
|
|
247
|
+
double result = 0;
|
|
248
|
+
for (size_t i = 0; i < size; ++i) {
|
|
249
|
+
uint32_t p = population[i];
|
|
250
|
+
total += p;
|
|
251
|
+
result += (double)p * FastLog2(p);
|
|
252
|
+
}
|
|
253
|
+
result = (double)total * FastLog2(total) - result;
|
|
254
|
+
return result;
|
|
255
|
+
}
|
|
256
|
+
|
|
246
257
|
/* Decide about the context map based on the ability of the prediction
|
|
247
258
|
ability of the previous byte UTF8-prefix on the next byte. The
|
|
248
259
|
prediction ability is calculated as Shannon entropy. Here we need
|
|
249
|
-
Shannon entropy instead of '
|
|
260
|
+
Shannon entropy instead of 'BrotliBitsEntropy' since the prefix will be
|
|
250
261
|
encoded with the remaining 6 bits of the following byte, and
|
|
251
|
-
|
|
262
|
+
BrotliBitsEntropy will assume that symbol to be stored alone using Huffman
|
|
252
263
|
coding. */
|
|
253
264
|
static void ChooseContextMap(int quality,
|
|
254
265
|
uint32_t* bigram_histo,
|
|
255
266
|
size_t* num_literal_contexts,
|
|
256
267
|
const uint32_t** literal_context_map) {
|
|
257
|
-
static const
|
|
268
|
+
static const BROTLI_MODEL("small")
|
|
269
|
+
uint32_t kStaticContextMapContinuation[64] = {
|
|
258
270
|
1, 1, 2, 2, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
|
|
259
271
|
0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
|
|
260
272
|
0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
|
|
261
273
|
0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
|
|
262
274
|
};
|
|
263
|
-
static const
|
|
275
|
+
static const BROTLI_MODEL("small")
|
|
276
|
+
uint32_t kStaticContextMapSimpleUTF8[64] = {
|
|
264
277
|
0, 0, 1, 1, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
|
|
265
278
|
0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
|
|
266
279
|
0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
|
|
@@ -271,18 +284,17 @@ static void ChooseContextMap(int quality,
|
|
|
271
284
|
uint32_t two_prefix_histo[6] = { 0 };
|
|
272
285
|
size_t total;
|
|
273
286
|
size_t i;
|
|
274
|
-
size_t dummy;
|
|
275
287
|
double entropy[4];
|
|
276
288
|
for (i = 0; i < 9; ++i) {
|
|
277
289
|
monogram_histo[i % 3] += bigram_histo[i];
|
|
278
290
|
two_prefix_histo[i % 6] += bigram_histo[i];
|
|
279
291
|
}
|
|
280
|
-
entropy[1] =
|
|
281
|
-
entropy[2] = (
|
|
282
|
-
|
|
292
|
+
entropy[1] = EstimateEntropy(monogram_histo, 3);
|
|
293
|
+
entropy[2] = (EstimateEntropy(two_prefix_histo, 3) +
|
|
294
|
+
EstimateEntropy(two_prefix_histo + 3, 3));
|
|
283
295
|
entropy[3] = 0;
|
|
284
296
|
for (i = 0; i < 3; ++i) {
|
|
285
|
-
entropy[3] +=
|
|
297
|
+
entropy[3] += EstimateEntropy(bigram_histo + 3 * i, 3);
|
|
286
298
|
}
|
|
287
299
|
|
|
288
300
|
total = monogram_histo[0] + monogram_histo[1] + monogram_histo[2];
|
|
@@ -317,7 +329,8 @@ static BROTLI_BOOL ShouldUseComplexStaticContextMap(const uint8_t* input,
|
|
|
317
329
|
size_t start_pos, size_t length, size_t mask, int quality, size_t size_hint,
|
|
318
330
|
size_t* num_literal_contexts, const uint32_t** literal_context_map,
|
|
319
331
|
uint32_t* arena) {
|
|
320
|
-
static const
|
|
332
|
+
static const BROTLI_MODEL("small")
|
|
333
|
+
uint32_t kStaticContextMapComplexUTF8[64] = {
|
|
321
334
|
11, 11, 12, 12, /* 0 special */
|
|
322
335
|
0, 0, 0, 0, /* 4 lf */
|
|
323
336
|
1, 1, 9, 9, /* 8 space */
|
|
@@ -348,10 +361,9 @@ static BROTLI_BOOL ShouldUseComplexStaticContextMap(const uint8_t* input,
|
|
|
348
361
|
uint32_t* BROTLI_RESTRICT const context_histo = arena + 32;
|
|
349
362
|
uint32_t total = 0;
|
|
350
363
|
double entropy[3];
|
|
351
|
-
size_t dummy;
|
|
352
364
|
size_t i;
|
|
353
365
|
ContextLut utf8_lut = BROTLI_CONTEXT_LUT(CONTEXT_UTF8);
|
|
354
|
-
memset(arena, 0, sizeof(arena[0]) * 32 *
|
|
366
|
+
memset(arena, 0, sizeof(arena[0]) * 32 * (BROTLI_MAX_STATIC_CONTEXTS + 1));
|
|
355
367
|
for (; start_pos + 64 <= end_pos; start_pos += 4096) {
|
|
356
368
|
const size_t stride_end_pos = start_pos + 64;
|
|
357
369
|
uint8_t prev2 = input[start_pos & mask];
|
|
@@ -370,10 +382,10 @@ static BROTLI_BOOL ShouldUseComplexStaticContextMap(const uint8_t* input,
|
|
|
370
382
|
prev1 = literal;
|
|
371
383
|
}
|
|
372
384
|
}
|
|
373
|
-
entropy[1] =
|
|
385
|
+
entropy[1] = EstimateEntropy(combined_histo, 32);
|
|
374
386
|
entropy[2] = 0;
|
|
375
|
-
for (i = 0; i <
|
|
376
|
-
entropy[2] +=
|
|
387
|
+
for (i = 0; i < BROTLI_MAX_STATIC_CONTEXTS; ++i) {
|
|
388
|
+
entropy[2] += EstimateEntropy(context_histo + (i << 5), 32);
|
|
377
389
|
}
|
|
378
390
|
entropy[0] = 1.0 / (double)total;
|
|
379
391
|
entropy[1] *= entropy[0];
|
|
@@ -388,7 +400,7 @@ static BROTLI_BOOL ShouldUseComplexStaticContextMap(const uint8_t* input,
|
|
|
388
400
|
if (entropy[2] > 3.0 || entropy[1] - entropy[2] < 0.2) {
|
|
389
401
|
return BROTLI_FALSE;
|
|
390
402
|
} else {
|
|
391
|
-
*num_literal_contexts =
|
|
403
|
+
*num_literal_contexts = BROTLI_MAX_STATIC_CONTEXTS;
|
|
392
404
|
*literal_context_map = kStaticContextMapComplexUTF8;
|
|
393
405
|
return BROTLI_TRUE;
|
|
394
406
|
}
|
|
@@ -437,9 +449,10 @@ static BROTLI_BOOL ShouldCompress(
|
|
|
437
449
|
if ((double)num_literals > 0.99 * (double)bytes) {
|
|
438
450
|
uint32_t literal_histo[256] = { 0 };
|
|
439
451
|
static const uint32_t kSampleRate = 13;
|
|
452
|
+
static const double kInvSampleRate = 1.0 / 13.0;
|
|
440
453
|
static const double kMinEntropy = 7.92;
|
|
441
454
|
const double bit_cost_threshold =
|
|
442
|
-
(double)bytes * kMinEntropy
|
|
455
|
+
(double)bytes * kMinEntropy * kInvSampleRate;
|
|
443
456
|
size_t t = (bytes + kSampleRate - 1) / kSampleRate;
|
|
444
457
|
uint32_t pos = (uint32_t)last_flush_pos;
|
|
445
458
|
size_t i;
|
|
@@ -447,7 +460,7 @@ static BROTLI_BOOL ShouldCompress(
|
|
|
447
460
|
++literal_histo[data[pos & mask]];
|
|
448
461
|
pos += kSampleRate;
|
|
449
462
|
}
|
|
450
|
-
if (
|
|
463
|
+
if (BrotliBitsEntropy(literal_histo, 256) > bit_cost_threshold) {
|
|
451
464
|
return BROTLI_FALSE;
|
|
452
465
|
}
|
|
453
466
|
}
|
|
@@ -532,7 +545,8 @@ static void WriteMetaBlockInternal(MemoryManager* m,
|
|
|
532
545
|
const uint32_t* literal_context_map = NULL;
|
|
533
546
|
if (!params->disable_literal_context_modeling) {
|
|
534
547
|
/* TODO(eustas): pull to higher level and reuse. */
|
|
535
|
-
uint32_t* arena =
|
|
548
|
+
uint32_t* arena =
|
|
549
|
+
BROTLI_ALLOC(m, uint32_t, 32 * (BROTLI_MAX_STATIC_CONTEXTS + 1));
|
|
536
550
|
if (BROTLI_IS_OOM(m) || BROTLI_IS_NULL(arena)) return;
|
|
537
551
|
DecideOverLiteralContextModeling(
|
|
538
552
|
data, wrapped_last_flush_pos, bytes, mask, params->quality,
|
|
@@ -686,7 +700,23 @@ static void BrotliEncoderCleanupParams(MemoryManager* m,
|
|
|
686
700
|
BrotliCleanupSharedEncoderDictionary(m, ¶ms->dictionary);
|
|
687
701
|
}
|
|
688
702
|
|
|
703
|
+
#ifdef BROTLI_REPORTING
|
|
704
|
+
/* When BROTLI_REPORTING is defined extra reporting module have to be linked. */
|
|
705
|
+
void BrotliEncoderOnStart(const BrotliEncoderState* s);
|
|
706
|
+
void BrotliEncoderOnFinish(const BrotliEncoderState* s);
|
|
707
|
+
#define BROTLI_ENCODER_ON_START(s) BrotliEncoderOnStart(s);
|
|
708
|
+
#define BROTLI_ENCODER_ON_FINISH(s) BrotliEncoderOnFinish(s);
|
|
709
|
+
#else
|
|
710
|
+
#if !defined(BROTLI_ENCODER_ON_START)
|
|
711
|
+
#define BROTLI_ENCODER_ON_START(s) (void)(s);
|
|
712
|
+
#endif
|
|
713
|
+
#if !defined(BROTLI_ENCODER_ON_FINISH)
|
|
714
|
+
#define BROTLI_ENCODER_ON_FINISH(s) (void)(s);
|
|
715
|
+
#endif
|
|
716
|
+
#endif
|
|
717
|
+
|
|
689
718
|
static void BrotliEncoderInitState(BrotliEncoderState* s) {
|
|
719
|
+
BROTLI_ENCODER_ON_START(s);
|
|
690
720
|
BrotliEncoderInitParams(&s->params);
|
|
691
721
|
s->input_pos_ = 0;
|
|
692
722
|
s->num_commands_ = 0;
|
|
@@ -730,6 +760,10 @@ static void BrotliEncoderInitState(BrotliEncoderState* s) {
|
|
|
730
760
|
|
|
731
761
|
BrotliEncoderState* BrotliEncoderCreateInstance(
|
|
732
762
|
brotli_alloc_func alloc_func, brotli_free_func free_func, void* opaque) {
|
|
763
|
+
BROTLI_BOOL healthy = BrotliEncoderEnsureStaticInit();
|
|
764
|
+
if (!healthy) {
|
|
765
|
+
return 0;
|
|
766
|
+
}
|
|
733
767
|
BrotliEncoderState* state = (BrotliEncoderState*)BrotliBootstrapAlloc(
|
|
734
768
|
sizeof(BrotliEncoderState), alloc_func, free_func, opaque);
|
|
735
769
|
if (state == NULL) {
|
|
@@ -742,16 +776,6 @@ BrotliEncoderState* BrotliEncoderCreateInstance(
|
|
|
742
776
|
return state;
|
|
743
777
|
}
|
|
744
778
|
|
|
745
|
-
#ifdef BROTLI_REPORTING
|
|
746
|
-
/* When BROTLI_REPORTING is defined extra reporting module have to be linked. */
|
|
747
|
-
void BrotliEncoderOnFinish(const BrotliEncoderState* s);
|
|
748
|
-
#define BROTLI_ENCODER_ON_FINISH(s) BrotliEncoderOnFinish(s);
|
|
749
|
-
#else
|
|
750
|
-
#if !defined(BROTLI_ENCODER_ON_FINISH)
|
|
751
|
-
#define BROTLI_ENCODER_ON_FINISH(s) (void)(s);
|
|
752
|
-
#endif
|
|
753
|
-
#endif
|
|
754
|
-
|
|
755
779
|
static void BrotliEncoderCleanupState(BrotliEncoderState* s) {
|
|
756
780
|
MemoryManager* m = &s->memory_manager_;
|
|
757
781
|
|
|
@@ -817,7 +841,7 @@ static void CopyInputToRingBuffer(BrotliEncoderState* s,
|
|
|
817
841
|
reading new bytes from the input. However, at the last few indexes of
|
|
818
842
|
the ring buffer, there are not enough bytes to build full-length
|
|
819
843
|
substrings from. Since the hash table always contains full-length
|
|
820
|
-
substrings, we
|
|
844
|
+
substrings, we overwrite with zeros here to make sure that those
|
|
821
845
|
substrings will contain zeros at the end instead of uninitialized
|
|
822
846
|
data.
|
|
823
847
|
|
|
@@ -1750,7 +1774,7 @@ BrotliEncoderPreparedDictionary* BrotliEncoderPrepareDictionary(
|
|
|
1750
1774
|
return (BrotliEncoderPreparedDictionary*)managed_dictionary;
|
|
1751
1775
|
}
|
|
1752
1776
|
|
|
1753
|
-
void BrotliEncoderDestroyPreparedDictionary(
|
|
1777
|
+
void BROTLI_COLD BrotliEncoderDestroyPreparedDictionary(
|
|
1754
1778
|
BrotliEncoderPreparedDictionary* dictionary) {
|
|
1755
1779
|
ManagedDictionary* dict = (ManagedDictionary*)dictionary;
|
|
1756
1780
|
if (!dictionary) return;
|
|
@@ -1776,7 +1800,8 @@ void BrotliEncoderDestroyPreparedDictionary(
|
|
|
1776
1800
|
BrotliDestroyManagedDictionary(dict);
|
|
1777
1801
|
}
|
|
1778
1802
|
|
|
1779
|
-
BROTLI_BOOL BrotliEncoderAttachPreparedDictionary(
|
|
1803
|
+
BROTLI_BOOL BROTLI_COLD BrotliEncoderAttachPreparedDictionary(
|
|
1804
|
+
BrotliEncoderState* state,
|
|
1780
1805
|
const BrotliEncoderPreparedDictionary* dictionary) {
|
|
1781
1806
|
/* First field of dictionary structs */
|
|
1782
1807
|
const BrotliEncoderPreparedDictionary* dict = dictionary;
|
|
@@ -1833,8 +1858,8 @@ BROTLI_BOOL BrotliEncoderAttachPreparedDictionary(BrotliEncoderState* state,
|
|
|
1833
1858
|
return BROTLI_TRUE;
|
|
1834
1859
|
}
|
|
1835
1860
|
|
|
1836
|
-
size_t BrotliEncoderEstimatePeakMemoryUsage(int quality, int lgwin,
|
|
1837
|
-
|
|
1861
|
+
size_t BROTLI_COLD BrotliEncoderEstimatePeakMemoryUsage(int quality, int lgwin,
|
|
1862
|
+
size_t input_size) {
|
|
1838
1863
|
BrotliEncoderParams params;
|
|
1839
1864
|
size_t memory_manager_slots = BROTLI_ENCODER_MEMORY_MANAGER_SLOTS;
|
|
1840
1865
|
size_t memory_manager_size = memory_manager_slots * sizeof(void*);
|
|
@@ -1849,7 +1874,7 @@ size_t BrotliEncoderEstimatePeakMemoryUsage(int quality, int lgwin,
|
|
|
1849
1874
|
if (params.quality == FAST_ONE_PASS_COMPRESSION_QUALITY ||
|
|
1850
1875
|
params.quality == FAST_TWO_PASS_COMPRESSION_QUALITY) {
|
|
1851
1876
|
size_t state_size = sizeof(BrotliEncoderState);
|
|
1852
|
-
size_t block_size = BROTLI_MIN(size_t, input_size, (1ul << params.lgwin));
|
|
1877
|
+
size_t block_size = BROTLI_MIN(size_t, input_size, ((size_t)1ul << params.lgwin));
|
|
1853
1878
|
size_t hash_table_size =
|
|
1854
1879
|
HashTableSize(MaxHashTableSize(params.quality), block_size);
|
|
1855
1880
|
size_t hash_size =
|
|
@@ -1866,7 +1891,7 @@ size_t BrotliEncoderEstimatePeakMemoryUsage(int quality, int lgwin,
|
|
|
1866
1891
|
size_t short_ringbuffer_size = (size_t)1 << params.lgblock;
|
|
1867
1892
|
int ringbuffer_bits = ComputeRbBits(¶ms);
|
|
1868
1893
|
size_t ringbuffer_size = input_size < short_ringbuffer_size ?
|
|
1869
|
-
input_size : (1u << ringbuffer_bits) + short_ringbuffer_size;
|
|
1894
|
+
input_size : ((size_t)1u << ringbuffer_bits) + short_ringbuffer_size;
|
|
1870
1895
|
size_t hash_size[4] = {0};
|
|
1871
1896
|
size_t metablock_size =
|
|
1872
1897
|
BROTLI_MIN(size_t, input_size, MaxMetablockSize(¶ms));
|
|
@@ -1901,7 +1926,7 @@ size_t BrotliEncoderEstimatePeakMemoryUsage(int quality, int lgwin,
|
|
|
1901
1926
|
histogram_size);
|
|
1902
1927
|
}
|
|
1903
1928
|
}
|
|
1904
|
-
size_t BrotliEncoderGetPreparedDictionarySize(
|
|
1929
|
+
size_t BROTLI_COLD BrotliEncoderGetPreparedDictionarySize(
|
|
1905
1930
|
const BrotliEncoderPreparedDictionary* prepared_dictionary) {
|
|
1906
1931
|
/* First field of dictionary structs */
|
|
1907
1932
|
const BrotliEncoderPreparedDictionary* prepared = prepared_dictionary;
|
|
@@ -1984,8 +2009,8 @@ size_t BrotliEncoderGetPreparedDictionarySize(
|
|
|
1984
2009
|
}
|
|
1985
2010
|
|
|
1986
2011
|
#if defined(BROTLI_TEST)
|
|
1987
|
-
size_t
|
|
1988
|
-
size_t
|
|
2012
|
+
size_t BrotliMakeUncompressedStreamForTest(const uint8_t*, size_t, uint8_t*);
|
|
2013
|
+
size_t BrotliMakeUncompressedStreamForTest(
|
|
1989
2014
|
const uint8_t* input, size_t input_size, uint8_t* output) {
|
|
1990
2015
|
return MakeUncompressedStream(input, input_size, output);
|
|
1991
2016
|
}
|
|
@@ -6,17 +6,19 @@
|
|
|
6
6
|
|
|
7
7
|
#include "encoder_dict.h"
|
|
8
8
|
|
|
9
|
-
#include <stdlib.h> /* malloc, free */
|
|
10
|
-
|
|
11
9
|
#include "../common/dictionary.h"
|
|
12
10
|
#include "../common/platform.h"
|
|
11
|
+
#include <brotli/shared_dictionary.h>
|
|
13
12
|
#include "../common/shared_dictionary_internal.h"
|
|
14
13
|
#include "../common/transform.h"
|
|
14
|
+
#include <brotli/encode.h>
|
|
15
15
|
#include "compound_dictionary.h"
|
|
16
16
|
#include "dictionary_hash.h"
|
|
17
|
+
#include "hash_base.h"
|
|
18
|
+
#include "hash.h"
|
|
17
19
|
#include "memory.h"
|
|
18
20
|
#include "quality.h"
|
|
19
|
-
#include "
|
|
21
|
+
#include "static_dict_lut.h"
|
|
20
22
|
|
|
21
23
|
#if defined(__cplusplus) || defined(c_plusplus)
|
|
22
24
|
extern "C" {
|
|
@@ -118,8 +120,8 @@ static uint32_t BrotliTrieAlloc(MemoryManager* m, size_t num, BrotliTrie* trie,
|
|
|
118
120
|
keep_index = (uint32_t)(*keep - trie->pool);
|
|
119
121
|
}
|
|
120
122
|
if (trie->pool_size == 0) {
|
|
121
|
-
/* Have a
|
|
122
|
-
|
|
123
|
+
/* Have a placeholder node in the front. We do not want the result to be 0,
|
|
124
|
+
it must be at least 1, 0 represents "null pointer" */
|
|
123
125
|
trie->pool_size = 1;
|
|
124
126
|
}
|
|
125
127
|
BROTLI_ENSURE_CAPACITY(m, BrotliTrieNode, trie->pool, trie->pool_capacity,
|
|
@@ -629,8 +631,8 @@ void BrotliDestroyManagedDictionary(ManagedDictionary* dictionary) {
|
|
|
629
631
|
|
|
630
632
|
/* Escalate internal functions visibility; for testing purposes only. */
|
|
631
633
|
#if defined(BROTLI_TEST)
|
|
632
|
-
void
|
|
633
|
-
void
|
|
634
|
+
void BrotliInitEncoderDictionaryForTest(BrotliEncoderDictionary*);
|
|
635
|
+
void BrotliInitEncoderDictionaryForTest(BrotliEncoderDictionary* d) {
|
|
634
636
|
InitEncoderDictionary(d);
|
|
635
637
|
}
|
|
636
638
|
#endif
|
|
@@ -7,10 +7,8 @@
|
|
|
7
7
|
#ifndef BROTLI_ENC_ENCODER_DICT_H_
|
|
8
8
|
#define BROTLI_ENC_ENCODER_DICT_H_
|
|
9
9
|
|
|
10
|
-
#include <brotli/shared_dictionary.h>
|
|
11
|
-
#include <brotli/types.h>
|
|
12
|
-
|
|
13
10
|
#include "../common/dictionary.h"
|
|
11
|
+
#include <brotli/shared_dictionary.h>
|
|
14
12
|
#include "../common/platform.h"
|
|
15
13
|
#include "compound_dictionary.h"
|
|
16
14
|
#include "memory.h"
|
|
@@ -30,7 +28,7 @@ Dictionary hierarchy for Encoder:
|
|
|
30
28
|
---BrotliEncoderDictionary [up to 64x]
|
|
31
29
|
= for each context, precomputed static dictionary with words + transforms
|
|
32
30
|
|
|
33
|
-
Dictionary
|
|
31
|
+
Dictionary hierarchy from common: similar, but without precomputed hashes
|
|
34
32
|
-BrotliSharedDictionary
|
|
35
33
|
--BrotliDictionary [up to 64x]
|
|
36
34
|
--BrotliTransforms [up to 64x]
|
|
@@ -8,10 +8,6 @@
|
|
|
8
8
|
|
|
9
9
|
#include "entropy_encode.h"
|
|
10
10
|
|
|
11
|
-
#include <string.h> /* memset */
|
|
12
|
-
|
|
13
|
-
#include <brotli/types.h>
|
|
14
|
-
|
|
15
11
|
#include "../common/constants.h"
|
|
16
12
|
#include "../common/platform.h"
|
|
17
13
|
|
|
@@ -19,7 +15,7 @@
|
|
|
19
15
|
extern "C" {
|
|
20
16
|
#endif
|
|
21
17
|
|
|
22
|
-
const size_t kBrotliShellGaps[] = {132, 57, 23, 10, 4, 1};
|
|
18
|
+
const BROTLI_MODEL("small") size_t kBrotliShellGaps[] = {132, 57, 23, 10, 4, 1};
|
|
23
19
|
|
|
24
20
|
BROTLI_BOOL BrotliSetDepth(
|
|
25
21
|
int p0, HuffmanTree* pool, uint8_t* depth, int max_depth) {
|
|
@@ -456,7 +452,8 @@ void BrotliWriteHuffmanTree(const uint8_t* depth,
|
|
|
456
452
|
}
|
|
457
453
|
|
|
458
454
|
static uint16_t BrotliReverseBits(size_t num_bits, uint16_t bits) {
|
|
459
|
-
static const size_t kLut[16] =
|
|
455
|
+
static const size_t BROTLI_MODEL("small") kLut[16] =
|
|
456
|
+
{ /* Pre-reversed 4-bit values. */
|
|
460
457
|
0x00, 0x08, 0x04, 0x0C, 0x02, 0x0A, 0x06, 0x0E,
|
|
461
458
|
0x01, 0x09, 0x05, 0x0D, 0x03, 0x0B, 0x07, 0x0F
|
|
462
459
|
};
|
|
@@ -9,8 +9,6 @@
|
|
|
9
9
|
#ifndef BROTLI_ENC_ENTROPY_ENCODE_H_
|
|
10
10
|
#define BROTLI_ENC_ENTROPY_ENCODE_H_
|
|
11
11
|
|
|
12
|
-
#include <brotli/types.h>
|
|
13
|
-
|
|
14
12
|
#include "../common/platform.h"
|
|
15
13
|
|
|
16
14
|
#if defined(__cplusplus) || defined(c_plusplus)
|
|
@@ -67,7 +65,7 @@ BROTLI_INTERNAL void BrotliOptimizeHuffmanCountsForRle(
|
|
|
67
65
|
of a Huffman tree. The generated Huffman tree is to be compressed once
|
|
68
66
|
more using a Huffman tree */
|
|
69
67
|
BROTLI_INTERNAL void BrotliWriteHuffmanTree(const uint8_t* depth,
|
|
70
|
-
size_t
|
|
68
|
+
size_t length,
|
|
71
69
|
size_t* tree_size,
|
|
72
70
|
uint8_t* tree,
|
|
73
71
|
uint8_t* extra_bits_data);
|
|
@@ -77,7 +75,7 @@ BROTLI_INTERNAL void BrotliConvertBitDepthsToSymbols(const uint8_t* depth,
|
|
|
77
75
|
size_t len,
|
|
78
76
|
uint16_t* bits);
|
|
79
77
|
|
|
80
|
-
BROTLI_INTERNAL extern const size_t kBrotliShellGaps[6];
|
|
78
|
+
BROTLI_INTERNAL extern BROTLI_MODEL("small") const size_t kBrotliShellGaps[6];
|
|
81
79
|
/* Input size optimized Shell sort. */
|
|
82
80
|
typedef BROTLI_BOOL (*HuffmanTreeComparator)(
|
|
83
81
|
const HuffmanTree*, const HuffmanTree*);
|
|
@@ -9,8 +9,6 @@
|
|
|
9
9
|
#ifndef BROTLI_ENC_ENTROPY_ENCODE_STATIC_H_
|
|
10
10
|
#define BROTLI_ENC_ENTROPY_ENCODE_STATIC_H_
|
|
11
11
|
|
|
12
|
-
#include <brotli/types.h>
|
|
13
|
-
|
|
14
12
|
#include "../common/constants.h"
|
|
15
13
|
#include "../common/platform.h"
|
|
16
14
|
#include "write_bits.h"
|
|
@@ -19,11 +17,12 @@
|
|
|
19
17
|
extern "C" {
|
|
20
18
|
#endif
|
|
21
19
|
|
|
22
|
-
static const uint8_t kCodeLengthDepth[18] = {
|
|
20
|
+
static const BROTLI_MODEL("small") uint8_t kCodeLengthDepth[18] = {
|
|
23
21
|
4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 5, 5, 0, 4, 4,
|
|
24
22
|
};
|
|
25
23
|
|
|
26
|
-
static const
|
|
24
|
+
static const BROTLI_MODEL("small")
|
|
25
|
+
uint8_t kStaticCommandCodeDepth[BROTLI_NUM_COMMAND_SYMBOLS] = {
|
|
27
26
|
9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9,
|
|
28
27
|
9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9,
|
|
29
28
|
9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9,
|
|
@@ -70,7 +69,8 @@ static const uint8_t kStaticCommandCodeDepth[BROTLI_NUM_COMMAND_SYMBOLS] = {
|
|
|
70
69
|
11, 11, 11, 11, 11, 11, 11, 11, 11, 11, 11, 11, 11, 11, 11, 11,
|
|
71
70
|
};
|
|
72
71
|
|
|
73
|
-
static const
|
|
72
|
+
static const BROTLI_MODEL("small")
|
|
73
|
+
uint8_t kStaticDistanceCodeDepth[64] = {
|
|
74
74
|
6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6,
|
|
75
75
|
6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6,
|
|
76
76
|
6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6,
|
|
@@ -78,7 +78,8 @@ static const uint8_t kStaticDistanceCodeDepth[64] = {
|
|
|
78
78
|
};
|
|
79
79
|
|
|
80
80
|
/* GENERATED CODE START */
|
|
81
|
-
static const
|
|
81
|
+
static const BROTLI_MODEL("small")
|
|
82
|
+
uint32_t kCodeLengthBits[18] = {
|
|
82
83
|
0, 8, 4, 12, 2, 10, 6, 14, 1, 9, 5, 13, 3, 15, 31, 0, 11, 7,
|
|
83
84
|
};
|
|
84
85
|
|
|
@@ -88,7 +89,8 @@ static BROTLI_INLINE void StoreStaticCodeLengthCode(
|
|
|
88
89
|
40, BROTLI_MAKE_UINT64_T(0x0000FFu, 0x55555554u), storage_ix, storage);
|
|
89
90
|
}
|
|
90
91
|
|
|
91
|
-
static const
|
|
92
|
+
static const BROTLI_MODEL("small")
|
|
93
|
+
uint64_t kZeroRepsBits[BROTLI_NUM_COMMAND_SYMBOLS] = {
|
|
92
94
|
0x00000000, 0x00000000, 0x00000000, 0x00000007, 0x00000017, 0x00000027,
|
|
93
95
|
0x00000037, 0x00000047, 0x00000057, 0x00000067, 0x00000077, 0x00000770,
|
|
94
96
|
0x00000b87, 0x00001387, 0x00001b87, 0x00002387, 0x00002b87, 0x00003387,
|
|
@@ -209,7 +211,8 @@ static const uint64_t kZeroRepsBits[BROTLI_NUM_COMMAND_SYMBOLS] = {
|
|
|
209
211
|
0x06f9cb87, 0x08f9cb87,
|
|
210
212
|
};
|
|
211
213
|
|
|
212
|
-
static const
|
|
214
|
+
static const BROTLI_MODEL("small")
|
|
215
|
+
uint32_t kZeroRepsDepth[BROTLI_NUM_COMMAND_SYMBOLS] = {
|
|
213
216
|
0, 4, 8, 7, 7, 7, 7, 7, 7, 7, 7, 11, 14, 14, 14, 14,
|
|
214
217
|
14, 14, 14, 14, 14, 14, 14, 14, 14, 14, 14, 14, 14, 14, 14, 14,
|
|
215
218
|
14, 14, 14, 14, 14, 14, 14, 14, 14, 14, 14, 14, 14, 14, 14, 14,
|
|
@@ -256,7 +259,8 @@ static const uint32_t kZeroRepsDepth[BROTLI_NUM_COMMAND_SYMBOLS] = {
|
|
|
256
259
|
28, 28, 28, 28, 28, 28, 28, 28, 28, 28, 28, 28, 28, 28, 28, 28,
|
|
257
260
|
};
|
|
258
261
|
|
|
259
|
-
static const
|
|
262
|
+
static const BROTLI_MODEL("small")
|
|
263
|
+
uint64_t kNonZeroRepsBits[BROTLI_NUM_COMMAND_SYMBOLS] = {
|
|
260
264
|
0x0000000b, 0x0000001b, 0x0000002b, 0x0000003b, 0x000002cb, 0x000006cb,
|
|
261
265
|
0x00000acb, 0x00000ecb, 0x000002db, 0x000006db, 0x00000adb, 0x00000edb,
|
|
262
266
|
0x000002eb, 0x000006eb, 0x00000aeb, 0x00000eeb, 0x000002fb, 0x000006fb,
|
|
@@ -377,7 +381,8 @@ static const uint64_t kNonZeroRepsBits[BROTLI_NUM_COMMAND_SYMBOLS] = {
|
|
|
377
381
|
0x2baeb6db, 0x3baeb6db,
|
|
378
382
|
};
|
|
379
383
|
|
|
380
|
-
static const
|
|
384
|
+
static const BROTLI_MODEL("small")
|
|
385
|
+
uint32_t kNonZeroRepsDepth[BROTLI_NUM_COMMAND_SYMBOLS] = {
|
|
381
386
|
6, 6, 6, 6, 12, 12, 12, 12, 12, 12, 12, 12, 12, 12, 12, 12,
|
|
382
387
|
12, 12, 12, 12, 18, 18, 18, 18, 18, 18, 18, 18, 18, 18, 18, 18,
|
|
383
388
|
18, 18, 18, 18, 18, 18, 18, 18, 18, 18, 18, 18, 18, 18, 18, 18,
|
|
@@ -424,7 +429,8 @@ static const uint32_t kNonZeroRepsDepth[BROTLI_NUM_COMMAND_SYMBOLS] = {
|
|
|
424
429
|
30, 30, 30, 30, 30, 30, 30, 30, 30, 30, 30, 30, 30, 30, 30, 30,
|
|
425
430
|
};
|
|
426
431
|
|
|
427
|
-
static const
|
|
432
|
+
static const BROTLI_MODEL("small")
|
|
433
|
+
uint16_t kStaticCommandCodeBits[BROTLI_NUM_COMMAND_SYMBOLS] = {
|
|
428
434
|
0, 256, 128, 384, 64, 320, 192, 448,
|
|
429
435
|
32, 288, 160, 416, 96, 352, 224, 480,
|
|
430
436
|
16, 272, 144, 400, 80, 336, 208, 464,
|
|
@@ -522,7 +528,7 @@ static BROTLI_INLINE void StoreStaticCommandHuffmanTree(
|
|
|
522
528
|
BrotliWriteBits(3, 0x00000000U, storage_ix, storage);
|
|
523
529
|
}
|
|
524
530
|
|
|
525
|
-
static const uint16_t kStaticDistanceCodeBits[64] = {
|
|
531
|
+
static const BROTLI_MODEL("small") uint16_t kStaticDistanceCodeBits[64] = {
|
|
526
532
|
0, 32, 16, 48, 8, 40, 24, 56, 4, 36, 20, 52, 12, 44, 28, 60,
|
|
527
533
|
2, 34, 18, 50, 10, 42, 26, 58, 6, 38, 22, 54, 14, 46, 30, 62,
|
|
528
534
|
1, 33, 17, 49, 9, 41, 25, 57, 5, 37, 21, 53, 13, 45, 29, 61,
|
|
@@ -11,7 +11,7 @@ extern "C" {
|
|
|
11
11
|
#endif
|
|
12
12
|
|
|
13
13
|
/* ", ".join(["%.16ff" % x for x in [0.0]+[log2(x) for x in range(1, 256)]]) */
|
|
14
|
-
const double kBrotliLog2Table[BROTLI_LOG2_TABLE_SIZE] = {
|
|
14
|
+
const BROTLI_MODEL("small") double kBrotliLog2Table[BROTLI_LOG2_TABLE_SIZE] = {
|
|
15
15
|
0.0000000000000000f, 0.0000000000000000f, 1.0000000000000000f,
|
|
16
16
|
1.5849625007211563f, 2.0000000000000000f, 2.3219280948873622f,
|
|
17
17
|
2.5849625007211561f, 2.8073549220576042f, 3.0000000000000000f,
|
|
@@ -11,8 +11,6 @@
|
|
|
11
11
|
|
|
12
12
|
#include <math.h>
|
|
13
13
|
|
|
14
|
-
#include <brotli/types.h>
|
|
15
|
-
|
|
16
14
|
#include "../common/platform.h"
|
|
17
15
|
|
|
18
16
|
#if defined(__cplusplus) || defined(c_plusplus)
|
|
@@ -33,7 +31,8 @@ static BROTLI_INLINE uint32_t Log2FloorNonZero(size_t n) {
|
|
|
33
31
|
|
|
34
32
|
/* A lookup table for small values of log2(int) to be used in entropy
|
|
35
33
|
computation. */
|
|
36
|
-
BROTLI_INTERNAL extern const
|
|
34
|
+
BROTLI_INTERNAL extern const BROTLI_MODEL("small")
|
|
35
|
+
double kBrotliLog2Table[BROTLI_LOG2_TABLE_SIZE];
|
|
37
36
|
|
|
38
37
|
/* Visual Studio 2012 and Android API levels < 18 do not have the log2()
|
|
39
38
|
* function defined, so we use log() and a multiplication instead. */
|