multi_compress 0.3.1 → 0.3.3
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 +15 -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 +22 -1
- data/ext/multi_compress/multi_compress.c +152 -72
- 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
- metadata +29 -2
|
@@ -137,12 +137,94 @@ static void init_id_cache(void) {
|
|
|
137
137
|
sym_cache.max_ratio = ID2SYM(id_cache.max_ratio);
|
|
138
138
|
}
|
|
139
139
|
|
|
140
|
-
|
|
141
|
-
|
|
140
|
+
typedef struct {
|
|
141
|
+
VALUE algo;
|
|
142
|
+
VALUE level;
|
|
143
|
+
VALUE dictionary;
|
|
144
|
+
VALUE size;
|
|
145
|
+
VALUE format;
|
|
146
|
+
VALUE max_output_size;
|
|
147
|
+
VALUE max_ratio;
|
|
148
|
+
int saw_algorithm_keyword;
|
|
149
|
+
} mc_opts_t;
|
|
150
|
+
|
|
151
|
+
static inline void mc_opts_init(mc_opts_t *opts) {
|
|
152
|
+
opts->algo = Qnil;
|
|
153
|
+
opts->level = Qnil;
|
|
154
|
+
opts->dictionary = Qnil;
|
|
155
|
+
opts->size = Qnil;
|
|
156
|
+
opts->format = Qnil;
|
|
157
|
+
opts->max_output_size = Qundef;
|
|
158
|
+
opts->max_ratio = Qundef;
|
|
159
|
+
opts->saw_algorithm_keyword = 0;
|
|
160
|
+
}
|
|
161
|
+
|
|
162
|
+
static int mc_opts_parse_i(VALUE key, VALUE value, VALUE arg) {
|
|
163
|
+
mc_opts_t *opts = (mc_opts_t *)arg;
|
|
164
|
+
|
|
165
|
+
if (!SYMBOL_P(key))
|
|
166
|
+
return ST_CONTINUE;
|
|
167
|
+
|
|
168
|
+
ID id = SYM2ID(key);
|
|
169
|
+
if (id == id_cache.algo) {
|
|
170
|
+
opts->algo = value;
|
|
171
|
+
} else if (id == id_cache.level) {
|
|
172
|
+
opts->level = value;
|
|
173
|
+
} else if (id == id_cache.dictionary) {
|
|
174
|
+
opts->dictionary = value;
|
|
175
|
+
} else if (id == id_cache.size) {
|
|
176
|
+
opts->size = value;
|
|
177
|
+
} else if (id == id_cache.format) {
|
|
178
|
+
opts->format = value;
|
|
179
|
+
} else if (id == id_cache.max_output_size) {
|
|
180
|
+
opts->max_output_size = value;
|
|
181
|
+
} else if (id == id_cache.max_ratio) {
|
|
182
|
+
opts->max_ratio = value;
|
|
183
|
+
} else if (id == id_cache.algorithm) {
|
|
184
|
+
opts->saw_algorithm_keyword = 1;
|
|
185
|
+
}
|
|
186
|
+
|
|
187
|
+
return ST_CONTINUE;
|
|
188
|
+
}
|
|
189
|
+
|
|
190
|
+
static inline void mc_parse_opts(VALUE opts_hash, mc_opts_t *opts) {
|
|
191
|
+
mc_opts_init(opts);
|
|
192
|
+
if (NIL_P(opts_hash))
|
|
193
|
+
return;
|
|
194
|
+
Check_Type(opts_hash, T_HASH);
|
|
195
|
+
rb_hash_foreach(opts_hash, mc_opts_parse_i, (VALUE)opts);
|
|
196
|
+
}
|
|
197
|
+
|
|
198
|
+
static inline void scan_one_required_keywords(int argc, VALUE *argv, VALUE *arg, VALUE *opts) {
|
|
199
|
+
if (argc == 1) {
|
|
200
|
+
*arg = argv[0];
|
|
201
|
+
*opts = Qnil;
|
|
202
|
+
return;
|
|
203
|
+
}
|
|
204
|
+
|
|
205
|
+
if (argc == 2 && rb_keyword_given_p()) {
|
|
206
|
+
*arg = argv[0];
|
|
207
|
+
*opts = argv[1];
|
|
208
|
+
Check_Type(*opts, T_HASH);
|
|
209
|
+
return;
|
|
210
|
+
}
|
|
211
|
+
|
|
212
|
+
rb_error_arity(argc, 1, 1);
|
|
142
213
|
}
|
|
143
214
|
|
|
144
|
-
static inline
|
|
145
|
-
|
|
215
|
+
static inline void scan_zero_required_keywords(int argc, VALUE *argv, VALUE *opts) {
|
|
216
|
+
if (argc == 0) {
|
|
217
|
+
*opts = Qnil;
|
|
218
|
+
return;
|
|
219
|
+
}
|
|
220
|
+
|
|
221
|
+
if (argc == 1 && rb_keyword_given_p()) {
|
|
222
|
+
*opts = argv[0];
|
|
223
|
+
Check_Type(*opts, T_HASH);
|
|
224
|
+
return;
|
|
225
|
+
}
|
|
226
|
+
|
|
227
|
+
rb_error_arity(argc, 0, 0);
|
|
146
228
|
}
|
|
147
229
|
|
|
148
230
|
enum { LZ4_FRAME_MAGIC_LEN = 4 };
|
|
@@ -152,8 +234,9 @@ static inline int is_lz4_frame_magic(const uint8_t *data, size_t len) {
|
|
|
152
234
|
return len >= LZ4_FRAME_MAGIC_LEN && memcmp(data, LZ4_FRAME_MAGIC, LZ4_FRAME_MAGIC_LEN) == 0;
|
|
153
235
|
}
|
|
154
236
|
|
|
155
|
-
static lz4_format_t parse_lz4_format(
|
|
156
|
-
|
|
237
|
+
static lz4_format_t parse_lz4_format(const mc_opts_t *opts, compress_algo_t algo,
|
|
238
|
+
int explicit_algo) {
|
|
239
|
+
VALUE format_val = opts->format;
|
|
157
240
|
if (format_val == Qundef || NIL_P(format_val))
|
|
158
241
|
return LZ4_FORMAT_BLOCK;
|
|
159
242
|
if (explicit_algo && algo != ALGO_LZ4)
|
|
@@ -169,10 +252,8 @@ static lz4_format_t parse_lz4_format(VALUE opts, compress_algo_t algo, int expli
|
|
|
169
252
|
return LZ4_FORMAT_BLOCK;
|
|
170
253
|
}
|
|
171
254
|
|
|
172
|
-
static inline void reject_algorithm_keyword(
|
|
173
|
-
if (
|
|
174
|
-
return;
|
|
175
|
-
if (rb_hash_lookup2(opts, sym_cache.algorithm, Qundef) != Qundef) {
|
|
255
|
+
static inline void reject_algorithm_keyword(const mc_opts_t *opts) {
|
|
256
|
+
if (opts->saw_algorithm_keyword) {
|
|
176
257
|
rb_raise(rb_eArgError, "unknown keyword: :algorithm (use :algo)");
|
|
177
258
|
}
|
|
178
259
|
}
|
|
@@ -383,11 +464,8 @@ static void limits_config_init(limits_config_t *limits) {
|
|
|
383
464
|
limits->max_ratio = DEFAULT_MAX_RATIO;
|
|
384
465
|
}
|
|
385
466
|
|
|
386
|
-
static void
|
|
387
|
-
|
|
388
|
-
return;
|
|
389
|
-
|
|
390
|
-
VALUE val = opt_lookup2(opts, sym_cache.max_output_size, Qundef);
|
|
467
|
+
static void limits_config_apply_parsed(const mc_opts_t *opts, limits_config_t *limits) {
|
|
468
|
+
VALUE val = opts->max_output_size;
|
|
391
469
|
if (val != Qundef && !NIL_P(val)) {
|
|
392
470
|
size_t max_output_size = NUM2SIZET(val);
|
|
393
471
|
if (max_output_size == 0)
|
|
@@ -395,7 +473,7 @@ static void limits_config_apply_opts(VALUE opts, limits_config_t *limits) {
|
|
|
395
473
|
limits->max_output_size = max_output_size;
|
|
396
474
|
}
|
|
397
475
|
|
|
398
|
-
val =
|
|
476
|
+
val = opts->max_ratio;
|
|
399
477
|
if (val == Qundef)
|
|
400
478
|
return;
|
|
401
479
|
if (NIL_P(val)) {
|
|
@@ -411,9 +489,9 @@ static void limits_config_apply_opts(VALUE opts, limits_config_t *limits) {
|
|
|
411
489
|
limits->max_ratio = max_ratio;
|
|
412
490
|
}
|
|
413
491
|
|
|
414
|
-
static void
|
|
492
|
+
static void parse_limits_from_parsed_opts(const mc_opts_t *opts, limits_config_t *limits) {
|
|
415
493
|
limits_config_init(limits);
|
|
416
|
-
|
|
494
|
+
limits_config_apply_parsed(opts, limits);
|
|
417
495
|
}
|
|
418
496
|
|
|
419
497
|
static inline size_t checked_add_size(size_t left, size_t right, const char *message) {
|
|
@@ -1107,20 +1185,20 @@ static void *zstd_fiber_compress_nogvl(void *arg) {
|
|
|
1107
1185
|
|
|
1108
1186
|
static VALUE compress_compress(int argc, VALUE *argv, VALUE self) {
|
|
1109
1187
|
VALUE data, opts;
|
|
1110
|
-
|
|
1188
|
+
scan_one_required_keywords(argc, argv, &data, &opts);
|
|
1111
1189
|
StringValue(data);
|
|
1112
|
-
reject_algorithm_keyword(opts);
|
|
1113
1190
|
|
|
1114
|
-
|
|
1115
|
-
|
|
1116
|
-
|
|
1117
|
-
|
|
1118
|
-
|
|
1119
|
-
|
|
1191
|
+
mc_opts_t parsed_opts;
|
|
1192
|
+
mc_parse_opts(opts, &parsed_opts);
|
|
1193
|
+
reject_algorithm_keyword(&parsed_opts);
|
|
1194
|
+
|
|
1195
|
+
VALUE algo_sym = parsed_opts.algo;
|
|
1196
|
+
VALUE level_val = parsed_opts.level;
|
|
1197
|
+
VALUE dict_val = parsed_opts.dictionary;
|
|
1120
1198
|
|
|
1121
1199
|
int explicit_algo = !NIL_P(algo_sym);
|
|
1122
1200
|
compress_algo_t algo = explicit_algo ? sym_to_algo(algo_sym) : ALGO_ZSTD;
|
|
1123
|
-
lz4_format_t lz4_format = parse_lz4_format(
|
|
1201
|
+
lz4_format_t lz4_format = parse_lz4_format(&parsed_opts, algo, explicit_algo);
|
|
1124
1202
|
int level = resolve_level(algo, level_val);
|
|
1125
1203
|
|
|
1126
1204
|
dictionary_t *dict = NULL;
|
|
@@ -1406,17 +1484,17 @@ static VALUE compress_compress(int argc, VALUE *argv, VALUE self) {
|
|
|
1406
1484
|
|
|
1407
1485
|
static VALUE compress_decompress(int argc, VALUE *argv, VALUE self) {
|
|
1408
1486
|
VALUE data, opts;
|
|
1409
|
-
|
|
1487
|
+
scan_one_required_keywords(argc, argv, &data, &opts);
|
|
1410
1488
|
StringValue(data);
|
|
1411
|
-
reject_algorithm_keyword(opts);
|
|
1412
1489
|
|
|
1413
|
-
|
|
1490
|
+
mc_opts_t parsed_opts;
|
|
1491
|
+
mc_parse_opts(opts, &parsed_opts);
|
|
1492
|
+
reject_algorithm_keyword(&parsed_opts);
|
|
1493
|
+
|
|
1494
|
+
VALUE algo_sym = parsed_opts.algo;
|
|
1495
|
+
VALUE dict_val = parsed_opts.dictionary;
|
|
1414
1496
|
limits_config_t limits;
|
|
1415
|
-
|
|
1416
|
-
if (!NIL_P(opts)) {
|
|
1417
|
-
algo_sym = opt_get(opts, sym_cache.algo);
|
|
1418
|
-
dict_val = opt_get(opts, sym_cache.dictionary);
|
|
1419
|
-
}
|
|
1497
|
+
parse_limits_from_parsed_opts(&parsed_opts, &limits);
|
|
1420
1498
|
|
|
1421
1499
|
const uint8_t *src = (const uint8_t *)RSTRING_PTR(data);
|
|
1422
1500
|
size_t slen = RSTRING_LEN(data);
|
|
@@ -1428,7 +1506,7 @@ static VALUE compress_decompress(int argc, VALUE *argv, VALUE self) {
|
|
|
1428
1506
|
} else {
|
|
1429
1507
|
algo = sym_to_algo(algo_sym);
|
|
1430
1508
|
}
|
|
1431
|
-
lz4_format_t lz4_format = parse_lz4_format(
|
|
1509
|
+
lz4_format_t lz4_format = parse_lz4_format(&parsed_opts, algo, explicit_algo);
|
|
1432
1510
|
|
|
1433
1511
|
const algo_policy_t *policy = algo_policy(algo);
|
|
1434
1512
|
|
|
@@ -2009,18 +2087,18 @@ static VALUE deflater_alloc(VALUE klass) {
|
|
|
2009
2087
|
|
|
2010
2088
|
static VALUE deflater_initialize(int argc, VALUE *argv, VALUE self) {
|
|
2011
2089
|
VALUE opts;
|
|
2012
|
-
|
|
2013
|
-
|
|
2090
|
+
scan_zero_required_keywords(argc, argv, &opts);
|
|
2091
|
+
|
|
2092
|
+
mc_opts_t parsed_opts;
|
|
2093
|
+
mc_parse_opts(opts, &parsed_opts);
|
|
2094
|
+
reject_algorithm_keyword(&parsed_opts);
|
|
2014
2095
|
|
|
2015
2096
|
deflater_t *d;
|
|
2016
2097
|
TypedData_Get_Struct(self, deflater_t, &deflater_type, d);
|
|
2017
2098
|
|
|
2018
|
-
VALUE algo_sym =
|
|
2019
|
-
|
|
2020
|
-
|
|
2021
|
-
level_val = opt_get(opts, sym_cache.level);
|
|
2022
|
-
dict_val = opt_get(opts, sym_cache.dictionary);
|
|
2023
|
-
}
|
|
2099
|
+
VALUE algo_sym = parsed_opts.algo;
|
|
2100
|
+
VALUE level_val = parsed_opts.level;
|
|
2101
|
+
VALUE dict_val = parsed_opts.dictionary;
|
|
2024
2102
|
|
|
2025
2103
|
d->algo = NIL_P(algo_sym) ? ALGO_ZSTD : sym_to_algo(algo_sym);
|
|
2026
2104
|
d->level = resolve_level(d->algo, level_val);
|
|
@@ -2663,19 +2741,19 @@ static VALUE inflater_alloc(VALUE klass) {
|
|
|
2663
2741
|
|
|
2664
2742
|
static VALUE inflater_initialize(int argc, VALUE *argv, VALUE self) {
|
|
2665
2743
|
VALUE opts;
|
|
2666
|
-
|
|
2667
|
-
|
|
2744
|
+
scan_zero_required_keywords(argc, argv, &opts);
|
|
2745
|
+
|
|
2746
|
+
mc_opts_t parsed_opts;
|
|
2747
|
+
mc_parse_opts(opts, &parsed_opts);
|
|
2748
|
+
reject_algorithm_keyword(&parsed_opts);
|
|
2668
2749
|
|
|
2669
2750
|
inflater_t *inf;
|
|
2670
2751
|
TypedData_Get_Struct(self, inflater_t, &inflater_type, inf);
|
|
2671
2752
|
|
|
2672
|
-
VALUE algo_sym =
|
|
2753
|
+
VALUE algo_sym = parsed_opts.algo;
|
|
2754
|
+
VALUE dict_val = parsed_opts.dictionary;
|
|
2673
2755
|
limits_config_t limits;
|
|
2674
|
-
|
|
2675
|
-
if (!NIL_P(opts)) {
|
|
2676
|
-
algo_sym = opt_get(opts, sym_cache.algo);
|
|
2677
|
-
dict_val = opt_get(opts, sym_cache.dictionary);
|
|
2678
|
-
}
|
|
2756
|
+
parse_limits_from_parsed_opts(&parsed_opts, &limits);
|
|
2679
2757
|
|
|
2680
2758
|
inf->algo = NIL_P(algo_sym) ? ALGO_ZSTD : sym_to_algo(algo_sym);
|
|
2681
2759
|
inf->closed = 0;
|
|
@@ -3088,17 +3166,17 @@ static VALUE inflater_closed_p(VALUE self) {
|
|
|
3088
3166
|
|
|
3089
3167
|
static VALUE dict_initialize(int argc, VALUE *argv, VALUE self) {
|
|
3090
3168
|
VALUE raw, opts;
|
|
3091
|
-
|
|
3169
|
+
scan_one_required_keywords(argc, argv, &raw, &opts);
|
|
3092
3170
|
StringValue(raw);
|
|
3093
|
-
|
|
3171
|
+
|
|
3172
|
+
mc_opts_t parsed_opts;
|
|
3173
|
+
mc_parse_opts(opts, &parsed_opts);
|
|
3174
|
+
reject_algorithm_keyword(&parsed_opts);
|
|
3094
3175
|
|
|
3095
3176
|
dictionary_t *d;
|
|
3096
3177
|
TypedData_Get_Struct(self, dictionary_t, &dictionary_type, d);
|
|
3097
3178
|
|
|
3098
|
-
VALUE algo_sym =
|
|
3099
|
-
if (!NIL_P(opts)) {
|
|
3100
|
-
algo_sym = opt_get(opts, sym_cache.algo);
|
|
3101
|
-
}
|
|
3179
|
+
VALUE algo_sym = parsed_opts.algo;
|
|
3102
3180
|
d->algo = NIL_P(algo_sym) ? ALGO_ZSTD : sym_to_algo(algo_sym);
|
|
3103
3181
|
|
|
3104
3182
|
if (d->algo == ALGO_LZ4)
|
|
@@ -3183,32 +3261,34 @@ static VALUE train_dictionary_internal(VALUE samples, VALUE size_val, compress_a
|
|
|
3183
3261
|
|
|
3184
3262
|
static VALUE zstd_train_dictionary(int argc, VALUE *argv, VALUE self) {
|
|
3185
3263
|
VALUE samples, opts;
|
|
3186
|
-
|
|
3187
|
-
|
|
3188
|
-
|
|
3189
|
-
|
|
3264
|
+
scan_one_required_keywords(argc, argv, &samples, &opts);
|
|
3265
|
+
mc_opts_t parsed_opts;
|
|
3266
|
+
mc_parse_opts(opts, &parsed_opts);
|
|
3267
|
+
reject_algorithm_keyword(&parsed_opts);
|
|
3268
|
+
return train_dictionary_internal(samples, parsed_opts.size, ALGO_ZSTD);
|
|
3190
3269
|
}
|
|
3191
3270
|
|
|
3192
3271
|
static VALUE brotli_train_dictionary(int argc, VALUE *argv, VALUE self) {
|
|
3193
3272
|
VALUE samples, opts;
|
|
3194
|
-
|
|
3195
|
-
|
|
3196
|
-
|
|
3273
|
+
scan_one_required_keywords(argc, argv, &samples, &opts);
|
|
3274
|
+
mc_opts_t parsed_opts;
|
|
3275
|
+
mc_parse_opts(opts, &parsed_opts);
|
|
3276
|
+
reject_algorithm_keyword(&parsed_opts);
|
|
3197
3277
|
|
|
3198
|
-
return train_dictionary_internal(samples,
|
|
3278
|
+
return train_dictionary_internal(samples, parsed_opts.size, ALGO_BROTLI);
|
|
3199
3279
|
}
|
|
3200
3280
|
|
|
3201
3281
|
static VALUE dict_load(int argc, VALUE *argv, VALUE self) {
|
|
3202
3282
|
VALUE path, opts;
|
|
3203
|
-
|
|
3283
|
+
scan_one_required_keywords(argc, argv, &path, &opts);
|
|
3204
3284
|
StringValue(path);
|
|
3205
|
-
reject_algorithm_keyword(opts);
|
|
3206
3285
|
raise_if_path_has_null_byte(path);
|
|
3207
3286
|
|
|
3208
|
-
|
|
3209
|
-
|
|
3210
|
-
|
|
3211
|
-
|
|
3287
|
+
mc_opts_t parsed_opts;
|
|
3288
|
+
mc_parse_opts(opts, &parsed_opts);
|
|
3289
|
+
reject_algorithm_keyword(&parsed_opts);
|
|
3290
|
+
|
|
3291
|
+
VALUE algo_sym = parsed_opts.algo;
|
|
3212
3292
|
compress_algo_t algo = NIL_P(algo_sym) ? ALGO_ZSTD : sym_to_algo(algo_sym);
|
|
3213
3293
|
|
|
3214
3294
|
if (algo == ALGO_LZ4)
|
|
@@ -1,3 +1,3 @@
|
|
|
1
|
-
zstd=1.5.
|
|
1
|
+
zstd=1.5.7
|
|
2
2
|
lz4=1.10.0
|
|
3
|
-
brotli=1.
|
|
3
|
+
brotli=1.2.0
|
|
@@ -0,0 +1,19 @@
|
|
|
1
|
+
Copyright (c) 2009, 2010, 2013-2016 by the Brotli Authors.
|
|
2
|
+
|
|
3
|
+
Permission is hereby granted, free of charge, to any person obtaining a copy
|
|
4
|
+
of this software and associated documentation files (the "Software"), to deal
|
|
5
|
+
in the Software without restriction, including without limitation the rights
|
|
6
|
+
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
|
7
|
+
copies of the Software, and to permit persons to whom the Software is
|
|
8
|
+
furnished to do so, subject to the following conditions:
|
|
9
|
+
|
|
10
|
+
The above copyright notice and this permission notice shall be included in
|
|
11
|
+
all copies or substantial portions of the Software.
|
|
12
|
+
|
|
13
|
+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
|
14
|
+
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
|
15
|
+
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
|
16
|
+
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
|
17
|
+
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
|
18
|
+
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
|
|
19
|
+
THE SOFTWARE.
|
|
@@ -6,10 +6,10 @@
|
|
|
6
6
|
|
|
7
7
|
#include "constants.h"
|
|
8
8
|
|
|
9
|
-
const
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
9
|
+
const BROTLI_MODEL("small")
|
|
10
|
+
BrotliPrefixCodeRange _kBrotliPrefixCodeRanges[BROTLI_NUM_BLOCK_LEN_SYMBOLS] = {
|
|
11
|
+
{1, 2}, {5, 2}, {9, 2}, {13, 2}, {17, 3}, {25, 3},
|
|
12
|
+
{33, 3}, {41, 3}, {49, 4}, {65, 4}, {81, 4}, {97, 4},
|
|
13
|
+
{113, 5}, {145, 5}, {177, 5}, {209, 5}, {241, 6}, {305, 6},
|
|
14
|
+
{369, 7}, {497, 8}, {753, 9}, {1265, 10}, {2289, 11}, {4337, 12},
|
|
15
|
+
{8433, 13}, {16625, 24}};
|
|
@@ -12,9 +12,6 @@
|
|
|
12
12
|
#ifndef BROTLI_COMMON_CONSTANTS_H_
|
|
13
13
|
#define BROTLI_COMMON_CONSTANTS_H_
|
|
14
14
|
|
|
15
|
-
#include <brotli/port.h>
|
|
16
|
-
#include <brotli/types.h>
|
|
17
|
-
|
|
18
15
|
#include "platform.h"
|
|
19
16
|
|
|
20
17
|
/* Specification: 7.3. Encoding of the context map */
|
|
@@ -195,7 +192,7 @@ typedef struct {
|
|
|
195
192
|
} BrotliPrefixCodeRange;
|
|
196
193
|
|
|
197
194
|
/* "Soft-private", it is exported, but not "advertised" as API. */
|
|
198
|
-
BROTLI_COMMON_API extern const
|
|
199
|
-
|
|
195
|
+
BROTLI_COMMON_API extern const BROTLI_MODEL("small")
|
|
196
|
+
BrotliPrefixCodeRange _kBrotliPrefixCodeRanges[BROTLI_NUM_BLOCK_LEN_SYMBOLS];
|
|
200
197
|
|
|
201
198
|
#endif /* BROTLI_COMMON_CONSTANTS_H_ */
|
|
@@ -1,9 +1,9 @@
|
|
|
1
1
|
#include "context.h"
|
|
2
2
|
|
|
3
|
-
#include
|
|
3
|
+
#include "platform.h"
|
|
4
4
|
|
|
5
5
|
/* Common context lookup table for all context modes. */
|
|
6
|
-
const uint8_t _kBrotliContextLookupTable[2048] = {
|
|
6
|
+
const BROTLI_MODEL("small") uint8_t _kBrotliContextLookupTable[2048] = {
|
|
7
7
|
/* CONTEXT_LSB6, last byte. */
|
|
8
8
|
0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15,
|
|
9
9
|
16, 17, 18, 19, 20, 21, 22, 23, 24, 25, 26, 27, 28, 29, 30, 31,
|