aboutsummaryrefslogtreecommitdiff
path: root/c/enc/metablock_inc.h
diff options
context:
space:
mode:
authorEugene Kliuchnikov <eustas.ru@gmail.com>2021-07-29 22:29:43 +0200
committerGitHub <noreply@github.com>2021-07-29 22:29:43 +0200
commit630b5084ee255549d25d6da7ec50b7a53861d95a (patch)
tree37df125945ae7eb37ae90db285de7cb9a5f2ee74 /c/enc/metablock_inc.h
parentce222e317e36aa362e83fc50c7a6226d238e03fd (diff)
downloadbrotli-630b5084ee255549d25d6da7ec50b7a53861d95a.zip
brotli-630b5084ee255549d25d6da7ec50b7a53861d95a.tar.gz
brotli-630b5084ee255549d25d6da7ec50b7a53861d95a.tar.bz2
Update (#914)
* slimmer stack frames in encoder * fix MSAN problem in hasher_composite (not dangerous, only in large_window mode) * fix JNI decoder wrapper - power-of-two payloads fail to decode sometimes * reformat polyfil.js and decode_test.js
Diffstat (limited to 'c/enc/metablock_inc.h')
-rw-r--r--c/enc/metablock_inc.h14
1 files changed, 8 insertions, 6 deletions
diff --git a/c/enc/metablock_inc.h b/c/enc/metablock_inc.h
index ed507ef..f939386 100644
--- a/c/enc/metablock_inc.h
+++ b/c/enc/metablock_inc.h
@@ -27,6 +27,9 @@ typedef struct FN(BlockSplitter) {
HistogramType* histograms_; /* not owned */
size_t* histograms_size_; /* not owned */
+ /* Temporary storage for BlockSplitterFinishBlock. */
+ HistogramType combined_histo[2];
+
/* The number of symbols that we want to collect before deciding on whether
or not to merge the block with a previous one or emit a new block. */
size_t target_block_size_;
@@ -104,17 +107,16 @@ static void FN(BlockSplitterFinishBlock)(
} else if (self->block_size_ > 0) {
double entropy = BitsEntropy(histograms[self->curr_histogram_ix_].data_,
self->alphabet_size_);
- HistogramType combined_histo[2];
double combined_entropy[2];
double diff[2];
size_t j;
for (j = 0; j < 2; ++j) {
size_t last_histogram_ix = self->last_histogram_ix_[j];
- combined_histo[j] = histograms[self->curr_histogram_ix_];
- FN(HistogramAddHistogram)(&combined_histo[j],
+ self->combined_histo[j] = histograms[self->curr_histogram_ix_];
+ FN(HistogramAddHistogram)(&self->combined_histo[j],
&histograms[last_histogram_ix]);
combined_entropy[j] = BitsEntropy(
- &combined_histo[j].data_[0], self->alphabet_size_);
+ &self->combined_histo[j].data_[0], self->alphabet_size_);
diff[j] = combined_entropy[j] - entropy - last_entropy[j];
}
@@ -141,7 +143,7 @@ static void FN(BlockSplitterFinishBlock)(
split->lengths[self->num_blocks_] = (uint32_t)self->block_size_;
split->types[self->num_blocks_] = split->types[self->num_blocks_ - 2];
BROTLI_SWAP(size_t, self->last_histogram_ix_, 0, 1);
- histograms[self->last_histogram_ix_[0]] = combined_histo[1];
+ histograms[self->last_histogram_ix_[0]] = self->combined_histo[1];
last_entropy[1] = last_entropy[0];
last_entropy[0] = combined_entropy[1];
++self->num_blocks_;
@@ -152,7 +154,7 @@ static void FN(BlockSplitterFinishBlock)(
} else {
/* Combine this block with last block. */
split->lengths[self->num_blocks_ - 1] += (uint32_t)self->block_size_;
- histograms[self->last_histogram_ix_[0]] = combined_histo[0];
+ histograms[self->last_histogram_ix_[0]] = self->combined_histo[0];
last_entropy[0] = combined_entropy[0];
if (split->num_types == 1) {
last_entropy[1] = last_entropy[0];