brotli 0.1.8 → 0.2.0

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.
Files changed (102) hide show
  1. checksums.yaml +4 -4
  2. data/.gitignore +1 -0
  3. data/.travis.yml +7 -3
  4. data/brotli.gemspec +1 -1
  5. data/ext/brotli/brotli.c +4 -4
  6. data/ext/brotli/brotli.h +2 -2
  7. data/ext/brotli/extconf.rb +9 -16
  8. data/lib/brotli/version.rb +1 -1
  9. data/vendor/brotli/{common → c/common}/constants.h +11 -1
  10. data/vendor/brotli/c/common/dictionary.bin +432 -0
  11. data/vendor/brotli/c/common/dictionary.c +5905 -0
  12. data/vendor/brotli/c/common/dictionary.h +64 -0
  13. data/vendor/brotli/c/common/version.h +19 -0
  14. data/vendor/brotli/{dec → c/dec}/bit_reader.c +2 -2
  15. data/vendor/brotli/{dec → c/dec}/bit_reader.h +11 -34
  16. data/vendor/brotli/{dec → c/dec}/context.h +1 -1
  17. data/vendor/brotli/{dec → c/dec}/decode.c +389 -356
  18. data/vendor/brotli/{dec → c/dec}/huffman.c +24 -23
  19. data/vendor/brotli/{dec → c/dec}/huffman.h +1 -1
  20. data/vendor/brotli/{dec → c/dec}/port.h +19 -10
  21. data/vendor/brotli/{dec → c/dec}/prefix.h +1 -1
  22. data/vendor/brotli/{dec → c/dec}/state.c +23 -19
  23. data/vendor/brotli/{dec → c/dec}/state.h +18 -17
  24. data/vendor/brotli/{dec → c/dec}/transform.h +2 -2
  25. data/vendor/brotli/c/enc/backward_references.c +134 -0
  26. data/vendor/brotli/c/enc/backward_references.h +39 -0
  27. data/vendor/brotli/{enc/backward_references.c → c/enc/backward_references_hq.c} +144 -232
  28. data/vendor/brotli/{enc/backward_references.h → c/enc/backward_references_hq.h} +28 -31
  29. data/vendor/brotli/{enc → c/enc}/backward_references_inc.h +37 -31
  30. data/vendor/brotli/{enc → c/enc}/bit_cost.c +1 -1
  31. data/vendor/brotli/{enc → c/enc}/bit_cost.h +1 -1
  32. data/vendor/brotli/{enc → c/enc}/bit_cost_inc.h +0 -0
  33. data/vendor/brotli/{enc → c/enc}/block_encoder_inc.h +0 -0
  34. data/vendor/brotli/{enc → c/enc}/block_splitter.c +2 -4
  35. data/vendor/brotli/{enc → c/enc}/block_splitter.h +1 -1
  36. data/vendor/brotli/{enc → c/enc}/block_splitter_inc.h +6 -7
  37. data/vendor/brotli/{enc → c/enc}/brotli_bit_stream.c +22 -26
  38. data/vendor/brotli/{enc → c/enc}/brotli_bit_stream.h +1 -5
  39. data/vendor/brotli/{enc → c/enc}/cluster.c +1 -1
  40. data/vendor/brotli/{enc → c/enc}/cluster.h +1 -1
  41. data/vendor/brotli/{enc → c/enc}/cluster_inc.h +2 -0
  42. data/vendor/brotli/{enc → c/enc}/command.h +34 -17
  43. data/vendor/brotli/{enc → c/enc}/compress_fragment.c +97 -53
  44. data/vendor/brotli/{enc → c/enc}/compress_fragment.h +5 -2
  45. data/vendor/brotli/{enc → c/enc}/compress_fragment_two_pass.c +106 -51
  46. data/vendor/brotli/{enc → c/enc}/compress_fragment_two_pass.h +5 -2
  47. data/vendor/brotli/{enc → c/enc}/context.h +3 -3
  48. data/vendor/brotli/c/enc/dictionary_hash.c +1120 -0
  49. data/vendor/brotli/c/enc/dictionary_hash.h +24 -0
  50. data/vendor/brotli/{enc → c/enc}/encode.c +442 -240
  51. data/vendor/brotli/{enc → c/enc}/entropy_encode.c +9 -9
  52. data/vendor/brotli/{enc → c/enc}/entropy_encode.h +4 -4
  53. data/vendor/brotli/{enc → c/enc}/entropy_encode_static.h +4 -4
  54. data/vendor/brotli/{enc → c/enc}/fast_log.h +3 -3
  55. data/vendor/brotli/{enc → c/enc}/find_match_length.h +8 -8
  56. data/vendor/brotli/c/enc/hash.h +446 -0
  57. data/vendor/brotli/{enc → c/enc}/hash_forgetful_chain_inc.h +72 -68
  58. data/vendor/brotli/c/enc/hash_longest_match64_inc.h +266 -0
  59. data/vendor/brotli/c/enc/hash_longest_match_inc.h +258 -0
  60. data/vendor/brotli/{enc → c/enc}/hash_longest_match_quickly_inc.h +81 -77
  61. data/vendor/brotli/c/enc/hash_to_binary_tree_inc.h +326 -0
  62. data/vendor/brotli/{enc → c/enc}/histogram.c +4 -2
  63. data/vendor/brotli/{enc → c/enc}/histogram.h +1 -1
  64. data/vendor/brotli/{enc → c/enc}/histogram_inc.h +0 -0
  65. data/vendor/brotli/{enc → c/enc}/literal_cost.c +4 -7
  66. data/vendor/brotli/{enc → c/enc}/literal_cost.h +2 -2
  67. data/vendor/brotli/{enc → c/enc}/memory.c +1 -1
  68. data/vendor/brotli/{enc → c/enc}/memory.h +3 -2
  69. data/vendor/brotli/{enc → c/enc}/metablock.c +136 -123
  70. data/vendor/brotli/{enc → c/enc}/metablock.h +2 -12
  71. data/vendor/brotli/{enc → c/enc}/metablock_inc.h +0 -0
  72. data/vendor/brotli/{enc → c/enc}/port.h +49 -33
  73. data/vendor/brotli/{enc → c/enc}/prefix.h +4 -2
  74. data/vendor/brotli/{enc → c/enc}/quality.h +47 -17
  75. data/vendor/brotli/{enc → c/enc}/ringbuffer.h +6 -6
  76. data/vendor/brotli/{enc → c/enc}/static_dict.c +26 -22
  77. data/vendor/brotli/{enc → c/enc}/static_dict.h +3 -1
  78. data/vendor/brotli/c/enc/static_dict_lut.h +5864 -0
  79. data/vendor/brotli/{enc → c/enc}/utf8_util.c +1 -1
  80. data/vendor/brotli/{enc → c/enc}/utf8_util.h +2 -2
  81. data/vendor/brotli/{enc → c/enc}/write_bits.h +3 -3
  82. data/vendor/brotli/c/include/brotli/decode.h +339 -0
  83. data/vendor/brotli/c/include/brotli/encode.h +402 -0
  84. data/vendor/brotli/c/include/brotli/port.h +146 -0
  85. data/vendor/brotli/c/include/brotli/types.h +90 -0
  86. metadata +80 -79
  87. data/vendor/brotli/common/dictionary.c +0 -9474
  88. data/vendor/brotli/common/dictionary.h +0 -29
  89. data/vendor/brotli/common/port.h +0 -107
  90. data/vendor/brotli/common/types.h +0 -58
  91. data/vendor/brotli/dec/decode.h +0 -188
  92. data/vendor/brotli/enc/compressor.cc +0 -139
  93. data/vendor/brotli/enc/compressor.h +0 -161
  94. data/vendor/brotli/enc/dictionary_hash.h +0 -4121
  95. data/vendor/brotli/enc/encode.h +0 -221
  96. data/vendor/brotli/enc/encode_parallel.cc +0 -289
  97. data/vendor/brotli/enc/encode_parallel.h +0 -27
  98. data/vendor/brotli/enc/hash.h +0 -717
  99. data/vendor/brotli/enc/hash_longest_match_inc.h +0 -241
  100. data/vendor/brotli/enc/static_dict_lut.h +0 -11241
  101. data/vendor/brotli/enc/streams.cc +0 -114
  102. 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 */
@@ -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_ */