brotli 0.1.0
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +7 -0
- data/.gitignore +14 -0
- data/.gitmodules +3 -0
- data/.rspec +2 -0
- data/.travis.yml +4 -0
- data/Gemfile +4 -0
- data/README.md +36 -0
- data/Rakefile +13 -0
- data/bin/console +14 -0
- data/bin/setup +7 -0
- data/brotli.gemspec +28 -0
- data/ext/brotli/brotli.cc +67 -0
- data/ext/brotli/brotli.h +9 -0
- data/ext/brotli/extconf.rb +34 -0
- data/lib/brotli.rb +2 -0
- data/lib/brotli/version.rb +3 -0
- data/vendor/brotli/LICENSE +202 -0
- data/vendor/brotli/dec/Makefile +12 -0
- data/vendor/brotli/dec/bit_reader.c +55 -0
- data/vendor/brotli/dec/bit_reader.h +256 -0
- data/vendor/brotli/dec/context.h +260 -0
- data/vendor/brotli/dec/decode.c +1573 -0
- data/vendor/brotli/dec/decode.h +160 -0
- data/vendor/brotli/dec/dictionary.h +9494 -0
- data/vendor/brotli/dec/huffman.c +325 -0
- data/vendor/brotli/dec/huffman.h +77 -0
- data/vendor/brotli/dec/port.h +148 -0
- data/vendor/brotli/dec/prefix.h +756 -0
- data/vendor/brotli/dec/state.c +149 -0
- data/vendor/brotli/dec/state.h +185 -0
- data/vendor/brotli/dec/streams.c +99 -0
- data/vendor/brotli/dec/streams.h +100 -0
- data/vendor/brotli/dec/transform.h +315 -0
- data/vendor/brotli/dec/types.h +36 -0
- data/vendor/brotli/enc/Makefile +11 -0
- data/vendor/brotli/enc/backward_references.cc +769 -0
- data/vendor/brotli/enc/backward_references.h +50 -0
- data/vendor/brotli/enc/bit_cost.h +147 -0
- data/vendor/brotli/enc/block_splitter.cc +418 -0
- data/vendor/brotli/enc/block_splitter.h +78 -0
- data/vendor/brotli/enc/brotli_bit_stream.cc +884 -0
- data/vendor/brotli/enc/brotli_bit_stream.h +149 -0
- data/vendor/brotli/enc/cluster.h +290 -0
- data/vendor/brotli/enc/command.h +140 -0
- data/vendor/brotli/enc/context.h +185 -0
- data/vendor/brotli/enc/dictionary.h +9485 -0
- data/vendor/brotli/enc/dictionary_hash.h +4125 -0
- data/vendor/brotli/enc/encode.cc +715 -0
- data/vendor/brotli/enc/encode.h +196 -0
- data/vendor/brotli/enc/encode_parallel.cc +354 -0
- data/vendor/brotli/enc/encode_parallel.h +37 -0
- data/vendor/brotli/enc/entropy_encode.cc +492 -0
- data/vendor/brotli/enc/entropy_encode.h +88 -0
- data/vendor/brotli/enc/fast_log.h +179 -0
- data/vendor/brotli/enc/find_match_length.h +87 -0
- data/vendor/brotli/enc/hash.h +686 -0
- data/vendor/brotli/enc/histogram.cc +76 -0
- data/vendor/brotli/enc/histogram.h +100 -0
- data/vendor/brotli/enc/literal_cost.cc +172 -0
- data/vendor/brotli/enc/literal_cost.h +38 -0
- data/vendor/brotli/enc/metablock.cc +544 -0
- data/vendor/brotli/enc/metablock.h +88 -0
- data/vendor/brotli/enc/port.h +151 -0
- data/vendor/brotli/enc/prefix.h +85 -0
- data/vendor/brotli/enc/ringbuffer.h +108 -0
- data/vendor/brotli/enc/static_dict.cc +441 -0
- data/vendor/brotli/enc/static_dict.h +40 -0
- data/vendor/brotli/enc/static_dict_lut.h +12063 -0
- data/vendor/brotli/enc/streams.cc +127 -0
- data/vendor/brotli/enc/streams.h +129 -0
- data/vendor/brotli/enc/transform.h +250 -0
- data/vendor/brotli/enc/write_bits.h +91 -0
- metadata +171 -0
@@ -0,0 +1,91 @@
|
|
1
|
+
// Copyright 2010 Google Inc. All Rights Reserved.
|
2
|
+
//
|
3
|
+
// Licensed under the Apache License, Version 2.0 (the "License");
|
4
|
+
// you may not use this file except in compliance with the License.
|
5
|
+
// You may obtain a copy of the License at
|
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
|
+
//
|
15
|
+
// Write bits into a byte array.
|
16
|
+
|
17
|
+
#ifndef BROTLI_ENC_WRITE_BITS_H_
|
18
|
+
#define BROTLI_ENC_WRITE_BITS_H_
|
19
|
+
|
20
|
+
#include <assert.h>
|
21
|
+
#include <stdint.h>
|
22
|
+
#include <stdio.h>
|
23
|
+
|
24
|
+
#include "./port.h"
|
25
|
+
|
26
|
+
namespace brotli {
|
27
|
+
|
28
|
+
//#define BIT_WRITER_DEBUG
|
29
|
+
|
30
|
+
// This function writes bits into bytes in increasing addresses, and within
|
31
|
+
// a byte least-significant-bit first.
|
32
|
+
//
|
33
|
+
// The function can write up to 56 bits in one go with WriteBits
|
34
|
+
// Example: let's assume that 3 bits (Rs below) have been written already:
|
35
|
+
//
|
36
|
+
// BYTE-0 BYTE+1 BYTE+2
|
37
|
+
//
|
38
|
+
// 0000 0RRR 0000 0000 0000 0000
|
39
|
+
//
|
40
|
+
// Now, we could write 5 or less bits in MSB by just sifting by 3
|
41
|
+
// and OR'ing to BYTE-0.
|
42
|
+
//
|
43
|
+
// For n bits, we take the last 5 bits, OR that with high bits in BYTE-0,
|
44
|
+
// and locate the rest in BYTE+1, BYTE+2, etc.
|
45
|
+
inline void WriteBits(int n_bits,
|
46
|
+
uint64_t bits,
|
47
|
+
int * __restrict pos,
|
48
|
+
uint8_t * __restrict array) {
|
49
|
+
#ifdef BIT_WRITER_DEBUG
|
50
|
+
printf("WriteBits %2d 0x%016llx %10d\n", n_bits, bits, *pos);
|
51
|
+
#endif
|
52
|
+
assert(bits < 1ULL << n_bits);
|
53
|
+
#ifdef IS_LITTLE_ENDIAN
|
54
|
+
// This branch of the code can write up to 56 bits at a time,
|
55
|
+
// 7 bits are lost by being perhaps already in *p and at least
|
56
|
+
// 1 bit is needed to initialize the bit-stream ahead (i.e. if 7
|
57
|
+
// bits are in *p and we write 57 bits, then the next write will
|
58
|
+
// access a byte that was never initialized).
|
59
|
+
uint8_t *p = &array[*pos >> 3];
|
60
|
+
uint64_t v = *p;
|
61
|
+
v |= bits << (*pos & 7);
|
62
|
+
BROTLI_UNALIGNED_STORE64(p, v); // Set some bits.
|
63
|
+
*pos += n_bits;
|
64
|
+
#else
|
65
|
+
// implicit & 0xff is assumed for uint8_t arithmetics
|
66
|
+
uint8_t *array_pos = &array[*pos >> 3];
|
67
|
+
const int bits_reserved_in_first_byte = (*pos & 7);
|
68
|
+
bits <<= bits_reserved_in_first_byte;
|
69
|
+
*array_pos++ |= bits;
|
70
|
+
for (int bits_left_to_write = n_bits - 8 + bits_reserved_in_first_byte;
|
71
|
+
bits_left_to_write >= 1;
|
72
|
+
bits_left_to_write -= 8) {
|
73
|
+
bits >>= 8;
|
74
|
+
*array_pos++ = bits;
|
75
|
+
}
|
76
|
+
*array_pos = 0;
|
77
|
+
*pos += n_bits;
|
78
|
+
#endif
|
79
|
+
}
|
80
|
+
|
81
|
+
inline void WriteBitsPrepareStorage(int pos, uint8_t *array) {
|
82
|
+
#ifdef BIT_WRITER_DEBUG
|
83
|
+
printf("WriteBitsPrepareStorage %10d\n", pos);
|
84
|
+
#endif
|
85
|
+
assert((pos & 7) == 0);
|
86
|
+
array[pos >> 3] = 0;
|
87
|
+
}
|
88
|
+
|
89
|
+
} // namespace brotli
|
90
|
+
|
91
|
+
#endif // BROTLI_ENC_WRITE_BITS_H_
|
metadata
ADDED
@@ -0,0 +1,171 @@
|
|
1
|
+
--- !ruby/object:Gem::Specification
|
2
|
+
name: brotli
|
3
|
+
version: !ruby/object:Gem::Version
|
4
|
+
version: 0.1.0
|
5
|
+
platform: ruby
|
6
|
+
authors:
|
7
|
+
- miyucy
|
8
|
+
autorequire:
|
9
|
+
bindir: exe
|
10
|
+
cert_chain: []
|
11
|
+
date: 2015-09-24 00:00:00.000000000 Z
|
12
|
+
dependencies:
|
13
|
+
- !ruby/object:Gem::Dependency
|
14
|
+
name: bundler
|
15
|
+
requirement: !ruby/object:Gem::Requirement
|
16
|
+
requirements:
|
17
|
+
- - "~>"
|
18
|
+
- !ruby/object:Gem::Version
|
19
|
+
version: '1.10'
|
20
|
+
type: :development
|
21
|
+
prerelease: false
|
22
|
+
version_requirements: !ruby/object:Gem::Requirement
|
23
|
+
requirements:
|
24
|
+
- - "~>"
|
25
|
+
- !ruby/object:Gem::Version
|
26
|
+
version: '1.10'
|
27
|
+
- !ruby/object:Gem::Dependency
|
28
|
+
name: rake
|
29
|
+
requirement: !ruby/object:Gem::Requirement
|
30
|
+
requirements:
|
31
|
+
- - "~>"
|
32
|
+
- !ruby/object:Gem::Version
|
33
|
+
version: '10.0'
|
34
|
+
type: :development
|
35
|
+
prerelease: false
|
36
|
+
version_requirements: !ruby/object:Gem::Requirement
|
37
|
+
requirements:
|
38
|
+
- - "~>"
|
39
|
+
- !ruby/object:Gem::Version
|
40
|
+
version: '10.0'
|
41
|
+
- !ruby/object:Gem::Dependency
|
42
|
+
name: rake-compiler
|
43
|
+
requirement: !ruby/object:Gem::Requirement
|
44
|
+
requirements:
|
45
|
+
- - ">="
|
46
|
+
- !ruby/object:Gem::Version
|
47
|
+
version: '0'
|
48
|
+
type: :development
|
49
|
+
prerelease: false
|
50
|
+
version_requirements: !ruby/object:Gem::Requirement
|
51
|
+
requirements:
|
52
|
+
- - ">="
|
53
|
+
- !ruby/object:Gem::Version
|
54
|
+
version: '0'
|
55
|
+
- !ruby/object:Gem::Dependency
|
56
|
+
name: rspec
|
57
|
+
requirement: !ruby/object:Gem::Requirement
|
58
|
+
requirements:
|
59
|
+
- - ">="
|
60
|
+
- !ruby/object:Gem::Version
|
61
|
+
version: '0'
|
62
|
+
type: :development
|
63
|
+
prerelease: false
|
64
|
+
version_requirements: !ruby/object:Gem::Requirement
|
65
|
+
requirements:
|
66
|
+
- - ">="
|
67
|
+
- !ruby/object:Gem::Version
|
68
|
+
version: '0'
|
69
|
+
description: Brotli compressor/decompressor
|
70
|
+
email:
|
71
|
+
- fistfvck@gmail.com
|
72
|
+
executables: []
|
73
|
+
extensions:
|
74
|
+
- ext/brotli/extconf.rb
|
75
|
+
extra_rdoc_files: []
|
76
|
+
files:
|
77
|
+
- ".gitignore"
|
78
|
+
- ".gitmodules"
|
79
|
+
- ".rspec"
|
80
|
+
- ".travis.yml"
|
81
|
+
- Gemfile
|
82
|
+
- README.md
|
83
|
+
- Rakefile
|
84
|
+
- bin/console
|
85
|
+
- bin/setup
|
86
|
+
- brotli.gemspec
|
87
|
+
- ext/brotli/brotli.cc
|
88
|
+
- ext/brotli/brotli.h
|
89
|
+
- ext/brotli/extconf.rb
|
90
|
+
- lib/brotli.rb
|
91
|
+
- lib/brotli/version.rb
|
92
|
+
- vendor/brotli/LICENSE
|
93
|
+
- vendor/brotli/dec/Makefile
|
94
|
+
- vendor/brotli/dec/bit_reader.c
|
95
|
+
- vendor/brotli/dec/bit_reader.h
|
96
|
+
- vendor/brotli/dec/context.h
|
97
|
+
- vendor/brotli/dec/decode.c
|
98
|
+
- vendor/brotli/dec/decode.h
|
99
|
+
- vendor/brotli/dec/dictionary.h
|
100
|
+
- vendor/brotli/dec/huffman.c
|
101
|
+
- vendor/brotli/dec/huffman.h
|
102
|
+
- vendor/brotli/dec/port.h
|
103
|
+
- vendor/brotli/dec/prefix.h
|
104
|
+
- vendor/brotli/dec/state.c
|
105
|
+
- vendor/brotli/dec/state.h
|
106
|
+
- vendor/brotli/dec/streams.c
|
107
|
+
- vendor/brotli/dec/streams.h
|
108
|
+
- vendor/brotli/dec/transform.h
|
109
|
+
- vendor/brotli/dec/types.h
|
110
|
+
- vendor/brotli/enc/Makefile
|
111
|
+
- vendor/brotli/enc/backward_references.cc
|
112
|
+
- vendor/brotli/enc/backward_references.h
|
113
|
+
- vendor/brotli/enc/bit_cost.h
|
114
|
+
- vendor/brotli/enc/block_splitter.cc
|
115
|
+
- vendor/brotli/enc/block_splitter.h
|
116
|
+
- vendor/brotli/enc/brotli_bit_stream.cc
|
117
|
+
- vendor/brotli/enc/brotli_bit_stream.h
|
118
|
+
- vendor/brotli/enc/cluster.h
|
119
|
+
- vendor/brotli/enc/command.h
|
120
|
+
- vendor/brotli/enc/context.h
|
121
|
+
- vendor/brotli/enc/dictionary.h
|
122
|
+
- vendor/brotli/enc/dictionary_hash.h
|
123
|
+
- vendor/brotli/enc/encode.cc
|
124
|
+
- vendor/brotli/enc/encode.h
|
125
|
+
- vendor/brotli/enc/encode_parallel.cc
|
126
|
+
- vendor/brotli/enc/encode_parallel.h
|
127
|
+
- vendor/brotli/enc/entropy_encode.cc
|
128
|
+
- vendor/brotli/enc/entropy_encode.h
|
129
|
+
- vendor/brotli/enc/fast_log.h
|
130
|
+
- vendor/brotli/enc/find_match_length.h
|
131
|
+
- vendor/brotli/enc/hash.h
|
132
|
+
- vendor/brotli/enc/histogram.cc
|
133
|
+
- vendor/brotli/enc/histogram.h
|
134
|
+
- vendor/brotli/enc/literal_cost.cc
|
135
|
+
- vendor/brotli/enc/literal_cost.h
|
136
|
+
- vendor/brotli/enc/metablock.cc
|
137
|
+
- vendor/brotli/enc/metablock.h
|
138
|
+
- vendor/brotli/enc/port.h
|
139
|
+
- vendor/brotli/enc/prefix.h
|
140
|
+
- vendor/brotli/enc/ringbuffer.h
|
141
|
+
- vendor/brotli/enc/static_dict.cc
|
142
|
+
- vendor/brotli/enc/static_dict.h
|
143
|
+
- vendor/brotli/enc/static_dict_lut.h
|
144
|
+
- vendor/brotli/enc/streams.cc
|
145
|
+
- vendor/brotli/enc/streams.h
|
146
|
+
- vendor/brotli/enc/transform.h
|
147
|
+
- vendor/brotli/enc/write_bits.h
|
148
|
+
homepage: https://github.com/miyucy/brotli
|
149
|
+
licenses: []
|
150
|
+
metadata: {}
|
151
|
+
post_install_message:
|
152
|
+
rdoc_options: []
|
153
|
+
require_paths:
|
154
|
+
- lib
|
155
|
+
required_ruby_version: !ruby/object:Gem::Requirement
|
156
|
+
requirements:
|
157
|
+
- - ">="
|
158
|
+
- !ruby/object:Gem::Version
|
159
|
+
version: '0'
|
160
|
+
required_rubygems_version: !ruby/object:Gem::Requirement
|
161
|
+
requirements:
|
162
|
+
- - ">="
|
163
|
+
- !ruby/object:Gem::Version
|
164
|
+
version: '0'
|
165
|
+
requirements: []
|
166
|
+
rubyforge_project:
|
167
|
+
rubygems_version: 2.4.5
|
168
|
+
signing_key:
|
169
|
+
specification_version: 4
|
170
|
+
summary: Brotli compressor/decompressor
|
171
|
+
test_files: []
|