brotli 0.1.3 → 0.1.4
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/.gitignore +3 -0
- data/.travis.yml +11 -3
- data/Gemfile +2 -0
- data/ext/brotli/brotli.c +279 -0
- data/ext/brotli/brotli.h +2 -0
- data/ext/brotli/buffer.c +95 -0
- data/ext/brotli/buffer.h +19 -0
- data/ext/brotli/extconf.rb +21 -81
- data/lib/brotli/version.rb +1 -1
- data/vendor/brotli/dec/bit_reader.c +5 -5
- data/vendor/brotli/dec/bit_reader.h +15 -15
- data/vendor/brotli/dec/context.h +1 -1
- data/vendor/brotli/dec/decode.c +433 -348
- data/vendor/brotli/dec/decode.h +74 -48
- data/vendor/brotli/dec/huffman.c +5 -4
- data/vendor/brotli/dec/huffman.h +4 -4
- data/vendor/brotli/dec/port.h +2 -95
- data/vendor/brotli/dec/prefix.h +5 -3
- data/vendor/brotli/dec/state.c +15 -27
- data/vendor/brotli/dec/state.h +21 -17
- data/vendor/brotli/dec/transform.h +1 -1
- data/vendor/brotli/enc/backward_references.c +892 -0
- data/vendor/brotli/enc/backward_references.h +85 -102
- data/vendor/brotli/enc/backward_references_inc.h +147 -0
- data/vendor/brotli/enc/bit_cost.c +35 -0
- data/vendor/brotli/enc/bit_cost.h +23 -121
- data/vendor/brotli/enc/bit_cost_inc.h +127 -0
- data/vendor/brotli/enc/block_encoder_inc.h +33 -0
- data/vendor/brotli/enc/block_splitter.c +197 -0
- data/vendor/brotli/enc/block_splitter.h +40 -50
- data/vendor/brotli/enc/block_splitter_inc.h +432 -0
- data/vendor/brotli/enc/brotli_bit_stream.c +1334 -0
- data/vendor/brotli/enc/brotli_bit_stream.h +95 -167
- data/vendor/brotli/enc/cluster.c +56 -0
- data/vendor/brotli/enc/cluster.h +23 -305
- data/vendor/brotli/enc/cluster_inc.h +315 -0
- data/vendor/brotli/enc/command.h +83 -76
- data/vendor/brotli/enc/compress_fragment.c +747 -0
- data/vendor/brotli/enc/compress_fragment.h +48 -37
- data/vendor/brotli/enc/compress_fragment_two_pass.c +557 -0
- data/vendor/brotli/enc/compress_fragment_two_pass.h +37 -26
- data/vendor/brotli/enc/compressor.cc +139 -0
- data/vendor/brotli/enc/compressor.h +146 -0
- data/vendor/brotli/enc/context.h +102 -96
- data/vendor/brotli/enc/dictionary_hash.h +9 -5
- data/vendor/brotli/enc/encode.c +1562 -0
- data/vendor/brotli/enc/encode.h +211 -199
- data/vendor/brotli/enc/encode_parallel.cc +161 -151
- data/vendor/brotli/enc/encode_parallel.h +7 -8
- data/vendor/brotli/enc/entropy_encode.c +501 -0
- data/vendor/brotli/enc/entropy_encode.h +107 -89
- data/vendor/brotli/enc/entropy_encode_static.h +29 -62
- data/vendor/brotli/enc/fast_log.h +26 -20
- data/vendor/brotli/enc/find_match_length.h +23 -20
- data/vendor/brotli/enc/hash.h +614 -871
- data/vendor/brotli/enc/hash_forgetful_chain_inc.h +249 -0
- data/vendor/brotli/enc/hash_longest_match_inc.h +241 -0
- data/vendor/brotli/enc/hash_longest_match_quickly_inc.h +230 -0
- data/vendor/brotli/enc/histogram.c +95 -0
- data/vendor/brotli/enc/histogram.h +49 -83
- data/vendor/brotli/enc/histogram_inc.h +51 -0
- data/vendor/brotli/enc/literal_cost.c +178 -0
- data/vendor/brotli/enc/literal_cost.h +16 -10
- data/vendor/brotli/enc/memory.c +181 -0
- data/vendor/brotli/enc/memory.h +62 -0
- data/vendor/brotli/enc/metablock.c +515 -0
- data/vendor/brotli/enc/metablock.h +87 -57
- data/vendor/brotli/enc/metablock_inc.h +183 -0
- data/vendor/brotli/enc/port.h +73 -47
- data/vendor/brotli/enc/prefix.h +34 -61
- data/vendor/brotli/enc/quality.h +130 -0
- data/vendor/brotli/enc/ringbuffer.h +137 -122
- data/vendor/brotli/enc/{static_dict.cc → static_dict.c} +162 -139
- data/vendor/brotli/enc/static_dict.h +23 -18
- data/vendor/brotli/enc/static_dict_lut.h +11223 -12037
- data/vendor/brotli/enc/streams.cc +7 -7
- data/vendor/brotli/enc/streams.h +32 -32
- data/vendor/brotli/enc/{utf8_util.cc → utf8_util.c} +22 -20
- data/vendor/brotli/enc/utf8_util.h +16 -9
- data/vendor/brotli/enc/write_bits.h +49 -43
- metadata +34 -25
- data/ext/brotli/brotli.cc +0 -181
- data/vendor/brotli/dec/Makefile +0 -12
- data/vendor/brotli/dec/dictionary.c +0 -9466
- data/vendor/brotli/dec/dictionary.h +0 -38
- data/vendor/brotli/dec/types.h +0 -38
- data/vendor/brotli/enc/Makefile +0 -14
- data/vendor/brotli/enc/backward_references.cc +0 -858
- data/vendor/brotli/enc/block_splitter.cc +0 -505
- data/vendor/brotli/enc/brotli_bit_stream.cc +0 -1181
- data/vendor/brotli/enc/compress_fragment.cc +0 -701
- data/vendor/brotli/enc/compress_fragment_two_pass.cc +0 -524
- data/vendor/brotli/enc/dictionary.cc +0 -9466
- data/vendor/brotli/enc/dictionary.h +0 -41
- data/vendor/brotli/enc/encode.cc +0 -1180
- data/vendor/brotli/enc/entropy_encode.cc +0 -480
- data/vendor/brotli/enc/histogram.cc +0 -67
- data/vendor/brotli/enc/literal_cost.cc +0 -165
- data/vendor/brotli/enc/metablock.cc +0 -539
- data/vendor/brotli/enc/transform.h +0 -248
- data/vendor/brotli/enc/types.h +0 -29
@@ -4,14 +4,14 @@
|
|
4
4
|
See file LICENSE for detail or copy at https://opensource.org/licenses/MIT
|
5
5
|
*/
|
6
6
|
|
7
|
-
|
8
|
-
|
7
|
+
/* Convience routines to make Brotli I/O classes from some memory containers and
|
8
|
+
files. */
|
9
9
|
|
10
10
|
#include "./streams.h"
|
11
11
|
|
12
12
|
#include <assert.h>
|
13
13
|
#include <stdlib.h>
|
14
|
-
#include <string.h>
|
14
|
+
#include <string.h> /* memcpy */
|
15
15
|
|
16
16
|
namespace brotli {
|
17
17
|
|
@@ -26,7 +26,7 @@ void BrotliMemOut::Reset(void* buf, size_t len) {
|
|
26
26
|
pos_ = 0;
|
27
27
|
}
|
28
28
|
|
29
|
-
|
29
|
+
/* Brotli output routine: copy n bytes to the output buffer. */
|
30
30
|
bool BrotliMemOut::Write(const void *buf, size_t n) {
|
31
31
|
if (n + pos_ > len_)
|
32
32
|
return false;
|
@@ -47,7 +47,7 @@ void BrotliStringOut::Reset(std::string* buf, size_t max_size) {
|
|
47
47
|
max_size_ = max_size;
|
48
48
|
}
|
49
49
|
|
50
|
-
|
50
|
+
/* Brotli output routine: add n bytes to a string. */
|
51
51
|
bool BrotliStringOut::Write(const void *buf, size_t n) {
|
52
52
|
if (buf_->size() + n > max_size_)
|
53
53
|
return false;
|
@@ -66,7 +66,7 @@ void BrotliMemIn::Reset(const void* buf, size_t len) {
|
|
66
66
|
pos_ = 0;
|
67
67
|
}
|
68
68
|
|
69
|
-
|
69
|
+
/* Brotli input routine: read the next chunk of memory. */
|
70
70
|
const void* BrotliMemIn::Read(size_t n, size_t* output) {
|
71
71
|
if (pos_ == len_) {
|
72
72
|
return NULL;
|
@@ -111,4 +111,4 @@ bool BrotliFileOut::Write(const void* buf, size_t n) {
|
|
111
111
|
return true;
|
112
112
|
}
|
113
113
|
|
114
|
-
}
|
114
|
+
} /* namespace brotli */
|
data/vendor/brotli/enc/streams.h
CHANGED
@@ -4,83 +4,83 @@
|
|
4
4
|
See file LICENSE for detail or copy at https://opensource.org/licenses/MIT
|
5
5
|
*/
|
6
6
|
|
7
|
-
|
7
|
+
/* Input and output classes for streaming brotli compression. */
|
8
8
|
|
9
9
|
#ifndef BROTLI_ENC_STREAMS_H_
|
10
10
|
#define BROTLI_ENC_STREAMS_H_
|
11
11
|
|
12
12
|
#include <stdio.h>
|
13
13
|
#include <string>
|
14
|
-
|
15
|
-
#include "
|
14
|
+
|
15
|
+
#include "../common/types.h"
|
16
16
|
|
17
17
|
namespace brotli {
|
18
18
|
|
19
|
-
|
19
|
+
/* Input interface for the compression routines. */
|
20
20
|
class BrotliIn {
|
21
21
|
public:
|
22
22
|
virtual ~BrotliIn(void) {}
|
23
23
|
|
24
|
-
|
25
|
-
|
26
|
-
|
27
|
-
|
28
|
-
|
24
|
+
/* Return a pointer to the next block of input of at most n bytes.
|
25
|
+
Return the actual length in *nread.
|
26
|
+
At end of data, return NULL. Don't return NULL if there is more data
|
27
|
+
to read, even if called with n == 0.
|
28
|
+
Read will only be called if some of its bytes are needed. */
|
29
29
|
virtual const void* Read(size_t n, size_t* nread) = 0;
|
30
30
|
};
|
31
31
|
|
32
|
-
|
32
|
+
/* Output interface for the compression routines. */
|
33
33
|
class BrotliOut {
|
34
34
|
public:
|
35
35
|
virtual ~BrotliOut(void) {}
|
36
36
|
|
37
|
-
|
38
|
-
|
37
|
+
/* Write n bytes of data from buf.
|
38
|
+
Return true if all written, false otherwise. */
|
39
39
|
virtual bool Write(const void *buf, size_t n) = 0;
|
40
40
|
};
|
41
41
|
|
42
|
-
|
42
|
+
/* Adapter class to make BrotliIn objects from raw memory. */
|
43
43
|
class BrotliMemIn : public BrotliIn {
|
44
44
|
public:
|
45
45
|
BrotliMemIn(const void* buf, size_t len);
|
46
46
|
|
47
47
|
void Reset(const void* buf, size_t len);
|
48
48
|
|
49
|
-
|
49
|
+
/* returns the amount of data consumed */
|
50
50
|
size_t position(void) const { return pos_; }
|
51
51
|
|
52
52
|
const void* Read(size_t n, size_t* OUTPUT);
|
53
53
|
|
54
54
|
private:
|
55
|
-
const void* buf_;
|
56
|
-
size_t len_;
|
57
|
-
size_t pos_;
|
55
|
+
const void* buf_; /* start of input buffer */
|
56
|
+
size_t len_; /* length of input */
|
57
|
+
size_t pos_; /* current read position within input */
|
58
58
|
};
|
59
59
|
|
60
|
-
|
60
|
+
/* Adapter class to make BrotliOut objects from raw memory. */
|
61
61
|
class BrotliMemOut : public BrotliOut {
|
62
62
|
public:
|
63
63
|
BrotliMemOut(void* buf, size_t len);
|
64
64
|
|
65
65
|
void Reset(void* buf, size_t len);
|
66
66
|
|
67
|
-
|
67
|
+
/* returns the amount of data written */
|
68
68
|
size_t position(void) const { return pos_; }
|
69
69
|
|
70
70
|
bool Write(const void* buf, size_t n);
|
71
71
|
|
72
72
|
private:
|
73
|
-
void* buf_;
|
74
|
-
size_t len_;
|
75
|
-
size_t pos_;
|
73
|
+
void* buf_; /* start of output buffer */
|
74
|
+
size_t len_; /* length of output */
|
75
|
+
size_t pos_; /* current write position within output */
|
76
76
|
};
|
77
77
|
|
78
|
-
|
78
|
+
/* Adapter class to make BrotliOut objects from a string. */
|
79
79
|
class BrotliStringOut : public BrotliOut {
|
80
80
|
public:
|
81
|
-
|
82
|
-
|
83
|
-
|
81
|
+
/* Create a writer that appends its data to buf.
|
82
|
+
buf->size() will grow to at most max_size
|
83
|
+
buf is expected to be empty when constructing BrotliStringOut. */
|
84
84
|
BrotliStringOut(std::string* buf, size_t max_size);
|
85
85
|
|
86
86
|
void Reset(std::string* buf, size_t max_len);
|
@@ -88,11 +88,11 @@ class BrotliStringOut : public BrotliOut {
|
|
88
88
|
bool Write(const void* buf, size_t n);
|
89
89
|
|
90
90
|
private:
|
91
|
-
std::string* buf_;
|
92
|
-
size_t max_size_;
|
91
|
+
std::string* buf_; /* start of output buffer */
|
92
|
+
size_t max_size_; /* max length of output */
|
93
93
|
};
|
94
94
|
|
95
|
-
|
95
|
+
/* Adapter class to make BrotliIn object from a file. */
|
96
96
|
class BrotliFileIn : public BrotliIn {
|
97
97
|
public:
|
98
98
|
BrotliFileIn(FILE* f, size_t max_read_size);
|
@@ -106,7 +106,7 @@ class BrotliFileIn : public BrotliIn {
|
|
106
106
|
size_t buf_size_;
|
107
107
|
};
|
108
108
|
|
109
|
-
|
109
|
+
/* Adapter class to make BrotliOut object from a file. */
|
110
110
|
class BrotliFileOut : public BrotliOut {
|
111
111
|
public:
|
112
112
|
explicit BrotliFileOut(FILE* f);
|
@@ -116,6 +116,6 @@ class BrotliFileOut : public BrotliOut {
|
|
116
116
|
FILE* f_;
|
117
117
|
};
|
118
118
|
|
119
|
-
}
|
119
|
+
} /* namespace brotli */
|
120
120
|
|
121
|
-
#endif
|
121
|
+
#endif /* BROTLI_ENC_STREAMS_H_ */
|
@@ -4,25 +4,26 @@
|
|
4
4
|
See file LICENSE for detail or copy at https://opensource.org/licenses/MIT
|
5
5
|
*/
|
6
6
|
|
7
|
-
|
7
|
+
/* Heuristics for deciding about the UTF8-ness of strings. */
|
8
8
|
|
9
9
|
#include "./utf8_util.h"
|
10
10
|
|
11
|
-
#include "
|
11
|
+
#include "../common/types.h"
|
12
12
|
|
13
|
-
|
13
|
+
#if defined(__cplusplus) || defined(c_plusplus)
|
14
|
+
extern "C" {
|
15
|
+
#endif
|
14
16
|
|
15
|
-
|
16
|
-
|
17
|
-
|
18
|
-
// ASCII
|
17
|
+
static size_t BrotliParseAsUTF8(
|
18
|
+
int* symbol, const uint8_t* input, size_t size) {
|
19
|
+
/* ASCII */
|
19
20
|
if ((input[0] & 0x80) == 0) {
|
20
21
|
*symbol = input[0];
|
21
22
|
if (*symbol > 0) {
|
22
23
|
return 1;
|
23
24
|
}
|
24
25
|
}
|
25
|
-
|
26
|
+
/* 2-byte UTF8 */
|
26
27
|
if (size > 1u &&
|
27
28
|
(input[0] & 0xe0) == 0xc0 &&
|
28
29
|
(input[1] & 0xc0) == 0x80) {
|
@@ -32,7 +33,7 @@ size_t ParseAsUTF8(int* symbol, const uint8_t* input, size_t size) {
|
|
32
33
|
return 2;
|
33
34
|
}
|
34
35
|
}
|
35
|
-
|
36
|
+
/* 3-byte UFT8 */
|
36
37
|
if (size > 2u &&
|
37
38
|
(input[0] & 0xf0) == 0xe0 &&
|
38
39
|
(input[1] & 0xc0) == 0x80 &&
|
@@ -44,7 +45,7 @@ size_t ParseAsUTF8(int* symbol, const uint8_t* input, size_t size) {
|
|
44
45
|
return 3;
|
45
46
|
}
|
46
47
|
}
|
47
|
-
|
48
|
+
/* 4-byte UFT8 */
|
48
49
|
if (size > 3u &&
|
49
50
|
(input[0] & 0xf8) == 0xf0 &&
|
50
51
|
(input[1] & 0xc0) == 0x80 &&
|
@@ -58,26 +59,27 @@ size_t ParseAsUTF8(int* symbol, const uint8_t* input, size_t size) {
|
|
58
59
|
return 4;
|
59
60
|
}
|
60
61
|
}
|
61
|
-
|
62
|
+
/* Not UTF8, emit a special symbol above the UTF8-code space */
|
62
63
|
*symbol = 0x110000 | input[0];
|
63
64
|
return 1;
|
64
65
|
}
|
65
66
|
|
66
|
-
|
67
|
-
|
68
|
-
|
69
|
-
|
70
|
-
const size_t length, const double min_fraction) {
|
67
|
+
/* Returns 1 if at least min_fraction of the data is UTF8-encoded.*/
|
68
|
+
BROTLI_BOOL BrotliIsMostlyUTF8(
|
69
|
+
const uint8_t* data, const size_t pos, const size_t mask,
|
70
|
+
const size_t length, const double min_fraction) {
|
71
71
|
size_t size_utf8 = 0;
|
72
72
|
size_t i = 0;
|
73
73
|
while (i < length) {
|
74
74
|
int symbol;
|
75
|
-
size_t bytes_read =
|
76
|
-
&symbol, &data[(pos + i) & mask], length - i);
|
75
|
+
size_t bytes_read =
|
76
|
+
BrotliParseAsUTF8(&symbol, &data[(pos + i) & mask], length - i);
|
77
77
|
i += bytes_read;
|
78
78
|
if (symbol < 0x110000) size_utf8 += bytes_read;
|
79
79
|
}
|
80
|
-
return size_utf8 > min_fraction *
|
80
|
+
return TO_BROTLI_BOOL(size_utf8 > min_fraction * (double)length);
|
81
81
|
}
|
82
82
|
|
83
|
-
|
83
|
+
#if defined(__cplusplus) || defined(c_plusplus)
|
84
|
+
} /* extern "C" */
|
85
|
+
#endif
|
@@ -4,22 +4,29 @@
|
|
4
4
|
See file LICENSE for detail or copy at https://opensource.org/licenses/MIT
|
5
5
|
*/
|
6
6
|
|
7
|
-
|
7
|
+
/* Heuristics for deciding about the UTF8-ness of strings. */
|
8
8
|
|
9
9
|
#ifndef BROTLI_ENC_UTF8_UTIL_H_
|
10
10
|
#define BROTLI_ENC_UTF8_UTIL_H_
|
11
11
|
|
12
|
-
#include "
|
12
|
+
#include "../common/types.h"
|
13
|
+
#include "./port.h"
|
13
14
|
|
14
|
-
|
15
|
+
#if defined(__cplusplus) || defined(c_plusplus)
|
16
|
+
extern "C" {
|
17
|
+
#endif
|
15
18
|
|
16
19
|
static const double kMinUTF8Ratio = 0.75;
|
17
20
|
|
18
|
-
|
19
|
-
|
20
|
-
|
21
|
-
|
21
|
+
/* Returns 1 if at least min_fraction of the bytes between pos and
|
22
|
+
pos + length in the (data, mask) ringbuffer is UTF8-encoded, otherwise
|
23
|
+
returns 0. */
|
24
|
+
BROTLI_INTERNAL BROTLI_BOOL BrotliIsMostlyUTF8(
|
25
|
+
const uint8_t* data, const size_t pos, const size_t mask,
|
26
|
+
const size_t length, const double min_fraction);
|
22
27
|
|
23
|
-
|
28
|
+
#if defined(__cplusplus) || defined(c_plusplus)
|
29
|
+
} /* extern "C" */
|
30
|
+
#endif
|
24
31
|
|
25
|
-
#endif
|
32
|
+
#endif /* BROTLI_ENC_UTF8_UTIL_H_ */
|
@@ -4,74 +4,78 @@
|
|
4
4
|
See file LICENSE for detail or copy at https://opensource.org/licenses/MIT
|
5
5
|
*/
|
6
6
|
|
7
|
-
|
7
|
+
/* Write bits into a byte array. */
|
8
8
|
|
9
9
|
#ifndef BROTLI_ENC_WRITE_BITS_H_
|
10
10
|
#define BROTLI_ENC_WRITE_BITS_H_
|
11
11
|
|
12
12
|
#include <assert.h>
|
13
|
-
#include <stdio.h>
|
13
|
+
#include <stdio.h> /* printf */
|
14
14
|
|
15
|
+
#include "../common/types.h"
|
15
16
|
#include "./port.h"
|
16
|
-
|
17
|
-
|
18
|
-
|
19
|
-
|
20
|
-
|
21
|
-
|
22
|
-
|
23
|
-
|
24
|
-
|
25
|
-
|
26
|
-
|
27
|
-
|
28
|
-
|
29
|
-
|
30
|
-
|
31
|
-
|
32
|
-
|
33
|
-
|
34
|
-
|
35
|
-
|
36
|
-
|
37
|
-
|
38
|
-
|
39
|
-
|
40
|
-
|
17
|
+
|
18
|
+
#if defined(__cplusplus) || defined(c_plusplus)
|
19
|
+
extern "C" {
|
20
|
+
#endif
|
21
|
+
|
22
|
+
/*#define BIT_WRITER_DEBUG */
|
23
|
+
|
24
|
+
/* This function writes bits into bytes in increasing addresses, and within
|
25
|
+
a byte least-significant-bit first.
|
26
|
+
|
27
|
+
The function can write up to 56 bits in one go with WriteBits
|
28
|
+
Example: let's assume that 3 bits (Rs below) have been written already:
|
29
|
+
|
30
|
+
BYTE-0 BYTE+1 BYTE+2
|
31
|
+
|
32
|
+
0000 0RRR 0000 0000 0000 0000
|
33
|
+
|
34
|
+
Now, we could write 5 or less bits in MSB by just sifting by 3
|
35
|
+
and OR'ing to BYTE-0.
|
36
|
+
|
37
|
+
For n bits, we take the last 5 bits, OR that with high bits in BYTE-0,
|
38
|
+
and locate the rest in BYTE+1, BYTE+2, etc. */
|
39
|
+
static BROTLI_INLINE void BrotliWriteBits(size_t n_bits,
|
40
|
+
uint64_t bits,
|
41
|
+
size_t * BROTLI_RESTRICT pos,
|
42
|
+
uint8_t * BROTLI_RESTRICT array) {
|
43
|
+
#ifdef IS_LITTLE_ENDIAN
|
44
|
+
/* This branch of the code can write up to 56 bits at a time,
|
45
|
+
7 bits are lost by being perhaps already in *p and at least
|
46
|
+
1 bit is needed to initialize the bit-stream ahead (i.e. if 7
|
47
|
+
bits are in *p and we write 57 bits, then the next write will
|
48
|
+
access a byte that was never initialized). */
|
49
|
+
uint8_t *p = &array[*pos >> 3];
|
50
|
+
uint64_t v = *p;
|
41
51
|
#ifdef BIT_WRITER_DEBUG
|
42
52
|
printf("WriteBits %2d 0x%016llx %10d\n", n_bits, bits, *pos);
|
43
53
|
#endif
|
44
54
|
assert((bits >> n_bits) == 0);
|
45
55
|
assert(n_bits <= 56);
|
46
|
-
#ifdef IS_LITTLE_ENDIAN
|
47
|
-
// This branch of the code can write up to 56 bits at a time,
|
48
|
-
// 7 bits are lost by being perhaps already in *p and at least
|
49
|
-
// 1 bit is needed to initialize the bit-stream ahead (i.e. if 7
|
50
|
-
// bits are in *p and we write 57 bits, then the next write will
|
51
|
-
// access a byte that was never initialized).
|
52
|
-
uint8_t *p = &array[*pos >> 3];
|
53
|
-
uint64_t v = *p;
|
54
56
|
v |= bits << (*pos & 7);
|
55
|
-
BROTLI_UNALIGNED_STORE64(p, v);
|
57
|
+
BROTLI_UNALIGNED_STORE64(p, v); /* Set some bits. */
|
56
58
|
*pos += n_bits;
|
57
59
|
#else
|
58
|
-
|
60
|
+
/* implicit & 0xff is assumed for uint8_t arithmetics */
|
59
61
|
uint8_t *array_pos = &array[*pos >> 3];
|
60
62
|
const size_t bits_reserved_in_first_byte = (*pos & 7);
|
63
|
+
size_t bits_left_to_write;
|
61
64
|
bits <<= bits_reserved_in_first_byte;
|
62
|
-
*array_pos++ |=
|
63
|
-
for (
|
65
|
+
*array_pos++ |= (uint8_t)bits;
|
66
|
+
for (bits_left_to_write = n_bits + bits_reserved_in_first_byte;
|
64
67
|
bits_left_to_write >= 9;
|
65
68
|
bits_left_to_write -= 8) {
|
66
69
|
bits >>= 8;
|
67
|
-
*array_pos++ =
|
70
|
+
*array_pos++ = (uint8_t)bits;
|
68
71
|
}
|
69
72
|
*array_pos = 0;
|
70
73
|
*pos += n_bits;
|
71
74
|
#endif
|
72
75
|
}
|
73
76
|
|
74
|
-
|
77
|
+
static BROTLI_INLINE void BrotliWriteBitsPrepareStorage(
|
78
|
+
size_t pos, uint8_t *array) {
|
75
79
|
#ifdef BIT_WRITER_DEBUG
|
76
80
|
printf("WriteBitsPrepareStorage %10d\n", pos);
|
77
81
|
#endif
|
@@ -79,6 +83,8 @@ inline void WriteBitsPrepareStorage(size_t pos, uint8_t *array) {
|
|
79
83
|
array[pos >> 3] = 0;
|
80
84
|
}
|
81
85
|
|
82
|
-
|
86
|
+
#if defined(__cplusplus) || defined(c_plusplus)
|
87
|
+
} /* extern "C" */
|
88
|
+
#endif
|
83
89
|
|
84
|
-
#endif
|
90
|
+
#endif /* BROTLI_ENC_WRITE_BITS_H_ */
|
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: brotli
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.1.
|
4
|
+
version: 0.1.4
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- miyucy
|
8
8
|
autorequire:
|
9
9
|
bindir: exe
|
10
10
|
cert_chain: []
|
11
|
-
date: 2016-12-
|
11
|
+
date: 2016-12-27 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: bundler
|
@@ -98,20 +98,19 @@ files:
|
|
98
98
|
- bin/console
|
99
99
|
- bin/setup
|
100
100
|
- brotli.gemspec
|
101
|
-
- ext/brotli/brotli.
|
101
|
+
- ext/brotli/brotli.c
|
102
102
|
- ext/brotli/brotli.h
|
103
|
+
- ext/brotli/buffer.c
|
104
|
+
- ext/brotli/buffer.h
|
103
105
|
- ext/brotli/extconf.rb
|
104
106
|
- lib/brotli.rb
|
105
107
|
- lib/brotli/version.rb
|
106
108
|
- vendor/brotli/LICENSE
|
107
|
-
- vendor/brotli/dec/Makefile
|
108
109
|
- vendor/brotli/dec/bit_reader.c
|
109
110
|
- vendor/brotli/dec/bit_reader.h
|
110
111
|
- vendor/brotli/dec/context.h
|
111
112
|
- vendor/brotli/dec/decode.c
|
112
113
|
- vendor/brotli/dec/decode.h
|
113
|
-
- vendor/brotli/dec/dictionary.c
|
114
|
-
- vendor/brotli/dec/dictionary.h
|
115
114
|
- vendor/brotli/dec/huffman.c
|
116
115
|
- vendor/brotli/dec/huffman.h
|
117
116
|
- vendor/brotli/dec/port.h
|
@@ -119,53 +118,63 @@ files:
|
|
119
118
|
- vendor/brotli/dec/state.c
|
120
119
|
- vendor/brotli/dec/state.h
|
121
120
|
- vendor/brotli/dec/transform.h
|
122
|
-
- vendor/brotli/
|
123
|
-
- vendor/brotli/enc/Makefile
|
124
|
-
- vendor/brotli/enc/backward_references.cc
|
121
|
+
- vendor/brotli/enc/backward_references.c
|
125
122
|
- vendor/brotli/enc/backward_references.h
|
123
|
+
- vendor/brotli/enc/backward_references_inc.h
|
124
|
+
- vendor/brotli/enc/bit_cost.c
|
126
125
|
- vendor/brotli/enc/bit_cost.h
|
127
|
-
- vendor/brotli/enc/
|
126
|
+
- vendor/brotli/enc/bit_cost_inc.h
|
127
|
+
- vendor/brotli/enc/block_encoder_inc.h
|
128
|
+
- vendor/brotli/enc/block_splitter.c
|
128
129
|
- vendor/brotli/enc/block_splitter.h
|
129
|
-
- vendor/brotli/enc/
|
130
|
+
- vendor/brotli/enc/block_splitter_inc.h
|
131
|
+
- vendor/brotli/enc/brotli_bit_stream.c
|
130
132
|
- vendor/brotli/enc/brotli_bit_stream.h
|
133
|
+
- vendor/brotli/enc/cluster.c
|
131
134
|
- vendor/brotli/enc/cluster.h
|
135
|
+
- vendor/brotli/enc/cluster_inc.h
|
132
136
|
- vendor/brotli/enc/command.h
|
133
|
-
- vendor/brotli/enc/compress_fragment.
|
137
|
+
- vendor/brotli/enc/compress_fragment.c
|
134
138
|
- vendor/brotli/enc/compress_fragment.h
|
135
|
-
- vendor/brotli/enc/compress_fragment_two_pass.
|
139
|
+
- vendor/brotli/enc/compress_fragment_two_pass.c
|
136
140
|
- vendor/brotli/enc/compress_fragment_two_pass.h
|
141
|
+
- vendor/brotli/enc/compressor.cc
|
137
142
|
- vendor/brotli/enc/compressor.h
|
138
143
|
- vendor/brotli/enc/context.h
|
139
|
-
- vendor/brotli/enc/dictionary.cc
|
140
|
-
- vendor/brotli/enc/dictionary.h
|
141
144
|
- vendor/brotli/enc/dictionary_hash.h
|
142
|
-
- vendor/brotli/enc/encode.
|
145
|
+
- vendor/brotli/enc/encode.c
|
143
146
|
- vendor/brotli/enc/encode.h
|
144
147
|
- vendor/brotli/enc/encode_parallel.cc
|
145
148
|
- vendor/brotli/enc/encode_parallel.h
|
146
|
-
- vendor/brotli/enc/entropy_encode.
|
149
|
+
- vendor/brotli/enc/entropy_encode.c
|
147
150
|
- vendor/brotli/enc/entropy_encode.h
|
148
151
|
- vendor/brotli/enc/entropy_encode_static.h
|
149
152
|
- vendor/brotli/enc/fast_log.h
|
150
153
|
- vendor/brotli/enc/find_match_length.h
|
151
154
|
- vendor/brotli/enc/hash.h
|
152
|
-
- vendor/brotli/enc/
|
155
|
+
- vendor/brotli/enc/hash_forgetful_chain_inc.h
|
156
|
+
- vendor/brotli/enc/hash_longest_match_inc.h
|
157
|
+
- vendor/brotli/enc/hash_longest_match_quickly_inc.h
|
158
|
+
- vendor/brotli/enc/histogram.c
|
153
159
|
- vendor/brotli/enc/histogram.h
|
154
|
-
- vendor/brotli/enc/
|
160
|
+
- vendor/brotli/enc/histogram_inc.h
|
161
|
+
- vendor/brotli/enc/literal_cost.c
|
155
162
|
- vendor/brotli/enc/literal_cost.h
|
156
|
-
- vendor/brotli/enc/
|
163
|
+
- vendor/brotli/enc/memory.c
|
164
|
+
- vendor/brotli/enc/memory.h
|
165
|
+
- vendor/brotli/enc/metablock.c
|
157
166
|
- vendor/brotli/enc/metablock.h
|
167
|
+
- vendor/brotli/enc/metablock_inc.h
|
158
168
|
- vendor/brotli/enc/port.h
|
159
169
|
- vendor/brotli/enc/prefix.h
|
170
|
+
- vendor/brotli/enc/quality.h
|
160
171
|
- vendor/brotli/enc/ringbuffer.h
|
161
|
-
- vendor/brotli/enc/static_dict.
|
172
|
+
- vendor/brotli/enc/static_dict.c
|
162
173
|
- vendor/brotli/enc/static_dict.h
|
163
174
|
- vendor/brotli/enc/static_dict_lut.h
|
164
175
|
- vendor/brotli/enc/streams.cc
|
165
176
|
- vendor/brotli/enc/streams.h
|
166
|
-
- vendor/brotli/enc/
|
167
|
-
- vendor/brotli/enc/types.h
|
168
|
-
- vendor/brotli/enc/utf8_util.cc
|
177
|
+
- vendor/brotli/enc/utf8_util.c
|
169
178
|
- vendor/brotli/enc/utf8_util.h
|
170
179
|
- vendor/brotli/enc/write_bits.h
|
171
180
|
homepage: https://github.com/miyucy/brotli
|
@@ -187,7 +196,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
|
|
187
196
|
version: '0'
|
188
197
|
requirements: []
|
189
198
|
rubyforge_project:
|
190
|
-
rubygems_version: 2.
|
199
|
+
rubygems_version: 2.4.5
|
191
200
|
signing_key:
|
192
201
|
specification_version: 4
|
193
202
|
summary: Brotli compressor/decompressor
|