igzip: Fix bug in default histogram generation

Change-Id: Ib1976633c2fbf6f48aeb4b38e73fd75d41c62be5
Signed-off-by: Roy Oursler <roy.j.oursler@intel.com>
This commit is contained in:
Roy Oursler 2016-09-26 16:39:34 -07:00 committed by Greg Tucker
parent e569ff70e7
commit d4c6067d28

View File

@ -178,9 +178,10 @@ void isal_update_histogram_base(uint8_t * start_stream, int length,
literal = *(uint32_t *) current;
hash = compute_hash(literal) & HASH_MASK;
seen = last_seen[hash];
last_seen[hash] = (uint64_t) current & 0xFFFF;
dist = ((uint64_t) current - seen) & 0xFFFF;
last_seen[hash] = ((uint64_t) current - (uint64_t) start_stream) & 0xFFFF;
dist = ((uint64_t) current - (uint64_t) start_stream - seen) & 0xFFFF;
if (dist - 1 < D - 1) {
assert(start_stream <= current - dist);
match_length =
compare258(current - dist, current, end_stream - current);
if (match_length >= SHORTEST_MATCH) {
@ -196,7 +197,9 @@ void isal_update_histogram_base(uint8_t * start_stream, int length,
for (; next_hash < end; next_hash++) {
literal = *(uint32_t *) next_hash;
hash = compute_hash(literal) & HASH_MASK;
last_seen[hash] = (uint64_t) next_hash & 0xFFFF;
last_seen[hash] =
((uint64_t) next_hash -
(uint64_t) start_stream) & 0xFFFF;
}
dist_histogram[convert_dist_to_dist_sym(dist)] += 1;
@ -211,8 +214,8 @@ void isal_update_histogram_base(uint8_t * start_stream, int length,
literal = literal >> 8;
hash = compute_hash(literal) & HASH_MASK;
seen = last_seen[hash];
last_seen[hash] = (uint64_t) current & 0xFFFF;
dist = ((uint64_t) current - seen) & 0xFFFF;
last_seen[hash] = ((uint64_t) current - (uint64_t) start_stream) & 0xFFFF;
dist = ((uint64_t) current - (uint64_t) start_stream - seen) & 0xFFFF;
if (dist < D) {
match_length = compare258(current - dist, current, end_stream - current);
if (match_length >= SHORTEST_MATCH) {