brotli 0.2.0 → 0.2.1
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.
- checksums.yaml +5 -5
- data/Gemfile +1 -0
- data/Rakefile +6 -1
- data/brotli.gemspec +1 -1
- data/docs/Brotli.html +485 -0
- data/docs/Brotli/Error.html +124 -0
- data/docs/_index.html +122 -0
- data/docs/class_list.html +51 -0
- data/docs/css/common.css +1 -0
- data/docs/css/full_list.css +58 -0
- data/docs/css/style.css +496 -0
- data/docs/file.README.html +127 -0
- data/docs/file_list.html +56 -0
- data/docs/frames.html +17 -0
- data/docs/index.html +127 -0
- data/docs/js/app.js +292 -0
- data/docs/js/full_list.js +216 -0
- data/docs/js/jquery.js +4 -0
- data/docs/method_list.html +67 -0
- data/docs/top-level-namespace.html +110 -0
- data/ext/brotli/brotli.c +20 -0
- data/lib/brotli/version.rb +1 -1
- data/vendor/brotli/c/common/constants.h +13 -6
- data/vendor/brotli/c/{dec → common}/context.h +182 -172
- data/vendor/brotli/c/common/dictionary.bin +0 -0
- data/vendor/brotli/c/common/dictionary.bin.br +0 -0
- data/vendor/brotli/c/common/dictionary.c +1 -1
- data/vendor/brotli/c/common/dictionary.h +4 -4
- data/vendor/brotli/c/common/platform.h +509 -0
- data/vendor/brotli/c/common/transform.c +235 -0
- data/vendor/brotli/c/common/transform.h +80 -0
- data/vendor/brotli/c/common/version.h +8 -1
- data/vendor/brotli/c/dec/bit_reader.c +1 -1
- data/vendor/brotli/c/dec/bit_reader.h +35 -86
- data/vendor/brotli/c/dec/decode.c +322 -205
- data/vendor/brotli/c/dec/huffman.c +35 -37
- data/vendor/brotli/c/dec/huffman.h +13 -9
- data/vendor/brotli/c/dec/prefix.h +3 -4
- data/vendor/brotli/c/dec/state.c +26 -34
- data/vendor/brotli/c/dec/state.h +34 -23
- data/vendor/brotli/c/enc/backward_references.c +25 -15
- data/vendor/brotli/c/enc/backward_references.h +5 -6
- data/vendor/brotli/c/enc/backward_references_hq.c +94 -68
- data/vendor/brotli/c/enc/backward_references_hq.h +22 -25
- data/vendor/brotli/c/enc/backward_references_inc.h +10 -10
- data/vendor/brotli/c/enc/bit_cost.c +1 -1
- data/vendor/brotli/c/enc/bit_cost.h +5 -5
- data/vendor/brotli/c/enc/block_encoder_inc.h +7 -6
- data/vendor/brotli/c/enc/block_splitter.c +2 -3
- data/vendor/brotli/c/enc/block_splitter.h +1 -1
- data/vendor/brotli/c/enc/block_splitter_inc.h +11 -11
- data/vendor/brotli/c/enc/brotli_bit_stream.c +102 -101
- data/vendor/brotli/c/enc/brotli_bit_stream.h +19 -38
- data/vendor/brotli/c/enc/cluster.c +1 -1
- data/vendor/brotli/c/enc/cluster.h +1 -1
- data/vendor/brotli/c/enc/command.h +40 -30
- data/vendor/brotli/c/enc/compress_fragment.c +21 -22
- data/vendor/brotli/c/enc/compress_fragment.h +1 -1
- data/vendor/brotli/c/enc/compress_fragment_two_pass.c +101 -68
- data/vendor/brotli/c/enc/compress_fragment_two_pass.h +1 -1
- data/vendor/brotli/c/enc/dictionary_hash.c +1 -1
- data/vendor/brotli/c/enc/encode.c +262 -162
- data/vendor/brotli/c/enc/encoder_dict.c +32 -0
- data/vendor/brotli/c/enc/encoder_dict.h +41 -0
- data/vendor/brotli/c/enc/entropy_encode.c +14 -14
- data/vendor/brotli/c/enc/entropy_encode.h +5 -5
- data/vendor/brotli/c/enc/entropy_encode_static.h +3 -3
- data/vendor/brotli/c/enc/fast_log.h +4 -2
- data/vendor/brotli/c/enc/find_match_length.h +3 -3
- data/vendor/brotli/c/enc/hash.h +75 -24
- data/vendor/brotli/c/enc/hash_composite_inc.h +133 -0
- data/vendor/brotli/c/enc/hash_forgetful_chain_inc.h +9 -8
- data/vendor/brotli/c/enc/hash_longest_match64_inc.h +8 -8
- data/vendor/brotli/c/enc/hash_longest_match_inc.h +8 -8
- data/vendor/brotli/c/enc/hash_longest_match_quickly_inc.h +10 -9
- data/vendor/brotli/c/enc/hash_rolling_inc.h +215 -0
- data/vendor/brotli/c/enc/hash_to_binary_tree_inc.h +9 -8
- data/vendor/brotli/c/enc/histogram.c +9 -6
- data/vendor/brotli/c/enc/histogram.h +6 -3
- data/vendor/brotli/c/enc/histogram_inc.h +1 -1
- data/vendor/brotli/c/enc/literal_cost.c +5 -5
- data/vendor/brotli/c/enc/literal_cost.h +2 -2
- data/vendor/brotli/c/enc/memory.c +5 -16
- data/vendor/brotli/c/enc/memory.h +40 -1
- data/vendor/brotli/c/enc/metablock.c +163 -25
- data/vendor/brotli/c/enc/metablock.h +13 -8
- data/vendor/brotli/c/enc/metablock_inc.h +1 -1
- data/vendor/brotli/c/enc/params.h +44 -0
- data/vendor/brotli/c/enc/prefix.h +3 -4
- data/vendor/brotli/c/enc/quality.h +29 -24
- data/vendor/brotli/c/enc/ringbuffer.h +15 -11
- data/vendor/brotli/c/enc/static_dict.c +49 -45
- data/vendor/brotli/c/enc/static_dict.h +4 -3
- data/vendor/brotli/c/enc/static_dict_lut.h +1 -1
- data/vendor/brotli/c/enc/utf8_util.c +20 -20
- data/vendor/brotli/c/enc/utf8_util.h +1 -1
- data/vendor/brotli/c/enc/write_bits.h +16 -21
- data/vendor/brotli/c/include/brotli/decode.h +13 -8
- data/vendor/brotli/c/include/brotli/encode.h +33 -8
- data/vendor/brotli/c/include/brotli/port.h +211 -83
- data/vendor/brotli/c/include/brotli/types.h +0 -7
- metadata +33 -12
- data/vendor/brotli/c/dec/port.h +0 -168
- data/vendor/brotli/c/dec/transform.h +0 -300
- data/vendor/brotli/c/enc/context.h +0 -184
- data/vendor/brotli/c/enc/port.h +0 -184
|
@@ -10,15 +10,16 @@
|
|
|
10
10
|
#define BROTLI_ENC_STATIC_DICT_H_
|
|
11
11
|
|
|
12
12
|
#include "../common/dictionary.h"
|
|
13
|
+
#include "../common/platform.h"
|
|
13
14
|
#include <brotli/types.h>
|
|
14
|
-
#include "./
|
|
15
|
+
#include "./encoder_dict.h"
|
|
15
16
|
|
|
16
17
|
#if defined(__cplusplus) || defined(c_plusplus)
|
|
17
18
|
extern "C" {
|
|
18
19
|
#endif
|
|
19
20
|
|
|
20
21
|
#define BROTLI_MAX_STATIC_DICTIONARY_MATCH_LEN 37
|
|
21
|
-
static const uint32_t kInvalidMatch =
|
|
22
|
+
static const uint32_t kInvalidMatch = 0xFFFFFFF;
|
|
22
23
|
|
|
23
24
|
/* Matches data against static dictionary words, and for each length l,
|
|
24
25
|
for which a match is found, updates matches[l] to be the minimum possible
|
|
@@ -28,7 +29,7 @@ static const uint32_t kInvalidMatch = 0xfffffff;
|
|
|
28
29
|
matches array is at least BROTLI_MAX_STATIC_DICTIONARY_MATCH_LEN + 1 long
|
|
29
30
|
all elements are initialized to kInvalidMatch */
|
|
30
31
|
BROTLI_INTERNAL BROTLI_BOOL BrotliFindAllStaticDictionaryMatches(
|
|
31
|
-
const
|
|
32
|
+
const BrotliEncoderDictionary* dictionary,
|
|
32
33
|
const uint8_t* data, size_t min_length, size_t max_length,
|
|
33
34
|
uint32_t* matches);
|
|
34
35
|
|
|
@@ -23,7 +23,7 @@ typedef struct DictWord {
|
|
|
23
23
|
} DictWord;
|
|
24
24
|
|
|
25
25
|
static const int kDictNumBits = 15;
|
|
26
|
-
static const uint32_t kDictHashMul32 =
|
|
26
|
+
static const uint32_t kDictHashMul32 = 0x1E35A7BD;
|
|
27
27
|
|
|
28
28
|
static const uint16_t kStaticDictionaryBuckets[32768] = {
|
|
29
29
|
1,0,0,0,0,0,0,0,0,3,6,0,0,0,0,0,20,0,0,0,21,0,22,0,0,0,0,0,0,0,0,23,0,0,25,0,29,
|
|
@@ -25,37 +25,37 @@ static size_t BrotliParseAsUTF8(
|
|
|
25
25
|
}
|
|
26
26
|
/* 2-byte UTF8 */
|
|
27
27
|
if (size > 1u &&
|
|
28
|
-
(input[0] &
|
|
29
|
-
(input[1] &
|
|
30
|
-
*symbol = (((input[0] &
|
|
31
|
-
(input[1] &
|
|
32
|
-
if (*symbol >
|
|
28
|
+
(input[0] & 0xE0) == 0xC0 &&
|
|
29
|
+
(input[1] & 0xC0) == 0x80) {
|
|
30
|
+
*symbol = (((input[0] & 0x1F) << 6) |
|
|
31
|
+
(input[1] & 0x3F));
|
|
32
|
+
if (*symbol > 0x7F) {
|
|
33
33
|
return 2;
|
|
34
34
|
}
|
|
35
35
|
}
|
|
36
36
|
/* 3-byte UFT8 */
|
|
37
37
|
if (size > 2u &&
|
|
38
|
-
(input[0] &
|
|
39
|
-
(input[1] &
|
|
40
|
-
(input[2] &
|
|
41
|
-
*symbol = (((input[0] &
|
|
42
|
-
((input[1] &
|
|
43
|
-
(input[2] &
|
|
44
|
-
if (*symbol >
|
|
38
|
+
(input[0] & 0xF0) == 0xE0 &&
|
|
39
|
+
(input[1] & 0xC0) == 0x80 &&
|
|
40
|
+
(input[2] & 0xC0) == 0x80) {
|
|
41
|
+
*symbol = (((input[0] & 0x0F) << 12) |
|
|
42
|
+
((input[1] & 0x3F) << 6) |
|
|
43
|
+
(input[2] & 0x3F));
|
|
44
|
+
if (*symbol > 0x7FF) {
|
|
45
45
|
return 3;
|
|
46
46
|
}
|
|
47
47
|
}
|
|
48
48
|
/* 4-byte UFT8 */
|
|
49
49
|
if (size > 3u &&
|
|
50
|
-
(input[0] &
|
|
51
|
-
(input[1] &
|
|
52
|
-
(input[2] &
|
|
53
|
-
(input[3] &
|
|
50
|
+
(input[0] & 0xF8) == 0xF0 &&
|
|
51
|
+
(input[1] & 0xC0) == 0x80 &&
|
|
52
|
+
(input[2] & 0xC0) == 0x80 &&
|
|
53
|
+
(input[3] & 0xC0) == 0x80) {
|
|
54
54
|
*symbol = (((input[0] & 0x07) << 18) |
|
|
55
|
-
((input[1] &
|
|
56
|
-
((input[2] &
|
|
57
|
-
(input[3] &
|
|
58
|
-
if (*symbol >
|
|
55
|
+
((input[1] & 0x3F) << 12) |
|
|
56
|
+
((input[2] & 0x3F) << 6) |
|
|
57
|
+
(input[3] & 0x3F));
|
|
58
|
+
if (*symbol > 0xFFFF && *symbol <= 0x10FFFF) {
|
|
59
59
|
return 4;
|
|
60
60
|
}
|
|
61
61
|
}
|
|
@@ -9,11 +9,8 @@
|
|
|
9
9
|
#ifndef BROTLI_ENC_WRITE_BITS_H_
|
|
10
10
|
#define BROTLI_ENC_WRITE_BITS_H_
|
|
11
11
|
|
|
12
|
-
#include
|
|
13
|
-
#include <stdio.h> /* printf */
|
|
14
|
-
|
|
12
|
+
#include "../common/platform.h"
|
|
15
13
|
#include <brotli/types.h>
|
|
16
|
-
#include "./port.h"
|
|
17
14
|
|
|
18
15
|
#if defined(__cplusplus) || defined(c_plusplus)
|
|
19
16
|
extern "C" {
|
|
@@ -38,27 +35,27 @@ extern "C" {
|
|
|
38
35
|
and locate the rest in BYTE+1, BYTE+2, etc. */
|
|
39
36
|
static BROTLI_INLINE void BrotliWriteBits(size_t n_bits,
|
|
40
37
|
uint64_t bits,
|
|
41
|
-
size_t
|
|
42
|
-
uint8_t
|
|
43
|
-
#
|
|
38
|
+
size_t* BROTLI_RESTRICT pos,
|
|
39
|
+
uint8_t* BROTLI_RESTRICT array) {
|
|
40
|
+
#if defined(BROTLI_LITTLE_ENDIAN)
|
|
44
41
|
/* This branch of the code can write up to 56 bits at a time,
|
|
45
42
|
7 bits are lost by being perhaps already in *p and at least
|
|
46
43
|
1 bit is needed to initialize the bit-stream ahead (i.e. if 7
|
|
47
44
|
bits are in *p and we write 57 bits, then the next write will
|
|
48
45
|
access a byte that was never initialized). */
|
|
49
|
-
uint8_t
|
|
50
|
-
uint64_t v = *p;
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
46
|
+
uint8_t* p = &array[*pos >> 3];
|
|
47
|
+
uint64_t v = (uint64_t)(*p); /* Zero-extend 8 to 64 bits. */
|
|
48
|
+
BROTLI_LOG(("WriteBits %2d 0x%08x%08x %10d\n", (int)n_bits,
|
|
49
|
+
(uint32_t)(bits >> 32), (uint32_t)(bits & 0xFFFFFFFF),
|
|
50
|
+
(int)*pos));
|
|
51
|
+
BROTLI_DCHECK((bits >> n_bits) == 0);
|
|
52
|
+
BROTLI_DCHECK(n_bits <= 56);
|
|
56
53
|
v |= bits << (*pos & 7);
|
|
57
54
|
BROTLI_UNALIGNED_STORE64LE(p, v); /* Set some bits. */
|
|
58
55
|
*pos += n_bits;
|
|
59
56
|
#else
|
|
60
|
-
/* implicit &
|
|
61
|
-
uint8_t
|
|
57
|
+
/* implicit & 0xFF is assumed for uint8_t arithmetics */
|
|
58
|
+
uint8_t* array_pos = &array[*pos >> 3];
|
|
62
59
|
const size_t bits_reserved_in_first_byte = (*pos & 7);
|
|
63
60
|
size_t bits_left_to_write;
|
|
64
61
|
bits <<= bits_reserved_in_first_byte;
|
|
@@ -75,11 +72,9 @@ static BROTLI_INLINE void BrotliWriteBits(size_t n_bits,
|
|
|
75
72
|
}
|
|
76
73
|
|
|
77
74
|
static BROTLI_INLINE void BrotliWriteBitsPrepareStorage(
|
|
78
|
-
size_t pos, uint8_t
|
|
79
|
-
|
|
80
|
-
|
|
81
|
-
#endif
|
|
82
|
-
assert((pos & 7) == 0);
|
|
75
|
+
size_t pos, uint8_t* array) {
|
|
76
|
+
BROTLI_LOG(("WriteBitsPrepareStorage %10d\n", (int)pos));
|
|
77
|
+
BROTLI_DCHECK((pos & 7) == 0);
|
|
83
78
|
array[pos >> 3] = 0;
|
|
84
79
|
}
|
|
85
80
|
|
|
@@ -34,11 +34,11 @@ typedef struct BrotliDecoderStateStruct BrotliDecoderState;
|
|
|
34
34
|
typedef enum {
|
|
35
35
|
/** Decoding error, e.g. corrupted input or memory allocation problem. */
|
|
36
36
|
BROTLI_DECODER_RESULT_ERROR = 0,
|
|
37
|
-
/** Decoding successfully completed */
|
|
37
|
+
/** Decoding successfully completed. */
|
|
38
38
|
BROTLI_DECODER_RESULT_SUCCESS = 1,
|
|
39
|
-
/** Partially done; should be called again with more input */
|
|
39
|
+
/** Partially done; should be called again with more input. */
|
|
40
40
|
BROTLI_DECODER_RESULT_NEEDS_MORE_INPUT = 2,
|
|
41
|
-
/** Partially done; should be called again with more output */
|
|
41
|
+
/** Partially done; should be called again with more output. */
|
|
42
42
|
BROTLI_DECODER_RESULT_NEEDS_MORE_OUTPUT = 3
|
|
43
43
|
} BrotliDecoderResult;
|
|
44
44
|
|
|
@@ -83,10 +83,10 @@ typedef enum {
|
|
|
83
83
|
BROTLI_ERROR_CODE(_ERROR_FORMAT_, WINDOW_BITS, -13) SEPARATOR \
|
|
84
84
|
BROTLI_ERROR_CODE(_ERROR_FORMAT_, PADDING_1, -14) SEPARATOR \
|
|
85
85
|
BROTLI_ERROR_CODE(_ERROR_FORMAT_, PADDING_2, -15) SEPARATOR \
|
|
86
|
+
BROTLI_ERROR_CODE(_ERROR_FORMAT_, DISTANCE, -16) SEPARATOR \
|
|
86
87
|
\
|
|
87
|
-
/* -
|
|
88
|
+
/* -17..-18 codes are reserved */ \
|
|
88
89
|
\
|
|
89
|
-
BROTLI_ERROR_CODE(_ERROR_, COMPOUND_DICTIONARY, -18) SEPARATOR \
|
|
90
90
|
BROTLI_ERROR_CODE(_ERROR_, DICTIONARY_NOT_SET, -19) SEPARATOR \
|
|
91
91
|
BROTLI_ERROR_CODE(_ERROR_, INVALID_ARGUMENTS, -20) SEPARATOR \
|
|
92
92
|
\
|
|
@@ -135,7 +135,11 @@ typedef enum BrotliDecoderParameter {
|
|
|
135
135
|
* Ring buffer is allocated according to window size, despite the real size of
|
|
136
136
|
* the content.
|
|
137
137
|
*/
|
|
138
|
-
BROTLI_DECODER_PARAM_DISABLE_RING_BUFFER_REALLOCATION = 0
|
|
138
|
+
BROTLI_DECODER_PARAM_DISABLE_RING_BUFFER_REALLOCATION = 0,
|
|
139
|
+
/**
|
|
140
|
+
* Flag that determines if "Large Window Brotli" is used.
|
|
141
|
+
*/
|
|
142
|
+
BROTLI_DECODER_PARAM_LARGE_WINDOW = 1
|
|
139
143
|
} BrotliDecoderParameter;
|
|
140
144
|
|
|
141
145
|
/**
|
|
@@ -159,10 +163,11 @@ BROTLI_DEC_API BROTLI_BOOL BrotliDecoderSetParameter(
|
|
|
159
163
|
*
|
|
160
164
|
* @p alloc_func and @p free_func @b MUST be both zero or both non-zero. In the
|
|
161
165
|
* case they are both zero, default memory allocators are used. @p opaque is
|
|
162
|
-
* passed to @p alloc_func and @p free_func when they are called.
|
|
166
|
+
* passed to @p alloc_func and @p free_func when they are called. @p free_func
|
|
167
|
+
* has to return without doing anything when asked to free a NULL pointer.
|
|
163
168
|
*
|
|
164
169
|
* @param alloc_func custom memory allocation function
|
|
165
|
-
* @param free_func custom memory
|
|
170
|
+
* @param free_func custom memory free function
|
|
166
171
|
* @param opaque custom memory manager handle
|
|
167
172
|
* @returns @c 0 if instance can not be allocated or initialized
|
|
168
173
|
* @returns pointer to initialized ::BrotliDecoderState otherwise
|
|
@@ -27,6 +27,11 @@ extern "C" {
|
|
|
27
27
|
* @note equal to @c BROTLI_MAX_DISTANCE_BITS constant.
|
|
28
28
|
*/
|
|
29
29
|
#define BROTLI_MAX_WINDOW_BITS 24
|
|
30
|
+
/**
|
|
31
|
+
* Maximal value for ::BROTLI_PARAM_LGWIN parameter
|
|
32
|
+
* in "Large Window Brotli" (32-bit).
|
|
33
|
+
*/
|
|
34
|
+
#define BROTLI_LARGE_MAX_WINDOW_BITS 30
|
|
30
35
|
/** Minimal value for ::BROTLI_PARAM_LGBLOCK parameter. */
|
|
31
36
|
#define BROTLI_MIN_INPUT_BLOCK_BITS 16
|
|
32
37
|
/** Maximal value for ::BROTLI_PARAM_LGBLOCK parameter. */
|
|
@@ -176,7 +181,27 @@ typedef enum BrotliEncoderParameter {
|
|
|
176
181
|
*
|
|
177
182
|
* The default value is 0, which means that the total input size is unknown.
|
|
178
183
|
*/
|
|
179
|
-
BROTLI_PARAM_SIZE_HINT = 5
|
|
184
|
+
BROTLI_PARAM_SIZE_HINT = 5,
|
|
185
|
+
/**
|
|
186
|
+
* Flag that determines if "Large Window Brotli" is used.
|
|
187
|
+
*/
|
|
188
|
+
BROTLI_PARAM_LARGE_WINDOW = 6,
|
|
189
|
+
/**
|
|
190
|
+
* Recommended number of postfix bits (NPOSTFIX).
|
|
191
|
+
*
|
|
192
|
+
* Encoder may change this value.
|
|
193
|
+
*
|
|
194
|
+
* Range is from 0 to ::BROTLI_MAX_NPOSTFIX.
|
|
195
|
+
*/
|
|
196
|
+
BROTLI_PARAM_NPOSTFIX = 7,
|
|
197
|
+
/**
|
|
198
|
+
* Recommended number of direct distance codes (NDIRECT).
|
|
199
|
+
*
|
|
200
|
+
* Encoder may change this value.
|
|
201
|
+
*
|
|
202
|
+
* Range is from 0 to (15 << NPOSTFIX) in steps of (1 << NPOSTFIX).
|
|
203
|
+
*/
|
|
204
|
+
BROTLI_PARAM_NDIRECT = 8
|
|
180
205
|
} BrotliEncoderParameter;
|
|
181
206
|
|
|
182
207
|
/**
|
|
@@ -209,10 +234,11 @@ BROTLI_ENC_API BROTLI_BOOL BrotliEncoderSetParameter(
|
|
|
209
234
|
*
|
|
210
235
|
* @p alloc_func and @p free_func @b MUST be both zero or both non-zero. In the
|
|
211
236
|
* case they are both zero, default memory allocators are used. @p opaque is
|
|
212
|
-
* passed to @p alloc_func and @p free_func when they are called.
|
|
237
|
+
* passed to @p alloc_func and @p free_func when they are called. @p free_func
|
|
238
|
+
* has to return without doing anything when asked to free a NULL pointer.
|
|
213
239
|
*
|
|
214
240
|
* @param alloc_func custom memory allocation function
|
|
215
|
-
* @param free_func custom memory
|
|
241
|
+
* @param free_func custom memory free function
|
|
216
242
|
* @param opaque custom memory manager handle
|
|
217
243
|
* @returns @c 0 if instance can not be allocated or initialized
|
|
218
244
|
* @returns pointer to initialized ::BrotliEncoderState otherwise
|
|
@@ -230,10 +256,9 @@ BROTLI_ENC_API void BrotliEncoderDestroyInstance(BrotliEncoderState* state);
|
|
|
230
256
|
/**
|
|
231
257
|
* Calculates the output size bound for the given @p input_size.
|
|
232
258
|
*
|
|
233
|
-
* @warning Result is
|
|
234
|
-
*
|
|
235
|
-
*
|
|
236
|
-
* after every chunk of input.
|
|
259
|
+
* @warning Result is only valid if quality is at least @c 2 and, in
|
|
260
|
+
* case ::BrotliEncoderCompressStream was used, no flushes
|
|
261
|
+
* (::BROTLI_OPERATION_FLUSH) were performed.
|
|
237
262
|
*
|
|
238
263
|
* @param input_size size of projected input
|
|
239
264
|
* @returns @c 0 if result does not fit @c size_t
|
|
@@ -283,7 +308,7 @@ BROTLI_ENC_API BROTLI_BOOL BrotliEncoderCompress(
|
|
|
283
308
|
* that amount.
|
|
284
309
|
*
|
|
285
310
|
* @p total_out, if it is not a null-pointer, will be set to the number
|
|
286
|
-
* of bytes
|
|
311
|
+
* of bytes compressed since the last @p state initialization.
|
|
287
312
|
*
|
|
288
313
|
*
|
|
289
314
|
*
|
|
@@ -4,90 +4,247 @@
|
|
|
4
4
|
See file LICENSE for detail or copy at https://opensource.org/licenses/MIT
|
|
5
5
|
*/
|
|
6
6
|
|
|
7
|
-
/* Macros for compiler / platform specific
|
|
7
|
+
/* Macros for compiler / platform specific API declarations. */
|
|
8
8
|
|
|
9
9
|
#ifndef BROTLI_COMMON_PORT_H_
|
|
10
10
|
#define BROTLI_COMMON_PORT_H_
|
|
11
11
|
|
|
12
|
-
/*
|
|
13
|
-
|
|
14
|
-
|
|
12
|
+
/* The following macros were borrowed from https://github.com/nemequ/hedley
|
|
13
|
+
* with permission of original author - Evan Nemerson <evan@nemerson.com> */
|
|
14
|
+
|
|
15
|
+
/* >>> >>> >>> hedley macros */
|
|
16
|
+
|
|
17
|
+
#define BROTLI_MAKE_VERSION(major, minor, revision) \
|
|
18
|
+
(((major) * 1000000) + ((minor) * 1000) + (revision))
|
|
19
|
+
|
|
20
|
+
#if defined(__GNUC__) && defined(__GNUC_PATCHLEVEL__)
|
|
21
|
+
#define BROTLI_GNUC_VERSION \
|
|
22
|
+
BROTLI_MAKE_VERSION(__GNUC__, __GNUC_MINOR__, __GNUC_PATCHLEVEL__)
|
|
23
|
+
#elif defined(__GNUC__)
|
|
24
|
+
#define BROTLI_GNUC_VERSION BROTLI_MAKE_VERSION(__GNUC__, __GNUC_MINOR__, 0)
|
|
15
25
|
#endif
|
|
16
26
|
|
|
17
|
-
#
|
|
18
|
-
#define
|
|
27
|
+
#if defined(BROTLI_GNUC_VERSION)
|
|
28
|
+
#define BROTLI_GNUC_VERSION_CHECK(major, minor, patch) \
|
|
29
|
+
(BROTLI_GNUC_VERSION >= BROTLI_MAKE_VERSION(major, minor, patch))
|
|
30
|
+
#else
|
|
31
|
+
#define BROTLI_GNUC_VERSION_CHECK(major, minor, patch) (0)
|
|
19
32
|
#endif
|
|
20
33
|
|
|
21
|
-
#
|
|
22
|
-
#define
|
|
34
|
+
#if defined(_MSC_FULL_VER) && (_MSC_FULL_VER >= 140000000)
|
|
35
|
+
#define BROTLI_MSVC_VERSION \
|
|
36
|
+
BROTLI_MAKE_VERSION((_MSC_FULL_VER / 10000000), \
|
|
37
|
+
(_MSC_FULL_VER % 10000000) / 100000, \
|
|
38
|
+
(_MSC_FULL_VER % 100000) / 100)
|
|
39
|
+
#elif defined(_MSC_FULL_VER)
|
|
40
|
+
#define BROTLI_MSVC_VERSION \
|
|
41
|
+
BROTLI_MAKE_VERSION((_MSC_FULL_VER / 1000000), \
|
|
42
|
+
(_MSC_FULL_VER % 1000000) / 10000, \
|
|
43
|
+
(_MSC_FULL_VER % 10000) / 10)
|
|
44
|
+
#elif defined(_MSC_VER)
|
|
45
|
+
#define BROTLI_MSVC_VERSION \
|
|
46
|
+
BROTLI_MAKE_VERSION(_MSC_VER / 100, _MSC_VER % 100, 0)
|
|
23
47
|
#endif
|
|
24
48
|
|
|
25
|
-
#if defined(
|
|
26
|
-
#define
|
|
49
|
+
#if !defined(_MSC_VER)
|
|
50
|
+
#define BROTLI_MSVC_VERSION_CHECK(major, minor, patch) (0)
|
|
51
|
+
#elif defined(_MSC_VER) && (_MSC_VER >= 1400)
|
|
52
|
+
#define BROTLI_MSVC_VERSION_CHECK(major, minor, patch) \
|
|
53
|
+
(_MSC_FULL_VER >= ((major * 10000000) + (minor * 100000) + (patch)))
|
|
54
|
+
#elif defined(_MSC_VER) && (_MSC_VER >= 1200)
|
|
55
|
+
#define BROTLI_MSVC_VERSION_CHECK(major, minor, patch) \
|
|
56
|
+
(_MSC_FULL_VER >= ((major * 1000000) + (minor * 10000) + (patch)))
|
|
27
57
|
#else
|
|
28
|
-
#define
|
|
58
|
+
#define BROTLI_MSVC_VERSION_CHECK(major, minor, patch) \
|
|
59
|
+
(_MSC_VER >= ((major * 100) + (minor)))
|
|
29
60
|
#endif
|
|
30
61
|
|
|
31
|
-
#if defined(
|
|
32
|
-
#define
|
|
62
|
+
#if defined(__INTEL_COMPILER) && defined(__INTEL_COMPILER_UPDATE)
|
|
63
|
+
#define BROTLI_INTEL_VERSION \
|
|
64
|
+
BROTLI_MAKE_VERSION(__INTEL_COMPILER / 100, \
|
|
65
|
+
__INTEL_COMPILER % 100, \
|
|
66
|
+
__INTEL_COMPILER_UPDATE)
|
|
67
|
+
#elif defined(__INTEL_COMPILER)
|
|
68
|
+
#define BROTLI_INTEL_VERSION \
|
|
69
|
+
BROTLI_MAKE_VERSION(__INTEL_COMPILER / 100, __INTEL_COMPILER % 100, 0)
|
|
70
|
+
#endif
|
|
71
|
+
|
|
72
|
+
#if defined(BROTLI_INTEL_VERSION)
|
|
73
|
+
#define BROTLI_INTEL_VERSION_CHECK(major, minor, patch) \
|
|
74
|
+
(BROTLI_INTEL_VERSION >= BROTLI_MAKE_VERSION(major, minor, patch))
|
|
33
75
|
#else
|
|
34
|
-
#define
|
|
76
|
+
#define BROTLI_INTEL_VERSION_CHECK(major, minor, patch) (0)
|
|
77
|
+
#endif
|
|
78
|
+
|
|
79
|
+
#if defined(__PGI) && \
|
|
80
|
+
defined(__PGIC__) && defined(__PGIC_MINOR__) && defined(__PGIC_PATCHLEVEL__)
|
|
81
|
+
#define BROTLI_PGI_VERSION \
|
|
82
|
+
BROTLI_MAKE_VERSION(__PGIC__, __PGIC_MINOR__, __PGIC_PATCHLEVEL__)
|
|
83
|
+
#endif
|
|
84
|
+
|
|
85
|
+
#if defined(BROTLI_PGI_VERSION)
|
|
86
|
+
#define BROTLI_PGI_VERSION_CHECK(major, minor, patch) \
|
|
87
|
+
(BROTLI_PGI_VERSION >= BROTLI_MAKE_VERSION(major, minor, patch))
|
|
88
|
+
#else
|
|
89
|
+
#define BROTLI_PGI_VERSION_CHECK(major, minor, patch) (0)
|
|
90
|
+
#endif
|
|
91
|
+
|
|
92
|
+
#if defined(__SUNPRO_C) && (__SUNPRO_C > 0x1000)
|
|
93
|
+
#define BROTLI_SUNPRO_VERSION \
|
|
94
|
+
BROTLI_MAKE_VERSION( \
|
|
95
|
+
(((__SUNPRO_C >> 16) & 0xf) * 10) + ((__SUNPRO_C >> 12) & 0xf), \
|
|
96
|
+
(((__SUNPRO_C >> 8) & 0xf) * 10) + ((__SUNPRO_C >> 4) & 0xf), \
|
|
97
|
+
(__SUNPRO_C & 0xf) * 10)
|
|
98
|
+
#elif defined(__SUNPRO_C)
|
|
99
|
+
#define BROTLI_SUNPRO_VERSION \
|
|
100
|
+
BROTLI_MAKE_VERSION((__SUNPRO_C >> 8) & 0xf, \
|
|
101
|
+
(__SUNPRO_C >> 4) & 0xf, \
|
|
102
|
+
(__SUNPRO_C) & 0xf)
|
|
103
|
+
#elif defined(__SUNPRO_CC) && (__SUNPRO_CC > 0x1000)
|
|
104
|
+
#define BROTLI_SUNPRO_VERSION \
|
|
105
|
+
BROTLI_MAKE_VERSION( \
|
|
106
|
+
(((__SUNPRO_CC >> 16) & 0xf) * 10) + ((__SUNPRO_CC >> 12) & 0xf), \
|
|
107
|
+
(((__SUNPRO_CC >> 8) & 0xf) * 10) + ((__SUNPRO_CC >> 4) & 0xf), \
|
|
108
|
+
(__SUNPRO_CC & 0xf) * 10)
|
|
109
|
+
#elif defined(__SUNPRO_CC)
|
|
110
|
+
#define BROTLI_SUNPRO_VERSION \
|
|
111
|
+
BROTLI_MAKE_VERSION((__SUNPRO_CC >> 8) & 0xf, \
|
|
112
|
+
(__SUNPRO_CC >> 4) & 0xf, \
|
|
113
|
+
(__SUNPRO_CC) & 0xf)
|
|
35
114
|
#endif
|
|
36
115
|
|
|
37
|
-
#if defined(
|
|
38
|
-
#define
|
|
39
|
-
|
|
40
|
-
#define BROTLI_MODERN_COMPILER 1
|
|
116
|
+
#if defined(BROTLI_SUNPRO_VERSION)
|
|
117
|
+
#define BROTLI_SUNPRO_VERSION_CHECK(major, minor, patch) \
|
|
118
|
+
(BROTLI_SUNPRO_VERSION >= BROTLI_MAKE_VERSION(major, minor, patch))
|
|
41
119
|
#else
|
|
42
|
-
#define
|
|
120
|
+
#define BROTLI_SUNPRO_VERSION_CHECK(major, minor, patch) (0)
|
|
43
121
|
#endif
|
|
44
122
|
|
|
45
|
-
|
|
46
|
-
|
|
123
|
+
#if defined(__CC_ARM) && defined(__ARMCOMPILER_VERSION)
|
|
124
|
+
#define BROTLI_ARM_VERSION \
|
|
125
|
+
BROTLI_MAKE_VERSION((__ARMCOMPILER_VERSION / 1000000), \
|
|
126
|
+
(__ARMCOMPILER_VERSION % 1000000) / 10000, \
|
|
127
|
+
(__ARMCOMPILER_VERSION % 10000) / 100)
|
|
128
|
+
#elif defined(__CC_ARM) && defined(__ARMCC_VERSION)
|
|
129
|
+
#define BROTLI_ARM_VERSION \
|
|
130
|
+
BROTLI_MAKE_VERSION((__ARMCC_VERSION / 1000000), \
|
|
131
|
+
(__ARMCC_VERSION % 1000000) / 10000, \
|
|
132
|
+
(__ARMCC_VERSION % 10000) / 100)
|
|
133
|
+
#endif
|
|
47
134
|
|
|
48
|
-
|
|
135
|
+
#if defined(BROTLI_ARM_VERSION)
|
|
136
|
+
#define BROTLI_ARM_VERSION_CHECK(major, minor, patch) \
|
|
137
|
+
(BROTLI_ARM_VERSION >= BROTLI_MAKE_VERSION(major, minor, patch))
|
|
138
|
+
#else
|
|
139
|
+
#define BROTLI_ARM_VERSION_CHECK(major, minor, patch) (0)
|
|
140
|
+
#endif
|
|
49
141
|
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
142
|
+
#if defined(__ibmxl__)
|
|
143
|
+
#define BROTLI_IBM_VERSION \
|
|
144
|
+
BROTLI_MAKE_VERSION(__ibmxl_version__, \
|
|
145
|
+
__ibmxl_release__, \
|
|
146
|
+
__ibmxl_modification__)
|
|
147
|
+
#elif defined(__xlC__) && defined(__xlC_ver__)
|
|
148
|
+
#define BROTLI_IBM_VERSION \
|
|
149
|
+
BROTLI_MAKE_VERSION(__xlC__ >> 8, __xlC__ & 0xff, (__xlC_ver__ >> 8) & 0xff)
|
|
150
|
+
#elif defined(__xlC__)
|
|
151
|
+
#define BROTLI_IBM_VERSION BROTLI_MAKE_VERSION(__xlC__ >> 8, __xlC__ & 0xff, 0)
|
|
152
|
+
#endif
|
|
55
153
|
|
|
56
|
-
|
|
154
|
+
#if defined(BROTLI_IBM_VERSION)
|
|
155
|
+
#define BROTLI_IBM_VERSION_CHECK(major, minor, patch) \
|
|
156
|
+
(BROTLI_IBM_VERSION >= BROTLI_MAKE_VERSION(major, minor, patch))
|
|
157
|
+
#else
|
|
158
|
+
#define BROTLI_IBM_VERSION_CHECK(major, minor, patch) (0)
|
|
159
|
+
#endif
|
|
57
160
|
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
|
|
161
|
+
#if defined(__TI_COMPILER_VERSION__)
|
|
162
|
+
#define BROTLI_TI_VERSION \
|
|
163
|
+
BROTLI_MAKE_VERSION((__TI_COMPILER_VERSION__ / 1000000), \
|
|
164
|
+
(__TI_COMPILER_VERSION__ % 1000000) / 1000, \
|
|
165
|
+
(__TI_COMPILER_VERSION__ % 1000))
|
|
166
|
+
#endif
|
|
61
167
|
|
|
62
|
-
|
|
63
|
-
#
|
|
64
|
-
|
|
65
|
-
#
|
|
168
|
+
#if defined(BROTLI_TI_VERSION)
|
|
169
|
+
#define BROTLI_TI_VERSION_CHECK(major, minor, patch) \
|
|
170
|
+
(BROTLI_TI_VERSION >= BROTLI_MAKE_VERSION(major, minor, patch))
|
|
171
|
+
#else
|
|
172
|
+
#define BROTLI_TI_VERSION_CHECK(major, minor, patch) (0)
|
|
173
|
+
#endif
|
|
174
|
+
|
|
175
|
+
#if defined(__IAR_SYSTEMS_ICC__)
|
|
176
|
+
#if __VER__ > 1000
|
|
177
|
+
#define BROTLI_IAR_VERSION \
|
|
178
|
+
BROTLI_MAKE_VERSION((__VER__ / 1000000), \
|
|
179
|
+
(__VER__ / 1000) % 1000, \
|
|
180
|
+
(__VER__ % 1000))
|
|
66
181
|
#else
|
|
67
|
-
#define
|
|
68
|
-
#
|
|
182
|
+
#define BROTLI_IAR_VERSION BROTLI_MAKE_VERSION(VER / 100, __VER__ % 100, 0)
|
|
183
|
+
#endif
|
|
69
184
|
#endif
|
|
70
185
|
|
|
71
|
-
#if
|
|
72
|
-
#define
|
|
186
|
+
#if defined(BROTLI_IAR_VERSION)
|
|
187
|
+
#define BROTLI_IAR_VERSION_CHECK(major, minor, patch) \
|
|
188
|
+
(BROTLI_IAR_VERSION >= BROTLI_MAKE_VERSION(major, minor, patch))
|
|
73
189
|
#else
|
|
74
|
-
#define
|
|
190
|
+
#define BROTLI_IAR_VERSION_CHECK(major, minor, patch) (0)
|
|
191
|
+
#endif
|
|
192
|
+
|
|
193
|
+
#if defined(__TINYC__)
|
|
194
|
+
#define BROTLI_TINYC_VERSION \
|
|
195
|
+
BROTLI_MAKE_VERSION(__TINYC__ / 1000, (__TINYC__ / 100) % 10, __TINYC__ % 100)
|
|
196
|
+
#endif
|
|
197
|
+
|
|
198
|
+
#if defined(BROTLI_TINYC_VERSION)
|
|
199
|
+
#define BROTLI_TINYC_VERSION_CHECK(major, minor, patch) \
|
|
200
|
+
(BROTLI_TINYC_VERSION >= BROTLI_MAKE_VERSION(major, minor, patch))
|
|
201
|
+
#else
|
|
202
|
+
#define BROTLI_TINYC_VERSION_CHECK(major, minor, patch) (0)
|
|
203
|
+
#endif
|
|
204
|
+
|
|
205
|
+
#if defined(__has_attribute)
|
|
206
|
+
#define BROTLI_GNUC_HAS_ATTRIBUTE(attribute, major, minor, patch) \
|
|
207
|
+
__has_attribute(attribute)
|
|
208
|
+
#else
|
|
209
|
+
#define BROTLI_GNUC_HAS_ATTRIBUTE(attribute, major, minor, patch) \
|
|
210
|
+
BROTLI_GNUC_VERSION_CHECK(major, minor, patch)
|
|
211
|
+
#endif
|
|
212
|
+
|
|
213
|
+
#if defined(__has_builtin)
|
|
214
|
+
#define BROTLI_GNUC_HAS_BUILTIN(builtin, major, minor, patch) \
|
|
215
|
+
__has_builtin(builtin)
|
|
216
|
+
#else
|
|
217
|
+
#define BROTLI_GNUC_HAS_BUILTIN(builtin, major, minor, patch) \
|
|
218
|
+
BROTLI_GNUC_VERSION_CHECK(major, minor, patch)
|
|
75
219
|
#endif
|
|
76
220
|
|
|
77
221
|
#if defined(_WIN32) || defined(__CYGWIN__)
|
|
78
|
-
#define
|
|
79
|
-
#elif
|
|
80
|
-
|
|
81
|
-
|
|
222
|
+
#define BROTLI_PUBLIC
|
|
223
|
+
#elif BROTLI_GNUC_VERSION_CHECK(3, 3, 0) || \
|
|
224
|
+
BROTLI_TI_VERSION_CHECK(8, 0, 0) || \
|
|
225
|
+
BROTLI_INTEL_VERSION_CHECK(16, 0, 0) || \
|
|
226
|
+
BROTLI_ARM_VERSION_CHECK(4, 1, 0) || \
|
|
227
|
+
BROTLI_IBM_VERSION_CHECK(13, 1, 0) || \
|
|
228
|
+
BROTLI_SUNPRO_VERSION_CHECK(5, 11, 0) || \
|
|
229
|
+
(BROTLI_TI_VERSION_CHECK(7, 3, 0) && \
|
|
230
|
+
defined(__TI_GNU_ATTRIBUTE_SUPPORT__) && defined(__TI_EABI__))
|
|
231
|
+
#define BROTLI_PUBLIC __attribute__ ((visibility ("default")))
|
|
82
232
|
#else
|
|
83
|
-
#define
|
|
233
|
+
#define BROTLI_PUBLIC
|
|
84
234
|
#endif
|
|
85
235
|
|
|
86
|
-
#
|
|
87
|
-
|
|
236
|
+
#if defined(__STDC_VERSION__) && (__STDC_VERSION__ >= 199901L) && \
|
|
237
|
+
!defined(__STDC_NO_VLA__) && !defined(__cplusplus) && \
|
|
238
|
+
!defined(__PGI) && !defined(__PGIC__) && !defined(__TINYC__)
|
|
239
|
+
#define BROTLI_ARRAY_PARAM(name) (name)
|
|
240
|
+
#else
|
|
241
|
+
#define BROTLI_ARRAY_PARAM(name)
|
|
88
242
|
#endif
|
|
89
243
|
|
|
90
|
-
|
|
244
|
+
/* <<< <<< <<< end of hedley macros. */
|
|
245
|
+
|
|
246
|
+
#if defined(BROTLI_SHARED_COMPILATION)
|
|
247
|
+
#if defined(_WIN32)
|
|
91
248
|
#if defined(BROTLICOMMON_SHARED_COMPILATION)
|
|
92
249
|
#define BROTLI_COMMON_API __declspec(dllexport)
|
|
93
250
|
#else
|
|
@@ -103,44 +260,15 @@ OR:
|
|
|
103
260
|
#else
|
|
104
261
|
#define BROTLI_ENC_API __declspec(dllimport)
|
|
105
262
|
#endif /* BROTLIENC_SHARED_COMPILATION */
|
|
106
|
-
#else /*
|
|
263
|
+
#else /* _WIN32 */
|
|
264
|
+
#define BROTLI_COMMON_API BROTLI_PUBLIC
|
|
265
|
+
#define BROTLI_DEC_API BROTLI_PUBLIC
|
|
266
|
+
#define BROTLI_ENC_API BROTLI_PUBLIC
|
|
267
|
+
#endif /* _WIN32 */
|
|
268
|
+
#else /* BROTLI_SHARED_COMPILATION */
|
|
107
269
|
#define BROTLI_COMMON_API
|
|
108
270
|
#define BROTLI_DEC_API
|
|
109
271
|
#define BROTLI_ENC_API
|
|
110
272
|
#endif
|
|
111
273
|
|
|
112
|
-
#ifndef _MSC_VER
|
|
113
|
-
#if defined(__cplusplus) || !defined(__STRICT_ANSI__) || \
|
|
114
|
-
(defined(__STDC_VERSION__) && __STDC_VERSION__ >= 199901L)
|
|
115
|
-
#define BROTLI_INLINE inline BROTLI_ATTRIBUTE_ALWAYS_INLINE
|
|
116
|
-
#else
|
|
117
|
-
#define BROTLI_INLINE
|
|
118
|
-
#endif
|
|
119
|
-
#else /* _MSC_VER */
|
|
120
|
-
#define BROTLI_INLINE __forceinline
|
|
121
|
-
#endif /* _MSC_VER */
|
|
122
|
-
|
|
123
|
-
#if !defined(__cplusplus) && !defined(c_plusplus) && \
|
|
124
|
-
(defined(__STDC_VERSION__) && __STDC_VERSION__ >= 199901L)
|
|
125
|
-
#define BROTLI_RESTRICT restrict
|
|
126
|
-
#elif BROTLI_GCC_VERSION > 295 || defined(__llvm__)
|
|
127
|
-
#define BROTLI_RESTRICT __restrict
|
|
128
|
-
#else
|
|
129
|
-
#define BROTLI_RESTRICT
|
|
130
|
-
#endif
|
|
131
|
-
|
|
132
|
-
#if BROTLI_MODERN_COMPILER || __has_attribute(noinline)
|
|
133
|
-
#define BROTLI_NOINLINE __attribute__((noinline))
|
|
134
|
-
#else
|
|
135
|
-
#define BROTLI_NOINLINE
|
|
136
|
-
#endif
|
|
137
|
-
|
|
138
|
-
#if BROTLI_MODERN_COMPILER || __has_attribute(deprecated)
|
|
139
|
-
#define BROTLI_DEPRECATED __attribute__((deprecated))
|
|
140
|
-
#else
|
|
141
|
-
#define BROTLI_DEPRECATED
|
|
142
|
-
#endif
|
|
143
|
-
|
|
144
|
-
#define BROTLI_UNUSED(X) (void)(X)
|
|
145
|
-
|
|
146
274
|
#endif /* BROTLI_COMMON_PORT_H_ */
|