brotli 0.1.3 → 0.1.4
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/.gitignore +3 -0
- data/.travis.yml +11 -3
- data/Gemfile +2 -0
- data/ext/brotli/brotli.c +279 -0
- data/ext/brotli/brotli.h +2 -0
- data/ext/brotli/buffer.c +95 -0
- data/ext/brotli/buffer.h +19 -0
- data/ext/brotli/extconf.rb +21 -81
- data/lib/brotli/version.rb +1 -1
- data/vendor/brotli/dec/bit_reader.c +5 -5
- data/vendor/brotli/dec/bit_reader.h +15 -15
- data/vendor/brotli/dec/context.h +1 -1
- data/vendor/brotli/dec/decode.c +433 -348
- data/vendor/brotli/dec/decode.h +74 -48
- data/vendor/brotli/dec/huffman.c +5 -4
- data/vendor/brotli/dec/huffman.h +4 -4
- data/vendor/brotli/dec/port.h +2 -95
- data/vendor/brotli/dec/prefix.h +5 -3
- data/vendor/brotli/dec/state.c +15 -27
- data/vendor/brotli/dec/state.h +21 -17
- data/vendor/brotli/dec/transform.h +1 -1
- data/vendor/brotli/enc/backward_references.c +892 -0
- data/vendor/brotli/enc/backward_references.h +85 -102
- data/vendor/brotli/enc/backward_references_inc.h +147 -0
- data/vendor/brotli/enc/bit_cost.c +35 -0
- data/vendor/brotli/enc/bit_cost.h +23 -121
- data/vendor/brotli/enc/bit_cost_inc.h +127 -0
- data/vendor/brotli/enc/block_encoder_inc.h +33 -0
- data/vendor/brotli/enc/block_splitter.c +197 -0
- data/vendor/brotli/enc/block_splitter.h +40 -50
- data/vendor/brotli/enc/block_splitter_inc.h +432 -0
- data/vendor/brotli/enc/brotli_bit_stream.c +1334 -0
- data/vendor/brotli/enc/brotli_bit_stream.h +95 -167
- data/vendor/brotli/enc/cluster.c +56 -0
- data/vendor/brotli/enc/cluster.h +23 -305
- data/vendor/brotli/enc/cluster_inc.h +315 -0
- data/vendor/brotli/enc/command.h +83 -76
- data/vendor/brotli/enc/compress_fragment.c +747 -0
- data/vendor/brotli/enc/compress_fragment.h +48 -37
- data/vendor/brotli/enc/compress_fragment_two_pass.c +557 -0
- data/vendor/brotli/enc/compress_fragment_two_pass.h +37 -26
- data/vendor/brotli/enc/compressor.cc +139 -0
- data/vendor/brotli/enc/compressor.h +146 -0
- data/vendor/brotli/enc/context.h +102 -96
- data/vendor/brotli/enc/dictionary_hash.h +9 -5
- data/vendor/brotli/enc/encode.c +1562 -0
- data/vendor/brotli/enc/encode.h +211 -199
- data/vendor/brotli/enc/encode_parallel.cc +161 -151
- data/vendor/brotli/enc/encode_parallel.h +7 -8
- data/vendor/brotli/enc/entropy_encode.c +501 -0
- data/vendor/brotli/enc/entropy_encode.h +107 -89
- data/vendor/brotli/enc/entropy_encode_static.h +29 -62
- data/vendor/brotli/enc/fast_log.h +26 -20
- data/vendor/brotli/enc/find_match_length.h +23 -20
- data/vendor/brotli/enc/hash.h +614 -871
- data/vendor/brotli/enc/hash_forgetful_chain_inc.h +249 -0
- data/vendor/brotli/enc/hash_longest_match_inc.h +241 -0
- data/vendor/brotli/enc/hash_longest_match_quickly_inc.h +230 -0
- data/vendor/brotli/enc/histogram.c +95 -0
- data/vendor/brotli/enc/histogram.h +49 -83
- data/vendor/brotli/enc/histogram_inc.h +51 -0
- data/vendor/brotli/enc/literal_cost.c +178 -0
- data/vendor/brotli/enc/literal_cost.h +16 -10
- data/vendor/brotli/enc/memory.c +181 -0
- data/vendor/brotli/enc/memory.h +62 -0
- data/vendor/brotli/enc/metablock.c +515 -0
- data/vendor/brotli/enc/metablock.h +87 -57
- data/vendor/brotli/enc/metablock_inc.h +183 -0
- data/vendor/brotli/enc/port.h +73 -47
- data/vendor/brotli/enc/prefix.h +34 -61
- data/vendor/brotli/enc/quality.h +130 -0
- data/vendor/brotli/enc/ringbuffer.h +137 -122
- data/vendor/brotli/enc/{static_dict.cc → static_dict.c} +162 -139
- data/vendor/brotli/enc/static_dict.h +23 -18
- data/vendor/brotli/enc/static_dict_lut.h +11223 -12037
- data/vendor/brotli/enc/streams.cc +7 -7
- data/vendor/brotli/enc/streams.h +32 -32
- data/vendor/brotli/enc/{utf8_util.cc → utf8_util.c} +22 -20
- data/vendor/brotli/enc/utf8_util.h +16 -9
- data/vendor/brotli/enc/write_bits.h +49 -43
- metadata +34 -25
- data/ext/brotli/brotli.cc +0 -181
- data/vendor/brotli/dec/Makefile +0 -12
- data/vendor/brotli/dec/dictionary.c +0 -9466
- data/vendor/brotli/dec/dictionary.h +0 -38
- data/vendor/brotli/dec/types.h +0 -38
- data/vendor/brotli/enc/Makefile +0 -14
- data/vendor/brotli/enc/backward_references.cc +0 -858
- data/vendor/brotli/enc/block_splitter.cc +0 -505
- data/vendor/brotli/enc/brotli_bit_stream.cc +0 -1181
- data/vendor/brotli/enc/compress_fragment.cc +0 -701
- data/vendor/brotli/enc/compress_fragment_two_pass.cc +0 -524
- data/vendor/brotli/enc/dictionary.cc +0 -9466
- data/vendor/brotli/enc/dictionary.h +0 -41
- data/vendor/brotli/enc/encode.cc +0 -1180
- data/vendor/brotli/enc/entropy_encode.cc +0 -480
- data/vendor/brotli/enc/histogram.cc +0 -67
- data/vendor/brotli/enc/literal_cost.cc +0 -165
- data/vendor/brotli/enc/metablock.cc +0 -539
- data/vendor/brotli/enc/transform.h +0 -248
- data/vendor/brotli/enc/types.h +0 -29
@@ -0,0 +1,127 @@
|
|
1
|
+
/* NOLINT(build/header_guard) */
|
2
|
+
/* Copyright 2013 Google Inc. All Rights Reserved.
|
3
|
+
|
4
|
+
Distributed under MIT license.
|
5
|
+
See file LICENSE for detail or copy at https://opensource.org/licenses/MIT
|
6
|
+
*/
|
7
|
+
|
8
|
+
/* template parameters: FN */
|
9
|
+
|
10
|
+
#define HistogramType FN(Histogram)
|
11
|
+
|
12
|
+
double FN(BrotliPopulationCost)(const HistogramType* histogram) {
|
13
|
+
static const double kOneSymbolHistogramCost = 12;
|
14
|
+
static const double kTwoSymbolHistogramCost = 20;
|
15
|
+
static const double kThreeSymbolHistogramCost = 28;
|
16
|
+
static const double kFourSymbolHistogramCost = 37;
|
17
|
+
const size_t data_size = FN(HistogramDataSize)();
|
18
|
+
int count = 0;
|
19
|
+
size_t s[5];
|
20
|
+
double bits = 0.0;
|
21
|
+
size_t i;
|
22
|
+
if (histogram->total_count_ == 0) {
|
23
|
+
return kOneSymbolHistogramCost;
|
24
|
+
}
|
25
|
+
for (i = 0; i < data_size; ++i) {
|
26
|
+
if (histogram->data_[i] > 0) {
|
27
|
+
s[count] = i;
|
28
|
+
++count;
|
29
|
+
if (count > 4) break;
|
30
|
+
}
|
31
|
+
}
|
32
|
+
if (count == 1) {
|
33
|
+
return kOneSymbolHistogramCost;
|
34
|
+
}
|
35
|
+
if (count == 2) {
|
36
|
+
return (kTwoSymbolHistogramCost + (double)histogram->total_count_);
|
37
|
+
}
|
38
|
+
if (count == 3) {
|
39
|
+
const uint32_t histo0 = histogram->data_[s[0]];
|
40
|
+
const uint32_t histo1 = histogram->data_[s[1]];
|
41
|
+
const uint32_t histo2 = histogram->data_[s[2]];
|
42
|
+
const uint32_t histomax =
|
43
|
+
BROTLI_MAX(uint32_t, histo0, BROTLI_MAX(uint32_t, histo1, histo2));
|
44
|
+
return (kThreeSymbolHistogramCost +
|
45
|
+
2 * (histo0 + histo1 + histo2) - histomax);
|
46
|
+
}
|
47
|
+
if (count == 4) {
|
48
|
+
uint32_t histo[4];
|
49
|
+
uint32_t h23;
|
50
|
+
uint32_t histomax;
|
51
|
+
for (i = 0; i < 4; ++i) {
|
52
|
+
histo[i] = histogram->data_[s[i]];
|
53
|
+
}
|
54
|
+
/* Sort */
|
55
|
+
for (i = 0; i < 4; ++i) {
|
56
|
+
size_t j;
|
57
|
+
for (j = i + 1; j < 4; ++j) {
|
58
|
+
if (histo[j] > histo[i]) {
|
59
|
+
BROTLI_SWAP(uint32_t, histo, j, i);
|
60
|
+
}
|
61
|
+
}
|
62
|
+
}
|
63
|
+
h23 = histo[2] + histo[3];
|
64
|
+
histomax = BROTLI_MAX(uint32_t, h23, histo[0]);
|
65
|
+
return (kFourSymbolHistogramCost +
|
66
|
+
3 * h23 + 2 * (histo[0] + histo[1]) - histomax);
|
67
|
+
}
|
68
|
+
|
69
|
+
{
|
70
|
+
/* In this loop we compute the entropy of the histogram and simultaneously
|
71
|
+
build a simplified histogram of the code length codes where we use the
|
72
|
+
zero repeat code 17, but we don't use the non-zero repeat code 16. */
|
73
|
+
size_t max_depth = 1;
|
74
|
+
uint32_t depth_histo[BROTLI_CODE_LENGTH_CODES] = { 0 };
|
75
|
+
const double log2total = FastLog2(histogram->total_count_);
|
76
|
+
for (i = 0; i < data_size;) {
|
77
|
+
if (histogram->data_[i] > 0) {
|
78
|
+
/* Compute -log2(P(symbol)) = -log2(count(symbol)/total_count) =
|
79
|
+
= log2(total_count) - log2(count(symbol)) */
|
80
|
+
double log2p = log2total - FastLog2(histogram->data_[i]);
|
81
|
+
/* Approximate the bit depth by round(-log2(P(symbol))) */
|
82
|
+
size_t depth = (size_t)(log2p + 0.5);
|
83
|
+
bits += histogram->data_[i] * log2p;
|
84
|
+
if (depth > 15) {
|
85
|
+
depth = 15;
|
86
|
+
}
|
87
|
+
if (depth > max_depth) {
|
88
|
+
max_depth = depth;
|
89
|
+
}
|
90
|
+
++depth_histo[depth];
|
91
|
+
++i;
|
92
|
+
} else {
|
93
|
+
/* Compute the run length of zeros and add the appropriate number of 0
|
94
|
+
and 17 code length codes to the code length code histogram. */
|
95
|
+
uint32_t reps = 1;
|
96
|
+
size_t k;
|
97
|
+
for (k = i + 1; k < data_size && histogram->data_[k] == 0; ++k) {
|
98
|
+
++reps;
|
99
|
+
}
|
100
|
+
i += reps;
|
101
|
+
if (i == data_size) {
|
102
|
+
/* Don't add any cost for the last zero run, since these are encoded
|
103
|
+
only implicitly. */
|
104
|
+
break;
|
105
|
+
}
|
106
|
+
if (reps < 3) {
|
107
|
+
depth_histo[0] += reps;
|
108
|
+
} else {
|
109
|
+
reps -= 2;
|
110
|
+
while (reps > 0) {
|
111
|
+
++depth_histo[BROTLI_REPEAT_ZERO_CODE_LENGTH];
|
112
|
+
/* Add the 3 extra bits for the 17 code length code. */
|
113
|
+
bits += 3;
|
114
|
+
reps >>= 3;
|
115
|
+
}
|
116
|
+
}
|
117
|
+
}
|
118
|
+
}
|
119
|
+
/* Add the estimated encoding cost of the code length code histogram. */
|
120
|
+
bits += (double)(18 + 2 * max_depth);
|
121
|
+
/* Add the entropy of the code length code histogram. */
|
122
|
+
bits += BitsEntropy(depth_histo, BROTLI_CODE_LENGTH_CODES);
|
123
|
+
}
|
124
|
+
return bits;
|
125
|
+
}
|
126
|
+
|
127
|
+
#undef HistogramType
|
@@ -0,0 +1,33 @@
|
|
1
|
+
/* NOLINT(build/header_guard) */
|
2
|
+
/* Copyright 2014 Google Inc. All Rights Reserved.
|
3
|
+
|
4
|
+
Distributed under MIT license.
|
5
|
+
See file LICENSE for detail or copy at https://opensource.org/licenses/MIT
|
6
|
+
*/
|
7
|
+
|
8
|
+
/* template parameters: FN */
|
9
|
+
|
10
|
+
#define HistogramType FN(Histogram)
|
11
|
+
|
12
|
+
/* Creates entropy codes for all block types and stores them to the bit
|
13
|
+
stream. */
|
14
|
+
static void FN(BuildAndStoreEntropyCodes)(MemoryManager* m, BlockEncoder* self,
|
15
|
+
const HistogramType* histograms, const size_t histograms_size,
|
16
|
+
HuffmanTree* tree, size_t* storage_ix, uint8_t* storage) {
|
17
|
+
const size_t alphabet_size = self->alphabet_size_;
|
18
|
+
const size_t table_size = histograms_size * alphabet_size;
|
19
|
+
self->depths_ = BROTLI_ALLOC(m, uint8_t, table_size);
|
20
|
+
self->bits_ = BROTLI_ALLOC(m, uint16_t, table_size);
|
21
|
+
if (BROTLI_IS_OOM(m)) return;
|
22
|
+
|
23
|
+
{
|
24
|
+
size_t i;
|
25
|
+
for (i = 0; i < histograms_size; ++i) {
|
26
|
+
size_t ix = i * alphabet_size;
|
27
|
+
BuildAndStoreHuffmanTree(&histograms[i].data_[0], alphabet_size, tree,
|
28
|
+
&self->depths_[ix], &self->bits_[ix], storage_ix, storage);
|
29
|
+
}
|
30
|
+
}
|
31
|
+
}
|
32
|
+
|
33
|
+
#undef HistogramType
|
@@ -0,0 +1,197 @@
|
|
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
|
+
/* Block split point selection utilities. */
|
8
|
+
|
9
|
+
#include "./block_splitter.h"
|
10
|
+
|
11
|
+
#include <assert.h>
|
12
|
+
#include <string.h> /* memcpy, memset */
|
13
|
+
|
14
|
+
#include "./bit_cost.h"
|
15
|
+
#include "./cluster.h"
|
16
|
+
#include "./command.h"
|
17
|
+
#include "./fast_log.h"
|
18
|
+
#include "./histogram.h"
|
19
|
+
#include "./memory.h"
|
20
|
+
#include "./port.h"
|
21
|
+
#include "./quality.h"
|
22
|
+
|
23
|
+
#if defined(__cplusplus) || defined(c_plusplus)
|
24
|
+
extern "C" {
|
25
|
+
#endif
|
26
|
+
|
27
|
+
static const size_t kMaxLiteralHistograms = 100;
|
28
|
+
static const size_t kMaxCommandHistograms = 50;
|
29
|
+
static const double kLiteralBlockSwitchCost = 28.1;
|
30
|
+
static const double kCommandBlockSwitchCost = 13.5;
|
31
|
+
static const double kDistanceBlockSwitchCost = 14.6;
|
32
|
+
static const size_t kLiteralStrideLength = 70;
|
33
|
+
static const size_t kCommandStrideLength = 40;
|
34
|
+
static const size_t kSymbolsPerLiteralHistogram = 544;
|
35
|
+
static const size_t kSymbolsPerCommandHistogram = 530;
|
36
|
+
static const size_t kSymbolsPerDistanceHistogram = 544;
|
37
|
+
static const size_t kMinLengthForBlockSplitting = 128;
|
38
|
+
static const size_t kIterMulForRefining = 2;
|
39
|
+
static const size_t kMinItersForRefining = 100;
|
40
|
+
|
41
|
+
static size_t CountLiterals(const Command* cmds, const size_t num_commands) {
|
42
|
+
/* Count how many we have. */
|
43
|
+
size_t total_length = 0;
|
44
|
+
size_t i;
|
45
|
+
for (i = 0; i < num_commands; ++i) {
|
46
|
+
total_length += cmds[i].insert_len_;
|
47
|
+
}
|
48
|
+
return total_length;
|
49
|
+
}
|
50
|
+
|
51
|
+
static void CopyLiteralsToByteArray(const Command* cmds,
|
52
|
+
const size_t num_commands,
|
53
|
+
const uint8_t* data,
|
54
|
+
const size_t offset,
|
55
|
+
const size_t mask,
|
56
|
+
uint8_t* literals) {
|
57
|
+
size_t pos = 0;
|
58
|
+
size_t from_pos = offset & mask;
|
59
|
+
size_t i;
|
60
|
+
for (i = 0; i < num_commands; ++i) {
|
61
|
+
size_t insert_len = cmds[i].insert_len_;
|
62
|
+
if (from_pos + insert_len > mask) {
|
63
|
+
size_t head_size = mask + 1 - from_pos;
|
64
|
+
memcpy(literals + pos, data + from_pos, head_size);
|
65
|
+
from_pos = 0;
|
66
|
+
pos += head_size;
|
67
|
+
insert_len -= head_size;
|
68
|
+
}
|
69
|
+
if (insert_len > 0) {
|
70
|
+
memcpy(literals + pos, data + from_pos, insert_len);
|
71
|
+
pos += insert_len;
|
72
|
+
}
|
73
|
+
from_pos = (from_pos + insert_len + CommandCopyLen(&cmds[i])) & mask;
|
74
|
+
}
|
75
|
+
}
|
76
|
+
|
77
|
+
static BROTLI_INLINE unsigned int MyRand(unsigned int* seed) {
|
78
|
+
*seed *= 16807U;
|
79
|
+
if (*seed == 0) {
|
80
|
+
*seed = 1;
|
81
|
+
}
|
82
|
+
return *seed;
|
83
|
+
}
|
84
|
+
|
85
|
+
static BROTLI_INLINE double BitCost(size_t count) {
|
86
|
+
return count == 0 ? -2.0 : FastLog2(count);
|
87
|
+
}
|
88
|
+
|
89
|
+
#define HISTOGRAMS_PER_BATCH 64
|
90
|
+
#define CLUSTERS_PER_BATCH 16
|
91
|
+
|
92
|
+
#define FN(X) X ## Literal
|
93
|
+
#define DataType uint8_t
|
94
|
+
/* NOLINTNEXTLINE(build/include) */
|
95
|
+
#include "./block_splitter_inc.h"
|
96
|
+
#undef DataType
|
97
|
+
#undef FN
|
98
|
+
|
99
|
+
#define FN(X) X ## Command
|
100
|
+
#define DataType uint16_t
|
101
|
+
/* NOLINTNEXTLINE(build/include) */
|
102
|
+
#include "./block_splitter_inc.h"
|
103
|
+
#undef FN
|
104
|
+
|
105
|
+
#define FN(X) X ## Distance
|
106
|
+
/* NOLINTNEXTLINE(build/include) */
|
107
|
+
#include "./block_splitter_inc.h"
|
108
|
+
#undef DataType
|
109
|
+
#undef FN
|
110
|
+
|
111
|
+
void BrotliInitBlockSplit(BlockSplit* self) {
|
112
|
+
self->num_types = 0;
|
113
|
+
self->num_blocks = 0;
|
114
|
+
self->types = 0;
|
115
|
+
self->lengths = 0;
|
116
|
+
self->types_alloc_size = 0;
|
117
|
+
self->lengths_alloc_size = 0;
|
118
|
+
}
|
119
|
+
|
120
|
+
void BrotliDestroyBlockSplit(MemoryManager* m, BlockSplit* self) {
|
121
|
+
BROTLI_FREE(m, self->types);
|
122
|
+
BROTLI_FREE(m, self->lengths);
|
123
|
+
}
|
124
|
+
|
125
|
+
void BrotliSplitBlock(MemoryManager* m,
|
126
|
+
const Command* cmds,
|
127
|
+
const size_t num_commands,
|
128
|
+
const uint8_t* data,
|
129
|
+
const size_t pos,
|
130
|
+
const size_t mask,
|
131
|
+
const BrotliEncoderParams* params,
|
132
|
+
BlockSplit* literal_split,
|
133
|
+
BlockSplit* insert_and_copy_split,
|
134
|
+
BlockSplit* dist_split) {
|
135
|
+
{
|
136
|
+
size_t literals_count = CountLiterals(cmds, num_commands);
|
137
|
+
uint8_t* literals = BROTLI_ALLOC(m, uint8_t, literals_count);
|
138
|
+
if (BROTLI_IS_OOM(m)) return;
|
139
|
+
/* Create a continuous array of literals. */
|
140
|
+
CopyLiteralsToByteArray(cmds, num_commands, data, pos, mask, literals);
|
141
|
+
/* Create the block split on the array of literals.
|
142
|
+
Literal histograms have alphabet size 256. */
|
143
|
+
SplitByteVectorLiteral(
|
144
|
+
m, literals, literals_count,
|
145
|
+
kSymbolsPerLiteralHistogram, kMaxLiteralHistograms,
|
146
|
+
kLiteralStrideLength, kLiteralBlockSwitchCost, params,
|
147
|
+
literal_split);
|
148
|
+
if (BROTLI_IS_OOM(m)) return;
|
149
|
+
BROTLI_FREE(m, literals);
|
150
|
+
}
|
151
|
+
|
152
|
+
{
|
153
|
+
/* Compute prefix codes for commands. */
|
154
|
+
uint16_t* insert_and_copy_codes = BROTLI_ALLOC(m, uint16_t, num_commands);
|
155
|
+
size_t i;
|
156
|
+
if (BROTLI_IS_OOM(m)) return;
|
157
|
+
for (i = 0; i < num_commands; ++i) {
|
158
|
+
insert_and_copy_codes[i] = cmds[i].cmd_prefix_;
|
159
|
+
}
|
160
|
+
/* Create the block split on the array of command prefixes. */
|
161
|
+
SplitByteVectorCommand(
|
162
|
+
m, insert_and_copy_codes, num_commands,
|
163
|
+
kSymbolsPerCommandHistogram, kMaxCommandHistograms,
|
164
|
+
kCommandStrideLength, kCommandBlockSwitchCost, params,
|
165
|
+
insert_and_copy_split);
|
166
|
+
if (BROTLI_IS_OOM(m)) return;
|
167
|
+
/* TODO: reuse for distances? */
|
168
|
+
BROTLI_FREE(m, insert_and_copy_codes);
|
169
|
+
}
|
170
|
+
|
171
|
+
{
|
172
|
+
/* Create a continuous array of distance prefixes. */
|
173
|
+
uint16_t* distance_prefixes = BROTLI_ALLOC(m, uint16_t, num_commands);
|
174
|
+
size_t j = 0;
|
175
|
+
size_t i;
|
176
|
+
if (BROTLI_IS_OOM(m)) return;
|
177
|
+
for (i = 0; i < num_commands; ++i) {
|
178
|
+
const Command* cmd = &cmds[i];
|
179
|
+
if (CommandCopyLen(cmd) && cmd->cmd_prefix_ >= 128) {
|
180
|
+
distance_prefixes[j++] = cmd->dist_prefix_;
|
181
|
+
}
|
182
|
+
}
|
183
|
+
/* Create the block split on the array of distance prefixes. */
|
184
|
+
SplitByteVectorDistance(
|
185
|
+
m, distance_prefixes, j,
|
186
|
+
kSymbolsPerDistanceHistogram, kMaxCommandHistograms,
|
187
|
+
kCommandStrideLength, kDistanceBlockSwitchCost, params,
|
188
|
+
dist_split);
|
189
|
+
if (BROTLI_IS_OOM(m)) return;
|
190
|
+
BROTLI_FREE(m, distance_prefixes);
|
191
|
+
}
|
192
|
+
}
|
193
|
+
|
194
|
+
|
195
|
+
#if defined(__cplusplus) || defined(c_plusplus)
|
196
|
+
} /* extern "C" */
|
197
|
+
#endif
|
@@ -4,58 +4,48 @@
|
|
4
4
|
See file LICENSE for detail or copy at https://opensource.org/licenses/MIT
|
5
5
|
*/
|
6
6
|
|
7
|
-
|
7
|
+
/* Block split point selection utilities. */
|
8
8
|
|
9
9
|
#ifndef BROTLI_ENC_BLOCK_SPLITTER_H_
|
10
10
|
#define BROTLI_ENC_BLOCK_SPLITTER_H_
|
11
11
|
|
12
|
-
#include
|
13
|
-
|
12
|
+
#include "../common/types.h"
|
14
13
|
#include "./command.h"
|
15
|
-
#include "./
|
16
|
-
#include "./
|
17
|
-
|
18
|
-
|
19
|
-
|
20
|
-
|
21
|
-
|
22
|
-
|
23
|
-
|
24
|
-
|
25
|
-
|
26
|
-
|
27
|
-
|
28
|
-
|
29
|
-
|
30
|
-
|
31
|
-
|
32
|
-
|
33
|
-
|
34
|
-
|
35
|
-
|
36
|
-
|
37
|
-
|
38
|
-
|
39
|
-
|
40
|
-
|
41
|
-
|
42
|
-
|
43
|
-
|
44
|
-
|
45
|
-
|
46
|
-
|
47
|
-
|
48
|
-
|
49
|
-
|
50
|
-
|
51
|
-
|
52
|
-
|
53
|
-
const size_t offset,
|
54
|
-
const size_t mask,
|
55
|
-
BlockSplit* literal_split,
|
56
|
-
BlockSplit* insert_and_copy_split,
|
57
|
-
BlockSplit* dist_split);
|
58
|
-
|
59
|
-
} // namespace brotli
|
60
|
-
|
61
|
-
#endif // BROTLI_ENC_BLOCK_SPLITTER_H_
|
14
|
+
#include "./memory.h"
|
15
|
+
#include "./port.h"
|
16
|
+
#include "./quality.h"
|
17
|
+
|
18
|
+
#if defined(__cplusplus) || defined(c_plusplus)
|
19
|
+
extern "C" {
|
20
|
+
#endif
|
21
|
+
|
22
|
+
typedef struct BlockSplit {
|
23
|
+
size_t num_types; /* Amount of distinct types */
|
24
|
+
size_t num_blocks; /* Amount of values in types and length */
|
25
|
+
uint8_t* types;
|
26
|
+
uint32_t* lengths;
|
27
|
+
|
28
|
+
size_t types_alloc_size;
|
29
|
+
size_t lengths_alloc_size;
|
30
|
+
} BlockSplit;
|
31
|
+
|
32
|
+
BROTLI_INTERNAL void BrotliInitBlockSplit(BlockSplit* self);
|
33
|
+
BROTLI_INTERNAL void BrotliDestroyBlockSplit(MemoryManager* m,
|
34
|
+
BlockSplit* self);
|
35
|
+
|
36
|
+
BROTLI_INTERNAL void BrotliSplitBlock(MemoryManager* m,
|
37
|
+
const Command* cmds,
|
38
|
+
const size_t num_commands,
|
39
|
+
const uint8_t* data,
|
40
|
+
const size_t offset,
|
41
|
+
const size_t mask,
|
42
|
+
const BrotliEncoderParams* params,
|
43
|
+
BlockSplit* literal_split,
|
44
|
+
BlockSplit* insert_and_copy_split,
|
45
|
+
BlockSplit* dist_split);
|
46
|
+
|
47
|
+
#if defined(__cplusplus) || defined(c_plusplus)
|
48
|
+
} /* extern "C" */
|
49
|
+
#endif
|
50
|
+
|
51
|
+
#endif /* BROTLI_ENC_BLOCK_SPLITTER_H_ */
|