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.
Files changed (212) hide show
  1. checksums.yaml +4 -4
  2. data/CHANGELOG.md +17 -3
  3. data/GET_STARTED.md +3 -3
  4. data/README.md +75 -66
  5. data/THIRD_PARTY_NOTICES.md +24 -0
  6. data/ext/multi_compress/brotli_dec_static_init.c +3 -0
  7. data/ext/multi_compress/brotli_enc_static_init.c +3 -0
  8. data/ext/multi_compress/extconf.rb +79 -3
  9. data/ext/multi_compress/multi_compress.c +199 -120
  10. data/ext/multi_compress/vendor/.vendored +2 -2
  11. data/ext/multi_compress/vendor/brotli/LICENSE +19 -0
  12. data/ext/multi_compress/vendor/brotli/c/common/constants.c +7 -7
  13. data/ext/multi_compress/vendor/brotli/c/common/constants.h +2 -5
  14. data/ext/multi_compress/vendor/brotli/c/common/context.c +2 -2
  15. data/ext/multi_compress/vendor/brotli/c/common/context.h +1 -2
  16. data/ext/multi_compress/vendor/brotli/c/common/dictionary.c +4 -5856
  17. data/ext/multi_compress/vendor/brotli/c/common/dictionary.h +1 -2
  18. data/ext/multi_compress/vendor/brotli/c/common/dictionary_inc.h +5847 -0
  19. data/ext/multi_compress/vendor/brotli/c/common/platform.c +0 -4
  20. data/ext/multi_compress/vendor/brotli/c/common/platform.h +182 -43
  21. data/ext/multi_compress/vendor/brotli/c/common/shared_dictionary.c +3 -7
  22. data/ext/multi_compress/vendor/brotli/c/common/shared_dictionary_internal.h +1 -1
  23. data/ext/multi_compress/vendor/brotli/c/common/static_init.h +56 -0
  24. data/ext/multi_compress/vendor/brotli/c/common/transform.c +6 -4
  25. data/ext/multi_compress/vendor/brotli/c/common/transform.h +1 -2
  26. data/ext/multi_compress/vendor/brotli/c/common/version.h +3 -3
  27. data/ext/multi_compress/vendor/brotli/c/dec/bit_reader.c +2 -3
  28. data/ext/multi_compress/vendor/brotli/c/dec/bit_reader.h +0 -4
  29. data/ext/multi_compress/vendor/brotli/c/dec/decode.c +128 -39
  30. data/ext/multi_compress/vendor/brotli/c/dec/huffman.c +2 -5
  31. data/ext/multi_compress/vendor/brotli/c/dec/huffman.h +0 -2
  32. data/ext/multi_compress/vendor/brotli/c/dec/prefix.c +67 -0
  33. data/ext/multi_compress/vendor/brotli/c/dec/prefix.h +18 -708
  34. data/ext/multi_compress/vendor/brotli/c/dec/prefix_inc.h +707 -0
  35. data/ext/multi_compress/vendor/brotli/c/dec/state.c +18 -15
  36. data/ext/multi_compress/vendor/brotli/c/dec/state.h +2 -6
  37. data/ext/multi_compress/vendor/brotli/c/dec/static_init.c +53 -0
  38. data/ext/multi_compress/vendor/brotli/c/dec/static_init.h +30 -0
  39. data/ext/multi_compress/vendor/brotli/c/enc/backward_references.c +32 -8
  40. data/ext/multi_compress/vendor/brotli/c/enc/backward_references.h +1 -5
  41. data/ext/multi_compress/vendor/brotli/c/enc/backward_references_hq.c +15 -15
  42. data/ext/multi_compress/vendor/brotli/c/enc/backward_references_hq.h +1 -5
  43. data/ext/multi_compress/vendor/brotli/c/enc/bit_cost.c +28 -4
  44. data/ext/multi_compress/vendor/brotli/c/enc/bit_cost.h +8 -40
  45. data/ext/multi_compress/vendor/brotli/c/enc/bit_cost_inc.h +1 -1
  46. data/ext/multi_compress/vendor/brotli/c/enc/block_splitter.c +9 -12
  47. data/ext/multi_compress/vendor/brotli/c/enc/block_splitter.h +0 -3
  48. data/ext/multi_compress/vendor/brotli/c/enc/block_splitter_inc.h +14 -8
  49. data/ext/multi_compress/vendor/brotli/c/enc/brotli_bit_stream.c +10 -9
  50. data/ext/multi_compress/vendor/brotli/c/enc/brotli_bit_stream.h +0 -6
  51. data/ext/multi_compress/vendor/brotli/c/enc/cluster.c +0 -2
  52. data/ext/multi_compress/vendor/brotli/c/enc/cluster.h +0 -2
  53. data/ext/multi_compress/vendor/brotli/c/enc/command.c +1 -1
  54. data/ext/multi_compress/vendor/brotli/c/enc/command.h +8 -10
  55. data/ext/multi_compress/vendor/brotli/c/enc/compound_dictionary.c +3 -5
  56. data/ext/multi_compress/vendor/brotli/c/enc/compound_dictionary.h +1 -4
  57. data/ext/multi_compress/vendor/brotli/c/enc/compress_fragment.c +3 -13
  58. data/ext/multi_compress/vendor/brotli/c/enc/compress_fragment.h +0 -2
  59. data/ext/multi_compress/vendor/brotli/c/enc/compress_fragment_two_pass.c +5 -15
  60. data/ext/multi_compress/vendor/brotli/c/enc/compress_fragment_two_pass.h +0 -2
  61. data/ext/multi_compress/vendor/brotli/c/enc/dictionary_hash.c +127 -1830
  62. data/ext/multi_compress/vendor/brotli/c/enc/dictionary_hash.h +23 -3
  63. data/ext/multi_compress/vendor/brotli/c/enc/dictionary_hash_inc.h +1829 -0
  64. data/ext/multi_compress/vendor/brotli/c/enc/encode.c +77 -52
  65. data/ext/multi_compress/vendor/brotli/c/enc/encoder_dict.c +9 -7
  66. data/ext/multi_compress/vendor/brotli/c/enc/encoder_dict.h +2 -4
  67. data/ext/multi_compress/vendor/brotli/c/enc/entropy_encode.c +3 -6
  68. data/ext/multi_compress/vendor/brotli/c/enc/entropy_encode.h +2 -4
  69. data/ext/multi_compress/vendor/brotli/c/enc/entropy_encode_static.h +18 -12
  70. data/ext/multi_compress/vendor/brotli/c/enc/fast_log.c +1 -1
  71. data/ext/multi_compress/vendor/brotli/c/enc/fast_log.h +2 -3
  72. data/ext/multi_compress/vendor/brotli/c/enc/find_match_length.h +0 -2
  73. data/ext/multi_compress/vendor/brotli/c/enc/hash.h +38 -31
  74. data/ext/multi_compress/vendor/brotli/c/enc/hash_base.h +38 -0
  75. data/ext/multi_compress/vendor/brotli/c/enc/hash_forgetful_chain_inc.h +11 -1
  76. data/ext/multi_compress/vendor/brotli/c/enc/hash_longest_match64_inc.h +24 -7
  77. data/ext/multi_compress/vendor/brotli/c/enc/hash_longest_match64_simd_inc.h +304 -0
  78. data/ext/multi_compress/vendor/brotli/c/enc/hash_longest_match_inc.h +30 -11
  79. data/ext/multi_compress/vendor/brotli/c/enc/hash_longest_match_quickly_inc.h +4 -0
  80. data/ext/multi_compress/vendor/brotli/c/enc/hash_longest_match_simd_inc.h +278 -0
  81. data/ext/multi_compress/vendor/brotli/c/enc/histogram.c +1 -0
  82. data/ext/multi_compress/vendor/brotli/c/enc/histogram.h +0 -4
  83. data/ext/multi_compress/vendor/brotli/c/enc/literal_cost.c +4 -6
  84. data/ext/multi_compress/vendor/brotli/c/enc/literal_cost.h +0 -2
  85. data/ext/multi_compress/vendor/brotli/c/enc/matching_tag_mask.h +69 -0
  86. data/ext/multi_compress/vendor/brotli/c/enc/memory.c +0 -5
  87. data/ext/multi_compress/vendor/brotli/c/enc/memory.h +0 -4
  88. data/ext/multi_compress/vendor/brotli/c/enc/metablock.c +7 -9
  89. data/ext/multi_compress/vendor/brotli/c/enc/metablock.h +3 -3
  90. data/ext/multi_compress/vendor/brotli/c/enc/metablock_inc.h +4 -4
  91. data/ext/multi_compress/vendor/brotli/c/enc/params.h +0 -1
  92. data/ext/multi_compress/vendor/brotli/c/enc/prefix.h +0 -2
  93. data/ext/multi_compress/vendor/brotli/c/enc/quality.h +17 -10
  94. data/ext/multi_compress/vendor/brotli/c/enc/ringbuffer.h +1 -4
  95. data/ext/multi_compress/vendor/brotli/c/enc/state.h +2 -2
  96. data/ext/multi_compress/vendor/brotli/c/enc/static_dict.c +5 -11
  97. data/ext/multi_compress/vendor/brotli/c/enc/static_dict.h +1 -3
  98. data/ext/multi_compress/vendor/brotli/c/enc/static_dict_lut.c +224 -0
  99. data/ext/multi_compress/vendor/brotli/c/enc/static_dict_lut.h +20 -5837
  100. data/ext/multi_compress/vendor/brotli/c/enc/static_dict_lut_inc.h +5830 -0
  101. data/ext/multi_compress/vendor/brotli/c/enc/static_init.c +59 -0
  102. data/ext/multi_compress/vendor/brotli/c/enc/static_init.h +30 -0
  103. data/ext/multi_compress/vendor/brotli/c/enc/static_init_lazy.cc +26 -0
  104. data/ext/multi_compress/vendor/brotli/c/enc/utf8_util.c +1 -1
  105. data/ext/multi_compress/vendor/brotli/c/enc/utf8_util.h +0 -2
  106. data/ext/multi_compress/vendor/brotli/c/enc/write_bits.h +0 -2
  107. data/ext/multi_compress/vendor/brotli/c/include/brotli/decode.h +1 -1
  108. data/ext/multi_compress/vendor/brotli/c/include/brotli/encode.h +5 -1
  109. data/ext/multi_compress/vendor/brotli/c/include/brotli/port.h +4 -7
  110. data/ext/multi_compress/vendor/brotli/c/include/brotli/types.h +2 -2
  111. data/ext/multi_compress/vendor/lz4/LICENSE +12 -0
  112. data/ext/multi_compress/vendor/zstd/COPYING +339 -0
  113. data/ext/multi_compress/vendor/zstd/LICENSE +30 -0
  114. data/ext/multi_compress/vendor/zstd/lib/Makefile +67 -35
  115. data/ext/multi_compress/vendor/zstd/lib/README.md +33 -2
  116. data/ext/multi_compress/vendor/zstd/lib/common/allocations.h +55 -0
  117. data/ext/multi_compress/vendor/zstd/lib/common/bits.h +205 -0
  118. data/ext/multi_compress/vendor/zstd/lib/common/bitstream.h +84 -108
  119. data/ext/multi_compress/vendor/zstd/lib/common/compiler.h +170 -41
  120. data/ext/multi_compress/vendor/zstd/lib/common/cpu.h +37 -1
  121. data/ext/multi_compress/vendor/zstd/lib/common/debug.c +7 -1
  122. data/ext/multi_compress/vendor/zstd/lib/common/debug.h +21 -21
  123. data/ext/multi_compress/vendor/zstd/lib/common/entropy_common.c +12 -40
  124. data/ext/multi_compress/vendor/zstd/lib/common/error_private.c +10 -2
  125. data/ext/multi_compress/vendor/zstd/lib/common/error_private.h +46 -47
  126. data/ext/multi_compress/vendor/zstd/lib/common/fse.h +8 -100
  127. data/ext/multi_compress/vendor/zstd/lib/common/fse_decompress.c +28 -116
  128. data/ext/multi_compress/vendor/zstd/lib/common/huf.h +79 -166
  129. data/ext/multi_compress/vendor/zstd/lib/common/mem.h +46 -66
  130. data/ext/multi_compress/vendor/zstd/lib/common/pool.c +27 -11
  131. data/ext/multi_compress/vendor/zstd/lib/common/pool.h +8 -11
  132. data/ext/multi_compress/vendor/zstd/lib/common/portability_macros.h +45 -11
  133. data/ext/multi_compress/vendor/zstd/lib/common/threading.c +74 -14
  134. data/ext/multi_compress/vendor/zstd/lib/common/threading.h +5 -18
  135. data/ext/multi_compress/vendor/zstd/lib/common/xxhash.c +5 -11
  136. data/ext/multi_compress/vendor/zstd/lib/common/xxhash.h +2411 -1003
  137. data/ext/multi_compress/vendor/zstd/lib/common/zstd_common.c +1 -36
  138. data/ext/multi_compress/vendor/zstd/lib/common/zstd_deps.h +13 -1
  139. data/ext/multi_compress/vendor/zstd/lib/common/zstd_internal.h +13 -182
  140. data/ext/multi_compress/vendor/zstd/lib/common/zstd_trace.h +6 -13
  141. data/ext/multi_compress/vendor/zstd/lib/compress/clevels.h +1 -1
  142. data/ext/multi_compress/vendor/zstd/lib/compress/fse_compress.c +15 -131
  143. data/ext/multi_compress/vendor/zstd/lib/compress/hist.c +11 -1
  144. data/ext/multi_compress/vendor/zstd/lib/compress/hist.h +8 -1
  145. data/ext/multi_compress/vendor/zstd/lib/compress/huf_compress.c +283 -189
  146. data/ext/multi_compress/vendor/zstd/lib/compress/zstd_compress.c +2419 -903
  147. data/ext/multi_compress/vendor/zstd/lib/compress/zstd_compress_internal.h +423 -245
  148. data/ext/multi_compress/vendor/zstd/lib/compress/zstd_compress_literals.c +116 -40
  149. data/ext/multi_compress/vendor/zstd/lib/compress/zstd_compress_literals.h +16 -8
  150. data/ext/multi_compress/vendor/zstd/lib/compress/zstd_compress_sequences.c +10 -10
  151. data/ext/multi_compress/vendor/zstd/lib/compress/zstd_compress_sequences.h +8 -7
  152. data/ext/multi_compress/vendor/zstd/lib/compress/zstd_compress_superblock.c +254 -139
  153. data/ext/multi_compress/vendor/zstd/lib/compress/zstd_compress_superblock.h +1 -1
  154. data/ext/multi_compress/vendor/zstd/lib/compress/zstd_cwksp.h +184 -95
  155. data/ext/multi_compress/vendor/zstd/lib/compress/zstd_double_fast.c +163 -81
  156. data/ext/multi_compress/vendor/zstd/lib/compress/zstd_double_fast.h +18 -14
  157. data/ext/multi_compress/vendor/zstd/lib/compress/zstd_fast.c +507 -197
  158. data/ext/multi_compress/vendor/zstd/lib/compress/zstd_fast.h +7 -14
  159. data/ext/multi_compress/vendor/zstd/lib/compress/zstd_lazy.c +579 -484
  160. data/ext/multi_compress/vendor/zstd/lib/compress/zstd_lazy.h +133 -65
  161. data/ext/multi_compress/vendor/zstd/lib/compress/zstd_ldm.c +61 -40
  162. data/ext/multi_compress/vendor/zstd/lib/compress/zstd_ldm.h +7 -15
  163. data/ext/multi_compress/vendor/zstd/lib/compress/zstd_ldm_geartab.h +1 -1
  164. data/ext/multi_compress/vendor/zstd/lib/compress/zstd_opt.c +352 -218
  165. data/ext/multi_compress/vendor/zstd/lib/compress/zstd_opt.h +37 -21
  166. data/ext/multi_compress/vendor/zstd/lib/compress/zstd_preSplit.c +238 -0
  167. data/ext/multi_compress/vendor/zstd/lib/compress/zstd_preSplit.h +33 -0
  168. data/ext/multi_compress/vendor/zstd/lib/compress/zstdmt_compress.c +239 -175
  169. data/ext/multi_compress/vendor/zstd/lib/compress/zstdmt_compress.h +5 -16
  170. data/ext/multi_compress/vendor/zstd/lib/decompress/huf_decompress.c +543 -488
  171. data/ext/multi_compress/vendor/zstd/lib/decompress/huf_decompress_amd64.S +78 -61
  172. data/ext/multi_compress/vendor/zstd/lib/decompress/zstd_ddict.c +4 -4
  173. data/ext/multi_compress/vendor/zstd/lib/decompress/zstd_ddict.h +1 -1
  174. data/ext/multi_compress/vendor/zstd/lib/decompress/zstd_decompress.c +295 -115
  175. data/ext/multi_compress/vendor/zstd/lib/decompress/zstd_decompress_block.c +430 -293
  176. data/ext/multi_compress/vendor/zstd/lib/decompress/zstd_decompress_block.h +7 -2
  177. data/ext/multi_compress/vendor/zstd/lib/decompress/zstd_decompress_internal.h +11 -7
  178. data/ext/multi_compress/vendor/zstd/lib/deprecated/zbuff.h +1 -1
  179. data/ext/multi_compress/vendor/zstd/lib/deprecated/zbuff_common.c +1 -1
  180. data/ext/multi_compress/vendor/zstd/lib/deprecated/zbuff_compress.c +1 -1
  181. data/ext/multi_compress/vendor/zstd/lib/deprecated/zbuff_decompress.c +3 -1
  182. data/ext/multi_compress/vendor/zstd/lib/dictBuilder/cover.c +95 -46
  183. data/ext/multi_compress/vendor/zstd/lib/dictBuilder/cover.h +3 -9
  184. data/ext/multi_compress/vendor/zstd/lib/dictBuilder/divsufsort.h +0 -10
  185. data/ext/multi_compress/vendor/zstd/lib/dictBuilder/fastcover.c +4 -4
  186. data/ext/multi_compress/vendor/zstd/lib/dictBuilder/zdict.c +25 -97
  187. data/ext/multi_compress/vendor/zstd/lib/dll/example/Makefile +1 -1
  188. data/ext/multi_compress/vendor/zstd/lib/dll/example/README.md +1 -1
  189. data/ext/multi_compress/vendor/zstd/lib/legacy/zstd_legacy.h +38 -1
  190. data/ext/multi_compress/vendor/zstd/lib/legacy/zstd_v01.c +19 -50
  191. data/ext/multi_compress/vendor/zstd/lib/legacy/zstd_v01.h +1 -1
  192. data/ext/multi_compress/vendor/zstd/lib/legacy/zstd_v02.c +27 -80
  193. data/ext/multi_compress/vendor/zstd/lib/legacy/zstd_v02.h +1 -1
  194. data/ext/multi_compress/vendor/zstd/lib/legacy/zstd_v03.c +28 -83
  195. data/ext/multi_compress/vendor/zstd/lib/legacy/zstd_v03.h +1 -1
  196. data/ext/multi_compress/vendor/zstd/lib/legacy/zstd_v04.c +25 -74
  197. data/ext/multi_compress/vendor/zstd/lib/legacy/zstd_v04.h +1 -1
  198. data/ext/multi_compress/vendor/zstd/lib/legacy/zstd_v05.c +31 -76
  199. data/ext/multi_compress/vendor/zstd/lib/legacy/zstd_v05.h +1 -1
  200. data/ext/multi_compress/vendor/zstd/lib/legacy/zstd_v06.c +44 -88
  201. data/ext/multi_compress/vendor/zstd/lib/legacy/zstd_v06.h +1 -1
  202. data/ext/multi_compress/vendor/zstd/lib/legacy/zstd_v07.c +33 -84
  203. data/ext/multi_compress/vendor/zstd/lib/legacy/zstd_v07.h +1 -1
  204. data/ext/multi_compress/vendor/zstd/lib/libzstd.mk +65 -33
  205. data/ext/multi_compress/vendor/zstd/lib/libzstd.pc.in +5 -5
  206. data/ext/multi_compress/vendor/zstd/lib/module.modulemap +13 -3
  207. data/ext/multi_compress/vendor/zstd/lib/zdict.h +65 -36
  208. data/ext/multi_compress/vendor/zstd/lib/zstd.h +890 -267
  209. data/ext/multi_compress/vendor/zstd/lib/zstd_errors.h +28 -16
  210. data/lib/multi_compress/version.rb +1 -1
  211. data/lib/multi_compress.rb +80 -41
  212. metadata +29 -2
@@ -6,19 +6,32 @@
6
6
 
7
7
  #include "state.h"
8
8
 
9
- #include <stdlib.h> /* free, malloc */
10
-
11
- #include <brotli/types.h>
12
-
13
9
  #include "../common/dictionary.h"
10
+ #include "../common/platform.h"
14
11
  #include "huffman.h"
15
12
 
16
13
  #if defined(__cplusplus) || defined(c_plusplus)
17
14
  extern "C" {
18
15
  #endif
19
16
 
17
+ #ifdef BROTLI_REPORTING
18
+ /* When BROTLI_REPORTING is defined extra reporting module have to be linked. */
19
+ void BrotliDecoderOnStart(const BrotliDecoderState* s);
20
+ void BrotliDecoderOnFinish(const BrotliDecoderState* s);
21
+ #define BROTLI_DECODER_ON_START(s) BrotliDecoderOnStart(s);
22
+ #define BROTLI_DECODER_ON_FINISH(s) BrotliDecoderOnFinish(s);
23
+ #else
24
+ #if !defined(BROTLI_DECODER_ON_START)
25
+ #define BROTLI_DECODER_ON_START(s) (void)(s);
26
+ #endif
27
+ #if !defined(BROTLI_DECODER_ON_FINISH)
28
+ #define BROTLI_DECODER_ON_FINISH(s) (void)(s);
29
+ #endif
30
+ #endif
31
+
20
32
  BROTLI_BOOL BrotliDecoderStateInit(BrotliDecoderState* s,
21
33
  brotli_alloc_func alloc_func, brotli_free_func free_func, void* opaque) {
34
+ BROTLI_DECODER_ON_START(s);
22
35
  if (!alloc_func) {
23
36
  s->alloc_func = BrotliDefaultAllocFunc;
24
37
  s->free_func = BrotliDefaultFreeFunc;
@@ -135,16 +148,6 @@ void BrotliDecoderStateCleanupAfterMetablock(BrotliDecoderState* s) {
135
148
  BROTLI_DECODER_FREE(s, s->distance_hgroup.htrees);
136
149
  }
137
150
 
138
- #ifdef BROTLI_REPORTING
139
- /* When BROTLI_REPORTING is defined extra reporting module have to be linked. */
140
- void BrotliDecoderOnFinish(const BrotliDecoderState* s);
141
- #define BROTLI_DECODER_ON_FINISH(s) BrotliDecoderOnFinish(s);
142
- #else
143
- #if !defined(BROTLI_DECODER_ON_FINISH)
144
- #define BROTLI_DECODER_ON_FINISH(s) (void)(s);
145
- #endif
146
- #endif
147
-
148
151
  void BrotliDecoderStateCleanup(BrotliDecoderState* s) {
149
152
  BrotliDecoderStateCleanupAfterMetablock(s);
150
153
 
@@ -174,7 +177,7 @@ BROTLI_BOOL BrotliDecoderHuffmanTreeGroupInit(BrotliDecoderState* s,
174
177
  group->alphabet_size_limit = (uint16_t)alphabet_size_limit;
175
178
  group->num_htrees = (uint16_t)ntrees;
176
179
  group->htrees = p;
177
- group->codes = (HuffmanCode*)(&p[ntrees]);
180
+ group->codes = p ? (HuffmanCode*)(&p[ntrees]) : NULL;
178
181
  return !!p;
179
182
  }
180
183
 
@@ -9,14 +9,10 @@
9
9
  #ifndef BROTLI_DEC_STATE_H_
10
10
  #define BROTLI_DEC_STATE_H_
11
11
 
12
- #include <brotli/decode.h>
13
- #include <brotli/shared_dictionary.h>
14
- #include <brotli/types.h>
15
-
16
12
  #include "../common/constants.h"
17
- #include "../common/dictionary.h"
18
13
  #include "../common/platform.h"
19
- #include "../common/transform.h"
14
+ #include <brotli/shared_dictionary.h>
15
+ #include <brotli/decode.h>
20
16
  #include "bit_reader.h"
21
17
  #include "huffman.h"
22
18
 
@@ -0,0 +1,53 @@
1
+ /* Copyright 2025 Google Inc. All Rights Reserved.
2
+
3
+ Distributed under MIT license.
4
+ See file LICENSE for detail or copy at https://opensource.org/licenses/MIT
5
+ */
6
+
7
+ #include "static_init.h"
8
+
9
+ #include "../common/platform.h"
10
+ #include "../common/static_init.h"
11
+
12
+ #if (BROTLI_STATIC_INIT != BROTLI_STATIC_INIT_NONE)
13
+ #include "../common/dictionary.h"
14
+ #include "prefix.h"
15
+ #endif
16
+
17
+ #if defined(__cplusplus) || defined(c_plusplus)
18
+ extern "C" {
19
+ #endif
20
+
21
+ #if (BROTLI_STATIC_INIT != BROTLI_STATIC_INIT_NONE)
22
+ static BROTLI_BOOL DoBrotliDecoderStaticInit(void) {
23
+ BROTLI_BOOL ok = BrotliDecoderInitCmdLut(kCmdLut);
24
+ if (!ok) return BROTLI_FALSE;
25
+ return BROTLI_TRUE;
26
+ }
27
+ #endif /* BROTLI_STATIC_INIT_NONE */
28
+
29
+ #if (BROTLI_STATIC_INIT == BROTLI_STATIC_INIT_EARLY)
30
+ static BROTLI_BOOL kEarlyInitOk;
31
+ static __attribute__((constructor)) void BrotliDecoderStaticInitEarly(void) {
32
+ kEarlyInitOk = DoBrotliDecoderStaticInit();
33
+ }
34
+ #elif (BROTLI_STATIC_INIT == BROTLI_STATIC_INIT_LAZY)
35
+ static BROTLI_BOOL kLazyInitOk;
36
+ void BrotliDecoderLazyStaticInitInner(void) {
37
+ kLazyInitOk = DoBrotliDecoderStaticInit();
38
+ }
39
+ #endif /* BROTLI_STATIC_INIT_EARLY */
40
+
41
+ BROTLI_BOOL BrotliDecoderEnsureStaticInit(void) {
42
+ #if (BROTLI_STATIC_INIT == BROTLI_STATIC_INIT_NONE)
43
+ return BROTLI_TRUE;
44
+ #elif (BROTLI_STATIC_INIT == BROTLI_STATIC_INIT_EARLY)
45
+ return kEarlyInitOk;
46
+ #else
47
+ return kLazyInitOk;
48
+ #endif
49
+ }
50
+
51
+ #if defined(__cplusplus) || defined(c_plusplus)
52
+ } /* extern "C" */
53
+ #endif
@@ -0,0 +1,30 @@
1
+ /* Copyright 2025 Google Inc. All Rights Reserved.
2
+
3
+ Distributed under MIT license.
4
+ See file LICENSE for detail or copy at https://opensource.org/licenses/MIT
5
+ */
6
+
7
+ /* Central point for static initialization. */
8
+
9
+ #ifndef THIRD_PARTY_BROTLI_DEC_STATIC_INIT_H_
10
+ #define THIRD_PARTY_BROTLI_DEC_STATIC_INIT_H_
11
+
12
+ #include "../common/platform.h"
13
+ #include "../common/static_init.h"
14
+
15
+ #if defined(__cplusplus) || defined(c_plusplus)
16
+ extern "C" {
17
+ #endif
18
+
19
+ #if (BROTLI_STATIC_INIT == BROTLI_STATIC_INIT_LAZY)
20
+ BROTLI_INTERNAL void BrotliDecoderLazyStaticInitInner(void);
21
+ BROTLI_INTERNAL void BrotliDecoderLazyStaticInit(void);
22
+ #endif /* BROTLI_STATIC_INIT */
23
+
24
+ BROTLI_INTERNAL BROTLI_BOOL BrotliDecoderEnsureStaticInit(void);
25
+
26
+ #if defined(__cplusplus) || defined(c_plusplus)
27
+ } /* extern "C" */
28
+ #endif
29
+
30
+ #endif // THIRD_PARTY_BROTLI_DEC_STATIC_INIT_H_
@@ -8,17 +8,15 @@
8
8
 
9
9
  #include "backward_references.h"
10
10
 
11
- #include <brotli/types.h>
12
-
13
11
  #include "../common/constants.h"
14
- #include "../common/dictionary.h"
12
+ #include "../common/context.h"
15
13
  #include "../common/platform.h"
16
14
  #include "command.h"
17
15
  #include "compound_dictionary.h"
18
- #include "dictionary_hash.h"
19
16
  #include "encoder_dict.h"
20
- #include "memory.h"
21
- #include "quality.h"
17
+ #include "hash.h"
18
+ #include "params.h"
19
+ #include "quality.h" /* IWYU pragma: keep for inc */
22
20
 
23
21
  #if defined(__cplusplus) || defined(c_plusplus)
24
22
  extern "C" {
@@ -116,6 +114,18 @@ static BROTLI_INLINE size_t ComputeDistanceCode(size_t distance,
116
114
  #include "backward_references_inc.h"
117
115
  #undef HASHER
118
116
 
117
+ #if defined(BROTLI_MAX_SIMD_QUALITY)
118
+ #define HASHER() H58
119
+ /* NOLINTNEXTLINE(build/include) */
120
+ #include "backward_references_inc.h"
121
+ #undef HASHER
122
+
123
+ #define HASHER() H68
124
+ /* NOLINTNEXTLINE(build/include) */
125
+ #include "backward_references_inc.h"
126
+ #undef HASHER
127
+ #endif
128
+
119
129
  #undef ENABLE_COMPOUND_DICTIONARY
120
130
  #undef PREFIX
121
131
  #define PREFIX() D
@@ -149,6 +159,16 @@ static BROTLI_INLINE size_t ComputeDistanceCode(size_t distance,
149
159
  /* NOLINTNEXTLINE(build/include) */
150
160
  #include "backward_references_inc.h"
151
161
  #undef HASHER
162
+ #if defined(BROTLI_MAX_SIMD_QUALITY)
163
+ #define HASHER() H58
164
+ /* NOLINTNEXTLINE(build/include) */
165
+ #include "backward_references_inc.h"
166
+ #undef HASHER
167
+ #define HASHER() H68
168
+ /* NOLINTNEXTLINE(build/include) */
169
+ #include "backward_references_inc.h"
170
+ #undef HASHER
171
+ #endif
152
172
 
153
173
  #undef ENABLE_COMPOUND_DICTIONARY
154
174
  #undef PREFIX
@@ -174,6 +194,10 @@ void BrotliCreateBackwardReferences(size_t num_bytes,
174
194
  return;
175
195
  CASE_(5)
176
196
  CASE_(6)
197
+ #if defined(BROTLI_MAX_SIMD_QUALITY)
198
+ CASE_(58)
199
+ CASE_(68)
200
+ #endif
177
201
  CASE_(40)
178
202
  CASE_(41)
179
203
  CASE_(42)
@@ -181,7 +205,7 @@ void BrotliCreateBackwardReferences(size_t num_bytes,
181
205
  CASE_(65)
182
206
  #undef CASE_
183
207
  default:
184
- BROTLI_DCHECK(false);
208
+ BROTLI_DCHECK(BROTLI_FALSE);
185
209
  break;
186
210
  }
187
211
  }
@@ -197,7 +221,7 @@ void BrotliCreateBackwardReferences(size_t num_bytes,
197
221
  FOR_GENERIC_HASHERS(CASE_)
198
222
  #undef CASE_
199
223
  default:
200
- BROTLI_DCHECK(false);
224
+ BROTLI_DCHECK(BROTLI_FALSE);
201
225
  break;
202
226
  }
203
227
  }
@@ -9,15 +9,11 @@
9
9
  #ifndef BROTLI_ENC_BACKWARD_REFERENCES_H_
10
10
  #define BROTLI_ENC_BACKWARD_REFERENCES_H_
11
11
 
12
- #include <brotli/types.h>
13
-
14
- #include "../common/constants.h"
15
12
  #include "../common/context.h"
16
- #include "../common/dictionary.h"
17
13
  #include "../common/platform.h"
18
14
  #include "command.h"
19
15
  #include "hash.h"
20
- #include "quality.h"
16
+ #include "params.h"
21
17
 
22
18
  #if defined(__cplusplus) || defined(c_plusplus)
23
19
  extern "C" {
@@ -8,17 +8,15 @@
8
8
 
9
9
  #include "backward_references_hq.h"
10
10
 
11
- #include <string.h> /* memcpy, memset */
12
-
13
- #include <brotli/types.h>
14
-
15
11
  #include "../common/constants.h"
12
+ #include "../common/context.h"
16
13
  #include "../common/platform.h"
17
14
  #include "command.h"
18
15
  #include "compound_dictionary.h"
19
16
  #include "encoder_dict.h"
20
17
  #include "fast_log.h"
21
18
  #include "find_match_length.h"
19
+ #include "hash.h"
22
20
  #include "literal_cost.h"
23
21
  #include "memory.h"
24
22
  #include "params.h"
@@ -34,10 +32,10 @@ extern "C" {
34
32
 
35
33
  static const float kInfinity = 1.7e38f; /* ~= 2 ^ 127 */
36
34
 
37
- static const uint32_t kDistanceCacheIndex[] = {
35
+ static const BROTLI_MODEL("small") uint32_t kDistanceCacheIndex[] = {
38
36
  0, 1, 2, 3, 0, 0, 0, 0, 0, 0, 1, 1, 1, 1, 1, 1,
39
37
  };
40
- static const int kDistanceCacheOffset[] = {
38
+ static const BROTLI_MODEL("small") int kDistanceCacheOffset[] = {
41
39
  0, 0, 0, 0, -1, 1, -2, 2, -3, 3, -1, 1, -2, 2, -3, 3
42
40
  };
43
41
 
@@ -345,22 +343,22 @@ static uint32_t ComputeDistanceShortcut(const size_t block_start,
345
343
  const size_t max_backward_limit,
346
344
  const size_t gap,
347
345
  const ZopfliNode* nodes) {
348
- const size_t clen = ZopfliNodeCopyLength(&nodes[pos]);
349
- const size_t ilen = nodes[pos].dcode_insert_length & 0x7FFFFFF;
346
+ const size_t c_len = ZopfliNodeCopyLength(&nodes[pos]);
347
+ const size_t i_len = nodes[pos].dcode_insert_length & 0x7FFFFFF;
350
348
  const size_t dist = ZopfliNodeCopyDistance(&nodes[pos]);
351
349
  /* Since |block_start + pos| is the end position of the command, the copy part
352
- starts from |block_start + pos - clen|. Distances that are greater than
350
+ starts from |block_start + pos - c_len|. Distances that are greater than
353
351
  this or greater than |max_backward_limit| + |gap| are static dictionary
354
352
  references, and do not update the last distances.
355
353
  Also distance code 0 (last distance) does not update the last distances. */
356
354
  if (pos == 0) {
357
355
  return 0;
358
- } else if (dist + clen <= block_start + pos + gap &&
356
+ } else if (dist + c_len <= block_start + pos + gap &&
359
357
  dist <= max_backward_limit + gap &&
360
358
  ZopfliNodeDistanceCode(&nodes[pos]) > 0) {
361
359
  return (uint32_t)pos;
362
360
  } else {
363
- return nodes[pos - clen - ilen].u.shortcut;
361
+ return nodes[pos - c_len - i_len].u.shortcut;
364
362
  }
365
363
  }
366
364
 
@@ -378,12 +376,12 @@ static void ComputeDistanceCache(const size_t pos,
378
376
  int idx = 0;
379
377
  size_t p = nodes[pos].u.shortcut;
380
378
  while (idx < 4 && p > 0) {
381
- const size_t ilen = nodes[p].dcode_insert_length & 0x7FFFFFF;
382
- const size_t clen = ZopfliNodeCopyLength(&nodes[p]);
379
+ const size_t i_len = nodes[p].dcode_insert_length & 0x7FFFFFF;
380
+ const size_t c_len = ZopfliNodeCopyLength(&nodes[p]);
383
381
  const size_t dist = ZopfliNodeCopyDistance(&nodes[p]);
384
382
  dist_cache[idx++] = (int)dist;
385
- /* Because of prerequisite, p >= clen + ilen >= 2. */
386
- p = nodes[p - clen - ilen].u.shortcut;
383
+ /* Because of prerequisite, p >= c_len + i_len >= 2. */
384
+ p = nodes[p - c_len - i_len].u.shortcut;
387
385
  }
388
386
  for (; idx < 4; ++idx) {
389
387
  dist_cache[idx] = *starting_dist_cache++;
@@ -435,6 +433,8 @@ static size_t UpdateNodes(
435
433
  const CompoundDictionary* addon = &params->dictionary.compound;
436
434
  size_t gap = addon->total_size;
437
435
 
436
+ BROTLI_DCHECK(cur_ix_masked + max_len <= ringbuffer_mask);
437
+
438
438
  EvaluateNode(block_start + stream_offset, pos, max_backward_limit, gap,
439
439
  starting_dist_cache, model, queue, nodes);
440
440
 
@@ -9,16 +9,12 @@
9
9
  #ifndef BROTLI_ENC_BACKWARD_REFERENCES_HQ_H_
10
10
  #define BROTLI_ENC_BACKWARD_REFERENCES_HQ_H_
11
11
 
12
- #include <brotli/types.h>
13
-
14
- #include "../common/constants.h"
15
12
  #include "../common/context.h"
16
- #include "../common/dictionary.h"
17
13
  #include "../common/platform.h"
18
14
  #include "command.h"
19
15
  #include "hash.h"
20
16
  #include "memory.h"
21
- #include "quality.h"
17
+ #include "params.h"
22
18
 
23
19
  #if defined(__cplusplus) || defined(c_plusplus)
24
20
  extern "C" {
@@ -8,17 +8,41 @@
8
8
 
9
9
  #include "bit_cost.h"
10
10
 
11
- #include <brotli/types.h>
12
-
13
- #include "../common/constants.h"
14
11
  #include "../common/platform.h"
15
12
  #include "fast_log.h"
16
- #include "histogram.h"
17
13
 
18
14
  #if defined(__cplusplus) || defined(c_plusplus)
19
15
  extern "C" {
20
16
  #endif
21
17
 
18
+ double BrotliBitsEntropy(const uint32_t* population, size_t size) {
19
+ size_t sum = 0;
20
+ double retval = 0;
21
+ const uint32_t* population_end = population + size;
22
+ size_t p;
23
+ if (size & 1) {
24
+ goto odd_number_of_elements_left;
25
+ }
26
+ while (population < population_end) {
27
+ p = *population++;
28
+ sum += p;
29
+ retval -= (double)p * FastLog2(p);
30
+ odd_number_of_elements_left:
31
+ p = *population++;
32
+ sum += p;
33
+ retval -= (double)p * FastLog2(p);
34
+ }
35
+ if (sum) retval += (double)sum * FastLog2(sum);
36
+
37
+ if (retval < (double)sum) {
38
+ /* TODO(eustas): consider doing that per-symbol? */
39
+ /* At least one bit per literal is needed. */
40
+ retval = (double)sum;
41
+ }
42
+
43
+ return retval;
44
+ }
45
+
22
46
  #define FN(X) X ## Literal
23
47
  #include "bit_cost_inc.h" /* NOLINT(build/include) */
24
48
  #undef FN
@@ -9,53 +9,21 @@
9
9
  #ifndef BROTLI_ENC_BIT_COST_H_
10
10
  #define BROTLI_ENC_BIT_COST_H_
11
11
 
12
- #include <brotli/types.h>
13
-
14
12
  #include "../common/platform.h"
15
- #include "fast_log.h"
16
13
  #include "histogram.h"
17
14
 
18
15
  #if defined(__cplusplus) || defined(c_plusplus)
19
16
  extern "C" {
20
17
  #endif
21
18
 
22
- static BROTLI_INLINE double ShannonEntropy(
23
- const uint32_t* population, size_t size, size_t* total) {
24
- size_t sum = 0;
25
- double retval = 0;
26
- const uint32_t* population_end = population + size;
27
- size_t p;
28
- if (size & 1) {
29
- goto odd_number_of_elements_left;
30
- }
31
- while (population < population_end) {
32
- p = *population++;
33
- sum += p;
34
- retval -= (double)p * FastLog2(p);
35
- odd_number_of_elements_left:
36
- p = *population++;
37
- sum += p;
38
- retval -= (double)p * FastLog2(p);
39
- }
40
- if (sum) retval += (double)sum * FastLog2(sum);
41
- *total = sum;
42
- return retval;
43
- }
44
-
45
- static BROTLI_INLINE double BitsEntropy(
46
- const uint32_t* population, size_t size) {
47
- size_t sum;
48
- double retval = ShannonEntropy(population, size, &sum);
49
- if (retval < (double)sum) {
50
- /* At least one bit per literal is needed. */
51
- retval = (double)sum;
52
- }
53
- return retval;
54
- }
55
-
56
- BROTLI_INTERNAL double BrotliPopulationCostLiteral(const HistogramLiteral*);
57
- BROTLI_INTERNAL double BrotliPopulationCostCommand(const HistogramCommand*);
58
- BROTLI_INTERNAL double BrotliPopulationCostDistance(const HistogramDistance*);
19
+ BROTLI_INTERNAL double BrotliBitsEntropy(
20
+ const uint32_t* population, size_t size);
21
+ BROTLI_INTERNAL double BrotliPopulationCostLiteral(
22
+ const HistogramLiteral* histogram);
23
+ BROTLI_INTERNAL double BrotliPopulationCostCommand(
24
+ const HistogramCommand* histogram);
25
+ BROTLI_INTERNAL double BrotliPopulationCostDistance(
26
+ const HistogramDistance* histogram);
59
27
 
60
28
  #if defined(__cplusplus) || defined(c_plusplus)
61
29
  } /* extern "C" */
@@ -119,7 +119,7 @@ double FN(BrotliPopulationCost)(const HistogramType* histogram) {
119
119
  /* Add the estimated encoding cost of the code length code histogram. */
120
120
  bits += (double)(18 + 2 * max_depth);
121
121
  /* Add the entropy of the code length code histogram. */
122
- bits += BitsEntropy(depth_histo, BROTLI_CODE_LENGTH_CODES);
122
+ bits += BrotliBitsEntropy(depth_histo, BROTLI_CODE_LENGTH_CODES);
123
123
  }
124
124
  return bits;
125
125
  }
@@ -8,8 +8,6 @@
8
8
 
9
9
  #include "block_splitter.h"
10
10
 
11
- #include <string.h> /* memcpy, memset */
12
-
13
11
  #include "../common/platform.h"
14
12
  #include "bit_cost.h"
15
13
  #include "cluster.h"
@@ -140,7 +138,7 @@ void BrotliSplitBlock(MemoryManager* m,
140
138
  CopyLiteralsToByteArray(cmds, num_commands, data, pos, mask, literals);
141
139
  /* Create the block split on the array of literals.
142
140
  * Literal histograms can have alphabet size up to 256.
143
- * Though, to accomodate context modeling, less than half of maximum size
141
+ * Though, to accommodate context modeling, less than half of maximum size
144
142
  * is allowed. */
145
143
  SplitByteVectorLiteral(
146
144
  m, literals, literals_count,
@@ -150,7 +148,7 @@ void BrotliSplitBlock(MemoryManager* m,
150
148
  if (BROTLI_IS_OOM(m)) return;
151
149
  BROTLI_FREE(m, literals);
152
150
  /* NB: this might be a good place for injecting extra splitting without
153
- * increasing encoder complexity; however, output parition would be less
151
+ * increasing encoder complexity; however, output partition would be less
154
152
  * optimal than one produced with forced splitting inside
155
153
  * SplitByteVector (FindBlocks / ClusterBlocks). */
156
154
  }
@@ -198,16 +196,15 @@ void BrotliSplitBlock(MemoryManager* m,
198
196
  }
199
197
 
200
198
  #if defined(BROTLI_TEST)
201
- size_t CountLiteralsForTest(const Command*, const size_t);
202
- size_t CountLiteralsForTest(const Command* cmds, const size_t num_commands) {
199
+ size_t BrotliCountLiteralsForTest(const Command*, size_t);
200
+ size_t BrotliCountLiteralsForTest(const Command* cmds, size_t num_commands) {
203
201
  return CountLiterals(cmds, num_commands);
204
202
  }
205
-
206
- void CopyLiteralsToByteArrayForTest(const Command*,
207
- const size_t, const uint8_t*, const size_t, const size_t, uint8_t*);
208
- void CopyLiteralsToByteArrayForTest(const Command* cmds,
209
- const size_t num_commands, const uint8_t* data, const size_t offset,
210
- const size_t mask, uint8_t* literals) {
203
+ void BrotliCopyLiteralsToByteArrayForTest(
204
+ const Command*, size_t, const uint8_t*, size_t, size_t, uint8_t*);
205
+ void BrotliCopyLiteralsToByteArrayForTest(const Command* cmds,
206
+ size_t num_commands, const uint8_t* data, size_t offset, size_t mask,
207
+ uint8_t* literals) {
211
208
  CopyLiteralsToByteArray(cmds, num_commands, data, offset, mask, literals);
212
209
  }
213
210
  #endif
@@ -9,12 +9,9 @@
9
9
  #ifndef BROTLI_ENC_BLOCK_SPLITTER_H_
10
10
  #define BROTLI_ENC_BLOCK_SPLITTER_H_
11
11
 
12
- #include <brotli/types.h>
13
-
14
12
  #include "../common/platform.h"
15
13
  #include "command.h"
16
14
  #include "memory.h"
17
- #include "quality.h"
18
15
 
19
16
  #if defined(__cplusplus) || defined(c_plusplus)
20
17
  extern "C" {
@@ -79,7 +79,7 @@ static size_t FN(FindBlocks)(const DataType* data, const size_t length,
79
79
  size_t j;
80
80
  BROTLI_DCHECK(num_histograms <= 256);
81
81
 
82
- /* Trivial case: single historgram -> single block type. */
82
+ /* Trivial case: single histogram -> single block type. */
83
83
  if (num_histograms <= 1) {
84
84
  for (i = 0; i < length; ++i) {
85
85
  block_id[i] = 0;
@@ -118,6 +118,8 @@ static size_t FN(FindBlocks)(const DataType* data, const size_t length,
118
118
  size_t insert_cost_ix = symbol * num_histograms;
119
119
  double min_cost = 1e99;
120
120
  double block_switch_cost = block_switch_bitcost;
121
+ static const size_t prologue_length = 2000;
122
+ static const double multiplier = 0.07 / 2000;
121
123
  size_t k;
122
124
  for (k = 0; k < num_histograms; ++k) {
123
125
  /* We are coding the symbol with entropy code k. */
@@ -128,8 +130,8 @@ static size_t FN(FindBlocks)(const DataType* data, const size_t length,
128
130
  }
129
131
  }
130
132
  /* More blocks for the beginning. */
131
- if (byte_ix < 2000) {
132
- block_switch_cost *= 0.77 + 0.07 * (double)byte_ix / 2000;
133
+ if (byte_ix < prologue_length) {
134
+ block_switch_cost *= 0.77 + multiplier * (double)byte_ix;
133
135
  }
134
136
  for (k = 0; k < num_histograms; ++k) {
135
137
  cost[k] -= min_cost;
@@ -228,12 +230,16 @@ static void FN(ClusterBlocks)(MemoryManager* m,
228
230
  static const uint32_t kInvalidIndex = BROTLI_UINT32_MAX;
229
231
  uint32_t* new_index;
230
232
  size_t i;
231
- uint32_t* BROTLI_RESTRICT const sizes = u32 + 0 * HISTOGRAMS_PER_BATCH;
232
- uint32_t* BROTLI_RESTRICT const new_clusters = u32 + 1 * HISTOGRAMS_PER_BATCH;
233
- uint32_t* BROTLI_RESTRICT const symbols = u32 + 2 * HISTOGRAMS_PER_BATCH;
234
- uint32_t* BROTLI_RESTRICT const remap = u32 + 3 * HISTOGRAMS_PER_BATCH;
233
+ uint32_t* BROTLI_RESTRICT const sizes =
234
+ u32 ? (u32 + 0 * HISTOGRAMS_PER_BATCH) : NULL;
235
+ uint32_t* BROTLI_RESTRICT const new_clusters =
236
+ u32 ? (u32 + 1 * HISTOGRAMS_PER_BATCH) : NULL;
237
+ uint32_t* BROTLI_RESTRICT const symbols =
238
+ u32 ? (u32 + 2 * HISTOGRAMS_PER_BATCH) : NULL;
239
+ uint32_t* BROTLI_RESTRICT const remap =
240
+ u32 ? (u32 + 3 * HISTOGRAMS_PER_BATCH) : NULL;
235
241
  uint32_t* BROTLI_RESTRICT const block_lengths =
236
- u32 + 4 * HISTOGRAMS_PER_BATCH;
242
+ u32 ? (u32 + 4 * HISTOGRAMS_PER_BATCH) : NULL;
237
243
  /* TODO(eustas): move to arena? */
238
244
  HistogramType* tmp = BROTLI_ALLOC(m, HistogramType, 2);
239
245
 
@@ -10,10 +10,6 @@
10
10
 
11
11
  #include "brotli_bit_stream.h"
12
12
 
13
- #include <string.h> /* memcpy, memset */
14
-
15
- #include <brotli/types.h>
16
-
17
13
  #include "../common/constants.h"
18
14
  #include "../common/context.h"
19
15
  #include "../common/platform.h"
@@ -169,7 +165,8 @@ static void BrotliStoreUncompressedMetaBlockHeader(size_t length,
169
165
  static void BrotliStoreHuffmanTreeOfHuffmanTreeToBitMask(
170
166
  const int num_codes, const uint8_t* code_length_bitdepth,
171
167
  size_t* storage_ix, uint8_t* storage) {
172
- static const uint8_t kStorageOrder[BROTLI_CODE_LENGTH_CODES] = {
168
+ static const BROTLI_MODEL("small")
169
+ uint8_t kStorageOrder[BROTLI_CODE_LENGTH_CODES] = {
173
170
  1, 2, 3, 4, 0, 5, 17, 6, 16, 7, 8, 9, 10, 11, 12, 13, 14, 15
174
171
  };
175
172
  /* The bit lengths of the Huffman code over the code length alphabet
@@ -182,10 +179,12 @@ static void BrotliStoreHuffmanTreeOfHuffmanTreeToBitMask(
182
179
  3 01
183
180
  4 10
184
181
  5 1111 */
185
- static const uint8_t kHuffmanBitLengthHuffmanCodeSymbols[6] = {
182
+ static const BROTLI_MODEL("small")
183
+ uint8_t kHuffmanBitLengthHuffmanCodeSymbols[6] = {
186
184
  0, 7, 3, 2, 1, 15
187
185
  };
188
- static const uint8_t kHuffmanBitLengthHuffmanCodeBitLengths[6] = {
186
+ static const BROTLI_MODEL("small")
187
+ uint8_t kHuffmanBitLengthHuffmanCodeBitLengths[6] = {
189
188
  2, 4, 3, 2, 2, 4
190
189
  };
191
190
 
@@ -1325,8 +1324,10 @@ void BrotliStoreUncompressedMetaBlock(BROTLI_BOOL is_final_block,
1325
1324
  }
1326
1325
 
1327
1326
  #if defined(BROTLI_TEST)
1328
- void GetBlockLengthPrefixCodeForTest(uint32_t len, size_t* code,
1329
- uint32_t* n_extra, uint32_t* extra) {
1327
+ void BrotliGetBlockLengthPrefixCodeForTest(uint32_t len, size_t* code,
1328
+ uint32_t* n_extra, uint32_t* extra);
1329
+ void BrotliGetBlockLengthPrefixCodeForTest(uint32_t len, size_t* code,
1330
+ uint32_t* n_extra, uint32_t* extra) {
1330
1331
  GetBlockLengthPrefixCode(len, code, n_extra, extra);
1331
1332
  }
1332
1333
  #endif
@@ -16,8 +16,6 @@
16
16
  #ifndef BROTLI_ENC_BROTLI_BIT_STREAM_H_
17
17
  #define BROTLI_ENC_BROTLI_BIT_STREAM_H_
18
18
 
19
- #include <brotli/types.h>
20
-
21
19
  #include "../common/context.h"
22
20
  #include "../common/platform.h"
23
21
  #include "command.h"
@@ -78,10 +76,6 @@ BROTLI_INTERNAL void BrotliStoreUncompressedMetaBlock(
78
76
  size_t position, size_t mask, size_t len,
79
77
  size_t* BROTLI_RESTRICT storage_ix, uint8_t* BROTLI_RESTRICT storage);
80
78
 
81
- #if defined(BROTLI_TEST)
82
- void GetBlockLengthPrefixCodeForTest(uint32_t, size_t*, uint32_t*, uint32_t*);
83
- #endif
84
-
85
79
  #if defined(__cplusplus) || defined(c_plusplus)
86
80
  } /* extern "C" */
87
81
  #endif