brotli 0.1.3 → 0.1.4
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/.gitignore +3 -0
- data/.travis.yml +11 -3
- data/Gemfile +2 -0
- data/ext/brotli/brotli.c +279 -0
- data/ext/brotli/brotli.h +2 -0
- data/ext/brotli/buffer.c +95 -0
- data/ext/brotli/buffer.h +19 -0
- data/ext/brotli/extconf.rb +21 -81
- data/lib/brotli/version.rb +1 -1
- data/vendor/brotli/dec/bit_reader.c +5 -5
- data/vendor/brotli/dec/bit_reader.h +15 -15
- data/vendor/brotli/dec/context.h +1 -1
- data/vendor/brotli/dec/decode.c +433 -348
- data/vendor/brotli/dec/decode.h +74 -48
- data/vendor/brotli/dec/huffman.c +5 -4
- data/vendor/brotli/dec/huffman.h +4 -4
- data/vendor/brotli/dec/port.h +2 -95
- data/vendor/brotli/dec/prefix.h +5 -3
- data/vendor/brotli/dec/state.c +15 -27
- data/vendor/brotli/dec/state.h +21 -17
- data/vendor/brotli/dec/transform.h +1 -1
- data/vendor/brotli/enc/backward_references.c +892 -0
- data/vendor/brotli/enc/backward_references.h +85 -102
- data/vendor/brotli/enc/backward_references_inc.h +147 -0
- data/vendor/brotli/enc/bit_cost.c +35 -0
- data/vendor/brotli/enc/bit_cost.h +23 -121
- data/vendor/brotli/enc/bit_cost_inc.h +127 -0
- data/vendor/brotli/enc/block_encoder_inc.h +33 -0
- data/vendor/brotli/enc/block_splitter.c +197 -0
- data/vendor/brotli/enc/block_splitter.h +40 -50
- data/vendor/brotli/enc/block_splitter_inc.h +432 -0
- data/vendor/brotli/enc/brotli_bit_stream.c +1334 -0
- data/vendor/brotli/enc/brotli_bit_stream.h +95 -167
- data/vendor/brotli/enc/cluster.c +56 -0
- data/vendor/brotli/enc/cluster.h +23 -305
- data/vendor/brotli/enc/cluster_inc.h +315 -0
- data/vendor/brotli/enc/command.h +83 -76
- data/vendor/brotli/enc/compress_fragment.c +747 -0
- data/vendor/brotli/enc/compress_fragment.h +48 -37
- data/vendor/brotli/enc/compress_fragment_two_pass.c +557 -0
- data/vendor/brotli/enc/compress_fragment_two_pass.h +37 -26
- data/vendor/brotli/enc/compressor.cc +139 -0
- data/vendor/brotli/enc/compressor.h +146 -0
- data/vendor/brotli/enc/context.h +102 -96
- data/vendor/brotli/enc/dictionary_hash.h +9 -5
- data/vendor/brotli/enc/encode.c +1562 -0
- data/vendor/brotli/enc/encode.h +211 -199
- data/vendor/brotli/enc/encode_parallel.cc +161 -151
- data/vendor/brotli/enc/encode_parallel.h +7 -8
- data/vendor/brotli/enc/entropy_encode.c +501 -0
- data/vendor/brotli/enc/entropy_encode.h +107 -89
- data/vendor/brotli/enc/entropy_encode_static.h +29 -62
- data/vendor/brotli/enc/fast_log.h +26 -20
- data/vendor/brotli/enc/find_match_length.h +23 -20
- data/vendor/brotli/enc/hash.h +614 -871
- data/vendor/brotli/enc/hash_forgetful_chain_inc.h +249 -0
- data/vendor/brotli/enc/hash_longest_match_inc.h +241 -0
- data/vendor/brotli/enc/hash_longest_match_quickly_inc.h +230 -0
- data/vendor/brotli/enc/histogram.c +95 -0
- data/vendor/brotli/enc/histogram.h +49 -83
- data/vendor/brotli/enc/histogram_inc.h +51 -0
- data/vendor/brotli/enc/literal_cost.c +178 -0
- data/vendor/brotli/enc/literal_cost.h +16 -10
- data/vendor/brotli/enc/memory.c +181 -0
- data/vendor/brotli/enc/memory.h +62 -0
- data/vendor/brotli/enc/metablock.c +515 -0
- data/vendor/brotli/enc/metablock.h +87 -57
- data/vendor/brotli/enc/metablock_inc.h +183 -0
- data/vendor/brotli/enc/port.h +73 -47
- data/vendor/brotli/enc/prefix.h +34 -61
- data/vendor/brotli/enc/quality.h +130 -0
- data/vendor/brotli/enc/ringbuffer.h +137 -122
- data/vendor/brotli/enc/{static_dict.cc → static_dict.c} +162 -139
- data/vendor/brotli/enc/static_dict.h +23 -18
- data/vendor/brotli/enc/static_dict_lut.h +11223 -12037
- data/vendor/brotli/enc/streams.cc +7 -7
- data/vendor/brotli/enc/streams.h +32 -32
- data/vendor/brotli/enc/{utf8_util.cc → utf8_util.c} +22 -20
- data/vendor/brotli/enc/utf8_util.h +16 -9
- data/vendor/brotli/enc/write_bits.h +49 -43
- metadata +34 -25
- data/ext/brotli/brotli.cc +0 -181
- data/vendor/brotli/dec/Makefile +0 -12
- data/vendor/brotli/dec/dictionary.c +0 -9466
- data/vendor/brotli/dec/dictionary.h +0 -38
- data/vendor/brotli/dec/types.h +0 -38
- data/vendor/brotli/enc/Makefile +0 -14
- data/vendor/brotli/enc/backward_references.cc +0 -858
- data/vendor/brotli/enc/block_splitter.cc +0 -505
- data/vendor/brotli/enc/brotli_bit_stream.cc +0 -1181
- data/vendor/brotli/enc/compress_fragment.cc +0 -701
- data/vendor/brotli/enc/compress_fragment_two_pass.cc +0 -524
- data/vendor/brotli/enc/dictionary.cc +0 -9466
- data/vendor/brotli/enc/dictionary.h +0 -41
- data/vendor/brotli/enc/encode.cc +0 -1180
- data/vendor/brotli/enc/entropy_encode.cc +0 -480
- data/vendor/brotli/enc/histogram.cc +0 -67
- data/vendor/brotli/enc/literal_cost.cc +0 -165
- data/vendor/brotli/enc/metablock.cc +0 -539
- data/vendor/brotli/enc/transform.h +0 -248
- data/vendor/brotli/enc/types.h +0 -29
@@ -11,8 +11,8 @@
|
|
11
11
|
|
12
12
|
#include <string.h> /* memcpy */
|
13
13
|
|
14
|
+
#include "../common/types.h"
|
14
15
|
#include "./port.h"
|
15
|
-
#include "./types.h"
|
16
16
|
|
17
17
|
#if defined(__cplusplus) || defined(c_plusplus)
|
18
18
|
extern "C" {
|
@@ -68,7 +68,7 @@ BROTLI_INTERNAL void BrotliInitBitReader(BrotliBitReader* const br);
|
|
68
68
|
Returns 0 if data is required but there is no input available.
|
69
69
|
For BROTLI_ALIGNED_READ this function also prepares bit reader for aligned
|
70
70
|
reading. */
|
71
|
-
BROTLI_INTERNAL
|
71
|
+
BROTLI_INTERNAL BROTLI_BOOL BrotliWarmupBitReader(BrotliBitReader* const br);
|
72
72
|
|
73
73
|
static BROTLI_INLINE void BrotliBitReaderSaveState(
|
74
74
|
BrotliBitReader* const from, BrotliBitReaderState* to) {
|
@@ -99,9 +99,9 @@ static BROTLI_INLINE size_t BrotliGetRemainingBytes(BrotliBitReader* br) {
|
|
99
99
|
|
100
100
|
/* Checks if there is at least num bytes left in the input ringbuffer (excluding
|
101
101
|
the bits remaining in br->val_). */
|
102
|
-
static BROTLI_INLINE
|
102
|
+
static BROTLI_INLINE BROTLI_BOOL BrotliCheckInputAmount(
|
103
103
|
BrotliBitReader* const br, size_t num) {
|
104
|
-
return br->avail_in >= num;
|
104
|
+
return TO_BROTLI_BOOL(br->avail_in >= num);
|
105
105
|
}
|
106
106
|
|
107
107
|
static BROTLI_INLINE uint16_t BrotliLoad16LE(const uint8_t* in) {
|
@@ -220,9 +220,9 @@ static BROTLI_INLINE void BrotliFillBitWindow16(BrotliBitReader* const br) {
|
|
220
220
|
}
|
221
221
|
|
222
222
|
/* Pulls one byte of input to accumulator. */
|
223
|
-
static BROTLI_INLINE
|
223
|
+
static BROTLI_INLINE BROTLI_BOOL BrotliPullByte(BrotliBitReader* const br) {
|
224
224
|
if (br->avail_in == 0) {
|
225
|
-
return
|
225
|
+
return BROTLI_FALSE;
|
226
226
|
}
|
227
227
|
br->val_ >>= 8;
|
228
228
|
#if (BROTLI_64_BITS)
|
@@ -233,7 +233,7 @@ static BROTLI_INLINE int BrotliPullByte(BrotliBitReader* const br) {
|
|
233
233
|
br->bit_pos_ -= 8;
|
234
234
|
--br->avail_in;
|
235
235
|
++br->next_in;
|
236
|
-
return
|
236
|
+
return BROTLI_TRUE;
|
237
237
|
}
|
238
238
|
|
239
239
|
/* Returns currently available bits.
|
@@ -259,15 +259,15 @@ static BROTLI_INLINE uint32_t BrotliGetBits(
|
|
259
259
|
|
260
260
|
/* Tries to peek the specified amount of bits. Returns 0, if there is not
|
261
261
|
enough input. */
|
262
|
-
static BROTLI_INLINE
|
262
|
+
static BROTLI_INLINE BROTLI_BOOL BrotliSafeGetBits(
|
263
263
|
BrotliBitReader* const br, uint32_t n_bits, uint32_t* val) {
|
264
264
|
while (BrotliGetAvailableBits(br) < n_bits) {
|
265
265
|
if (!BrotliPullByte(br)) {
|
266
|
-
return
|
266
|
+
return BROTLI_FALSE;
|
267
267
|
}
|
268
268
|
}
|
269
269
|
*val = (uint32_t)BrotliGetBitsUnmasked(br) & BitMask(n_bits);
|
270
|
-
return
|
270
|
+
return BROTLI_TRUE;
|
271
271
|
}
|
272
272
|
|
273
273
|
/* Advances the bit pos by n_bits. */
|
@@ -321,26 +321,26 @@ static BROTLI_INLINE uint32_t BrotliReadBits(
|
|
321
321
|
|
322
322
|
/* Tries to read the specified amount of bits. Returns 0, if there is not
|
323
323
|
enough input. n_bits MUST be positive. */
|
324
|
-
static BROTLI_INLINE
|
324
|
+
static BROTLI_INLINE BROTLI_BOOL BrotliSafeReadBits(
|
325
325
|
BrotliBitReader* const br, uint32_t n_bits, uint32_t* val) {
|
326
326
|
while (BrotliGetAvailableBits(br) < n_bits) {
|
327
327
|
if (!BrotliPullByte(br)) {
|
328
|
-
return
|
328
|
+
return BROTLI_FALSE;
|
329
329
|
}
|
330
330
|
}
|
331
331
|
BrotliTakeBits(br, n_bits, val);
|
332
|
-
return
|
332
|
+
return BROTLI_TRUE;
|
333
333
|
}
|
334
334
|
|
335
335
|
/* Advances the bit reader position to the next byte boundary and verifies
|
336
336
|
that any skipped bits are set to zero. */
|
337
|
-
static BROTLI_INLINE
|
337
|
+
static BROTLI_INLINE BROTLI_BOOL BrotliJumpToByteBoundary(BrotliBitReader* br) {
|
338
338
|
uint32_t pad_bits_count = BrotliGetAvailableBits(br) & 0x7;
|
339
339
|
uint32_t pad_bits = 0;
|
340
340
|
if (pad_bits_count != 0) {
|
341
341
|
BrotliTakeBits(br, pad_bits_count, &pad_bits);
|
342
342
|
}
|
343
|
-
return pad_bits == 0;
|
343
|
+
return TO_BROTLI_BOOL(pad_bits == 0);
|
344
344
|
}
|
345
345
|
|
346
346
|
/* Peeks a byte at specified offset.
|