aboutsummaryrefslogtreecommitdiff
path: root/c/enc/histogram.c
diff options
context:
space:
mode:
Diffstat (limited to 'c/enc/histogram.c')
-rw-r--r--c/enc/histogram.c15
1 files changed, 9 insertions, 6 deletions
diff --git a/c/enc/histogram.c b/c/enc/histogram.c
index bb7b4c5..6da2ff6 100644
--- a/c/enc/histogram.c
+++ b/c/enc/histogram.c
@@ -8,9 +8,9 @@
#include "./histogram.h"
+#include "../common/context.h"
#include "./block_splitter.h"
#include "./command.h"
-#include "./context.h"
#if defined(__cplusplus) || defined(c_plusplus)
extern "C" {
@@ -63,13 +63,16 @@ void BrotliBuildHistogramsWithContext(
BlockSplitIteratorNext(&insert_and_copy_it);
HistogramAddCommand(&insert_and_copy_histograms[insert_and_copy_it.type_],
cmd->cmd_prefix_);
+ /* TODO: unwrap iterator blocks. */
for (j = cmd->insert_len_; j != 0; --j) {
size_t context;
BlockSplitIteratorNext(&literal_it);
- context = context_modes ?
- ((literal_it.type_ << BROTLI_LITERAL_CONTEXT_BITS) +
- Context(prev_byte, prev_byte2, context_modes[literal_it.type_])) :
- literal_it.type_;
+ context = literal_it.type_;
+ if (context_modes) {
+ ContextLut lut = BROTLI_CONTEXT_LUT(context_modes[context]);
+ context = (context << BROTLI_LITERAL_CONTEXT_BITS) +
+ BROTLI_CONTEXT(prev_byte, prev_byte2, lut);
+ }
HistogramAddLiteral(&literal_histograms[context],
ringbuffer[pos & mask]);
prev_byte2 = prev_byte;
@@ -86,7 +89,7 @@ void BrotliBuildHistogramsWithContext(
context = (dist_it.type_ << BROTLI_DISTANCE_CONTEXT_BITS) +
CommandDistanceContext(cmd);
HistogramAddDistance(&copy_dist_histograms[context],
- cmd->dist_prefix_);
+ cmd->dist_prefix_ & 0x3FF);
}
}
}