brotli 0.1.8 → 0.2.0
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/.gitignore +1 -0
- data/.travis.yml +7 -3
- data/brotli.gemspec +1 -1
- data/ext/brotli/brotli.c +4 -4
- data/ext/brotli/brotli.h +2 -2
- data/ext/brotli/extconf.rb +9 -16
- data/lib/brotli/version.rb +1 -1
- data/vendor/brotli/{common → c/common}/constants.h +11 -1
- data/vendor/brotli/c/common/dictionary.bin +432 -0
- data/vendor/brotli/c/common/dictionary.c +5905 -0
- data/vendor/brotli/c/common/dictionary.h +64 -0
- data/vendor/brotli/c/common/version.h +19 -0
- data/vendor/brotli/{dec → c/dec}/bit_reader.c +2 -2
- data/vendor/brotli/{dec → c/dec}/bit_reader.h +11 -34
- data/vendor/brotli/{dec → c/dec}/context.h +1 -1
- data/vendor/brotli/{dec → c/dec}/decode.c +389 -356
- data/vendor/brotli/{dec → c/dec}/huffman.c +24 -23
- data/vendor/brotli/{dec → c/dec}/huffman.h +1 -1
- data/vendor/brotli/{dec → c/dec}/port.h +19 -10
- data/vendor/brotli/{dec → c/dec}/prefix.h +1 -1
- data/vendor/brotli/{dec → c/dec}/state.c +23 -19
- data/vendor/brotli/{dec → c/dec}/state.h +18 -17
- data/vendor/brotli/{dec → c/dec}/transform.h +2 -2
- data/vendor/brotli/c/enc/backward_references.c +134 -0
- data/vendor/brotli/c/enc/backward_references.h +39 -0
- data/vendor/brotli/{enc/backward_references.c → c/enc/backward_references_hq.c} +144 -232
- data/vendor/brotli/{enc/backward_references.h → c/enc/backward_references_hq.h} +28 -31
- data/vendor/brotli/{enc → c/enc}/backward_references_inc.h +37 -31
- data/vendor/brotli/{enc → c/enc}/bit_cost.c +1 -1
- data/vendor/brotli/{enc → c/enc}/bit_cost.h +1 -1
- data/vendor/brotli/{enc → c/enc}/bit_cost_inc.h +0 -0
- data/vendor/brotli/{enc → c/enc}/block_encoder_inc.h +0 -0
- data/vendor/brotli/{enc → c/enc}/block_splitter.c +2 -4
- data/vendor/brotli/{enc → c/enc}/block_splitter.h +1 -1
- data/vendor/brotli/{enc → c/enc}/block_splitter_inc.h +6 -7
- data/vendor/brotli/{enc → c/enc}/brotli_bit_stream.c +22 -26
- data/vendor/brotli/{enc → c/enc}/brotli_bit_stream.h +1 -5
- data/vendor/brotli/{enc → c/enc}/cluster.c +1 -1
- data/vendor/brotli/{enc → c/enc}/cluster.h +1 -1
- data/vendor/brotli/{enc → c/enc}/cluster_inc.h +2 -0
- data/vendor/brotli/{enc → c/enc}/command.h +34 -17
- data/vendor/brotli/{enc → c/enc}/compress_fragment.c +97 -53
- data/vendor/brotli/{enc → c/enc}/compress_fragment.h +5 -2
- data/vendor/brotli/{enc → c/enc}/compress_fragment_two_pass.c +106 -51
- data/vendor/brotli/{enc → c/enc}/compress_fragment_two_pass.h +5 -2
- data/vendor/brotli/{enc → c/enc}/context.h +3 -3
- data/vendor/brotli/c/enc/dictionary_hash.c +1120 -0
- data/vendor/brotli/c/enc/dictionary_hash.h +24 -0
- data/vendor/brotli/{enc → c/enc}/encode.c +442 -240
- data/vendor/brotli/{enc → c/enc}/entropy_encode.c +9 -9
- data/vendor/brotli/{enc → c/enc}/entropy_encode.h +4 -4
- data/vendor/brotli/{enc → c/enc}/entropy_encode_static.h +4 -4
- data/vendor/brotli/{enc → c/enc}/fast_log.h +3 -3
- data/vendor/brotli/{enc → c/enc}/find_match_length.h +8 -8
- data/vendor/brotli/c/enc/hash.h +446 -0
- data/vendor/brotli/{enc → c/enc}/hash_forgetful_chain_inc.h +72 -68
- data/vendor/brotli/c/enc/hash_longest_match64_inc.h +266 -0
- data/vendor/brotli/c/enc/hash_longest_match_inc.h +258 -0
- data/vendor/brotli/{enc → c/enc}/hash_longest_match_quickly_inc.h +81 -77
- data/vendor/brotli/c/enc/hash_to_binary_tree_inc.h +326 -0
- data/vendor/brotli/{enc → c/enc}/histogram.c +4 -2
- data/vendor/brotli/{enc → c/enc}/histogram.h +1 -1
- data/vendor/brotli/{enc → c/enc}/histogram_inc.h +0 -0
- data/vendor/brotli/{enc → c/enc}/literal_cost.c +4 -7
- data/vendor/brotli/{enc → c/enc}/literal_cost.h +2 -2
- data/vendor/brotli/{enc → c/enc}/memory.c +1 -1
- data/vendor/brotli/{enc → c/enc}/memory.h +3 -2
- data/vendor/brotli/{enc → c/enc}/metablock.c +136 -123
- data/vendor/brotli/{enc → c/enc}/metablock.h +2 -12
- data/vendor/brotli/{enc → c/enc}/metablock_inc.h +0 -0
- data/vendor/brotli/{enc → c/enc}/port.h +49 -33
- data/vendor/brotli/{enc → c/enc}/prefix.h +4 -2
- data/vendor/brotli/{enc → c/enc}/quality.h +47 -17
- data/vendor/brotli/{enc → c/enc}/ringbuffer.h +6 -6
- data/vendor/brotli/{enc → c/enc}/static_dict.c +26 -22
- data/vendor/brotli/{enc → c/enc}/static_dict.h +3 -1
- data/vendor/brotli/c/enc/static_dict_lut.h +5864 -0
- data/vendor/brotli/{enc → c/enc}/utf8_util.c +1 -1
- data/vendor/brotli/{enc → c/enc}/utf8_util.h +2 -2
- data/vendor/brotli/{enc → c/enc}/write_bits.h +3 -3
- data/vendor/brotli/c/include/brotli/decode.h +339 -0
- data/vendor/brotli/c/include/brotli/encode.h +402 -0
- data/vendor/brotli/c/include/brotli/port.h +146 -0
- data/vendor/brotli/c/include/brotli/types.h +90 -0
- metadata +80 -79
- data/vendor/brotli/common/dictionary.c +0 -9474
- data/vendor/brotli/common/dictionary.h +0 -29
- data/vendor/brotli/common/port.h +0 -107
- data/vendor/brotli/common/types.h +0 -58
- data/vendor/brotli/dec/decode.h +0 -188
- data/vendor/brotli/enc/compressor.cc +0 -139
- data/vendor/brotli/enc/compressor.h +0 -161
- data/vendor/brotli/enc/dictionary_hash.h +0 -4121
- data/vendor/brotli/enc/encode.h +0 -221
- data/vendor/brotli/enc/encode_parallel.cc +0 -289
- data/vendor/brotli/enc/encode_parallel.h +0 -27
- data/vendor/brotli/enc/hash.h +0 -717
- data/vendor/brotli/enc/hash_longest_match_inc.h +0 -241
- data/vendor/brotli/enc/static_dict_lut.h +0 -11241
- data/vendor/brotli/enc/streams.cc +0 -114
- data/vendor/brotli/enc/streams.h +0 -121
@@ -1,114 +0,0 @@
|
|
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
|
-
|
7
|
-
/* Convience routines to make Brotli I/O classes from some memory containers and
|
8
|
-
files. */
|
9
|
-
|
10
|
-
#include "./streams.h"
|
11
|
-
|
12
|
-
#include <assert.h>
|
13
|
-
#include <stdlib.h>
|
14
|
-
#include <string.h> /* memcpy */
|
15
|
-
|
16
|
-
namespace brotli {
|
17
|
-
|
18
|
-
BrotliMemOut::BrotliMemOut(void* buf, size_t len)
|
19
|
-
: buf_(buf),
|
20
|
-
len_(len),
|
21
|
-
pos_(0) {}
|
22
|
-
|
23
|
-
void BrotliMemOut::Reset(void* buf, size_t len) {
|
24
|
-
buf_ = buf;
|
25
|
-
len_ = len;
|
26
|
-
pos_ = 0;
|
27
|
-
}
|
28
|
-
|
29
|
-
/* Brotli output routine: copy n bytes to the output buffer. */
|
30
|
-
bool BrotliMemOut::Write(const void *buf, size_t n) {
|
31
|
-
if (n + pos_ > len_)
|
32
|
-
return false;
|
33
|
-
char* p = reinterpret_cast<char*>(buf_) + pos_;
|
34
|
-
memcpy(p, buf, n);
|
35
|
-
pos_ += n;
|
36
|
-
return true;
|
37
|
-
}
|
38
|
-
|
39
|
-
BrotliStringOut::BrotliStringOut(std::string* buf, size_t max_size)
|
40
|
-
: buf_(buf),
|
41
|
-
max_size_(max_size) {
|
42
|
-
assert(buf->empty());
|
43
|
-
}
|
44
|
-
|
45
|
-
void BrotliStringOut::Reset(std::string* buf, size_t max_size) {
|
46
|
-
buf_ = buf;
|
47
|
-
max_size_ = max_size;
|
48
|
-
}
|
49
|
-
|
50
|
-
/* Brotli output routine: add n bytes to a string. */
|
51
|
-
bool BrotliStringOut::Write(const void *buf, size_t n) {
|
52
|
-
if (buf_->size() + n > max_size_)
|
53
|
-
return false;
|
54
|
-
buf_->append(static_cast<const char*>(buf), n);
|
55
|
-
return true;
|
56
|
-
}
|
57
|
-
|
58
|
-
BrotliMemIn::BrotliMemIn(const void* buf, size_t len)
|
59
|
-
: buf_(buf),
|
60
|
-
len_(len),
|
61
|
-
pos_(0) {}
|
62
|
-
|
63
|
-
void BrotliMemIn::Reset(const void* buf, size_t len) {
|
64
|
-
buf_ = buf;
|
65
|
-
len_ = len;
|
66
|
-
pos_ = 0;
|
67
|
-
}
|
68
|
-
|
69
|
-
/* Brotli input routine: read the next chunk of memory. */
|
70
|
-
const void* BrotliMemIn::Read(size_t n, size_t* output) {
|
71
|
-
if (pos_ == len_) {
|
72
|
-
return NULL;
|
73
|
-
}
|
74
|
-
if (n > len_ - pos_)
|
75
|
-
n = len_ - pos_;
|
76
|
-
const char* p = reinterpret_cast<const char*>(buf_) + pos_;
|
77
|
-
pos_ += n;
|
78
|
-
*output = n;
|
79
|
-
return p;
|
80
|
-
}
|
81
|
-
|
82
|
-
BrotliFileIn::BrotliFileIn(FILE* f, size_t max_read_size)
|
83
|
-
: f_(f),
|
84
|
-
buf_(new char[max_read_size]),
|
85
|
-
buf_size_(max_read_size) { }
|
86
|
-
|
87
|
-
BrotliFileIn::~BrotliFileIn(void) {
|
88
|
-
delete[] buf_;
|
89
|
-
}
|
90
|
-
|
91
|
-
const void* BrotliFileIn::Read(size_t n, size_t* bytes_read) {
|
92
|
-
if (n > buf_size_) {
|
93
|
-
n = buf_size_;
|
94
|
-
} else if (n == 0) {
|
95
|
-
return feof(f_) ? NULL : buf_;
|
96
|
-
}
|
97
|
-
*bytes_read = fread(buf_, 1, n, f_);
|
98
|
-
if (*bytes_read == 0) {
|
99
|
-
return NULL;
|
100
|
-
} else {
|
101
|
-
return buf_;
|
102
|
-
}
|
103
|
-
}
|
104
|
-
|
105
|
-
BrotliFileOut::BrotliFileOut(FILE* f) : f_(f) {}
|
106
|
-
|
107
|
-
bool BrotliFileOut::Write(const void* buf, size_t n) {
|
108
|
-
if (fwrite(buf, n, 1, f_) != 1) {
|
109
|
-
return false;
|
110
|
-
}
|
111
|
-
return true;
|
112
|
-
}
|
113
|
-
|
114
|
-
} /* namespace brotli */
|
data/vendor/brotli/enc/streams.h
DELETED
@@ -1,121 +0,0 @@
|
|
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
|
-
|
7
|
-
/* Input and output classes for streaming brotli compression. */
|
8
|
-
|
9
|
-
#ifndef BROTLI_ENC_STREAMS_H_
|
10
|
-
#define BROTLI_ENC_STREAMS_H_
|
11
|
-
|
12
|
-
#include <stdio.h>
|
13
|
-
#include <string>
|
14
|
-
|
15
|
-
#include "../common/types.h"
|
16
|
-
|
17
|
-
namespace brotli {
|
18
|
-
|
19
|
-
/* Input interface for the compression routines. */
|
20
|
-
class BrotliIn {
|
21
|
-
public:
|
22
|
-
virtual ~BrotliIn(void) {}
|
23
|
-
|
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
|
-
virtual const void* Read(size_t n, size_t* nread) = 0;
|
30
|
-
};
|
31
|
-
|
32
|
-
/* Output interface for the compression routines. */
|
33
|
-
class BrotliOut {
|
34
|
-
public:
|
35
|
-
virtual ~BrotliOut(void) {}
|
36
|
-
|
37
|
-
/* Write n bytes of data from buf.
|
38
|
-
Return true if all written, false otherwise. */
|
39
|
-
virtual bool Write(const void *buf, size_t n) = 0;
|
40
|
-
};
|
41
|
-
|
42
|
-
/* Adapter class to make BrotliIn objects from raw memory. */
|
43
|
-
class BrotliMemIn : public BrotliIn {
|
44
|
-
public:
|
45
|
-
BrotliMemIn(const void* buf, size_t len);
|
46
|
-
|
47
|
-
void Reset(const void* buf, size_t len);
|
48
|
-
|
49
|
-
/* returns the amount of data consumed */
|
50
|
-
size_t position(void) const { return pos_; }
|
51
|
-
|
52
|
-
const void* Read(size_t n, size_t* OUTPUT);
|
53
|
-
|
54
|
-
private:
|
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
|
-
};
|
59
|
-
|
60
|
-
/* Adapter class to make BrotliOut objects from raw memory. */
|
61
|
-
class BrotliMemOut : public BrotliOut {
|
62
|
-
public:
|
63
|
-
BrotliMemOut(void* buf, size_t len);
|
64
|
-
|
65
|
-
void Reset(void* buf, size_t len);
|
66
|
-
|
67
|
-
/* returns the amount of data written */
|
68
|
-
size_t position(void) const { return pos_; }
|
69
|
-
|
70
|
-
bool Write(const void* buf, size_t n);
|
71
|
-
|
72
|
-
private:
|
73
|
-
void* buf_; /* start of output buffer */
|
74
|
-
size_t len_; /* length of output */
|
75
|
-
size_t pos_; /* current write position within output */
|
76
|
-
};
|
77
|
-
|
78
|
-
/* Adapter class to make BrotliOut objects from a string. */
|
79
|
-
class BrotliStringOut : public BrotliOut {
|
80
|
-
public:
|
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
|
-
BrotliStringOut(std::string* buf, size_t max_size);
|
85
|
-
|
86
|
-
void Reset(std::string* buf, size_t max_len);
|
87
|
-
|
88
|
-
bool Write(const void* buf, size_t n);
|
89
|
-
|
90
|
-
private:
|
91
|
-
std::string* buf_; /* start of output buffer */
|
92
|
-
size_t max_size_; /* max length of output */
|
93
|
-
};
|
94
|
-
|
95
|
-
/* Adapter class to make BrotliIn object from a file. */
|
96
|
-
class BrotliFileIn : public BrotliIn {
|
97
|
-
public:
|
98
|
-
BrotliFileIn(FILE* f, size_t max_read_size);
|
99
|
-
~BrotliFileIn(void);
|
100
|
-
|
101
|
-
const void* Read(size_t n, size_t* bytes_read);
|
102
|
-
|
103
|
-
private:
|
104
|
-
FILE* f_;
|
105
|
-
char* buf_;
|
106
|
-
size_t buf_size_;
|
107
|
-
};
|
108
|
-
|
109
|
-
/* Adapter class to make BrotliOut object from a file. */
|
110
|
-
class BrotliFileOut : public BrotliOut {
|
111
|
-
public:
|
112
|
-
explicit BrotliFileOut(FILE* f);
|
113
|
-
|
114
|
-
bool Write(const void* buf, size_t n);
|
115
|
-
private:
|
116
|
-
FILE* f_;
|
117
|
-
};
|
118
|
-
|
119
|
-
} /* namespace brotli */
|
120
|
-
|
121
|
-
#endif /* BROTLI_ENC_STREAMS_H_ */
|