multi_compress 0.1.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 (219) hide show
  1. checksums.yaml +7 -0
  2. data/CHANGELOG.md +13 -0
  3. data/LICENSE.txt +21 -0
  4. data/README.md +116 -0
  5. data/ext/multi_compress/extconf.rb +171 -0
  6. data/ext/multi_compress/multi_compress.c +1534 -0
  7. data/ext/multi_compress/vendor/brotli/c/common/constants.c +15 -0
  8. data/ext/multi_compress/vendor/brotli/c/common/constants.h +201 -0
  9. data/ext/multi_compress/vendor/brotli/c/common/context.c +156 -0
  10. data/ext/multi_compress/vendor/brotli/c/common/context.h +113 -0
  11. data/ext/multi_compress/vendor/brotli/c/common/dictionary.c +5916 -0
  12. data/ext/multi_compress/vendor/brotli/c/common/dictionary.h +64 -0
  13. data/ext/multi_compress/vendor/brotli/c/common/platform.c +23 -0
  14. data/ext/multi_compress/vendor/brotli/c/common/platform.h +541 -0
  15. data/ext/multi_compress/vendor/brotli/c/common/shared_dictionary.c +521 -0
  16. data/ext/multi_compress/vendor/brotli/c/common/shared_dictionary_internal.h +75 -0
  17. data/ext/multi_compress/vendor/brotli/c/common/transform.c +291 -0
  18. data/ext/multi_compress/vendor/brotli/c/common/transform.h +85 -0
  19. data/ext/multi_compress/vendor/brotli/c/common/version.h +51 -0
  20. data/ext/multi_compress/vendor/brotli/c/dec/bit_reader.c +78 -0
  21. data/ext/multi_compress/vendor/brotli/c/dec/bit_reader.h +423 -0
  22. data/ext/multi_compress/vendor/brotli/c/dec/decode.c +2875 -0
  23. data/ext/multi_compress/vendor/brotli/c/dec/huffman.c +342 -0
  24. data/ext/multi_compress/vendor/brotli/c/dec/huffman.h +122 -0
  25. data/ext/multi_compress/vendor/brotli/c/dec/prefix.h +733 -0
  26. data/ext/multi_compress/vendor/brotli/c/dec/state.c +183 -0
  27. data/ext/multi_compress/vendor/brotli/c/dec/state.h +400 -0
  28. data/ext/multi_compress/vendor/brotli/c/enc/backward_references.c +207 -0
  29. data/ext/multi_compress/vendor/brotli/c/enc/backward_references.h +40 -0
  30. data/ext/multi_compress/vendor/brotli/c/enc/backward_references_hq.c +939 -0
  31. data/ext/multi_compress/vendor/brotli/c/enc/backward_references_hq.h +96 -0
  32. data/ext/multi_compress/vendor/brotli/c/enc/backward_references_inc.h +189 -0
  33. data/ext/multi_compress/vendor/brotli/c/enc/bit_cost.c +36 -0
  34. data/ext/multi_compress/vendor/brotli/c/enc/bit_cost.h +64 -0
  35. data/ext/multi_compress/vendor/brotli/c/enc/bit_cost_inc.h +127 -0
  36. data/ext/multi_compress/vendor/brotli/c/enc/block_encoder_inc.h +34 -0
  37. data/ext/multi_compress/vendor/brotli/c/enc/block_splitter.c +217 -0
  38. data/ext/multi_compress/vendor/brotli/c/enc/block_splitter.h +52 -0
  39. data/ext/multi_compress/vendor/brotli/c/enc/block_splitter_inc.h +481 -0
  40. data/ext/multi_compress/vendor/brotli/c/enc/brotli_bit_stream.c +1336 -0
  41. data/ext/multi_compress/vendor/brotli/c/enc/brotli_bit_stream.h +89 -0
  42. data/ext/multi_compress/vendor/brotli/c/enc/cluster.c +57 -0
  43. data/ext/multi_compress/vendor/brotli/c/enc/cluster.h +49 -0
  44. data/ext/multi_compress/vendor/brotli/c/enc/cluster_inc.h +325 -0
  45. data/ext/multi_compress/vendor/brotli/c/enc/command.c +28 -0
  46. data/ext/multi_compress/vendor/brotli/c/enc/command.h +191 -0
  47. data/ext/multi_compress/vendor/brotli/c/enc/compound_dictionary.c +207 -0
  48. data/ext/multi_compress/vendor/brotli/c/enc/compound_dictionary.h +74 -0
  49. data/ext/multi_compress/vendor/brotli/c/enc/compress_fragment.c +800 -0
  50. data/ext/multi_compress/vendor/brotli/c/enc/compress_fragment.h +86 -0
  51. data/ext/multi_compress/vendor/brotli/c/enc/compress_fragment_two_pass.c +657 -0
  52. data/ext/multi_compress/vendor/brotli/c/enc/compress_fragment_two_pass.h +72 -0
  53. data/ext/multi_compress/vendor/brotli/c/enc/dictionary_hash.c +1848 -0
  54. data/ext/multi_compress/vendor/brotli/c/enc/dictionary_hash.h +25 -0
  55. data/ext/multi_compress/vendor/brotli/c/enc/encode.c +1996 -0
  56. data/ext/multi_compress/vendor/brotli/c/enc/encoder_dict.c +640 -0
  57. data/ext/multi_compress/vendor/brotli/c/enc/encoder_dict.h +157 -0
  58. data/ext/multi_compress/vendor/brotli/c/enc/entropy_encode.c +504 -0
  59. data/ext/multi_compress/vendor/brotli/c/enc/entropy_encode.h +123 -0
  60. data/ext/multi_compress/vendor/brotli/c/enc/entropy_encode_static.h +542 -0
  61. data/ext/multi_compress/vendor/brotli/c/enc/fast_log.c +105 -0
  62. data/ext/multi_compress/vendor/brotli/c/enc/fast_log.h +67 -0
  63. data/ext/multi_compress/vendor/brotli/c/enc/find_match_length.h +72 -0
  64. data/ext/multi_compress/vendor/brotli/c/enc/hash.h +728 -0
  65. data/ext/multi_compress/vendor/brotli/c/enc/hash_composite_inc.h +140 -0
  66. data/ext/multi_compress/vendor/brotli/c/enc/hash_forgetful_chain_inc.h +295 -0
  67. data/ext/multi_compress/vendor/brotli/c/enc/hash_longest_match64_inc.h +262 -0
  68. data/ext/multi_compress/vendor/brotli/c/enc/hash_longest_match_inc.h +258 -0
  69. data/ext/multi_compress/vendor/brotli/c/enc/hash_longest_match_quickly_inc.h +266 -0
  70. data/ext/multi_compress/vendor/brotli/c/enc/hash_rolling_inc.h +212 -0
  71. data/ext/multi_compress/vendor/brotli/c/enc/hash_to_binary_tree_inc.h +330 -0
  72. data/ext/multi_compress/vendor/brotli/c/enc/histogram.c +100 -0
  73. data/ext/multi_compress/vendor/brotli/c/enc/histogram.h +64 -0
  74. data/ext/multi_compress/vendor/brotli/c/enc/histogram_inc.h +51 -0
  75. data/ext/multi_compress/vendor/brotli/c/enc/literal_cost.c +180 -0
  76. data/ext/multi_compress/vendor/brotli/c/enc/literal_cost.h +32 -0
  77. data/ext/multi_compress/vendor/brotli/c/enc/memory.c +194 -0
  78. data/ext/multi_compress/vendor/brotli/c/enc/memory.h +131 -0
  79. data/ext/multi_compress/vendor/brotli/c/enc/metablock.c +677 -0
  80. data/ext/multi_compress/vendor/brotli/c/enc/metablock.h +106 -0
  81. data/ext/multi_compress/vendor/brotli/c/enc/metablock_inc.h +185 -0
  82. data/ext/multi_compress/vendor/brotli/c/enc/params.h +47 -0
  83. data/ext/multi_compress/vendor/brotli/c/enc/prefix.h +54 -0
  84. data/ext/multi_compress/vendor/brotli/c/enc/quality.h +202 -0
  85. data/ext/multi_compress/vendor/brotli/c/enc/ringbuffer.h +168 -0
  86. data/ext/multi_compress/vendor/brotli/c/enc/state.h +104 -0
  87. data/ext/multi_compress/vendor/brotli/c/enc/static_dict.c +542 -0
  88. data/ext/multi_compress/vendor/brotli/c/enc/static_dict.h +41 -0
  89. data/ext/multi_compress/vendor/brotli/c/enc/static_dict_lut.h +5866 -0
  90. data/ext/multi_compress/vendor/brotli/c/enc/utf8_util.c +85 -0
  91. data/ext/multi_compress/vendor/brotli/c/enc/utf8_util.h +33 -0
  92. data/ext/multi_compress/vendor/brotli/c/enc/write_bits.h +88 -0
  93. data/ext/multi_compress/vendor/brotli/c/include/brotli/decode.h +409 -0
  94. data/ext/multi_compress/vendor/brotli/c/include/brotli/encode.h +501 -0
  95. data/ext/multi_compress/vendor/brotli/c/include/brotli/port.h +305 -0
  96. data/ext/multi_compress/vendor/brotli/c/include/brotli/shared_dictionary.h +100 -0
  97. data/ext/multi_compress/vendor/brotli/c/include/brotli/types.h +83 -0
  98. data/ext/multi_compress/vendor/lz4/lib/LICENSE +24 -0
  99. data/ext/multi_compress/vendor/lz4/lib/Makefile +244 -0
  100. data/ext/multi_compress/vendor/lz4/lib/README.md +193 -0
  101. data/ext/multi_compress/vendor/lz4/lib/dll/example/Makefile +63 -0
  102. data/ext/multi_compress/vendor/lz4/lib/dll/example/README.md +69 -0
  103. data/ext/multi_compress/vendor/lz4/lib/dll/example/fullbench-dll.sln +25 -0
  104. data/ext/multi_compress/vendor/lz4/lib/dll/example/fullbench-dll.vcxproj +182 -0
  105. data/ext/multi_compress/vendor/lz4/lib/liblz4-dll.rc.in +35 -0
  106. data/ext/multi_compress/vendor/lz4/lib/liblz4.pc.in +14 -0
  107. data/ext/multi_compress/vendor/lz4/lib/lz4.c +2829 -0
  108. data/ext/multi_compress/vendor/lz4/lib/lz4.h +884 -0
  109. data/ext/multi_compress/vendor/lz4/lib/lz4file.c +341 -0
  110. data/ext/multi_compress/vendor/lz4/lib/lz4file.h +93 -0
  111. data/ext/multi_compress/vendor/lz4/lib/lz4frame.c +2136 -0
  112. data/ext/multi_compress/vendor/lz4/lib/lz4frame.h +751 -0
  113. data/ext/multi_compress/vendor/lz4/lib/lz4frame_static.h +47 -0
  114. data/ext/multi_compress/vendor/lz4/lib/lz4hc.c +2192 -0
  115. data/ext/multi_compress/vendor/lz4/lib/lz4hc.h +414 -0
  116. data/ext/multi_compress/vendor/lz4/lib/xxhash.c +1030 -0
  117. data/ext/multi_compress/vendor/lz4/lib/xxhash.h +328 -0
  118. data/ext/multi_compress/vendor/zstd/lib/BUCK +232 -0
  119. data/ext/multi_compress/vendor/zstd/lib/Makefile +369 -0
  120. data/ext/multi_compress/vendor/zstd/lib/README.md +237 -0
  121. data/ext/multi_compress/vendor/zstd/lib/common/allocations.h +55 -0
  122. data/ext/multi_compress/vendor/zstd/lib/common/bits.h +200 -0
  123. data/ext/multi_compress/vendor/zstd/lib/common/bitstream.h +457 -0
  124. data/ext/multi_compress/vendor/zstd/lib/common/compiler.h +450 -0
  125. data/ext/multi_compress/vendor/zstd/lib/common/cpu.h +249 -0
  126. data/ext/multi_compress/vendor/zstd/lib/common/debug.c +30 -0
  127. data/ext/multi_compress/vendor/zstd/lib/common/debug.h +116 -0
  128. data/ext/multi_compress/vendor/zstd/lib/common/entropy_common.c +340 -0
  129. data/ext/multi_compress/vendor/zstd/lib/common/error_private.c +63 -0
  130. data/ext/multi_compress/vendor/zstd/lib/common/error_private.h +168 -0
  131. data/ext/multi_compress/vendor/zstd/lib/common/fse.h +640 -0
  132. data/ext/multi_compress/vendor/zstd/lib/common/fse_decompress.c +313 -0
  133. data/ext/multi_compress/vendor/zstd/lib/common/huf.h +286 -0
  134. data/ext/multi_compress/vendor/zstd/lib/common/mem.h +426 -0
  135. data/ext/multi_compress/vendor/zstd/lib/common/pool.c +371 -0
  136. data/ext/multi_compress/vendor/zstd/lib/common/pool.h +90 -0
  137. data/ext/multi_compress/vendor/zstd/lib/common/portability_macros.h +158 -0
  138. data/ext/multi_compress/vendor/zstd/lib/common/threading.c +182 -0
  139. data/ext/multi_compress/vendor/zstd/lib/common/threading.h +150 -0
  140. data/ext/multi_compress/vendor/zstd/lib/common/xxhash.c +18 -0
  141. data/ext/multi_compress/vendor/zstd/lib/common/xxhash.h +7020 -0
  142. data/ext/multi_compress/vendor/zstd/lib/common/zstd_common.c +48 -0
  143. data/ext/multi_compress/vendor/zstd/lib/common/zstd_deps.h +111 -0
  144. data/ext/multi_compress/vendor/zstd/lib/common/zstd_internal.h +392 -0
  145. data/ext/multi_compress/vendor/zstd/lib/common/zstd_trace.h +163 -0
  146. data/ext/multi_compress/vendor/zstd/lib/compress/clevels.h +134 -0
  147. data/ext/multi_compress/vendor/zstd/lib/compress/fse_compress.c +625 -0
  148. data/ext/multi_compress/vendor/zstd/lib/compress/hist.c +181 -0
  149. data/ext/multi_compress/vendor/zstd/lib/compress/hist.h +75 -0
  150. data/ext/multi_compress/vendor/zstd/lib/compress/huf_compress.c +1464 -0
  151. data/ext/multi_compress/vendor/zstd/lib/compress/zstd_compress.c +7153 -0
  152. data/ext/multi_compress/vendor/zstd/lib/compress/zstd_compress_internal.h +1534 -0
  153. data/ext/multi_compress/vendor/zstd/lib/compress/zstd_compress_literals.c +235 -0
  154. data/ext/multi_compress/vendor/zstd/lib/compress/zstd_compress_literals.h +39 -0
  155. data/ext/multi_compress/vendor/zstd/lib/compress/zstd_compress_sequences.c +442 -0
  156. data/ext/multi_compress/vendor/zstd/lib/compress/zstd_compress_sequences.h +54 -0
  157. data/ext/multi_compress/vendor/zstd/lib/compress/zstd_compress_superblock.c +688 -0
  158. data/ext/multi_compress/vendor/zstd/lib/compress/zstd_compress_superblock.h +32 -0
  159. data/ext/multi_compress/vendor/zstd/lib/compress/zstd_cwksp.h +748 -0
  160. data/ext/multi_compress/vendor/zstd/lib/compress/zstd_double_fast.c +770 -0
  161. data/ext/multi_compress/vendor/zstd/lib/compress/zstd_double_fast.h +50 -0
  162. data/ext/multi_compress/vendor/zstd/lib/compress/zstd_fast.c +968 -0
  163. data/ext/multi_compress/vendor/zstd/lib/compress/zstd_fast.h +38 -0
  164. data/ext/multi_compress/vendor/zstd/lib/compress/zstd_lazy.c +2199 -0
  165. data/ext/multi_compress/vendor/zstd/lib/compress/zstd_lazy.h +202 -0
  166. data/ext/multi_compress/vendor/zstd/lib/compress/zstd_ldm.c +730 -0
  167. data/ext/multi_compress/vendor/zstd/lib/compress/zstd_ldm.h +117 -0
  168. data/ext/multi_compress/vendor/zstd/lib/compress/zstd_ldm_geartab.h +106 -0
  169. data/ext/multi_compress/vendor/zstd/lib/compress/zstd_opt.c +1576 -0
  170. data/ext/multi_compress/vendor/zstd/lib/compress/zstd_opt.h +80 -0
  171. data/ext/multi_compress/vendor/zstd/lib/compress/zstdmt_compress.c +1882 -0
  172. data/ext/multi_compress/vendor/zstd/lib/compress/zstdmt_compress.h +113 -0
  173. data/ext/multi_compress/vendor/zstd/lib/decompress/huf_decompress.c +1944 -0
  174. data/ext/multi_compress/vendor/zstd/lib/decompress/huf_decompress_amd64.S +595 -0
  175. data/ext/multi_compress/vendor/zstd/lib/decompress/zstd_ddict.c +244 -0
  176. data/ext/multi_compress/vendor/zstd/lib/decompress/zstd_ddict.h +44 -0
  177. data/ext/multi_compress/vendor/zstd/lib/decompress/zstd_decompress.c +2407 -0
  178. data/ext/multi_compress/vendor/zstd/lib/decompress/zstd_decompress_block.c +2215 -0
  179. data/ext/multi_compress/vendor/zstd/lib/decompress/zstd_decompress_block.h +73 -0
  180. data/ext/multi_compress/vendor/zstd/lib/decompress/zstd_decompress_internal.h +240 -0
  181. data/ext/multi_compress/vendor/zstd/lib/deprecated/zbuff.h +214 -0
  182. data/ext/multi_compress/vendor/zstd/lib/deprecated/zbuff_common.c +26 -0
  183. data/ext/multi_compress/vendor/zstd/lib/deprecated/zbuff_compress.c +167 -0
  184. data/ext/multi_compress/vendor/zstd/lib/deprecated/zbuff_decompress.c +77 -0
  185. data/ext/multi_compress/vendor/zstd/lib/dictBuilder/cover.c +1261 -0
  186. data/ext/multi_compress/vendor/zstd/lib/dictBuilder/cover.h +152 -0
  187. data/ext/multi_compress/vendor/zstd/lib/dictBuilder/divsufsort.c +1913 -0
  188. data/ext/multi_compress/vendor/zstd/lib/dictBuilder/divsufsort.h +67 -0
  189. data/ext/multi_compress/vendor/zstd/lib/dictBuilder/fastcover.c +766 -0
  190. data/ext/multi_compress/vendor/zstd/lib/dictBuilder/zdict.c +1133 -0
  191. data/ext/multi_compress/vendor/zstd/lib/dll/example/Makefile +48 -0
  192. data/ext/multi_compress/vendor/zstd/lib/dll/example/README.md +63 -0
  193. data/ext/multi_compress/vendor/zstd/lib/dll/example/build_package.bat +20 -0
  194. data/ext/multi_compress/vendor/zstd/lib/dll/example/fullbench-dll.sln +25 -0
  195. data/ext/multi_compress/vendor/zstd/lib/dll/example/fullbench-dll.vcxproj +181 -0
  196. data/ext/multi_compress/vendor/zstd/lib/legacy/zstd_legacy.h +452 -0
  197. data/ext/multi_compress/vendor/zstd/lib/legacy/zstd_v01.c +2127 -0
  198. data/ext/multi_compress/vendor/zstd/lib/legacy/zstd_v01.h +94 -0
  199. data/ext/multi_compress/vendor/zstd/lib/legacy/zstd_v02.c +3465 -0
  200. data/ext/multi_compress/vendor/zstd/lib/legacy/zstd_v02.h +93 -0
  201. data/ext/multi_compress/vendor/zstd/lib/legacy/zstd_v03.c +3105 -0
  202. data/ext/multi_compress/vendor/zstd/lib/legacy/zstd_v03.h +93 -0
  203. data/ext/multi_compress/vendor/zstd/lib/legacy/zstd_v04.c +3598 -0
  204. data/ext/multi_compress/vendor/zstd/lib/legacy/zstd_v04.h +142 -0
  205. data/ext/multi_compress/vendor/zstd/lib/legacy/zstd_v05.c +4005 -0
  206. data/ext/multi_compress/vendor/zstd/lib/legacy/zstd_v05.h +162 -0
  207. data/ext/multi_compress/vendor/zstd/lib/legacy/zstd_v06.c +4106 -0
  208. data/ext/multi_compress/vendor/zstd/lib/legacy/zstd_v06.h +172 -0
  209. data/ext/multi_compress/vendor/zstd/lib/legacy/zstd_v07.c +4490 -0
  210. data/ext/multi_compress/vendor/zstd/lib/legacy/zstd_v07.h +187 -0
  211. data/ext/multi_compress/vendor/zstd/lib/libzstd.mk +237 -0
  212. data/ext/multi_compress/vendor/zstd/lib/libzstd.pc.in +16 -0
  213. data/ext/multi_compress/vendor/zstd/lib/module.modulemap +35 -0
  214. data/ext/multi_compress/vendor/zstd/lib/zdict.h +474 -0
  215. data/ext/multi_compress/vendor/zstd/lib/zstd.h +3089 -0
  216. data/ext/multi_compress/vendor/zstd/lib/zstd_errors.h +114 -0
  217. data/lib/multi_compress/version.rb +5 -0
  218. data/lib/multi_compress.rb +329 -0
  219. metadata +322 -0
@@ -0,0 +1,501 @@
1
+ /* Copyright 2013 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
+ /**
8
+ * @file
9
+ * API for Brotli compression.
10
+ */
11
+
12
+ #ifndef BROTLI_ENC_ENCODE_H_
13
+ #define BROTLI_ENC_ENCODE_H_
14
+
15
+ #include <brotli/port.h>
16
+ #include <brotli/shared_dictionary.h>
17
+ #include <brotli/types.h>
18
+
19
+ #if defined(__cplusplus) || defined(c_plusplus)
20
+ extern "C" {
21
+ #endif
22
+
23
+ /** Minimal value for ::BROTLI_PARAM_LGWIN parameter. */
24
+ #define BROTLI_MIN_WINDOW_BITS 10
25
+ /**
26
+ * Maximal value for ::BROTLI_PARAM_LGWIN parameter.
27
+ *
28
+ * @note equal to @c BROTLI_MAX_DISTANCE_BITS constant.
29
+ */
30
+ #define BROTLI_MAX_WINDOW_BITS 24
31
+ /**
32
+ * Maximal value for ::BROTLI_PARAM_LGWIN parameter
33
+ * in "Large Window Brotli" (32-bit).
34
+ */
35
+ #define BROTLI_LARGE_MAX_WINDOW_BITS 30
36
+ /** Minimal value for ::BROTLI_PARAM_LGBLOCK parameter. */
37
+ #define BROTLI_MIN_INPUT_BLOCK_BITS 16
38
+ /** Maximal value for ::BROTLI_PARAM_LGBLOCK parameter. */
39
+ #define BROTLI_MAX_INPUT_BLOCK_BITS 24
40
+ /** Minimal value for ::BROTLI_PARAM_QUALITY parameter. */
41
+ #define BROTLI_MIN_QUALITY 0
42
+ /** Maximal value for ::BROTLI_PARAM_QUALITY parameter. */
43
+ #define BROTLI_MAX_QUALITY 11
44
+
45
+ /** Options for ::BROTLI_PARAM_MODE parameter. */
46
+ typedef enum BrotliEncoderMode {
47
+ /**
48
+ * Default compression mode.
49
+ *
50
+ * In this mode compressor does not know anything in advance about the
51
+ * properties of the input.
52
+ */
53
+ BROTLI_MODE_GENERIC = 0,
54
+ /** Compression mode for UTF-8 formatted text input. */
55
+ BROTLI_MODE_TEXT = 1,
56
+ /** Compression mode used in WOFF 2.0. */
57
+ BROTLI_MODE_FONT = 2
58
+ } BrotliEncoderMode;
59
+
60
+ /** Default value for ::BROTLI_PARAM_QUALITY parameter. */
61
+ #define BROTLI_DEFAULT_QUALITY 11
62
+ /** Default value for ::BROTLI_PARAM_LGWIN parameter. */
63
+ #define BROTLI_DEFAULT_WINDOW 22
64
+ /** Default value for ::BROTLI_PARAM_MODE parameter. */
65
+ #define BROTLI_DEFAULT_MODE BROTLI_MODE_GENERIC
66
+
67
+ /** Operations that can be performed by streaming encoder. */
68
+ typedef enum BrotliEncoderOperation {
69
+ /**
70
+ * Process input.
71
+ *
72
+ * Encoder may postpone producing output, until it has processed enough input.
73
+ */
74
+ BROTLI_OPERATION_PROCESS = 0,
75
+ /**
76
+ * Produce output for all processed input.
77
+ *
78
+ * Actual flush is performed when input stream is depleted and there is enough
79
+ * space in output stream. This means that client should repeat
80
+ * ::BROTLI_OPERATION_FLUSH operation until @p available_in becomes @c 0, and
81
+ * ::BrotliEncoderHasMoreOutput returns ::BROTLI_FALSE. If output is acquired
82
+ * via ::BrotliEncoderTakeOutput, then operation should be repeated after
83
+ * output buffer is drained.
84
+ *
85
+ * @warning Until flush is complete, client @b SHOULD @b NOT swap,
86
+ * reduce or extend input stream.
87
+ *
88
+ * When flush is complete, output data will be sufficient for decoder to
89
+ * reproduce all the given input.
90
+ */
91
+ BROTLI_OPERATION_FLUSH = 1,
92
+ /**
93
+ * Finalize the stream.
94
+ *
95
+ * Actual finalization is performed when input stream is depleted and there is
96
+ * enough space in output stream. This means that client should repeat
97
+ * ::BROTLI_OPERATION_FINISH operation until @p available_in becomes @c 0, and
98
+ * ::BrotliEncoderHasMoreOutput returns ::BROTLI_FALSE. If output is acquired
99
+ * via ::BrotliEncoderTakeOutput, then operation should be repeated after
100
+ * output buffer is drained.
101
+ *
102
+ * @warning Until finalization is complete, client @b SHOULD @b NOT swap,
103
+ * reduce or extend input stream.
104
+ *
105
+ * Helper function ::BrotliEncoderIsFinished checks if stream is finalized and
106
+ * output fully dumped.
107
+ *
108
+ * Adding more input data to finalized stream is impossible.
109
+ */
110
+ BROTLI_OPERATION_FINISH = 2,
111
+ /**
112
+ * Emit metadata block to stream.
113
+ *
114
+ * Metadata is opaque to Brotli: neither encoder, nor decoder processes this
115
+ * data or relies on it. It may be used to pass some extra information from
116
+ * encoder client to decoder client without interfering with main data stream.
117
+ *
118
+ * @note Encoder may emit empty metadata blocks internally, to pad encoded
119
+ * stream to byte boundary.
120
+ *
121
+ * @warning Until emitting metadata is complete client @b SHOULD @b NOT swap,
122
+ * reduce or extend input stream.
123
+ *
124
+ * @warning The whole content of input buffer is considered to be the content
125
+ * of metadata block. Do @b NOT @e append metadata to input stream,
126
+ * before it is depleted with other operations.
127
+ *
128
+ * Stream is soft-flushed before metadata block is emitted. Metadata block
129
+ * @b MUST be no longer than than 16MiB.
130
+ */
131
+ BROTLI_OPERATION_EMIT_METADATA = 3
132
+ } BrotliEncoderOperation;
133
+
134
+ /** Options to be used with ::BrotliEncoderSetParameter. */
135
+ typedef enum BrotliEncoderParameter {
136
+ /**
137
+ * Tune encoder for specific input.
138
+ *
139
+ * ::BrotliEncoderMode enumerates all available values.
140
+ */
141
+ BROTLI_PARAM_MODE = 0,
142
+ /**
143
+ * The main compression speed-density lever.
144
+ *
145
+ * The higher the quality, the slower the compression. Range is
146
+ * from ::BROTLI_MIN_QUALITY to ::BROTLI_MAX_QUALITY.
147
+ */
148
+ BROTLI_PARAM_QUALITY = 1,
149
+ /**
150
+ * Recommended sliding LZ77 window size.
151
+ *
152
+ * Encoder may reduce this value, e.g. if input is much smaller than
153
+ * window size.
154
+ *
155
+ * Window size is `(1 << value) - 16`.
156
+ *
157
+ * Range is from ::BROTLI_MIN_WINDOW_BITS to ::BROTLI_MAX_WINDOW_BITS.
158
+ */
159
+ BROTLI_PARAM_LGWIN = 2,
160
+ /**
161
+ * Recommended input block size.
162
+ *
163
+ * Encoder may reduce this value, e.g. if input is much smaller than input
164
+ * block size.
165
+ *
166
+ * Range is from ::BROTLI_MIN_INPUT_BLOCK_BITS to
167
+ * ::BROTLI_MAX_INPUT_BLOCK_BITS.
168
+ *
169
+ * @note Bigger input block size allows better compression, but consumes more
170
+ * memory. \n The rough formula of memory used for temporary input
171
+ * storage is `3 << lgBlock`.
172
+ */
173
+ BROTLI_PARAM_LGBLOCK = 3,
174
+ /**
175
+ * Flag that affects usage of "literal context modeling" format feature.
176
+ *
177
+ * This flag is a "decoding-speed vs compression ratio" trade-off.
178
+ */
179
+ BROTLI_PARAM_DISABLE_LITERAL_CONTEXT_MODELING = 4,
180
+ /**
181
+ * Estimated total input size for all ::BrotliEncoderCompressStream calls.
182
+ *
183
+ * The default value is 0, which means that the total input size is unknown.
184
+ */
185
+ BROTLI_PARAM_SIZE_HINT = 5,
186
+ /**
187
+ * Flag that determines if "Large Window Brotli" is used.
188
+ */
189
+ BROTLI_PARAM_LARGE_WINDOW = 6,
190
+ /**
191
+ * Recommended number of postfix bits (NPOSTFIX).
192
+ *
193
+ * Encoder may change this value.
194
+ *
195
+ * Range is from 0 to ::BROTLI_MAX_NPOSTFIX.
196
+ */
197
+ BROTLI_PARAM_NPOSTFIX = 7,
198
+ /**
199
+ * Recommended number of direct distance codes (NDIRECT).
200
+ *
201
+ * Encoder may change this value.
202
+ *
203
+ * Range is from 0 to (15 << NPOSTFIX) in steps of (1 << NPOSTFIX).
204
+ */
205
+ BROTLI_PARAM_NDIRECT = 8,
206
+ /**
207
+ * Number of bytes of input stream already processed by a different instance.
208
+ *
209
+ * @note It is important to configure all the encoder instances with same
210
+ * parameters (except this one) in order to allow all the encoded parts
211
+ * obey the same restrictions implied by header.
212
+ *
213
+ * If offset is not 0, then stream header is omitted.
214
+ * In any case output start is byte aligned, so for proper streams stitching
215
+ * "predecessor" stream must be flushed.
216
+ *
217
+ * Range is not artificially limited, but all the values greater or equal to
218
+ * maximal window size have the same effect. Values greater than 2**30 are not
219
+ * allowed.
220
+ */
221
+ BROTLI_PARAM_STREAM_OFFSET = 9
222
+ } BrotliEncoderParameter;
223
+
224
+ /**
225
+ * Opaque structure that holds encoder state.
226
+ *
227
+ * Allocated and initialized with ::BrotliEncoderCreateInstance.
228
+ * Cleaned up and deallocated with ::BrotliEncoderDestroyInstance.
229
+ */
230
+ typedef struct BrotliEncoderStateStruct BrotliEncoderState;
231
+
232
+ /**
233
+ * Sets the specified parameter to the given encoder instance.
234
+ *
235
+ * @param state encoder instance
236
+ * @param param parameter to set
237
+ * @param value new parameter value
238
+ * @returns ::BROTLI_FALSE if parameter is unrecognized, or value is invalid
239
+ * @returns ::BROTLI_FALSE if value of parameter can not be changed at current
240
+ * encoder state (e.g. when encoding is started, window size might be
241
+ * already encoded and therefore it is impossible to change it)
242
+ * @returns ::BROTLI_TRUE if value is accepted
243
+ * @warning invalid values might be accepted in case they would not break
244
+ * encoding process.
245
+ */
246
+ BROTLI_ENC_API BROTLI_BOOL BrotliEncoderSetParameter(
247
+ BrotliEncoderState* state, BrotliEncoderParameter param, uint32_t value);
248
+
249
+ /**
250
+ * Creates an instance of ::BrotliEncoderState and initializes it.
251
+ *
252
+ * @p alloc_func and @p free_func @b MUST be both zero or both non-zero. In the
253
+ * case they are both zero, default memory allocators are used. @p opaque is
254
+ * passed to @p alloc_func and @p free_func when they are called. @p free_func
255
+ * has to return without doing anything when asked to free a NULL pointer.
256
+ *
257
+ * @param alloc_func custom memory allocation function
258
+ * @param free_func custom memory free function
259
+ * @param opaque custom memory manager handle
260
+ * @returns @c 0 if instance can not be allocated or initialized
261
+ * @returns pointer to initialized ::BrotliEncoderState otherwise
262
+ */
263
+ BROTLI_ENC_API BrotliEncoderState* BrotliEncoderCreateInstance(
264
+ brotli_alloc_func alloc_func, brotli_free_func free_func, void* opaque);
265
+
266
+ /**
267
+ * Deinitializes and frees ::BrotliEncoderState instance.
268
+ *
269
+ * @param state decoder instance to be cleaned up and deallocated
270
+ */
271
+ BROTLI_ENC_API void BrotliEncoderDestroyInstance(BrotliEncoderState* state);
272
+
273
+ /* Opaque type for pointer to different possible internal structures containing
274
+ dictionary prepared for the encoder */
275
+ typedef struct BrotliEncoderPreparedDictionaryStruct
276
+ BrotliEncoderPreparedDictionary;
277
+
278
+ /**
279
+ * Prepares a shared dictionary from the given file format for the encoder.
280
+ *
281
+ * @p alloc_func and @p free_func @b MUST be both zero or both non-zero. In the
282
+ * case they are both zero, default memory allocators are used. @p opaque is
283
+ * passed to @p alloc_func and @p free_func when they are called. @p free_func
284
+ * has to return without doing anything when asked to free a NULL pointer.
285
+ *
286
+ * @param type type of dictionary stored in data
287
+ * @param data_size size of @p data buffer
288
+ * @param data pointer to the dictionary data
289
+ * @param quality the maximum Brotli quality to prepare the dictionary for,
290
+ * use BROTLI_MAX_QUALITY by default
291
+ * @param alloc_func custom memory allocation function
292
+ * @param free_func custom memory free function
293
+ * @param opaque custom memory manager handle
294
+ */
295
+ BROTLI_ENC_API BrotliEncoderPreparedDictionary*
296
+ BrotliEncoderPrepareDictionary(BrotliSharedDictionaryType type,
297
+ size_t data_size, const uint8_t data[BROTLI_ARRAY_PARAM(data_size)],
298
+ int quality,
299
+ brotli_alloc_func alloc_func, brotli_free_func free_func, void* opaque);
300
+
301
+ BROTLI_ENC_API void BrotliEncoderDestroyPreparedDictionary(
302
+ BrotliEncoderPreparedDictionary* dictionary);
303
+
304
+ /**
305
+ * Attaches a prepared dictionary of any type to the encoder. Can be used
306
+ * multiple times to attach multiple dictionaries. The dictionary type was
307
+ * determined by BrotliEncoderPrepareDictionary. Multiple raw prefix
308
+ * dictionaries and/or max 1 serialized dictionary with custom words can be
309
+ * attached.
310
+ *
311
+ * @returns ::BROTLI_FALSE in case of error
312
+ * @returns ::BROTLI_TRUE otherwise
313
+ */
314
+ BROTLI_ENC_API BROTLI_BOOL BrotliEncoderAttachPreparedDictionary(
315
+ BrotliEncoderState* state,
316
+ const BrotliEncoderPreparedDictionary* dictionary);
317
+
318
+ /**
319
+ * Calculates the output size bound for the given @p input_size.
320
+ *
321
+ * @warning Result is only valid if quality is at least @c 2 and, in
322
+ * case ::BrotliEncoderCompressStream was used, no flushes
323
+ * (::BROTLI_OPERATION_FLUSH) were performed.
324
+ *
325
+ * @param input_size size of projected input
326
+ * @returns @c 0 if result does not fit @c size_t
327
+ */
328
+ BROTLI_ENC_API size_t BrotliEncoderMaxCompressedSize(size_t input_size);
329
+
330
+ /**
331
+ * Performs one-shot memory-to-memory compression.
332
+ *
333
+ * Compresses the data in @p input_buffer into @p encoded_buffer, and sets
334
+ * @p *encoded_size to the compressed length.
335
+ *
336
+ * @note If ::BrotliEncoderMaxCompressedSize(@p input_size) returns non-zero
337
+ * value, then output is guaranteed to be no longer than that.
338
+ *
339
+ * @note If @p lgwin is greater than ::BROTLI_MAX_WINDOW_BITS then resulting
340
+ * stream might be incompatible with RFC 7932; to decode such streams,
341
+ * decoder should be configured with
342
+ * ::BROTLI_DECODER_PARAM_LARGE_WINDOW = @c 1
343
+ *
344
+ * @param quality quality parameter value, e.g. ::BROTLI_DEFAULT_QUALITY
345
+ * @param lgwin lgwin parameter value, e.g. ::BROTLI_DEFAULT_WINDOW
346
+ * @param mode mode parameter value, e.g. ::BROTLI_DEFAULT_MODE
347
+ * @param input_size size of @p input_buffer
348
+ * @param input_buffer input data buffer with at least @p input_size
349
+ * addressable bytes
350
+ * @param[in, out] encoded_size @b in: size of @p encoded_buffer; \n
351
+ * @b out: length of compressed data written to
352
+ * @p encoded_buffer, or @c 0 if compression fails
353
+ * @param encoded_buffer compressed data destination buffer
354
+ * @returns ::BROTLI_FALSE in case of compression error
355
+ * @returns ::BROTLI_FALSE if output buffer is too small
356
+ * @returns ::BROTLI_TRUE otherwise
357
+ */
358
+ BROTLI_ENC_API BROTLI_BOOL BrotliEncoderCompress(
359
+ int quality, int lgwin, BrotliEncoderMode mode, size_t input_size,
360
+ const uint8_t input_buffer[BROTLI_ARRAY_PARAM(input_size)],
361
+ size_t* encoded_size,
362
+ uint8_t encoded_buffer[BROTLI_ARRAY_PARAM(*encoded_size)]);
363
+
364
+ /**
365
+ * Compresses input stream to output stream.
366
+ *
367
+ * The values @p *available_in and @p *available_out must specify the number of
368
+ * bytes addressable at @p *next_in and @p *next_out respectively.
369
+ * When @p *available_out is @c 0, @p next_out is allowed to be @c NULL.
370
+ *
371
+ * After each call, @p *available_in will be decremented by the amount of input
372
+ * bytes consumed, and the @p *next_in pointer will be incremented by that
373
+ * amount. Similarly, @p *available_out will be decremented by the amount of
374
+ * output bytes written, and the @p *next_out pointer will be incremented by
375
+ * that amount.
376
+ *
377
+ * @p total_out, if it is not a null-pointer, will be set to the number
378
+ * of bytes compressed since the last @p state initialization.
379
+ *
380
+ *
381
+ *
382
+ * Internally workflow consists of 3 tasks:
383
+ * -# (optionally) copy input data to internal buffer
384
+ * -# actually compress data and (optionally) store it to internal buffer
385
+ * -# (optionally) copy compressed bytes from internal buffer to output stream
386
+ *
387
+ * Whenever all 3 tasks can't move forward anymore, or error occurs, this
388
+ * method returns the control flow to caller.
389
+ *
390
+ * @p op is used to perform flush, finish the stream, or inject metadata block.
391
+ * See ::BrotliEncoderOperation for more information.
392
+ *
393
+ * Flushing the stream means forcing encoding of all input passed to encoder and
394
+ * completing the current output block, so it could be fully decoded by stream
395
+ * decoder. To perform flush set @p op to ::BROTLI_OPERATION_FLUSH.
396
+ * Under some circumstances (e.g. lack of output stream capacity) this operation
397
+ * would require several calls to ::BrotliEncoderCompressStream. The method must
398
+ * be called again until both input stream is depleted and encoder has no more
399
+ * output (see ::BrotliEncoderHasMoreOutput) after the method is called.
400
+ *
401
+ * Finishing the stream means encoding of all input passed to encoder and
402
+ * adding specific "final" marks, so stream decoder could determine that stream
403
+ * is complete. To perform finish set @p op to ::BROTLI_OPERATION_FINISH.
404
+ * Under some circumstances (e.g. lack of output stream capacity) this operation
405
+ * would require several calls to ::BrotliEncoderCompressStream. The method must
406
+ * be called again until both input stream is depleted and encoder has no more
407
+ * output (see ::BrotliEncoderHasMoreOutput) after the method is called.
408
+ *
409
+ * @warning When flushing and finishing, @p op should not change until operation
410
+ * is complete; input stream should not be swapped, reduced or
411
+ * extended as well.
412
+ *
413
+ * @param state encoder instance
414
+ * @param op requested operation
415
+ * @param[in, out] available_in @b in: amount of available input; \n
416
+ * @b out: amount of unused input
417
+ * @param[in, out] next_in pointer to the next input byte
418
+ * @param[in, out] available_out @b in: length of output buffer; \n
419
+ * @b out: remaining size of output buffer
420
+ * @param[in, out] next_out compressed output buffer cursor;
421
+ * can be @c NULL if @p available_out is @c 0
422
+ * @param[out] total_out number of bytes produced so far; can be @c NULL
423
+ * @returns ::BROTLI_FALSE if there was an error
424
+ * @returns ::BROTLI_TRUE otherwise
425
+ */
426
+ BROTLI_ENC_API BROTLI_BOOL BrotliEncoderCompressStream(
427
+ BrotliEncoderState* state, BrotliEncoderOperation op, size_t* available_in,
428
+ const uint8_t** next_in, size_t* available_out, uint8_t** next_out,
429
+ size_t* total_out);
430
+
431
+ /**
432
+ * Checks if encoder instance reached the final state.
433
+ *
434
+ * @param state encoder instance
435
+ * @returns ::BROTLI_TRUE if encoder is in a state where it reached the end of
436
+ * the input and produced all of the output
437
+ * @returns ::BROTLI_FALSE otherwise
438
+ */
439
+ BROTLI_ENC_API BROTLI_BOOL BrotliEncoderIsFinished(BrotliEncoderState* state);
440
+
441
+ /**
442
+ * Checks if encoder has more output.
443
+ *
444
+ * @param state encoder instance
445
+ * @returns ::BROTLI_TRUE, if encoder has some unconsumed output
446
+ * @returns ::BROTLI_FALSE otherwise
447
+ */
448
+ BROTLI_ENC_API BROTLI_BOOL BrotliEncoderHasMoreOutput(
449
+ BrotliEncoderState* state);
450
+
451
+ /**
452
+ * Acquires pointer to internal output buffer.
453
+ *
454
+ * This method is used to make language bindings easier and more efficient:
455
+ * -# push data to ::BrotliEncoderCompressStream,
456
+ * until ::BrotliEncoderHasMoreOutput returns BROTLI_TRUE
457
+ * -# use ::BrotliEncoderTakeOutput to peek bytes and copy to language-specific
458
+ * entity
459
+ *
460
+ * Also this could be useful if there is an output stream that is able to
461
+ * consume all the provided data (e.g. when data is saved to file system).
462
+ *
463
+ * @attention After every call to ::BrotliEncoderTakeOutput @p *size bytes of
464
+ * output are considered consumed for all consecutive calls to the
465
+ * instance methods; returned pointer becomes invalidated as well.
466
+ *
467
+ * @note Encoder output is not guaranteed to be contiguous. This means that
468
+ * after the size-unrestricted call to ::BrotliEncoderTakeOutput,
469
+ * immediate next call to ::BrotliEncoderTakeOutput may return more data.
470
+ *
471
+ * @param state encoder instance
472
+ * @param[in, out] size @b in: number of bytes caller is ready to take, @c 0 if
473
+ * any amount could be handled; \n
474
+ * @b out: amount of data pointed by returned pointer and
475
+ * considered consumed; \n
476
+ * out value is never greater than in value, unless it is @c 0
477
+ * @returns pointer to output data
478
+ */
479
+ BROTLI_ENC_API const uint8_t* BrotliEncoderTakeOutput(
480
+ BrotliEncoderState* state, size_t* size);
481
+
482
+ /* Returns the estimated peak memory usage (in bytes) of the BrotliCompress()
483
+ function, not counting the memory needed for the input and output. */
484
+ BROTLI_ENC_EXTRA_API size_t BrotliEncoderEstimatePeakMemoryUsage(
485
+ int quality, int lgwin, size_t input_size);
486
+ /* Returns 0 if dictionary is not valid; otherwise returns allocation size. */
487
+ BROTLI_ENC_EXTRA_API size_t BrotliEncoderGetPreparedDictionarySize(
488
+ const BrotliEncoderPreparedDictionary* dictionary);
489
+
490
+ /**
491
+ * Gets an encoder library version.
492
+ *
493
+ * Look at BROTLI_MAKE_HEX_VERSION for more information.
494
+ */
495
+ BROTLI_ENC_API uint32_t BrotliEncoderVersion(void);
496
+
497
+ #if defined(__cplusplus) || defined(c_plusplus)
498
+ } /* extern "C" */
499
+ #endif
500
+
501
+ #endif /* BROTLI_ENC_ENCODE_H_ */