brotli 0.1.1 → 0.1.2

Sign up to get free protection for your applications and to get access to all the features.
Files changed (67) hide show
  1. checksums.yaml +4 -4
  2. data/ext/brotli/brotli.cc +114 -24
  3. data/ext/brotli/brotli.h +0 -1
  4. data/ext/brotli/extconf.rb +30 -23
  5. data/lib/brotli/version.rb +1 -1
  6. data/vendor/brotli/LICENSE +1 -1
  7. data/vendor/brotli/dec/Makefile +1 -1
  8. data/vendor/brotli/dec/bit_reader.c +3 -3
  9. data/vendor/brotli/dec/bit_reader.h +25 -27
  10. data/vendor/brotli/dec/context.h +4 -4
  11. data/vendor/brotli/dec/decode.c +410 -486
  12. data/vendor/brotli/dec/decode.h +101 -105
  13. data/vendor/brotli/dec/dictionary.c +1 -1
  14. data/vendor/brotli/dec/dictionary.h +7 -8
  15. data/vendor/brotli/dec/huffman.c +103 -105
  16. data/vendor/brotli/dec/huffman.h +18 -18
  17. data/vendor/brotli/dec/port.h +52 -40
  18. data/vendor/brotli/dec/prefix.h +2 -0
  19. data/vendor/brotli/dec/state.c +13 -19
  20. data/vendor/brotli/dec/state.h +25 -39
  21. data/vendor/brotli/dec/transform.h +38 -44
  22. data/vendor/brotli/dec/types.h +2 -2
  23. data/vendor/brotli/enc/Makefile +1 -1
  24. data/vendor/brotli/enc/backward_references.cc +455 -359
  25. data/vendor/brotli/enc/backward_references.h +79 -3
  26. data/vendor/brotli/enc/bit_cost.h +54 -32
  27. data/vendor/brotli/enc/block_splitter.cc +285 -193
  28. data/vendor/brotli/enc/block_splitter.h +4 -12
  29. data/vendor/brotli/enc/brotli_bit_stream.cc +623 -324
  30. data/vendor/brotli/enc/brotli_bit_stream.h +76 -37
  31. data/vendor/brotli/enc/cluster.h +161 -120
  32. data/vendor/brotli/enc/command.h +60 -37
  33. data/vendor/brotli/enc/compress_fragment.cc +701 -0
  34. data/vendor/brotli/enc/compress_fragment.h +47 -0
  35. data/vendor/brotli/enc/compress_fragment_two_pass.cc +524 -0
  36. data/vendor/brotli/enc/compress_fragment_two_pass.h +40 -0
  37. data/vendor/brotli/enc/compressor.h +15 -0
  38. data/vendor/brotli/enc/context.h +1 -1
  39. data/vendor/brotli/enc/dictionary.h +2 -2
  40. data/vendor/brotli/enc/encode.cc +819 -286
  41. data/vendor/brotli/enc/encode.h +38 -15
  42. data/vendor/brotli/enc/encode_parallel.cc +40 -42
  43. data/vendor/brotli/enc/entropy_encode.cc +144 -147
  44. data/vendor/brotli/enc/entropy_encode.h +32 -8
  45. data/vendor/brotli/enc/entropy_encode_static.h +572 -0
  46. data/vendor/brotli/enc/fast_log.h +7 -40
  47. data/vendor/brotli/enc/find_match_length.h +9 -9
  48. data/vendor/brotli/enc/hash.h +462 -154
  49. data/vendor/brotli/enc/histogram.cc +6 -6
  50. data/vendor/brotli/enc/histogram.h +13 -13
  51. data/vendor/brotli/enc/literal_cost.cc +45 -45
  52. data/vendor/brotli/enc/metablock.cc +92 -89
  53. data/vendor/brotli/enc/metablock.h +12 -12
  54. data/vendor/brotli/enc/port.h +7 -16
  55. data/vendor/brotli/enc/prefix.h +23 -22
  56. data/vendor/brotli/enc/ringbuffer.h +75 -29
  57. data/vendor/brotli/enc/static_dict.cc +56 -48
  58. data/vendor/brotli/enc/static_dict.h +5 -5
  59. data/vendor/brotli/enc/streams.cc +1 -1
  60. data/vendor/brotli/enc/streams.h +5 -5
  61. data/vendor/brotli/enc/transform.h +40 -35
  62. data/vendor/brotli/enc/types.h +2 -0
  63. data/vendor/brotli/enc/utf8_util.cc +3 -2
  64. data/vendor/brotli/enc/write_bits.h +6 -6
  65. metadata +9 -5
  66. data/vendor/brotli/dec/streams.c +0 -102
  67. data/vendor/brotli/dec/streams.h +0 -95
@@ -1,102 +0,0 @@
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
- /* Functions for streaming input and output. */
8
-
9
- #include <string.h>
10
- #ifndef _WIN32
11
- #include <unistd.h>
12
- #endif
13
- #include "./streams.h"
14
-
15
- #if defined(__cplusplus) || defined(c_plusplus)
16
- extern "C" {
17
- #endif
18
-
19
- int BrotliMemInputFunction(void* data, uint8_t* buf, size_t count) {
20
- BrotliMemInput* input = (BrotliMemInput*)data;
21
- if (input->pos > input->length) {
22
- return -1;
23
- }
24
- if (input->pos + count > input->length) {
25
- count = input->length - input->pos;
26
- }
27
- memcpy(buf, input->buffer + input->pos, count);
28
- input->pos += count;
29
- return (int)count;
30
- }
31
-
32
- BrotliInput BrotliInitMemInput(const uint8_t* buffer, size_t length,
33
- BrotliMemInput* mem_input) {
34
- BrotliInput input;
35
- mem_input->buffer = buffer;
36
- mem_input->length = length;
37
- mem_input->pos = 0;
38
- input.cb_ = &BrotliMemInputFunction;
39
- input.data_ = mem_input;
40
- return input;
41
- }
42
-
43
- int BrotliMemOutputFunction(void* data, const uint8_t* buf, size_t count) {
44
- BrotliMemOutput* output = (BrotliMemOutput*)data;
45
- size_t limit = output->length - output->pos;
46
- if (count > limit) {
47
- count = limit;
48
- }
49
- memcpy(output->buffer + output->pos, buf, count);
50
- output->pos += count;
51
- return (int)count;
52
- }
53
-
54
- BrotliOutput BrotliInitMemOutput(uint8_t* buffer, size_t length,
55
- BrotliMemOutput* mem_output) {
56
- BrotliOutput output;
57
- mem_output->buffer = buffer;
58
- mem_output->length = length;
59
- mem_output->pos = 0;
60
- output.cb_ = &BrotliMemOutputFunction;
61
- output.data_ = mem_output;
62
- return output;
63
- }
64
-
65
- int BrotliFileInputFunction(void* data, uint8_t* buf, size_t count) {
66
- return (int)fread(buf, 1, count, (FILE*)data);
67
- }
68
-
69
- BrotliInput BrotliFileInput(FILE* f) {
70
- BrotliInput in;
71
- in.cb_ = BrotliFileInputFunction;
72
- in.data_ = f;
73
- return in;
74
- }
75
-
76
- int BrotliFileOutputFunction(void* data, const uint8_t* buf, size_t count) {
77
- return (int)fwrite(buf, 1, count, (FILE*)data);
78
- }
79
-
80
- BrotliOutput BrotliFileOutput(FILE* f) {
81
- BrotliOutput out;
82
- out.cb_ = BrotliFileOutputFunction;
83
- out.data_ = f;
84
- return out;
85
- }
86
-
87
- int BrotliNullOutputFunction(void* data , const uint8_t* buf, size_t count) {
88
- BROTLI_UNUSED(data);
89
- BROTLI_UNUSED(buf);
90
- return (int)count;
91
- }
92
-
93
- BrotliOutput BrotliNullOutput(void) {
94
- BrotliOutput out;
95
- out.cb_ = BrotliNullOutputFunction;
96
- out.data_ = NULL;
97
- return out;
98
- }
99
-
100
- #if defined(__cplusplus) || defined(c_plusplus)
101
- } /* extern "C" */
102
- #endif
@@ -1,95 +0,0 @@
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
- /* Functions for streaming input and output. */
8
-
9
- #ifndef BROTLI_DEC_STREAMS_H_
10
- #define BROTLI_DEC_STREAMS_H_
11
-
12
- #include <stdio.h>
13
- #include "./port.h"
14
- #include "./types.h"
15
-
16
- #if defined(__cplusplus) || defined(c_plusplus)
17
- extern "C" {
18
- #endif
19
-
20
- /* Function pointer type used to read len bytes into buf. Returns the */
21
- /* number of bytes read or -1 on error. */
22
- typedef int (*BrotliInputFunction)(void* data, uint8_t* buf, size_t len);
23
-
24
- /* Input callback function with associated data. */
25
- typedef struct {
26
- BrotliInputFunction cb_;
27
- void* data_;
28
- } BrotliInput;
29
-
30
- /* Reads len bytes into buf, using the in callback. */
31
- static BROTLI_INLINE int BrotliRead(BrotliInput in, uint8_t* buf, size_t len) {
32
- return in.cb_(in.data_, buf, len);
33
- }
34
-
35
- /* Function pointer type used to write len bytes into buf. Returns the */
36
- /* number of bytes written or -1 on error. */
37
- typedef int (*BrotliOutputFunction)(void* data, const uint8_t* buf, size_t len);
38
-
39
- /* Output callback function with associated data. */
40
- typedef struct {
41
- BrotliOutputFunction cb_;
42
- void* data_;
43
- } BrotliOutput;
44
-
45
- /* Writes len bytes into buf, using the out callback. */
46
- static BROTLI_INLINE int BrotliWrite(BrotliOutput out,
47
- const uint8_t* buf, size_t len) {
48
- return out.cb_(out.data_, buf, len);
49
- }
50
-
51
- /* Memory region with position. */
52
- typedef struct {
53
- const uint8_t* buffer;
54
- size_t length;
55
- size_t pos;
56
- } BrotliMemInput;
57
-
58
- /* Input callback where *data is a BrotliMemInput struct. */
59
- int BrotliMemInputFunction(void* data, uint8_t* buf, size_t count);
60
-
61
- /* Returns an input callback that wraps the given memory region. */
62
- BrotliInput BrotliInitMemInput(const uint8_t* buffer, size_t length,
63
- BrotliMemInput* mem_input);
64
-
65
- /* Output buffer with position. */
66
- typedef struct {
67
- uint8_t* buffer;
68
- size_t length;
69
- size_t pos;
70
- } BrotliMemOutput;
71
-
72
- /* Output callback where *data is a BrotliMemOutput struct. */
73
- int BrotliMemOutputFunction(void* data, const uint8_t* buf, size_t count);
74
-
75
- /* Returns an output callback that wraps the given memory region. */
76
- BrotliOutput BrotliInitMemOutput(uint8_t* buffer, size_t length,
77
- BrotliMemOutput* mem_output);
78
-
79
- /* Input callback that reads from a file. */
80
- int BrotliFileInputFunction(void* data, uint8_t* buf, size_t count);
81
- BrotliInput BrotliFileInput(FILE* f);
82
-
83
- /* Output callback that writes to a file. */
84
- int BrotliFileOutputFunction(void* data, const uint8_t* buf, size_t count);
85
- BrotliOutput BrotliFileOutput(FILE* f);
86
-
87
- /* Output callback that does nothing, always consumes the whole input. */
88
- int BrotliNullOutputFunction(void* data, const uint8_t* buf, size_t count);
89
- BrotliOutput BrotliNullOutput(void);
90
-
91
- #if defined(__cplusplus) || defined(c_plusplus)
92
- } /* extern "C" */
93
- #endif
94
-
95
- #endif /* BROTLI_DEC_STREAMS_H_ */