brotli 0.1.0 → 0.1.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 +4 -4
- data/.gitmodules +1 -1
- data/.travis.yml +2 -1
- data/README.md +1 -1
- data/Rakefile +1 -1
- data/ext/brotli/brotli.cc +1 -1
- data/ext/brotli/extconf.rb +72 -14
- data/lib/brotli/version.rb +1 -1
- data/vendor/brotli/LICENSE +19 -202
- data/vendor/brotli/dec/Makefile +1 -1
- data/vendor/brotli/dec/bit_reader.c +23 -30
- data/vendor/brotli/dec/bit_reader.h +270 -141
- data/vendor/brotli/dec/context.h +3 -12
- data/vendor/brotli/dec/decode.c +1813 -1048
- data/vendor/brotli/dec/decode.h +22 -16
- data/vendor/brotli/dec/dictionary.c +9466 -0
- data/vendor/brotli/dec/dictionary.h +6 -9461
- data/vendor/brotli/dec/huffman.c +104 -71
- data/vendor/brotli/dec/huffman.h +19 -28
- data/vendor/brotli/dec/port.h +124 -32
- data/vendor/brotli/dec/prefix.h +4 -13
- data/vendor/brotli/dec/state.c +93 -56
- data/vendor/brotli/dec/state.h +124 -53
- data/vendor/brotli/dec/streams.c +14 -11
- data/vendor/brotli/dec/streams.h +6 -11
- data/vendor/brotli/dec/transform.h +2 -11
- data/vendor/brotli/dec/types.h +21 -19
- data/vendor/brotli/enc/Makefile +4 -1
- data/vendor/brotli/enc/backward_references.cc +87 -94
- data/vendor/brotli/enc/backward_references.h +8 -18
- data/vendor/brotli/enc/bit_cost.h +11 -19
- data/vendor/brotli/enc/block_splitter.cc +43 -48
- data/vendor/brotli/enc/block_splitter.h +7 -16
- data/vendor/brotli/enc/brotli_bit_stream.cc +48 -50
- data/vendor/brotli/enc/brotli_bit_stream.h +7 -16
- data/vendor/brotli/enc/cluster.h +24 -25
- data/vendor/brotli/enc/command.h +34 -41
- data/vendor/brotli/enc/context.h +11 -18
- data/vendor/brotli/enc/dictionary.cc +9466 -0
- data/vendor/brotli/enc/dictionary.h +20 -9464
- data/vendor/brotli/enc/dictionary_hash.h +7 -15
- data/vendor/brotli/enc/encode.cc +80 -148
- data/vendor/brotli/enc/encode.h +19 -29
- data/vendor/brotli/enc/encode_parallel.cc +35 -108
- data/vendor/brotli/enc/encode_parallel.h +7 -16
- data/vendor/brotli/enc/entropy_encode.cc +33 -42
- data/vendor/brotli/enc/entropy_encode.h +8 -16
- data/vendor/brotli/enc/fast_log.h +8 -15
- data/vendor/brotli/enc/find_match_length.h +7 -17
- data/vendor/brotli/enc/hash.h +130 -150
- data/vendor/brotli/enc/histogram.cc +7 -16
- data/vendor/brotli/enc/histogram.h +11 -17
- data/vendor/brotli/enc/literal_cost.cc +28 -35
- data/vendor/brotli/enc/literal_cost.h +9 -23
- data/vendor/brotli/enc/metablock.cc +18 -26
- data/vendor/brotli/enc/metablock.h +6 -14
- data/vendor/brotli/enc/port.h +14 -14
- data/vendor/brotli/enc/prefix.h +11 -18
- data/vendor/brotli/enc/ringbuffer.h +18 -27
- data/vendor/brotli/enc/static_dict.cc +7 -1
- data/vendor/brotli/enc/static_dict.h +7 -15
- data/vendor/brotli/enc/static_dict_lut.h +7 -15
- data/vendor/brotli/enc/streams.cc +15 -28
- data/vendor/brotli/enc/streams.h +27 -35
- data/vendor/brotli/enc/transform.h +9 -16
- data/vendor/brotli/enc/types.h +27 -0
- data/vendor/brotli/enc/utf8_util.cc +82 -0
- data/vendor/brotli/enc/utf8_util.h +25 -0
- data/vendor/brotli/enc/write_bits.h +11 -18
- metadata +7 -2
@@ -1,17 +1,9 @@
|
|
1
|
-
|
2
|
-
|
3
|
-
|
4
|
-
|
5
|
-
|
6
|
-
|
7
|
-
// http://www.apache.org/licenses/LICENSE-2.0
|
8
|
-
//
|
9
|
-
// Unless required by applicable law or agreed to in writing, software
|
10
|
-
// distributed under the License is distributed on an "AS IS" BASIS,
|
11
|
-
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
12
|
-
// See the License for the specific language governing permissions and
|
13
|
-
// limitations under the License.
|
14
|
-
//
|
1
|
+
/* Copyright 2009 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
|
+
|
15
7
|
// Convience routines to make Brotli I/O classes from some memory containers and
|
16
8
|
// files.
|
17
9
|
|
@@ -23,12 +15,12 @@
|
|
23
15
|
|
24
16
|
namespace brotli {
|
25
17
|
|
26
|
-
BrotliMemOut::BrotliMemOut(void* buf,
|
18
|
+
BrotliMemOut::BrotliMemOut(void* buf, size_t len)
|
27
19
|
: buf_(buf),
|
28
20
|
len_(len),
|
29
21
|
pos_(0) {}
|
30
22
|
|
31
|
-
void BrotliMemOut::Reset(void* buf,
|
23
|
+
void BrotliMemOut::Reset(void* buf, size_t len) {
|
32
24
|
buf_ = buf;
|
33
25
|
len_ = len;
|
34
26
|
pos_ = 0;
|
@@ -44,13 +36,13 @@ bool BrotliMemOut::Write(const void *buf, size_t n) {
|
|
44
36
|
return true;
|
45
37
|
}
|
46
38
|
|
47
|
-
BrotliStringOut::BrotliStringOut(std::string* buf,
|
39
|
+
BrotliStringOut::BrotliStringOut(std::string* buf, size_t max_size)
|
48
40
|
: buf_(buf),
|
49
41
|
max_size_(max_size) {
|
50
42
|
assert(buf->empty());
|
51
43
|
}
|
52
44
|
|
53
|
-
void BrotliStringOut::Reset(std::string* buf,
|
45
|
+
void BrotliStringOut::Reset(std::string* buf, size_t max_size) {
|
54
46
|
buf_ = buf;
|
55
47
|
max_size_ = max_size;
|
56
48
|
}
|
@@ -63,12 +55,12 @@ bool BrotliStringOut::Write(const void *buf, size_t n) {
|
|
63
55
|
return true;
|
64
56
|
}
|
65
57
|
|
66
|
-
BrotliMemIn::BrotliMemIn(const void* buf,
|
58
|
+
BrotliMemIn::BrotliMemIn(const void* buf, size_t len)
|
67
59
|
: buf_(buf),
|
68
60
|
len_(len),
|
69
61
|
pos_(0) {}
|
70
62
|
|
71
|
-
void BrotliMemIn::Reset(const void* buf,
|
63
|
+
void BrotliMemIn::Reset(const void* buf, size_t len) {
|
72
64
|
buf_ = buf;
|
73
65
|
len_ = len;
|
74
66
|
pos_ = 0;
|
@@ -89,18 +81,14 @@ const void* BrotliMemIn::Read(size_t n, size_t* output) {
|
|
89
81
|
|
90
82
|
BrotliFileIn::BrotliFileIn(FILE* f, size_t max_read_size)
|
91
83
|
: f_(f),
|
92
|
-
buf_(
|
93
|
-
buf_size_(max_read_size) {}
|
84
|
+
buf_(new char[max_read_size]),
|
85
|
+
buf_size_(max_read_size) { }
|
94
86
|
|
95
87
|
BrotliFileIn::~BrotliFileIn() {
|
96
|
-
|
88
|
+
delete[] buf_;
|
97
89
|
}
|
98
90
|
|
99
91
|
const void* BrotliFileIn::Read(size_t n, size_t* bytes_read) {
|
100
|
-
if (buf_ == NULL) {
|
101
|
-
*bytes_read = 0;
|
102
|
-
return NULL;
|
103
|
-
}
|
104
92
|
if (n > buf_size_) {
|
105
93
|
n = buf_size_;
|
106
94
|
} else if (n == 0) {
|
@@ -123,5 +111,4 @@ bool BrotliFileOut::Write(const void* buf, size_t n) {
|
|
123
111
|
return true;
|
124
112
|
}
|
125
113
|
|
126
|
-
|
127
114
|
} // namespace brotli
|
data/vendor/brotli/enc/streams.h
CHANGED
@@ -1,25 +1,18 @@
|
|
1
|
-
|
2
|
-
|
3
|
-
|
4
|
-
|
5
|
-
|
6
|
-
|
7
|
-
// http://www.apache.org/licenses/LICENSE-2.0
|
8
|
-
//
|
9
|
-
// Unless required by applicable law or agreed to in writing, software
|
10
|
-
// distributed under the License is distributed on an "AS IS" BASIS,
|
11
|
-
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
12
|
-
// See the License for the specific language governing permissions and
|
13
|
-
// limitations under the License.
|
14
|
-
//
|
1
|
+
/* Copyright 2009 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
|
+
|
15
7
|
// Input and output classes for streaming brotli compression.
|
16
8
|
|
17
9
|
#ifndef BROTLI_ENC_STREAMS_H_
|
18
10
|
#define BROTLI_ENC_STREAMS_H_
|
19
11
|
|
20
|
-
#include <stddef.h>
|
21
12
|
#include <stdio.h>
|
22
13
|
#include <string>
|
14
|
+
#include "./port.h"
|
15
|
+
#include "./types.h"
|
23
16
|
|
24
17
|
namespace brotli {
|
25
18
|
|
@@ -49,37 +42,37 @@ class BrotliOut {
|
|
49
42
|
// Adapter class to make BrotliIn objects from raw memory.
|
50
43
|
class BrotliMemIn : public BrotliIn {
|
51
44
|
public:
|
52
|
-
BrotliMemIn(const void* buf,
|
45
|
+
BrotliMemIn(const void* buf, size_t len);
|
53
46
|
|
54
|
-
void Reset(const void* buf,
|
47
|
+
void Reset(const void* buf, size_t len);
|
55
48
|
|
56
49
|
// returns the amount of data consumed
|
57
|
-
|
50
|
+
size_t position() const { return pos_; }
|
58
51
|
|
59
|
-
const void* Read(size_t n, size_t* OUTPUT)
|
52
|
+
const void* Read(size_t n, size_t* OUTPUT);
|
60
53
|
|
61
54
|
private:
|
62
55
|
const void* buf_; // start of input buffer
|
63
|
-
|
64
|
-
|
56
|
+
size_t len_; // length of input
|
57
|
+
size_t pos_; // current read position within input
|
65
58
|
};
|
66
59
|
|
67
60
|
// Adapter class to make BrotliOut objects from raw memory.
|
68
61
|
class BrotliMemOut : public BrotliOut {
|
69
62
|
public:
|
70
|
-
BrotliMemOut(void* buf,
|
63
|
+
BrotliMemOut(void* buf, size_t len);
|
71
64
|
|
72
|
-
void Reset(void* buf,
|
65
|
+
void Reset(void* buf, size_t len);
|
73
66
|
|
74
67
|
// returns the amount of data written
|
75
|
-
|
68
|
+
size_t position() const { return pos_; }
|
76
69
|
|
77
|
-
bool Write(const void* buf, size_t n)
|
70
|
+
bool Write(const void* buf, size_t n);
|
78
71
|
|
79
72
|
private:
|
80
73
|
void* buf_; // start of output buffer
|
81
|
-
|
82
|
-
|
74
|
+
size_t len_; // length of output
|
75
|
+
size_t pos_; // current write position within output
|
83
76
|
};
|
84
77
|
|
85
78
|
// Adapter class to make BrotliOut objects from a string.
|
@@ -88,15 +81,15 @@ class BrotliStringOut : public BrotliOut {
|
|
88
81
|
// Create a writer that appends its data to buf.
|
89
82
|
// buf->size() will grow to at most max_size
|
90
83
|
// buf is expected to be empty when constructing BrotliStringOut.
|
91
|
-
BrotliStringOut(std::string* buf,
|
84
|
+
BrotliStringOut(std::string* buf, size_t max_size);
|
92
85
|
|
93
|
-
void Reset(std::string* buf,
|
86
|
+
void Reset(std::string* buf, size_t max_len);
|
94
87
|
|
95
|
-
bool Write(const void* buf, size_t n)
|
88
|
+
bool Write(const void* buf, size_t n);
|
96
89
|
|
97
90
|
private:
|
98
91
|
std::string* buf_; // start of output buffer
|
99
|
-
|
92
|
+
size_t max_size_; // max length of output
|
100
93
|
};
|
101
94
|
|
102
95
|
// Adapter class to make BrotliIn object from a file.
|
@@ -105,11 +98,11 @@ class BrotliFileIn : public BrotliIn {
|
|
105
98
|
BrotliFileIn(FILE* f, size_t max_read_size);
|
106
99
|
~BrotliFileIn();
|
107
100
|
|
108
|
-
const void* Read(size_t n, size_t* bytes_read)
|
101
|
+
const void* Read(size_t n, size_t* bytes_read);
|
109
102
|
|
110
103
|
private:
|
111
104
|
FILE* f_;
|
112
|
-
|
105
|
+
char* buf_;
|
113
106
|
size_t buf_size_;
|
114
107
|
};
|
115
108
|
|
@@ -118,12 +111,11 @@ class BrotliFileOut : public BrotliOut {
|
|
118
111
|
public:
|
119
112
|
explicit BrotliFileOut(FILE* f);
|
120
113
|
|
121
|
-
bool Write(const void* buf, size_t n)
|
114
|
+
bool Write(const void* buf, size_t n);
|
122
115
|
private:
|
123
116
|
FILE* f_;
|
124
117
|
};
|
125
118
|
|
126
|
-
|
127
119
|
} // namespace brotli
|
128
120
|
|
129
121
|
#endif // BROTLI_ENC_STREAMS_H_
|
@@ -1,17 +1,9 @@
|
|
1
|
-
|
2
|
-
|
3
|
-
|
4
|
-
|
5
|
-
|
6
|
-
|
7
|
-
// http://www.apache.org/licenses/LICENSE-2.0
|
8
|
-
//
|
9
|
-
// Unless required by applicable law or agreed to in writing, software
|
10
|
-
// distributed under the License is distributed on an "AS IS" BASIS,
|
11
|
-
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
12
|
-
// See the License for the specific language governing permissions and
|
13
|
-
// limitations under the License.
|
14
|
-
//
|
1
|
+
/* Copyright 2010 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
|
+
|
15
7
|
// Transformations on dictionary words.
|
16
8
|
|
17
9
|
#ifndef BROTLI_ENC_TRANSFORM_H_
|
@@ -44,7 +36,7 @@ enum WordTransformType {
|
|
44
36
|
kOmitFirst6 = 17,
|
45
37
|
kOmitFirst7 = 18,
|
46
38
|
kOmitFirst8 = 19,
|
47
|
-
kOmitFirst9 = 20
|
39
|
+
kOmitFirst9 = 20
|
48
40
|
};
|
49
41
|
|
50
42
|
struct Transform {
|
@@ -177,7 +169,8 @@ static const Transform kTransforms[] = {
|
|
177
169
|
{ " ", kUppercaseFirst, "='" },
|
178
170
|
};
|
179
171
|
|
180
|
-
static const
|
172
|
+
static const size_t kNumTransforms =
|
173
|
+
sizeof(kTransforms) / sizeof(kTransforms[0]);
|
181
174
|
|
182
175
|
static const int kOmitFirstNTransforms[10] = {
|
183
176
|
0, 3, 11, 26, 34, 39, 40, 55, 0, 54
|
@@ -0,0 +1,27 @@
|
|
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
|
+
/* Common types */
|
8
|
+
|
9
|
+
#ifndef BROTLI_ENC_TYPES_H_
|
10
|
+
#define BROTLI_ENC_TYPES_H_
|
11
|
+
|
12
|
+
#include <stddef.h> /* for size_t */
|
13
|
+
|
14
|
+
#if defined(_MSC_VER) && (_MSC_VER < 1600)
|
15
|
+
typedef __int8 int8_t;
|
16
|
+
typedef unsigned __int8 uint8_t;
|
17
|
+
typedef __int16 int16_t;
|
18
|
+
typedef unsigned __int16 uint16_t;
|
19
|
+
typedef __int32 int32_t;
|
20
|
+
typedef unsigned __int32 uint32_t;
|
21
|
+
typedef unsigned __int64 uint64_t;
|
22
|
+
typedef __int64 int64_t;
|
23
|
+
#else
|
24
|
+
#include <stdint.h>
|
25
|
+
#endif /* defined(_MSC_VER) && (_MSC_VER < 1600) */
|
26
|
+
|
27
|
+
#endif /* BROTLI_ENC_TYPES_H_ */
|
@@ -0,0 +1,82 @@
|
|
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
|
+
// Heuristics for deciding about the UTF8-ness of strings.
|
8
|
+
|
9
|
+
#include "./utf8_util.h"
|
10
|
+
|
11
|
+
#include "./types.h"
|
12
|
+
|
13
|
+
namespace brotli {
|
14
|
+
|
15
|
+
namespace {
|
16
|
+
|
17
|
+
int ParseAsUTF8(int* symbol, const uint8_t* input, size_t size) {
|
18
|
+
// ASCII
|
19
|
+
if ((input[0] & 0x80) == 0) {
|
20
|
+
*symbol = input[0];
|
21
|
+
if (*symbol > 0) {
|
22
|
+
return 1;
|
23
|
+
}
|
24
|
+
}
|
25
|
+
// 2-byte UTF8
|
26
|
+
if (size > 1u &&
|
27
|
+
(input[0] & 0xe0) == 0xc0 &&
|
28
|
+
(input[1] & 0xc0) == 0x80) {
|
29
|
+
*symbol = (((input[0] & 0x1f) << 6) |
|
30
|
+
(input[1] & 0x3f));
|
31
|
+
if (*symbol > 0x7f) {
|
32
|
+
return 2;
|
33
|
+
}
|
34
|
+
}
|
35
|
+
// 3-byte UFT8
|
36
|
+
if (size > 2u &&
|
37
|
+
(input[0] & 0xf0) == 0xe0 &&
|
38
|
+
(input[1] & 0xc0) == 0x80 &&
|
39
|
+
(input[2] & 0xc0) == 0x80) {
|
40
|
+
*symbol = (((input[0] & 0x0f) << 12) |
|
41
|
+
((input[1] & 0x3f) << 6) |
|
42
|
+
(input[2] & 0x3f));
|
43
|
+
if (*symbol > 0x7ff) {
|
44
|
+
return 3;
|
45
|
+
}
|
46
|
+
}
|
47
|
+
// 4-byte UFT8
|
48
|
+
if (size > 3u &&
|
49
|
+
(input[0] & 0xf8) == 0xf0 &&
|
50
|
+
(input[1] & 0xc0) == 0x80 &&
|
51
|
+
(input[2] & 0xc0) == 0x80 &&
|
52
|
+
(input[3] & 0xc0) == 0x80) {
|
53
|
+
*symbol = (((input[0] & 0x07) << 18) |
|
54
|
+
((input[1] & 0x3f) << 12) |
|
55
|
+
((input[2] & 0x3f) << 6) |
|
56
|
+
(input[3] & 0x3f));
|
57
|
+
if (*symbol > 0xffff && *symbol <= 0x10ffff) {
|
58
|
+
return 4;
|
59
|
+
}
|
60
|
+
}
|
61
|
+
// Not UTF8, emit a special symbol above the UTF8-code space
|
62
|
+
*symbol = 0x110000 | input[0];
|
63
|
+
return 1;
|
64
|
+
}
|
65
|
+
|
66
|
+
} // namespace
|
67
|
+
|
68
|
+
// Returns true if at least min_fraction of the data is UTF8-encoded.
|
69
|
+
bool IsMostlyUTF8(const uint8_t* data, const size_t pos, const size_t mask,
|
70
|
+
const size_t length, const double min_fraction) {
|
71
|
+
size_t size_utf8 = 0;
|
72
|
+
size_t i = 0;
|
73
|
+
while (i < length) {
|
74
|
+
int symbol;
|
75
|
+
int bytes_read = ParseAsUTF8(&symbol, &data[(pos + i) & mask], length - i);
|
76
|
+
i += bytes_read;
|
77
|
+
if (symbol < 0x110000) size_utf8 += bytes_read;
|
78
|
+
}
|
79
|
+
return size_utf8 > min_fraction * static_cast<double>(length);
|
80
|
+
}
|
81
|
+
|
82
|
+
} // namespace brotli
|
@@ -0,0 +1,25 @@
|
|
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
|
+
// Heuristics for deciding about the UTF8-ness of strings.
|
8
|
+
|
9
|
+
#ifndef BROTLI_ENC_UTF8_UTIL_H_
|
10
|
+
#define BROTLI_ENC_UTF8_UTIL_H_
|
11
|
+
|
12
|
+
#include "./types.h"
|
13
|
+
|
14
|
+
namespace brotli {
|
15
|
+
|
16
|
+
static const double kMinUTF8Ratio = 0.75;
|
17
|
+
|
18
|
+
// Returns true if at least min_fraction of the bytes between pos and
|
19
|
+
// pos + length in the (data, mask) ringbuffer is UTF8-encoded.
|
20
|
+
bool IsMostlyUTF8(const uint8_t* data, const size_t pos, const size_t mask,
|
21
|
+
const size_t length, const double min_fraction);
|
22
|
+
|
23
|
+
} // namespace brotli
|
24
|
+
|
25
|
+
#endif // BROTLI_ENC_UTF8_UTIL_H_
|
@@ -1,27 +1,19 @@
|
|
1
|
-
|
2
|
-
|
3
|
-
|
4
|
-
|
5
|
-
|
6
|
-
|
7
|
-
// http://www.apache.org/licenses/LICENSE-2.0
|
8
|
-
//
|
9
|
-
// Unless required by applicable law or agreed to in writing, software
|
10
|
-
// distributed under the License is distributed on an "AS IS" BASIS,
|
11
|
-
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
12
|
-
// See the License for the specific language governing permissions and
|
13
|
-
// limitations under the License.
|
14
|
-
//
|
1
|
+
/* Copyright 2010 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
|
+
|
15
7
|
// Write bits into a byte array.
|
16
8
|
|
17
9
|
#ifndef BROTLI_ENC_WRITE_BITS_H_
|
18
10
|
#define BROTLI_ENC_WRITE_BITS_H_
|
19
11
|
|
20
12
|
#include <assert.h>
|
21
|
-
#include <stdint.h>
|
22
13
|
#include <stdio.h>
|
23
14
|
|
24
15
|
#include "./port.h"
|
16
|
+
#include "./types.h"
|
25
17
|
|
26
18
|
namespace brotli {
|
27
19
|
|
@@ -49,7 +41,8 @@ inline void WriteBits(int n_bits,
|
|
49
41
|
#ifdef BIT_WRITER_DEBUG
|
50
42
|
printf("WriteBits %2d 0x%016llx %10d\n", n_bits, bits, *pos);
|
51
43
|
#endif
|
52
|
-
assert(bits
|
44
|
+
assert((bits >> n_bits) == 0);
|
45
|
+
assert(n_bits <= 56);
|
53
46
|
#ifdef IS_LITTLE_ENDIAN
|
54
47
|
// This branch of the code can write up to 56 bits at a time,
|
55
48
|
// 7 bits are lost by being perhaps already in *p and at least
|
@@ -66,12 +59,12 @@ inline void WriteBits(int n_bits,
|
|
66
59
|
uint8_t *array_pos = &array[*pos >> 3];
|
67
60
|
const int bits_reserved_in_first_byte = (*pos & 7);
|
68
61
|
bits <<= bits_reserved_in_first_byte;
|
69
|
-
*array_pos++ |= bits;
|
62
|
+
*array_pos++ |= static_cast<uint8_t>(bits);
|
70
63
|
for (int bits_left_to_write = n_bits - 8 + bits_reserved_in_first_byte;
|
71
64
|
bits_left_to_write >= 1;
|
72
65
|
bits_left_to_write -= 8) {
|
73
66
|
bits >>= 8;
|
74
|
-
*array_pos++ = bits;
|
67
|
+
*array_pos++ = static_cast<uint8_t>(bits);
|
75
68
|
}
|
76
69
|
*array_pos = 0;
|
77
70
|
*pos += n_bits;
|
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.1
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- miyucy
|
8
8
|
autorequire:
|
9
9
|
bindir: exe
|
10
10
|
cert_chain: []
|
11
|
-
date: 2015-
|
11
|
+
date: 2015-12-29 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: bundler
|
@@ -96,6 +96,7 @@ files:
|
|
96
96
|
- vendor/brotli/dec/context.h
|
97
97
|
- vendor/brotli/dec/decode.c
|
98
98
|
- vendor/brotli/dec/decode.h
|
99
|
+
- vendor/brotli/dec/dictionary.c
|
99
100
|
- vendor/brotli/dec/dictionary.h
|
100
101
|
- vendor/brotli/dec/huffman.c
|
101
102
|
- vendor/brotli/dec/huffman.h
|
@@ -118,6 +119,7 @@ files:
|
|
118
119
|
- vendor/brotli/enc/cluster.h
|
119
120
|
- vendor/brotli/enc/command.h
|
120
121
|
- vendor/brotli/enc/context.h
|
122
|
+
- vendor/brotli/enc/dictionary.cc
|
121
123
|
- vendor/brotli/enc/dictionary.h
|
122
124
|
- vendor/brotli/enc/dictionary_hash.h
|
123
125
|
- vendor/brotli/enc/encode.cc
|
@@ -144,6 +146,9 @@ files:
|
|
144
146
|
- vendor/brotli/enc/streams.cc
|
145
147
|
- vendor/brotli/enc/streams.h
|
146
148
|
- vendor/brotli/enc/transform.h
|
149
|
+
- vendor/brotli/enc/types.h
|
150
|
+
- vendor/brotli/enc/utf8_util.cc
|
151
|
+
- vendor/brotli/enc/utf8_util.h
|
147
152
|
- vendor/brotli/enc/write_bits.h
|
148
153
|
homepage: https://github.com/miyucy/brotli
|
149
154
|
licenses: []
|