brotli 0.1.3 → 0.1.4

Sign up to get free protection for your applications and to get access to all the features.
Files changed (102) hide show
  1. checksums.yaml +4 -4
  2. data/.gitignore +3 -0
  3. data/.travis.yml +11 -3
  4. data/Gemfile +2 -0
  5. data/ext/brotli/brotli.c +279 -0
  6. data/ext/brotli/brotli.h +2 -0
  7. data/ext/brotli/buffer.c +95 -0
  8. data/ext/brotli/buffer.h +19 -0
  9. data/ext/brotli/extconf.rb +21 -81
  10. data/lib/brotli/version.rb +1 -1
  11. data/vendor/brotli/dec/bit_reader.c +5 -5
  12. data/vendor/brotli/dec/bit_reader.h +15 -15
  13. data/vendor/brotli/dec/context.h +1 -1
  14. data/vendor/brotli/dec/decode.c +433 -348
  15. data/vendor/brotli/dec/decode.h +74 -48
  16. data/vendor/brotli/dec/huffman.c +5 -4
  17. data/vendor/brotli/dec/huffman.h +4 -4
  18. data/vendor/brotli/dec/port.h +2 -95
  19. data/vendor/brotli/dec/prefix.h +5 -3
  20. data/vendor/brotli/dec/state.c +15 -27
  21. data/vendor/brotli/dec/state.h +21 -17
  22. data/vendor/brotli/dec/transform.h +1 -1
  23. data/vendor/brotli/enc/backward_references.c +892 -0
  24. data/vendor/brotli/enc/backward_references.h +85 -102
  25. data/vendor/brotli/enc/backward_references_inc.h +147 -0
  26. data/vendor/brotli/enc/bit_cost.c +35 -0
  27. data/vendor/brotli/enc/bit_cost.h +23 -121
  28. data/vendor/brotli/enc/bit_cost_inc.h +127 -0
  29. data/vendor/brotli/enc/block_encoder_inc.h +33 -0
  30. data/vendor/brotli/enc/block_splitter.c +197 -0
  31. data/vendor/brotli/enc/block_splitter.h +40 -50
  32. data/vendor/brotli/enc/block_splitter_inc.h +432 -0
  33. data/vendor/brotli/enc/brotli_bit_stream.c +1334 -0
  34. data/vendor/brotli/enc/brotli_bit_stream.h +95 -167
  35. data/vendor/brotli/enc/cluster.c +56 -0
  36. data/vendor/brotli/enc/cluster.h +23 -305
  37. data/vendor/brotli/enc/cluster_inc.h +315 -0
  38. data/vendor/brotli/enc/command.h +83 -76
  39. data/vendor/brotli/enc/compress_fragment.c +747 -0
  40. data/vendor/brotli/enc/compress_fragment.h +48 -37
  41. data/vendor/brotli/enc/compress_fragment_two_pass.c +557 -0
  42. data/vendor/brotli/enc/compress_fragment_two_pass.h +37 -26
  43. data/vendor/brotli/enc/compressor.cc +139 -0
  44. data/vendor/brotli/enc/compressor.h +146 -0
  45. data/vendor/brotli/enc/context.h +102 -96
  46. data/vendor/brotli/enc/dictionary_hash.h +9 -5
  47. data/vendor/brotli/enc/encode.c +1562 -0
  48. data/vendor/brotli/enc/encode.h +211 -199
  49. data/vendor/brotli/enc/encode_parallel.cc +161 -151
  50. data/vendor/brotli/enc/encode_parallel.h +7 -8
  51. data/vendor/brotli/enc/entropy_encode.c +501 -0
  52. data/vendor/brotli/enc/entropy_encode.h +107 -89
  53. data/vendor/brotli/enc/entropy_encode_static.h +29 -62
  54. data/vendor/brotli/enc/fast_log.h +26 -20
  55. data/vendor/brotli/enc/find_match_length.h +23 -20
  56. data/vendor/brotli/enc/hash.h +614 -871
  57. data/vendor/brotli/enc/hash_forgetful_chain_inc.h +249 -0
  58. data/vendor/brotli/enc/hash_longest_match_inc.h +241 -0
  59. data/vendor/brotli/enc/hash_longest_match_quickly_inc.h +230 -0
  60. data/vendor/brotli/enc/histogram.c +95 -0
  61. data/vendor/brotli/enc/histogram.h +49 -83
  62. data/vendor/brotli/enc/histogram_inc.h +51 -0
  63. data/vendor/brotli/enc/literal_cost.c +178 -0
  64. data/vendor/brotli/enc/literal_cost.h +16 -10
  65. data/vendor/brotli/enc/memory.c +181 -0
  66. data/vendor/brotli/enc/memory.h +62 -0
  67. data/vendor/brotli/enc/metablock.c +515 -0
  68. data/vendor/brotli/enc/metablock.h +87 -57
  69. data/vendor/brotli/enc/metablock_inc.h +183 -0
  70. data/vendor/brotli/enc/port.h +73 -47
  71. data/vendor/brotli/enc/prefix.h +34 -61
  72. data/vendor/brotli/enc/quality.h +130 -0
  73. data/vendor/brotli/enc/ringbuffer.h +137 -122
  74. data/vendor/brotli/enc/{static_dict.cc → static_dict.c} +162 -139
  75. data/vendor/brotli/enc/static_dict.h +23 -18
  76. data/vendor/brotli/enc/static_dict_lut.h +11223 -12037
  77. data/vendor/brotli/enc/streams.cc +7 -7
  78. data/vendor/brotli/enc/streams.h +32 -32
  79. data/vendor/brotli/enc/{utf8_util.cc → utf8_util.c} +22 -20
  80. data/vendor/brotli/enc/utf8_util.h +16 -9
  81. data/vendor/brotli/enc/write_bits.h +49 -43
  82. metadata +34 -25
  83. data/ext/brotli/brotli.cc +0 -181
  84. data/vendor/brotli/dec/Makefile +0 -12
  85. data/vendor/brotli/dec/dictionary.c +0 -9466
  86. data/vendor/brotli/dec/dictionary.h +0 -38
  87. data/vendor/brotli/dec/types.h +0 -38
  88. data/vendor/brotli/enc/Makefile +0 -14
  89. data/vendor/brotli/enc/backward_references.cc +0 -858
  90. data/vendor/brotli/enc/block_splitter.cc +0 -505
  91. data/vendor/brotli/enc/brotli_bit_stream.cc +0 -1181
  92. data/vendor/brotli/enc/compress_fragment.cc +0 -701
  93. data/vendor/brotli/enc/compress_fragment_two_pass.cc +0 -524
  94. data/vendor/brotli/enc/dictionary.cc +0 -9466
  95. data/vendor/brotli/enc/dictionary.h +0 -41
  96. data/vendor/brotli/enc/encode.cc +0 -1180
  97. data/vendor/brotli/enc/entropy_encode.cc +0 -480
  98. data/vendor/brotli/enc/histogram.cc +0 -67
  99. data/vendor/brotli/enc/literal_cost.cc +0 -165
  100. data/vendor/brotli/enc/metablock.cc +0 -539
  101. data/vendor/brotli/enc/transform.h +0 -248
  102. 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
- // Convience routines to make Brotli I/O classes from some memory containers and
8
- // files.
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
- // Brotli output routine: copy n bytes to the output buffer.
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
- // Brotli output routine: add n bytes to a string.
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
- // Brotli input routine: read the next chunk of memory.
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
- } // namespace brotli
114
+ } /* namespace brotli */
@@ -4,83 +4,83 @@
4
4
  See file LICENSE for detail or copy at https://opensource.org/licenses/MIT
5
5
  */
6
6
 
7
- // Input and output classes for streaming brotli compression.
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
- #include "./port.h"
15
- #include "./types.h"
14
+
15
+ #include "../common/types.h"
16
16
 
17
17
  namespace brotli {
18
18
 
19
- // Input interface for the compression routines.
19
+ /* Input interface for the compression routines. */
20
20
  class BrotliIn {
21
21
  public:
22
22
  virtual ~BrotliIn(void) {}
23
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.
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
- // Output interface for the compression routines.
32
+ /* Output interface for the compression routines. */
33
33
  class BrotliOut {
34
34
  public:
35
35
  virtual ~BrotliOut(void) {}
36
36
 
37
- // Write n bytes of data from buf.
38
- // Return true if all written, false otherwise.
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
- // Adapter class to make BrotliIn objects from raw memory.
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
- // returns the amount of data consumed
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_; // start of input buffer
56
- size_t len_; // length of input
57
- size_t pos_; // current read position within input
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
- // Adapter class to make BrotliOut objects from raw memory.
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
- // returns the amount of data written
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_; // start of output buffer
74
- size_t len_; // length of output
75
- size_t pos_; // current write position within output
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
- // Adapter class to make BrotliOut objects from a string.
78
+ /* Adapter class to make BrotliOut objects from a string. */
79
79
  class BrotliStringOut : public BrotliOut {
80
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.
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_; // start of output buffer
92
- size_t max_size_; // max length of output
91
+ std::string* buf_; /* start of output buffer */
92
+ size_t max_size_; /* max length of output */
93
93
  };
94
94
 
95
- // Adapter class to make BrotliIn object from a file.
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
- // Adapter class to make BrotliOut object from a file.
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
- } // namespace brotli
119
+ } /* namespace brotli */
120
120
 
121
- #endif // BROTLI_ENC_STREAMS_H_
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
- // Heuristics for deciding about the UTF8-ness of strings.
7
+ /* Heuristics for deciding about the UTF8-ness of strings. */
8
8
 
9
9
  #include "./utf8_util.h"
10
10
 
11
- #include "./types.h"
11
+ #include "../common/types.h"
12
12
 
13
- namespace brotli {
13
+ #if defined(__cplusplus) || defined(c_plusplus)
14
+ extern "C" {
15
+ #endif
14
16
 
15
- namespace {
16
-
17
- size_t ParseAsUTF8(int* symbol, const uint8_t* input, size_t size) {
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
- // 2-byte UTF8
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
- // 3-byte UFT8
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
- // 4-byte UFT8
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
- // Not UTF8, emit a special symbol above the UTF8-code space
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
- } // 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) {
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 = ParseAsUTF8(
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 * static_cast<double>(length);
80
+ return TO_BROTLI_BOOL(size_utf8 > min_fraction * (double)length);
81
81
  }
82
82
 
83
- } // namespace brotli
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
- // Heuristics for deciding about the UTF8-ness of strings.
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 "./types.h"
12
+ #include "../common/types.h"
13
+ #include "./port.h"
13
14
 
14
- namespace brotli {
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
- // 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);
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
- } // namespace brotli
28
+ #if defined(__cplusplus) || defined(c_plusplus)
29
+ } /* extern "C" */
30
+ #endif
24
31
 
25
- #endif // BROTLI_ENC_UTF8_UTIL_H_
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
- // Write bits into a byte array.
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
- #include "./types.h"
17
-
18
- namespace brotli {
19
-
20
- //#define BIT_WRITER_DEBUG
21
-
22
- // This function writes bits into bytes in increasing addresses, and within
23
- // a byte least-significant-bit first.
24
- //
25
- // The function can write up to 56 bits in one go with WriteBits
26
- // Example: let's assume that 3 bits (Rs below) have been written already:
27
- //
28
- // BYTE-0 BYTE+1 BYTE+2
29
- //
30
- // 0000 0RRR 0000 0000 0000 0000
31
- //
32
- // Now, we could write 5 or less bits in MSB by just sifting by 3
33
- // and OR'ing to BYTE-0.
34
- //
35
- // For n bits, we take the last 5 bits, OR that with high bits in BYTE-0,
36
- // and locate the rest in BYTE+1, BYTE+2, etc.
37
- inline void WriteBits(size_t n_bits,
38
- uint64_t bits,
39
- size_t * __restrict pos,
40
- uint8_t * __restrict array) {
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); // Set some bits.
57
+ BROTLI_UNALIGNED_STORE64(p, v); /* Set some bits. */
56
58
  *pos += n_bits;
57
59
  #else
58
- // implicit & 0xff is assumed for uint8_t arithmetics
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++ |= static_cast<uint8_t>(bits);
63
- for (size_t bits_left_to_write = n_bits + bits_reserved_in_first_byte;
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++ = static_cast<uint8_t>(bits);
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
- inline void WriteBitsPrepareStorage(size_t pos, uint8_t *array) {
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
- } // namespace brotli
86
+ #if defined(__cplusplus) || defined(c_plusplus)
87
+ } /* extern "C" */
88
+ #endif
83
89
 
84
- #endif // BROTLI_ENC_WRITE_BITS_H_
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.3
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-14 00:00:00.000000000 Z
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.cc
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/dec/types.h
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/block_splitter.cc
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/brotli_bit_stream.cc
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.cc
137
+ - vendor/brotli/enc/compress_fragment.c
134
138
  - vendor/brotli/enc/compress_fragment.h
135
- - vendor/brotli/enc/compress_fragment_two_pass.cc
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.cc
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.cc
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/histogram.cc
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/literal_cost.cc
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/metablock.cc
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.cc
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/transform.h
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.6.8
199
+ rubygems_version: 2.4.5
191
200
  signing_key:
192
201
  specification_version: 4
193
202
  summary: Brotli compressor/decompressor