Skip to content

Commit

Permalink
igzip: Fix bug in default histogram generation
Browse files Browse the repository at this point in the history
Change-Id: Ib1976633c2fbf6f48aeb4b38e73fd75d41c62be5
Signed-off-by: Roy Oursler <[email protected]>
  • Loading branch information
rjoursler authored and gbtucker committed Dec 6, 2016
1 parent e569ff7 commit d4c6067
Showing 1 changed file with 8 additions and 5 deletions.
13 changes: 8 additions & 5 deletions igzip/huff_codes.c
Original file line number Diff line number Diff line change
Expand Up @@ -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) {
Expand All @@ -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;
Expand All @@ -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) {
Expand Down

0 comments on commit d4c6067

Please sign in to comment.