brotli 0.1.3 → 0.1.4

Sign up to get free protection for your applications and to get access to all the features.
Files changed (102) hide show
  1. checksums.yaml +4 -4
  2. data/.gitignore +3 -0
  3. data/.travis.yml +11 -3
  4. data/Gemfile +2 -0
  5. data/ext/brotli/brotli.c +279 -0
  6. data/ext/brotli/brotli.h +2 -0
  7. data/ext/brotli/buffer.c +95 -0
  8. data/ext/brotli/buffer.h +19 -0
  9. data/ext/brotli/extconf.rb +21 -81
  10. data/lib/brotli/version.rb +1 -1
  11. data/vendor/brotli/dec/bit_reader.c +5 -5
  12. data/vendor/brotli/dec/bit_reader.h +15 -15
  13. data/vendor/brotli/dec/context.h +1 -1
  14. data/vendor/brotli/dec/decode.c +433 -348
  15. data/vendor/brotli/dec/decode.h +74 -48
  16. data/vendor/brotli/dec/huffman.c +5 -4
  17. data/vendor/brotli/dec/huffman.h +4 -4
  18. data/vendor/brotli/dec/port.h +2 -95
  19. data/vendor/brotli/dec/prefix.h +5 -3
  20. data/vendor/brotli/dec/state.c +15 -27
  21. data/vendor/brotli/dec/state.h +21 -17
  22. data/vendor/brotli/dec/transform.h +1 -1
  23. data/vendor/brotli/enc/backward_references.c +892 -0
  24. data/vendor/brotli/enc/backward_references.h +85 -102
  25. data/vendor/brotli/enc/backward_references_inc.h +147 -0
  26. data/vendor/brotli/enc/bit_cost.c +35 -0
  27. data/vendor/brotli/enc/bit_cost.h +23 -121
  28. data/vendor/brotli/enc/bit_cost_inc.h +127 -0
  29. data/vendor/brotli/enc/block_encoder_inc.h +33 -0
  30. data/vendor/brotli/enc/block_splitter.c +197 -0
  31. data/vendor/brotli/enc/block_splitter.h +40 -50
  32. data/vendor/brotli/enc/block_splitter_inc.h +432 -0
  33. data/vendor/brotli/enc/brotli_bit_stream.c +1334 -0
  34. data/vendor/brotli/enc/brotli_bit_stream.h +95 -167
  35. data/vendor/brotli/enc/cluster.c +56 -0
  36. data/vendor/brotli/enc/cluster.h +23 -305
  37. data/vendor/brotli/enc/cluster_inc.h +315 -0
  38. data/vendor/brotli/enc/command.h +83 -76
  39. data/vendor/brotli/enc/compress_fragment.c +747 -0
  40. data/vendor/brotli/enc/compress_fragment.h +48 -37
  41. data/vendor/brotli/enc/compress_fragment_two_pass.c +557 -0
  42. data/vendor/brotli/enc/compress_fragment_two_pass.h +37 -26
  43. data/vendor/brotli/enc/compressor.cc +139 -0
  44. data/vendor/brotli/enc/compressor.h +146 -0
  45. data/vendor/brotli/enc/context.h +102 -96
  46. data/vendor/brotli/enc/dictionary_hash.h +9 -5
  47. data/vendor/brotli/enc/encode.c +1562 -0
  48. data/vendor/brotli/enc/encode.h +211 -199
  49. data/vendor/brotli/enc/encode_parallel.cc +161 -151
  50. data/vendor/brotli/enc/encode_parallel.h +7 -8
  51. data/vendor/brotli/enc/entropy_encode.c +501 -0
  52. data/vendor/brotli/enc/entropy_encode.h +107 -89
  53. data/vendor/brotli/enc/entropy_encode_static.h +29 -62
  54. data/vendor/brotli/enc/fast_log.h +26 -20
  55. data/vendor/brotli/enc/find_match_length.h +23 -20
  56. data/vendor/brotli/enc/hash.h +614 -871
  57. data/vendor/brotli/enc/hash_forgetful_chain_inc.h +249 -0
  58. data/vendor/brotli/enc/hash_longest_match_inc.h +241 -0
  59. data/vendor/brotli/enc/hash_longest_match_quickly_inc.h +230 -0
  60. data/vendor/brotli/enc/histogram.c +95 -0
  61. data/vendor/brotli/enc/histogram.h +49 -83
  62. data/vendor/brotli/enc/histogram_inc.h +51 -0
  63. data/vendor/brotli/enc/literal_cost.c +178 -0
  64. data/vendor/brotli/enc/literal_cost.h +16 -10
  65. data/vendor/brotli/enc/memory.c +181 -0
  66. data/vendor/brotli/enc/memory.h +62 -0
  67. data/vendor/brotli/enc/metablock.c +515 -0
  68. data/vendor/brotli/enc/metablock.h +87 -57
  69. data/vendor/brotli/enc/metablock_inc.h +183 -0
  70. data/vendor/brotli/enc/port.h +73 -47
  71. data/vendor/brotli/enc/prefix.h +34 -61
  72. data/vendor/brotli/enc/quality.h +130 -0
  73. data/vendor/brotli/enc/ringbuffer.h +137 -122
  74. data/vendor/brotli/enc/{static_dict.cc → static_dict.c} +162 -139
  75. data/vendor/brotli/enc/static_dict.h +23 -18
  76. data/vendor/brotli/enc/static_dict_lut.h +11223 -12037
  77. data/vendor/brotli/enc/streams.cc +7 -7
  78. data/vendor/brotli/enc/streams.h +32 -32
  79. data/vendor/brotli/enc/{utf8_util.cc → utf8_util.c} +22 -20
  80. data/vendor/brotli/enc/utf8_util.h +16 -9
  81. data/vendor/brotli/enc/write_bits.h +49 -43
  82. metadata +34 -25
  83. data/ext/brotli/brotli.cc +0 -181
  84. data/vendor/brotli/dec/Makefile +0 -12
  85. data/vendor/brotli/dec/dictionary.c +0 -9466
  86. data/vendor/brotli/dec/dictionary.h +0 -38
  87. data/vendor/brotli/dec/types.h +0 -38
  88. data/vendor/brotli/enc/Makefile +0 -14
  89. data/vendor/brotli/enc/backward_references.cc +0 -858
  90. data/vendor/brotli/enc/block_splitter.cc +0 -505
  91. data/vendor/brotli/enc/brotli_bit_stream.cc +0 -1181
  92. data/vendor/brotli/enc/compress_fragment.cc +0 -701
  93. data/vendor/brotli/enc/compress_fragment_two_pass.cc +0 -524
  94. data/vendor/brotli/enc/dictionary.cc +0 -9466
  95. data/vendor/brotli/enc/dictionary.h +0 -41
  96. data/vendor/brotli/enc/encode.cc +0 -1180
  97. data/vendor/brotli/enc/entropy_encode.cc +0 -480
  98. data/vendor/brotli/enc/histogram.cc +0 -67
  99. data/vendor/brotli/enc/literal_cost.cc +0 -165
  100. data/vendor/brotli/enc/metablock.cc +0 -539
  101. data/vendor/brotli/enc/transform.h +0 -248
  102. 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 int BrotliWarmupBitReader(BrotliBitReader* const br);
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 int BrotliCheckInputAmount(
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 int BrotliPullByte(BrotliBitReader* const br) {
223
+ static BROTLI_INLINE BROTLI_BOOL BrotliPullByte(BrotliBitReader* const br) {
224
224
  if (br->avail_in == 0) {
225
- return 0;
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 1;
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 int BrotliSafeGetBits(
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 0;
266
+ return BROTLI_FALSE;
267
267
  }
268
268
  }
269
269
  *val = (uint32_t)BrotliGetBitsUnmasked(br) & BitMask(n_bits);
270
- return 1;
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 int BrotliSafeReadBits(
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 0;
328
+ return BROTLI_FALSE;
329
329
  }
330
330
  }
331
331
  BrotliTakeBits(br, n_bits, val);
332
- return 1;
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 int BrotliJumpToByteBoundary(BrotliBitReader* br) {
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.
@@ -99,7 +99,7 @@
99
99
  #ifndef BROTLI_DEC_CONTEXT_H_
100
100
  #define BROTLI_DEC_CONTEXT_H_
101
101
 
102
- #include "./types.h"
102
+ #include "../common/types.h"
103
103
 
104
104
  enum ContextType {
105
105
  CONTEXT_LSB6 = 0,