mirror of
https://github.com/intel/isa-l.git
synced 2025-07-04 17:40:07 +02:00
igzip: Fix issue with isal_create_hufftables_subset
isal_create_hufftables_subset failed to generate length symbols, but should generate those symbols as a histogram does not guarantee finding all lengths found in compression Change-Id: I880210fe1b1078de8617cab0ecb93c9810b9c9de Signed-off-by: Roy Oursler <roy.j.oursler@intel.com>
This commit is contained in:
parent
23159441e0
commit
e79c57c7e3
@ -870,6 +870,44 @@ static inline uint32_t init_heap64(struct heap_tree *heap_space, uint64_t * hist
|
|||||||
return heap_size;
|
return heap_size;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
static inline uint32_t init_heap64_semi_complete(struct heap_tree *heap_space,
|
||||||
|
uint64_t * histogram, uint64_t hist_size,
|
||||||
|
uint64_t complete_start)
|
||||||
|
{
|
||||||
|
uint32_t heap_size, i;
|
||||||
|
|
||||||
|
memset(heap_space, 0, sizeof(struct heap_tree));
|
||||||
|
|
||||||
|
heap_size = 0;
|
||||||
|
for (i = 0; i < complete_start; i++) {
|
||||||
|
if (histogram[i] != 0)
|
||||||
|
heap_space->heap[++heap_size] = ((histogram[i]) << FREQ_SHIFT) | i;
|
||||||
|
}
|
||||||
|
|
||||||
|
for (; i < hist_size; i++)
|
||||||
|
heap_space->heap[++heap_size] = ((histogram[i]) << FREQ_SHIFT) | i;
|
||||||
|
|
||||||
|
// make sure heap has at least two elements in it
|
||||||
|
if (heap_size < 2) {
|
||||||
|
if (heap_size == 0) {
|
||||||
|
heap_space->heap[1] = 1ULL << FREQ_SHIFT;
|
||||||
|
heap_space->heap[2] = (1ULL << FREQ_SHIFT) | 1;
|
||||||
|
heap_size = 2;
|
||||||
|
} else {
|
||||||
|
// heap size == 1
|
||||||
|
if (histogram[0] == 0)
|
||||||
|
heap_space->heap[2] = 1ULL << FREQ_SHIFT;
|
||||||
|
else
|
||||||
|
heap_space->heap[2] = (1ULL << FREQ_SHIFT) | 1;
|
||||||
|
heap_size = 2;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
build_heap(heap_space->heap, heap_size);
|
||||||
|
|
||||||
|
return heap_size;
|
||||||
|
}
|
||||||
|
|
||||||
static inline uint32_t init_heap64_complete(struct heap_tree *heap_space, uint64_t * histogram,
|
static inline uint32_t init_heap64_complete(struct heap_tree *heap_space, uint64_t * histogram,
|
||||||
uint64_t hist_size)
|
uint64_t hist_size)
|
||||||
{
|
{
|
||||||
@ -1444,7 +1482,9 @@ int isal_create_hufftables_subset(struct isal_hufftables *hufftables,
|
|||||||
|
|
||||||
memset(hufftables, 0, sizeof(struct isal_hufftables));
|
memset(hufftables, 0, sizeof(struct isal_hufftables));
|
||||||
|
|
||||||
heap_size = init_heap64(&heap_space, lit_len_histogram, LIT_LEN);
|
heap_size =
|
||||||
|
init_heap64_semi_complete(&heap_space, lit_len_histogram, LIT_LEN,
|
||||||
|
ISAL_DEF_LIT_SYMBOLS);
|
||||||
gen_huff_code_lens(&heap_space, heap_size, code_len_count,
|
gen_huff_code_lens(&heap_space, heap_size, code_len_count,
|
||||||
(struct huff_code *)lit_huff_table, LIT_LEN, MAX_DEFLATE_CODE_LEN);
|
(struct huff_code *)lit_huff_table, LIT_LEN, MAX_DEFLATE_CODE_LEN);
|
||||||
max_lit_len_sym = set_huff_codes(lit_huff_table, LIT_LEN, code_len_count);
|
max_lit_len_sym = set_huff_codes(lit_huff_table, LIT_LEN, code_len_count);
|
||||||
|
Loading…
x
Reference in New Issue
Block a user