brotli 0.2.0 → 0.2.1

Sign up to get free protection for your applications and to get access to all the features.
Files changed (106) hide show
  1. checksums.yaml +5 -5
  2. data/Gemfile +1 -0
  3. data/Rakefile +6 -1
  4. data/brotli.gemspec +1 -1
  5. data/docs/Brotli.html +485 -0
  6. data/docs/Brotli/Error.html +124 -0
  7. data/docs/_index.html +122 -0
  8. data/docs/class_list.html +51 -0
  9. data/docs/css/common.css +1 -0
  10. data/docs/css/full_list.css +58 -0
  11. data/docs/css/style.css +496 -0
  12. data/docs/file.README.html +127 -0
  13. data/docs/file_list.html +56 -0
  14. data/docs/frames.html +17 -0
  15. data/docs/index.html +127 -0
  16. data/docs/js/app.js +292 -0
  17. data/docs/js/full_list.js +216 -0
  18. data/docs/js/jquery.js +4 -0
  19. data/docs/method_list.html +67 -0
  20. data/docs/top-level-namespace.html +110 -0
  21. data/ext/brotli/brotli.c +20 -0
  22. data/lib/brotli/version.rb +1 -1
  23. data/vendor/brotli/c/common/constants.h +13 -6
  24. data/vendor/brotli/c/{dec → common}/context.h +182 -172
  25. data/vendor/brotli/c/common/dictionary.bin +0 -0
  26. data/vendor/brotli/c/common/dictionary.bin.br +0 -0
  27. data/vendor/brotli/c/common/dictionary.c +1 -1
  28. data/vendor/brotli/c/common/dictionary.h +4 -4
  29. data/vendor/brotli/c/common/platform.h +509 -0
  30. data/vendor/brotli/c/common/transform.c +235 -0
  31. data/vendor/brotli/c/common/transform.h +80 -0
  32. data/vendor/brotli/c/common/version.h +8 -1
  33. data/vendor/brotli/c/dec/bit_reader.c +1 -1
  34. data/vendor/brotli/c/dec/bit_reader.h +35 -86
  35. data/vendor/brotli/c/dec/decode.c +322 -205
  36. data/vendor/brotli/c/dec/huffman.c +35 -37
  37. data/vendor/brotli/c/dec/huffman.h +13 -9
  38. data/vendor/brotli/c/dec/prefix.h +3 -4
  39. data/vendor/brotli/c/dec/state.c +26 -34
  40. data/vendor/brotli/c/dec/state.h +34 -23
  41. data/vendor/brotli/c/enc/backward_references.c +25 -15
  42. data/vendor/brotli/c/enc/backward_references.h +5 -6
  43. data/vendor/brotli/c/enc/backward_references_hq.c +94 -68
  44. data/vendor/brotli/c/enc/backward_references_hq.h +22 -25
  45. data/vendor/brotli/c/enc/backward_references_inc.h +10 -10
  46. data/vendor/brotli/c/enc/bit_cost.c +1 -1
  47. data/vendor/brotli/c/enc/bit_cost.h +5 -5
  48. data/vendor/brotli/c/enc/block_encoder_inc.h +7 -6
  49. data/vendor/brotli/c/enc/block_splitter.c +2 -3
  50. data/vendor/brotli/c/enc/block_splitter.h +1 -1
  51. data/vendor/brotli/c/enc/block_splitter_inc.h +11 -11
  52. data/vendor/brotli/c/enc/brotli_bit_stream.c +102 -101
  53. data/vendor/brotli/c/enc/brotli_bit_stream.h +19 -38
  54. data/vendor/brotli/c/enc/cluster.c +1 -1
  55. data/vendor/brotli/c/enc/cluster.h +1 -1
  56. data/vendor/brotli/c/enc/command.h +40 -30
  57. data/vendor/brotli/c/enc/compress_fragment.c +21 -22
  58. data/vendor/brotli/c/enc/compress_fragment.h +1 -1
  59. data/vendor/brotli/c/enc/compress_fragment_two_pass.c +101 -68
  60. data/vendor/brotli/c/enc/compress_fragment_two_pass.h +1 -1
  61. data/vendor/brotli/c/enc/dictionary_hash.c +1 -1
  62. data/vendor/brotli/c/enc/encode.c +262 -162
  63. data/vendor/brotli/c/enc/encoder_dict.c +32 -0
  64. data/vendor/brotli/c/enc/encoder_dict.h +41 -0
  65. data/vendor/brotli/c/enc/entropy_encode.c +14 -14
  66. data/vendor/brotli/c/enc/entropy_encode.h +5 -5
  67. data/vendor/brotli/c/enc/entropy_encode_static.h +3 -3
  68. data/vendor/brotli/c/enc/fast_log.h +4 -2
  69. data/vendor/brotli/c/enc/find_match_length.h +3 -3
  70. data/vendor/brotli/c/enc/hash.h +75 -24
  71. data/vendor/brotli/c/enc/hash_composite_inc.h +133 -0
  72. data/vendor/brotli/c/enc/hash_forgetful_chain_inc.h +9 -8
  73. data/vendor/brotli/c/enc/hash_longest_match64_inc.h +8 -8
  74. data/vendor/brotli/c/enc/hash_longest_match_inc.h +8 -8
  75. data/vendor/brotli/c/enc/hash_longest_match_quickly_inc.h +10 -9
  76. data/vendor/brotli/c/enc/hash_rolling_inc.h +215 -0
  77. data/vendor/brotli/c/enc/hash_to_binary_tree_inc.h +9 -8
  78. data/vendor/brotli/c/enc/histogram.c +9 -6
  79. data/vendor/brotli/c/enc/histogram.h +6 -3
  80. data/vendor/brotli/c/enc/histogram_inc.h +1 -1
  81. data/vendor/brotli/c/enc/literal_cost.c +5 -5
  82. data/vendor/brotli/c/enc/literal_cost.h +2 -2
  83. data/vendor/brotli/c/enc/memory.c +5 -16
  84. data/vendor/brotli/c/enc/memory.h +40 -1
  85. data/vendor/brotli/c/enc/metablock.c +163 -25
  86. data/vendor/brotli/c/enc/metablock.h +13 -8
  87. data/vendor/brotli/c/enc/metablock_inc.h +1 -1
  88. data/vendor/brotli/c/enc/params.h +44 -0
  89. data/vendor/brotli/c/enc/prefix.h +3 -4
  90. data/vendor/brotli/c/enc/quality.h +29 -24
  91. data/vendor/brotli/c/enc/ringbuffer.h +15 -11
  92. data/vendor/brotli/c/enc/static_dict.c +49 -45
  93. data/vendor/brotli/c/enc/static_dict.h +4 -3
  94. data/vendor/brotli/c/enc/static_dict_lut.h +1 -1
  95. data/vendor/brotli/c/enc/utf8_util.c +20 -20
  96. data/vendor/brotli/c/enc/utf8_util.h +1 -1
  97. data/vendor/brotli/c/enc/write_bits.h +16 -21
  98. data/vendor/brotli/c/include/brotli/decode.h +13 -8
  99. data/vendor/brotli/c/include/brotli/encode.h +33 -8
  100. data/vendor/brotli/c/include/brotli/port.h +211 -83
  101. data/vendor/brotli/c/include/brotli/types.h +0 -7
  102. metadata +33 -12
  103. data/vendor/brotli/c/dec/port.h +0 -168
  104. data/vendor/brotli/c/dec/transform.h +0 -300
  105. data/vendor/brotli/c/enc/context.h +0 -184
  106. data/vendor/brotli/c/enc/port.h +0 -184
@@ -1,184 +0,0 @@
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
- /* Functions to map previous bytes into a context id. */
8
-
9
- #ifndef BROTLI_ENC_CONTEXT_H_
10
- #define BROTLI_ENC_CONTEXT_H_
11
-
12
- #include <brotli/port.h>
13
- #include <brotli/types.h>
14
-
15
- #if defined(__cplusplus) || defined(c_plusplus)
16
- extern "C" {
17
- #endif
18
-
19
- /* Second-order context lookup table for UTF8 byte streams.
20
-
21
- If p1 and p2 are the previous two bytes, we calculate the context as
22
-
23
- context = kUTF8ContextLookup[p1] | kUTF8ContextLookup[p2 + 256].
24
-
25
- If the previous two bytes are ASCII characters (i.e. < 128), this will be
26
- equivalent to
27
-
28
- context = 4 * context1(p1) + context2(p2),
29
-
30
- where context1 is based on the previous byte in the following way:
31
-
32
- 0 : non-ASCII control
33
- 1 : \t, \n, \r
34
- 2 : space
35
- 3 : other punctuation
36
- 4 : " '
37
- 5 : %
38
- 6 : ( < [ {
39
- 7 : ) > ] }
40
- 8 : , ; :
41
- 9 : .
42
- 10 : =
43
- 11 : number
44
- 12 : upper-case vowel
45
- 13 : upper-case consonant
46
- 14 : lower-case vowel
47
- 15 : lower-case consonant
48
-
49
- and context2 is based on the second last byte:
50
-
51
- 0 : control, space
52
- 1 : punctuation
53
- 2 : upper-case letter, number
54
- 3 : lower-case letter
55
-
56
- If the last byte is ASCII, and the second last byte is not (in a valid UTF8
57
- stream it will be a continuation byte, value between 128 and 191), the
58
- context is the same as if the second last byte was an ASCII control or space.
59
-
60
- If the last byte is a UTF8 lead byte (value >= 192), then the next byte will
61
- be a continuation byte and the context id is 2 or 3 depending on the LSB of
62
- the last byte and to a lesser extent on the second last byte if it is ASCII.
63
-
64
- If the last byte is a UTF8 continuation byte, the second last byte can be:
65
- - continuation byte: the next byte is probably ASCII or lead byte (assuming
66
- 4-byte UTF8 characters are rare) and the context id is 0 or 1.
67
- - lead byte (192 - 207): next byte is ASCII or lead byte, context is 0 or 1
68
- - lead byte (208 - 255): next byte is continuation byte, context is 2 or 3
69
-
70
- The possible value combinations of the previous two bytes, the range of
71
- context ids and the type of the next byte is summarized in the table below:
72
-
73
- |--------\-----------------------------------------------------------------|
74
- | \ Last byte |
75
- | Second \---------------------------------------------------------------|
76
- | last byte \ ASCII | cont. byte | lead byte |
77
- | \ (0-127) | (128-191) | (192-) |
78
- |=============|===================|=====================|==================|
79
- | ASCII | next: ASCII/lead | not valid | next: cont. |
80
- | (0-127) | context: 4 - 63 | | context: 2 - 3 |
81
- |-------------|-------------------|---------------------|------------------|
82
- | cont. byte | next: ASCII/lead | next: ASCII/lead | next: cont. |
83
- | (128-191) | context: 4 - 63 | context: 0 - 1 | context: 2 - 3 |
84
- |-------------|-------------------|---------------------|------------------|
85
- | lead byte | not valid | next: ASCII/lead | not valid |
86
- | (192-207) | | context: 0 - 1 | |
87
- |-------------|-------------------|---------------------|------------------|
88
- | lead byte | not valid | next: cont. | not valid |
89
- | (208-) | | context: 2 - 3 | |
90
- |-------------|-------------------|---------------------|------------------|
91
- */
92
- static const uint8_t kUTF8ContextLookup[512] = {
93
- /* Last byte. */
94
- /* */
95
- /* ASCII range. */
96
- 0, 0, 0, 0, 0, 0, 0, 0, 0, 4, 4, 0, 0, 4, 0, 0,
97
- 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
98
- 8, 12, 16, 12, 12, 20, 12, 16, 24, 28, 12, 12, 32, 12, 36, 12,
99
- 44, 44, 44, 44, 44, 44, 44, 44, 44, 44, 32, 32, 24, 40, 28, 12,
100
- 12, 48, 52, 52, 52, 48, 52, 52, 52, 48, 52, 52, 52, 52, 52, 48,
101
- 52, 52, 52, 52, 52, 48, 52, 52, 52, 52, 52, 24, 12, 28, 12, 12,
102
- 12, 56, 60, 60, 60, 56, 60, 60, 60, 56, 60, 60, 60, 60, 60, 56,
103
- 60, 60, 60, 60, 60, 56, 60, 60, 60, 60, 60, 24, 12, 28, 12, 0,
104
- /* UTF8 continuation byte range. */
105
- 0, 1, 0, 1, 0, 1, 0, 1, 0, 1, 0, 1, 0, 1, 0, 1,
106
- 0, 1, 0, 1, 0, 1, 0, 1, 0, 1, 0, 1, 0, 1, 0, 1,
107
- 0, 1, 0, 1, 0, 1, 0, 1, 0, 1, 0, 1, 0, 1, 0, 1,
108
- 0, 1, 0, 1, 0, 1, 0, 1, 0, 1, 0, 1, 0, 1, 0, 1,
109
- /* UTF8 lead byte range. */
110
- 2, 3, 2, 3, 2, 3, 2, 3, 2, 3, 2, 3, 2, 3, 2, 3,
111
- 2, 3, 2, 3, 2, 3, 2, 3, 2, 3, 2, 3, 2, 3, 2, 3,
112
- 2, 3, 2, 3, 2, 3, 2, 3, 2, 3, 2, 3, 2, 3, 2, 3,
113
- 2, 3, 2, 3, 2, 3, 2, 3, 2, 3, 2, 3, 2, 3, 2, 3,
114
- /* Second last byte. */
115
- /* */
116
- /* ASCII range. */
117
- 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
118
- 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
119
- 0, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1,
120
- 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 1, 1, 1, 1, 1, 1,
121
- 1, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2,
122
- 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 1, 1, 1, 1, 1,
123
- 1, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3,
124
- 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 1, 1, 1, 1, 0,
125
- /* UTF8 continuation byte range. */
126
- 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
127
- 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
128
- 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
129
- 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
130
- /* UTF8 lead byte range. */
131
- 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
132
- 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
133
- 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2,
134
- 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2,
135
- };
136
-
137
- /* Context lookup table for small signed integers. */
138
- static const uint8_t kSigned3BitContextLookup[] = {
139
- 0, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1,
140
- 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2,
141
- 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2,
142
- 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2,
143
- 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3,
144
- 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3,
145
- 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3,
146
- 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3,
147
- 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4,
148
- 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4,
149
- 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4,
150
- 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4,
151
- 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5,
152
- 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5,
153
- 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5,
154
- 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 7,
155
- };
156
-
157
- typedef enum ContextType {
158
- CONTEXT_LSB6 = 0,
159
- CONTEXT_MSB6 = 1,
160
- CONTEXT_UTF8 = 2,
161
- CONTEXT_SIGNED = 3
162
- } ContextType;
163
-
164
- static BROTLI_INLINE uint8_t Context(uint8_t p1, uint8_t p2, ContextType mode) {
165
- switch (mode) {
166
- case CONTEXT_LSB6:
167
- return p1 & 0x3f;
168
- case CONTEXT_MSB6:
169
- return (uint8_t)(p1 >> 2);
170
- case CONTEXT_UTF8:
171
- return kUTF8ContextLookup[p1] | kUTF8ContextLookup[p2 + 256];
172
- case CONTEXT_SIGNED:
173
- return (uint8_t)((kSigned3BitContextLookup[p1] << 3) +
174
- kSigned3BitContextLookup[p2]);
175
- default:
176
- return 0;
177
- }
178
- }
179
-
180
- #if defined(__cplusplus) || defined(c_plusplus)
181
- } /* extern "C" */
182
- #endif
183
-
184
- #endif /* BROTLI_ENC_CONTEXT_H_ */
@@ -1,184 +0,0 @@
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
- /* Macros for endianness, branch prediction and unaligned loads and stores. */
8
-
9
- #ifndef BROTLI_ENC_PORT_H_
10
- #define BROTLI_ENC_PORT_H_
11
-
12
- #include <assert.h>
13
- #include <string.h> /* memcpy */
14
-
15
- #include <brotli/port.h>
16
- #include <brotli/types.h>
17
-
18
- #if defined OS_LINUX || defined OS_CYGWIN
19
- #include <endian.h>
20
- #elif defined OS_FREEBSD
21
- #include <machine/endian.h>
22
- #elif defined OS_MACOSX
23
- #include <machine/endian.h>
24
- /* Let's try and follow the Linux convention */
25
- #define __BYTE_ORDER BYTE_ORDER
26
- #define __LITTLE_ENDIAN LITTLE_ENDIAN
27
- #endif
28
-
29
- /* define the macro BROTLI_LITTLE_ENDIAN
30
- using the above endian definitions from endian.h if
31
- endian.h was included */
32
- #ifdef __BYTE_ORDER
33
- #if __BYTE_ORDER == __LITTLE_ENDIAN
34
- #define BROTLI_LITTLE_ENDIAN
35
- #endif
36
-
37
- #else
38
-
39
- #if defined(__LITTLE_ENDIAN__)
40
- #define BROTLI_LITTLE_ENDIAN
41
- #endif
42
- #endif /* __BYTE_ORDER */
43
-
44
- #if defined(__BYTE_ORDER__) && (__BYTE_ORDER__ == __ORDER_LITTLE_ENDIAN__)
45
- #define BROTLI_LITTLE_ENDIAN
46
- #endif
47
-
48
- /* Enable little-endian optimization for x64 architecture on Windows. */
49
- #if (defined(_WIN32) || defined(_WIN64)) && defined(_M_X64)
50
- #define BROTLI_LITTLE_ENDIAN
51
- #endif
52
-
53
- /* Portable handling of unaligned loads, stores, and copies.
54
- On some platforms, like ARM, the copy functions can be more efficient
55
- then a load and a store. */
56
-
57
- #if defined(BROTLI_LITTLE_ENDIAN) && (\
58
- defined(ARCH_PIII) || defined(ARCH_ATHLON) || \
59
- defined(ARCH_K8) || defined(_ARCH_PPC))
60
-
61
- /* x86 and x86-64 can perform unaligned loads/stores directly;
62
- modern PowerPC hardware can also do unaligned integer loads and stores;
63
- but note: the FPU still sends unaligned loads and stores to a trap handler!
64
- */
65
-
66
- #define BROTLI_UNALIGNED_LOAD32(_p) (*(const uint32_t *)(_p))
67
- #define BROTLI_UNALIGNED_LOAD64LE(_p) (*(const uint64_t *)(_p))
68
-
69
- #define BROTLI_UNALIGNED_STORE64LE(_p, _val) \
70
- (*(uint64_t *)(_p) = (_val))
71
-
72
- #elif defined(BROTLI_LITTLE_ENDIAN) && defined(__arm__) && \
73
- !defined(__ARM_ARCH_5__) && \
74
- !defined(__ARM_ARCH_5T__) && \
75
- !defined(__ARM_ARCH_5TE__) && \
76
- !defined(__ARM_ARCH_5TEJ__) && \
77
- !defined(__ARM_ARCH_6__) && \
78
- !defined(__ARM_ARCH_6J__) && \
79
- !defined(__ARM_ARCH_6K__) && \
80
- !defined(__ARM_ARCH_6Z__) && \
81
- !defined(__ARM_ARCH_6ZK__) && \
82
- !defined(__ARM_ARCH_6T2__)
83
-
84
- /* ARMv7 and newer support native unaligned accesses, but only of 16-bit
85
- and 32-bit values (not 64-bit); older versions either raise a fatal signal,
86
- do an unaligned read and rotate the words around a bit, or do the reads very
87
- slowly (trip through kernel mode). */
88
-
89
- #define BROTLI_UNALIGNED_LOAD32(_p) (*(const uint32_t *)(_p))
90
-
91
- static BROTLI_INLINE uint64_t BROTLI_UNALIGNED_LOAD64LE(const void *p) {
92
- uint64_t t;
93
- memcpy(&t, p, sizeof t);
94
- return t;
95
- }
96
-
97
- static BROTLI_INLINE void BROTLI_UNALIGNED_STORE64LE(void *p, uint64_t v) {
98
- memcpy(p, &v, sizeof v);
99
- }
100
-
101
- #else
102
-
103
- /* These functions are provided for architectures that don't support */
104
- /* unaligned loads and stores. */
105
-
106
- static BROTLI_INLINE uint32_t BROTLI_UNALIGNED_LOAD32(const void *p) {
107
- uint32_t t;
108
- memcpy(&t, p, sizeof t);
109
- return t;
110
- }
111
-
112
- #if defined(BROTLI_LITTLE_ENDIAN)
113
-
114
- static BROTLI_INLINE uint64_t BROTLI_UNALIGNED_LOAD64LE(const void *p) {
115
- uint64_t t;
116
- memcpy(&t, p, sizeof t);
117
- return t;
118
- }
119
-
120
- static BROTLI_INLINE void BROTLI_UNALIGNED_STORE64LE(void *p, uint64_t v) {
121
- memcpy(p, &v, sizeof v);
122
- }
123
-
124
- #else /* BROTLI_LITTLE_ENDIAN */
125
-
126
- static BROTLI_INLINE uint64_t BROTLI_UNALIGNED_LOAD64LE(const void *p) {
127
- const uint8_t* in = (const uint8_t*)p;
128
- uint64_t value = (uint64_t)(in[0]);
129
- value |= (uint64_t)(in[1]) << 8;
130
- value |= (uint64_t)(in[2]) << 16;
131
- value |= (uint64_t)(in[3]) << 24;
132
- value |= (uint64_t)(in[4]) << 32;
133
- value |= (uint64_t)(in[5]) << 40;
134
- value |= (uint64_t)(in[6]) << 48;
135
- value |= (uint64_t)(in[7]) << 56;
136
- return value;
137
- }
138
-
139
- static BROTLI_INLINE void BROTLI_UNALIGNED_STORE64LE(void *p, uint64_t v) {
140
- uint8_t* out = (uint8_t*)p;
141
- out[0] = (uint8_t)v;
142
- out[1] = (uint8_t)(v >> 8);
143
- out[2] = (uint8_t)(v >> 16);
144
- out[3] = (uint8_t)(v >> 24);
145
- out[4] = (uint8_t)(v >> 32);
146
- out[5] = (uint8_t)(v >> 40);
147
- out[6] = (uint8_t)(v >> 48);
148
- out[7] = (uint8_t)(v >> 56);
149
- }
150
-
151
- #endif /* BROTLI_LITTLE_ENDIAN */
152
-
153
- #endif
154
-
155
- #define TEMPLATE_(T) \
156
- static BROTLI_INLINE T brotli_min_ ## T (T a, T b) { return a < b ? a : b; } \
157
- static BROTLI_INLINE T brotli_max_ ## T (T a, T b) { return a > b ? a : b; }
158
- TEMPLATE_(double) TEMPLATE_(float) TEMPLATE_(int)
159
- TEMPLATE_(size_t) TEMPLATE_(uint32_t) TEMPLATE_(uint8_t)
160
- #undef TEMPLATE_
161
- #define BROTLI_MIN(T, A, B) (brotli_min_ ## T((A), (B)))
162
- #define BROTLI_MAX(T, A, B) (brotli_max_ ## T((A), (B)))
163
-
164
- #define BROTLI_SWAP(T, A, I, J) { \
165
- T __brotli_swap_tmp = (A)[(I)]; \
166
- (A)[(I)] = (A)[(J)]; \
167
- (A)[(J)] = __brotli_swap_tmp; \
168
- }
169
-
170
- #define BROTLI_ENSURE_CAPACITY(M, T, A, C, R) { \
171
- if (C < (R)) { \
172
- size_t _new_size = (C == 0) ? (R) : C; \
173
- T* new_array; \
174
- while (_new_size < (R)) _new_size *= 2; \
175
- new_array = BROTLI_ALLOC((M), T, _new_size); \
176
- if (!BROTLI_IS_OOM(m) && C != 0) \
177
- memcpy(new_array, A, C * sizeof(T)); \
178
- BROTLI_FREE((M), A); \
179
- A = new_array; \
180
- C = _new_size; \
181
- } \
182
- }
183
-
184
- #endif /* BROTLI_ENC_PORT_H_ */