brotli 0.2.3 → 0.5.0

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.
Files changed (124) hide show
  1. checksums.yaml +4 -4
  2. data/.github/workflows/main.yml +37 -0
  3. data/.github/workflows/publish.yml +24 -0
  4. data/.gitmodules +1 -1
  5. data/Gemfile +6 -3
  6. data/README.md +2 -2
  7. data/Rakefile +16 -9
  8. data/brotli.gemspec +7 -13
  9. data/ext/brotli/brotli.c +210 -31
  10. data/ext/brotli/buffer.c +1 -7
  11. data/ext/brotli/buffer.h +1 -1
  12. data/ext/brotli/extconf.rb +25 -17
  13. data/lib/brotli/version.rb +1 -1
  14. data/test/brotli_test.rb +107 -0
  15. data/test/brotli_writer_test.rb +36 -0
  16. data/test/test_helper.rb +8 -0
  17. data/vendor/brotli/c/common/constants.c +15 -0
  18. data/vendor/brotli/c/common/constants.h +137 -0
  19. data/vendor/brotli/c/common/context.c +156 -0
  20. data/vendor/brotli/c/common/context.h +4 -152
  21. data/vendor/brotli/c/common/dictionary.bin.br +0 -0
  22. data/vendor/brotli/c/common/dictionary.c +14 -3
  23. data/vendor/brotli/c/common/platform.c +23 -0
  24. data/vendor/brotli/c/common/platform.h +95 -122
  25. data/vendor/brotli/c/common/shared_dictionary.c +521 -0
  26. data/vendor/brotli/c/common/shared_dictionary_internal.h +75 -0
  27. data/vendor/brotli/c/common/transform.c +60 -4
  28. data/vendor/brotli/c/common/transform.h +5 -0
  29. data/vendor/brotli/c/common/version.h +31 -6
  30. data/vendor/brotli/c/dec/bit_reader.c +34 -4
  31. data/vendor/brotli/c/dec/bit_reader.h +221 -107
  32. data/vendor/brotli/c/dec/decode.c +772 -403
  33. data/vendor/brotli/c/dec/huffman.c +7 -4
  34. data/vendor/brotli/c/dec/huffman.h +8 -13
  35. data/vendor/brotli/c/dec/prefix.h +1 -18
  36. data/vendor/brotli/c/dec/state.c +40 -21
  37. data/vendor/brotli/c/dec/state.h +201 -59
  38. data/vendor/brotli/c/enc/backward_references.c +88 -25
  39. data/vendor/brotli/c/enc/backward_references.h +10 -8
  40. data/vendor/brotli/c/enc/backward_references_hq.c +194 -80
  41. data/vendor/brotli/c/enc/backward_references_hq.h +17 -13
  42. data/vendor/brotli/c/enc/backward_references_inc.h +52 -16
  43. data/vendor/brotli/c/enc/bit_cost.c +8 -7
  44. data/vendor/brotli/c/enc/bit_cost.h +5 -4
  45. data/vendor/brotli/c/enc/block_splitter.c +40 -17
  46. data/vendor/brotli/c/enc/block_splitter.h +5 -4
  47. data/vendor/brotli/c/enc/block_splitter_inc.h +99 -49
  48. data/vendor/brotli/c/enc/brotli_bit_stream.c +142 -137
  49. data/vendor/brotli/c/enc/brotli_bit_stream.h +11 -6
  50. data/vendor/brotli/c/enc/cluster.c +10 -9
  51. data/vendor/brotli/c/enc/cluster.h +7 -6
  52. data/vendor/brotli/c/enc/cluster_inc.h +30 -22
  53. data/vendor/brotli/c/enc/command.c +28 -0
  54. data/vendor/brotli/c/enc/command.h +17 -16
  55. data/vendor/brotli/c/enc/compound_dictionary.c +207 -0
  56. data/vendor/brotli/c/enc/compound_dictionary.h +74 -0
  57. data/vendor/brotli/c/enc/compress_fragment.c +93 -83
  58. data/vendor/brotli/c/enc/compress_fragment.h +32 -7
  59. data/vendor/brotli/c/enc/compress_fragment_two_pass.c +100 -88
  60. data/vendor/brotli/c/enc/compress_fragment_two_pass.h +21 -3
  61. data/vendor/brotli/c/enc/dictionary_hash.c +1829 -1101
  62. data/vendor/brotli/c/enc/dictionary_hash.h +2 -1
  63. data/vendor/brotli/c/enc/encode.c +550 -416
  64. data/vendor/brotli/c/enc/encoder_dict.c +613 -5
  65. data/vendor/brotli/c/enc/encoder_dict.h +120 -4
  66. data/vendor/brotli/c/enc/entropy_encode.c +5 -2
  67. data/vendor/brotli/c/enc/entropy_encode.h +4 -3
  68. data/vendor/brotli/c/enc/entropy_encode_static.h +5 -2
  69. data/vendor/brotli/c/enc/fast_log.c +105 -0
  70. data/vendor/brotli/c/enc/fast_log.h +21 -101
  71. data/vendor/brotli/c/enc/find_match_length.h +17 -25
  72. data/vendor/brotli/c/enc/hash.h +350 -120
  73. data/vendor/brotli/c/enc/hash_composite_inc.h +71 -67
  74. data/vendor/brotli/c/enc/hash_forgetful_chain_inc.h +92 -51
  75. data/vendor/brotli/c/enc/hash_longest_match64_inc.h +79 -84
  76. data/vendor/brotli/c/enc/hash_longest_match_inc.h +53 -54
  77. data/vendor/brotli/c/enc/hash_longest_match_quickly_inc.h +93 -62
  78. data/vendor/brotli/c/enc/hash_rolling_inc.h +25 -29
  79. data/vendor/brotli/c/enc/hash_to_binary_tree_inc.h +42 -40
  80. data/vendor/brotli/c/enc/histogram.c +4 -4
  81. data/vendor/brotli/c/enc/histogram.h +7 -6
  82. data/vendor/brotli/c/enc/literal_cost.c +20 -15
  83. data/vendor/brotli/c/enc/literal_cost.h +4 -2
  84. data/vendor/brotli/c/enc/memory.c +29 -5
  85. data/vendor/brotli/c/enc/memory.h +43 -14
  86. data/vendor/brotli/c/enc/metablock.c +95 -85
  87. data/vendor/brotli/c/enc/metablock.h +9 -8
  88. data/vendor/brotli/c/enc/metablock_inc.h +9 -7
  89. data/vendor/brotli/c/enc/params.h +7 -4
  90. data/vendor/brotli/c/enc/prefix.h +3 -2
  91. data/vendor/brotli/c/enc/quality.h +40 -3
  92. data/vendor/brotli/c/enc/ringbuffer.h +8 -4
  93. data/vendor/brotli/c/enc/state.h +104 -0
  94. data/vendor/brotli/c/enc/static_dict.c +60 -4
  95. data/vendor/brotli/c/enc/static_dict.h +3 -2
  96. data/vendor/brotli/c/enc/static_dict_lut.h +2 -0
  97. data/vendor/brotli/c/enc/utf8_util.c +2 -2
  98. data/vendor/brotli/c/enc/utf8_util.h +2 -1
  99. data/vendor/brotli/c/enc/write_bits.h +29 -26
  100. data/vendor/brotli/c/include/brotli/decode.h +67 -2
  101. data/vendor/brotli/c/include/brotli/encode.h +77 -3
  102. data/vendor/brotli/c/include/brotli/port.h +34 -3
  103. data/vendor/brotli/c/include/brotli/shared_dictionary.h +100 -0
  104. metadata +23 -97
  105. data/.travis.yml +0 -31
  106. data/docs/Brotli/Error.html +0 -124
  107. data/docs/Brotli.html +0 -485
  108. data/docs/_index.html +0 -122
  109. data/docs/class_list.html +0 -51
  110. data/docs/css/common.css +0 -1
  111. data/docs/css/full_list.css +0 -58
  112. data/docs/css/style.css +0 -496
  113. data/docs/file.README.html +0 -127
  114. data/docs/file_list.html +0 -56
  115. data/docs/frames.html +0 -17
  116. data/docs/index.html +0 -127
  117. data/docs/js/app.js +0 -292
  118. data/docs/js/full_list.js +0 -216
  119. data/docs/js/jquery.js +0 -4
  120. data/docs/method_list.html +0 -67
  121. data/docs/top-level-namespace.html +0 -110
  122. data/spec/brotli_spec.rb +0 -88
  123. data/spec/inflate_spec.rb +0 -75
  124. data/spec/spec_helper.rb +0 -4
@@ -6,16 +6,19 @@
6
6
 
7
7
  /* Function to find backward reference copies. */
8
8
 
9
- #include "./backward_references.h"
9
+ #include "backward_references.h"
10
+
11
+ #include <brotli/types.h>
10
12
 
11
13
  #include "../common/constants.h"
12
14
  #include "../common/dictionary.h"
13
15
  #include "../common/platform.h"
14
- #include <brotli/types.h>
15
- #include "./command.h"
16
- #include "./dictionary_hash.h"
17
- #include "./memory.h"
18
- #include "./quality.h"
16
+ #include "command.h"
17
+ #include "compound_dictionary.h"
18
+ #include "dictionary_hash.h"
19
+ #include "encoder_dict.h"
20
+ #include "memory.h"
21
+ #include "quality.h"
19
22
 
20
23
  #if defined(__cplusplus) || defined(c_plusplus)
21
24
  extern "C" {
@@ -51,67 +54,103 @@ static BROTLI_INLINE size_t ComputeDistanceCode(size_t distance,
51
54
  #define EXPORT_FN(X) EXPAND_CAT(X, EXPAND_CAT(PREFIX(), HASHER()))
52
55
 
53
56
  #define PREFIX() N
57
+ #define ENABLE_COMPOUND_DICTIONARY 0
54
58
 
55
59
  #define HASHER() H2
56
60
  /* NOLINTNEXTLINE(build/include) */
57
- #include "./backward_references_inc.h"
61
+ #include "backward_references_inc.h"
58
62
  #undef HASHER
59
63
 
60
64
  #define HASHER() H3
61
65
  /* NOLINTNEXTLINE(build/include) */
62
- #include "./backward_references_inc.h"
66
+ #include "backward_references_inc.h"
63
67
  #undef HASHER
64
68
 
65
69
  #define HASHER() H4
66
70
  /* NOLINTNEXTLINE(build/include) */
67
- #include "./backward_references_inc.h"
71
+ #include "backward_references_inc.h"
68
72
  #undef HASHER
69
73
 
70
74
  #define HASHER() H5
71
75
  /* NOLINTNEXTLINE(build/include) */
72
- #include "./backward_references_inc.h"
76
+ #include "backward_references_inc.h"
73
77
  #undef HASHER
74
78
 
75
79
  #define HASHER() H6
76
80
  /* NOLINTNEXTLINE(build/include) */
77
- #include "./backward_references_inc.h"
81
+ #include "backward_references_inc.h"
78
82
  #undef HASHER
79
83
 
80
84
  #define HASHER() H40
81
85
  /* NOLINTNEXTLINE(build/include) */
82
- #include "./backward_references_inc.h"
86
+ #include "backward_references_inc.h"
83
87
  #undef HASHER
84
88
 
85
89
  #define HASHER() H41
86
90
  /* NOLINTNEXTLINE(build/include) */
87
- #include "./backward_references_inc.h"
91
+ #include "backward_references_inc.h"
88
92
  #undef HASHER
89
93
 
90
94
  #define HASHER() H42
91
95
  /* NOLINTNEXTLINE(build/include) */
92
- #include "./backward_references_inc.h"
96
+ #include "backward_references_inc.h"
93
97
  #undef HASHER
94
98
 
95
99
  #define HASHER() H54
96
100
  /* NOLINTNEXTLINE(build/include) */
97
- #include "./backward_references_inc.h"
101
+ #include "backward_references_inc.h"
98
102
  #undef HASHER
99
103
 
100
104
  #define HASHER() H35
101
105
  /* NOLINTNEXTLINE(build/include) */
102
- #include "./backward_references_inc.h"
106
+ #include "backward_references_inc.h"
103
107
  #undef HASHER
104
108
 
105
109
  #define HASHER() H55
106
110
  /* NOLINTNEXTLINE(build/include) */
107
- #include "./backward_references_inc.h"
111
+ #include "backward_references_inc.h"
108
112
  #undef HASHER
109
113
 
110
114
  #define HASHER() H65
111
115
  /* NOLINTNEXTLINE(build/include) */
112
- #include "./backward_references_inc.h"
116
+ #include "backward_references_inc.h"
113
117
  #undef HASHER
114
118
 
119
+ #undef ENABLE_COMPOUND_DICTIONARY
120
+ #undef PREFIX
121
+ #define PREFIX() D
122
+ #define ENABLE_COMPOUND_DICTIONARY 1
123
+
124
+ #define HASHER() H5
125
+ /* NOLINTNEXTLINE(build/include) */
126
+ #include "backward_references_inc.h"
127
+ #undef HASHER
128
+ #define HASHER() H6
129
+ /* NOLINTNEXTLINE(build/include) */
130
+ #include "backward_references_inc.h"
131
+ #undef HASHER
132
+ #define HASHER() H40
133
+ /* NOLINTNEXTLINE(build/include) */
134
+ #include "backward_references_inc.h"
135
+ #undef HASHER
136
+ #define HASHER() H41
137
+ /* NOLINTNEXTLINE(build/include) */
138
+ #include "backward_references_inc.h"
139
+ #undef HASHER
140
+ #define HASHER() H42
141
+ /* NOLINTNEXTLINE(build/include) */
142
+ #include "backward_references_inc.h"
143
+ #undef HASHER
144
+ #define HASHER() H55
145
+ /* NOLINTNEXTLINE(build/include) */
146
+ #include "backward_references_inc.h"
147
+ #undef HASHER
148
+ #define HASHER() H65
149
+ /* NOLINTNEXTLINE(build/include) */
150
+ #include "backward_references_inc.h"
151
+ #undef HASHER
152
+
153
+ #undef ENABLE_COMPOUND_DICTIONARY
115
154
  #undef PREFIX
116
155
 
117
156
  #undef EXPORT_FN
@@ -119,22 +158,46 @@ static BROTLI_INLINE size_t ComputeDistanceCode(size_t distance,
119
158
  #undef CAT
120
159
  #undef EXPAND_CAT
121
160
 
122
- void BrotliCreateBackwardReferences(
123
- size_t num_bytes, size_t position, const uint8_t* ringbuffer,
124
- size_t ringbuffer_mask, const BrotliEncoderParams* params,
125
- HasherHandle hasher, int* dist_cache, size_t* last_insert_len,
161
+ void BrotliCreateBackwardReferences(size_t num_bytes,
162
+ size_t position, const uint8_t* ringbuffer, size_t ringbuffer_mask,
163
+ ContextLut literal_context_lut, const BrotliEncoderParams* params,
164
+ Hasher* hasher, int* dist_cache, size_t* last_insert_len,
126
165
  Command* commands, size_t* num_commands, size_t* num_literals) {
166
+ if (params->dictionary.compound.num_chunks != 0) {
167
+ switch (params->hasher.type) {
168
+ #define CASE_(N) \
169
+ case N: \
170
+ CreateBackwardReferencesDH ## N(num_bytes, \
171
+ position, ringbuffer, ringbuffer_mask, \
172
+ literal_context_lut, params, hasher, dist_cache, \
173
+ last_insert_len, commands, num_commands, num_literals); \
174
+ return;
175
+ CASE_(5)
176
+ CASE_(6)
177
+ CASE_(40)
178
+ CASE_(41)
179
+ CASE_(42)
180
+ CASE_(55)
181
+ CASE_(65)
182
+ #undef CASE_
183
+ default:
184
+ BROTLI_DCHECK(false);
185
+ break;
186
+ }
187
+ }
188
+
127
189
  switch (params->hasher.type) {
128
190
  #define CASE_(N) \
129
191
  case N: \
130
- CreateBackwardReferencesNH ## N( \
131
- num_bytes, position, ringbuffer, \
132
- ringbuffer_mask, params, hasher, dist_cache, \
192
+ CreateBackwardReferencesNH ## N(num_bytes, \
193
+ position, ringbuffer, ringbuffer_mask, \
194
+ literal_context_lut, params, hasher, dist_cache, \
133
195
  last_insert_len, commands, num_commands, num_literals); \
134
196
  return;
135
197
  FOR_GENERIC_HASHERS(CASE_)
136
198
  #undef CASE_
137
199
  default:
200
+ BROTLI_DCHECK(false);
138
201
  break;
139
202
  }
140
203
  }
@@ -9,13 +9,15 @@
9
9
  #ifndef BROTLI_ENC_BACKWARD_REFERENCES_H_
10
10
  #define BROTLI_ENC_BACKWARD_REFERENCES_H_
11
11
 
12
+ #include <brotli/types.h>
13
+
12
14
  #include "../common/constants.h"
15
+ #include "../common/context.h"
13
16
  #include "../common/dictionary.h"
14
17
  #include "../common/platform.h"
15
- #include <brotli/types.h>
16
- #include "./command.h"
17
- #include "./hash.h"
18
- #include "./quality.h"
18
+ #include "command.h"
19
+ #include "hash.h"
20
+ #include "quality.h"
19
21
 
20
22
  #if defined(__cplusplus) || defined(c_plusplus)
21
23
  extern "C" {
@@ -25,10 +27,10 @@ extern "C" {
25
27
  initially the total amount of commands output by previous
26
28
  CreateBackwardReferences calls, and must be incremented by the amount written
27
29
  by this call. */
28
- BROTLI_INTERNAL void BrotliCreateBackwardReferences(
29
- size_t num_bytes, size_t position, const uint8_t* ringbuffer,
30
- size_t ringbuffer_mask, const BrotliEncoderParams* params,
31
- HasherHandle hasher, int* dist_cache, size_t* last_insert_len,
30
+ BROTLI_INTERNAL void BrotliCreateBackwardReferences(size_t num_bytes,
31
+ size_t position, const uint8_t* ringbuffer, size_t ringbuffer_mask,
32
+ ContextLut literal_context_lut, const BrotliEncoderParams* params,
33
+ Hasher* hasher, int* dist_cache, size_t* last_insert_len,
32
34
  Command* commands, size_t* num_commands, size_t* num_literals);
33
35
 
34
36
  #if defined(__cplusplus) || defined(c_plusplus)