mirror of
https://github.com/intel/isa-l.git
synced 2024-12-12 09:23:50 +01:00
igzip: Separate concept of level and compression method
Change-Id: I82a5fbeb93adc77057893c643e044e311e4f393c Signed-off-by: Roy Oursler <roy.j.oursler@intel.com>
This commit is contained in:
parent
fe68f02dac
commit
7a12bcb2a8
@ -96,29 +96,29 @@ FIELD _lit_len_table, 513 * HUFF_CODE_SIZE, HUFF_CODE_SIZE
|
||||
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
|
||||
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
|
||||
|
||||
START_FIELDS ;; lvl1_buf
|
||||
START_FIELDS ;; hash8k_buf
|
||||
|
||||
;; name size align
|
||||
FIELD _hash_table_lvl1, 2 * IGZIP_LVL1_HASH_SIZE, 2
|
||||
FIELD _hash8k_table, 2 * IGZIP_HASH8K_HASH_SIZE, 2
|
||||
|
||||
%assign _lvl1_buf_size _FIELD_OFFSET
|
||||
%assign _lvl1_buf_align _STRUCT_ALIGN
|
||||
%assign _hash_buf1_size _FIELD_OFFSET
|
||||
%assign _hash_buf1_align _STRUCT_ALIGN
|
||||
|
||||
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
|
||||
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
|
||||
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
|
||||
|
||||
START_FIELDS ;; lvl2_buf
|
||||
START_FIELDS ;; hash_map_buf
|
||||
|
||||
;; name size align
|
||||
FIELD _hash_table, 2 * IGZIP_LVL2_HASH_SIZE, 2
|
||||
FIELD _hash_table, 2 * IGZIP_HASH_MAP_HASH_SIZE, 2
|
||||
FIELD _matches_next, 8, 8
|
||||
FIELD _matches_end, 8, 8
|
||||
FIELD _matches, 4*4*1024, 4
|
||||
FIELD _overflow, 4*LA, 4
|
||||
|
||||
%assign _lvl2_buf_size _FIELD_OFFSET
|
||||
%assign _lvl2_buf_align _STRUCT_ALIGN
|
||||
%assign _hash_map_buf_size _FIELD_OFFSET
|
||||
%assign _hash_map_buf_align _STRUCT_ALIGN
|
||||
|
||||
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
|
||||
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
|
||||
@ -136,16 +136,16 @@ FIELD _deflate_hdr, DEF_MAX_HDR_SIZE, 1
|
||||
FIELD _icf_buf_next, 8, 8
|
||||
FIELD _icf_buf_avail_out, 8, 8
|
||||
FIELD _icf_buf_start, 8, 8
|
||||
FIELD _lvl_extra, _lvl2_buf_size, _lvl2_buf_align
|
||||
FIELD _lvl_extra, _hash_map_buf_size, _hash_map_buf_align
|
||||
|
||||
%assign _level_buf_base_size _FIELD_OFFSET
|
||||
%assign _level_buf_base_align _STRUCT_ALIGN
|
||||
|
||||
_lvl1_hash_table equ _lvl_extra + _hash_table_lvl1
|
||||
_lvl2_hash_table equ _lvl_extra + _hash_table
|
||||
_lvl2_matches_next equ _lvl_extra + _matches_next
|
||||
_lvl2_matches_end equ _lvl_extra + _matches_end
|
||||
_lvl2_matches equ _lvl_extra + _matches
|
||||
_hash8k_hash_table equ _lvl_extra + _hash8k_table
|
||||
_hash_map_hash_table equ _lvl_extra + _hash_table
|
||||
_hash_map_matches_next equ _lvl_extra + _matches_next
|
||||
_hash_map_matches_end equ _lvl_extra + _matches_end
|
||||
_hash_map_matches equ _lvl_extra + _matches
|
||||
_hist_lit_len equ _hist+_ll_hist
|
||||
_hist_dist equ _hist+_d_hist
|
||||
|
||||
|
@ -76,6 +76,9 @@
|
||||
#define INVALID_DIST_HUFFCODE 1
|
||||
#define INVALID_HUFFCODE 1
|
||||
|
||||
#define HASH8K_HASH_MASK (IGZIP_HASH8K_HASH_SIZE - 1)
|
||||
#define HASH_MAP_HASH_MASK (IGZIP_HASH_MAP_HASH_SIZE - 1)
|
||||
|
||||
#define LVL0_HASH_MASK (IGZIP_LVL0_HASH_SIZE - 1)
|
||||
#define LVL1_HASH_MASK (IGZIP_LVL1_HASH_SIZE - 1)
|
||||
#define LVL2_HASH_MASK (IGZIP_LVL2_HASH_SIZE - 1)
|
||||
|
@ -65,6 +65,7 @@
|
||||
#endif
|
||||
|
||||
extern void isal_deflate_hash_lvl0(uint16_t *, uint32_t, uint32_t, uint8_t *, uint32_t);
|
||||
extern void isal_deflate_hash_lvl1(uint16_t *, uint32_t, uint32_t, uint8_t *, uint32_t);
|
||||
extern void isal_deflate_hash_lvl2(uint16_t *, uint32_t, uint32_t, uint8_t *, uint32_t);
|
||||
extern const uint8_t gzip_hdr[];
|
||||
extern const uint32_t gzip_hdr_bytes;
|
||||
@ -267,32 +268,38 @@ static int check_level_req(struct isal_zstream *stream)
|
||||
return 0;
|
||||
}
|
||||
|
||||
static int init_hash8k_buf(struct isal_zstream *stream)
|
||||
{
|
||||
struct isal_zstate *state = &stream->internal_state;
|
||||
struct level_buf *level_buf = (struct level_buf *)stream->level_buf;
|
||||
state->has_level_buf_init = 1;
|
||||
return sizeof(struct level_buf) - MAX_LVL_BUF_SIZE + sizeof(level_buf->hash8k);
|
||||
}
|
||||
|
||||
static int init_hash_map_buf(struct isal_zstream *stream)
|
||||
{
|
||||
struct isal_zstate *state = &stream->internal_state;
|
||||
struct level_buf *level_buf = (struct level_buf *)stream->level_buf;
|
||||
if (!state->has_level_buf_init) {
|
||||
level_buf->hash_map.matches_next = level_buf->hash_map.matches;
|
||||
level_buf->hash_map.matches_end = level_buf->hash_map.matches;
|
||||
}
|
||||
state->has_level_buf_init = 1;
|
||||
|
||||
return sizeof(struct level_buf) - MAX_LVL_BUF_SIZE + sizeof(level_buf->hash_map);
|
||||
|
||||
}
|
||||
|
||||
/* returns the size of the level specific buffer */
|
||||
static int init_lvlX_buf(struct isal_zstream *stream)
|
||||
{
|
||||
int level_struct_size;
|
||||
struct level_buf *level_buf = (struct level_buf *)stream->level_buf;
|
||||
struct isal_zstate *state = &stream->internal_state;
|
||||
|
||||
level_struct_size = sizeof(struct level_buf) - MAX_LVL_BUF_SIZE;
|
||||
|
||||
switch (stream->level) {
|
||||
case 2:
|
||||
if (!state->has_level_buf_init) {
|
||||
level_buf->lvl2.matches_next = level_buf->lvl2.matches;
|
||||
level_buf->lvl2.matches_end = level_buf->lvl2.matches;
|
||||
}
|
||||
|
||||
level_struct_size += sizeof(struct lvl2_buf);
|
||||
break;
|
||||
case 1:
|
||||
level_struct_size += sizeof(struct lvl1_buf);
|
||||
break;
|
||||
return init_hash_map_buf(stream);
|
||||
default:
|
||||
return init_hash8k_buf(stream);
|
||||
}
|
||||
|
||||
state->has_level_buf_init = 1;
|
||||
return level_struct_size;
|
||||
|
||||
}
|
||||
|
||||
static void init_new_icf_block(struct isal_zstream *stream)
|
||||
@ -315,16 +322,27 @@ static void init_new_icf_block(struct isal_zstream *stream)
|
||||
state->state = ZSTATE_BODY;
|
||||
}
|
||||
|
||||
static int are_buffers_empty(struct isal_zstream *stream)
|
||||
static int are_buffers_empty_hashX(struct isal_zstream *stream)
|
||||
{
|
||||
return !stream->avail_in;
|
||||
}
|
||||
|
||||
static int are_buffers_empty_hash_map(struct isal_zstream *stream)
|
||||
{
|
||||
struct level_buf *level_buf = (struct level_buf *)stream->level_buf;
|
||||
|
||||
return (!stream->avail_in
|
||||
&& level_buf->hash_map.matches_next >= level_buf->hash_map.matches_end);
|
||||
}
|
||||
|
||||
static int are_buffers_empty(struct isal_zstream *stream)
|
||||
{
|
||||
|
||||
switch (stream->level) {
|
||||
case 2:
|
||||
return (!stream->avail_in
|
||||
&& level_buf->lvl2.matches_next >= level_buf->lvl2.matches_end);
|
||||
return are_buffers_empty_hash_map(stream);
|
||||
default:
|
||||
return !stream->avail_in;
|
||||
return are_buffers_empty_hashX(stream);
|
||||
}
|
||||
}
|
||||
|
||||
@ -980,7 +998,7 @@ void isal_deflate_hash(struct isal_zstream *stream, uint8_t * dict, uint32_t dic
|
||||
stream->total_in, dict, dict_len);
|
||||
case 1:
|
||||
memset(level_buf->lvl1.hash_table, -1, sizeof(level_buf->lvl1.hash_table));
|
||||
isal_deflate_hash_lvl0(level_buf->lvl1.hash_table, LVL1_HASH_MASK,
|
||||
isal_deflate_hash_lvl1(level_buf->lvl1.hash_table, LVL1_HASH_MASK,
|
||||
stream->total_in, dict, dict_len);
|
||||
default:
|
||||
memset(stream->internal_state.head, -1, sizeof(stream->internal_state.head));
|
||||
|
@ -35,9 +35,9 @@
|
||||
void isal_deflate_body_base(struct isal_zstream *stream);
|
||||
void isal_deflate_finish_base(struct isal_zstream *stream);
|
||||
void isal_deflate_icf_body_base(struct isal_zstream *stream);
|
||||
void isal_deflate_icf_body_lvl1_base(struct isal_zstream *stream);
|
||||
void isal_deflate_icf_finish_lvl1_base(struct isal_zstream *stream);
|
||||
void isal_deflate_icf_finish_lvl2_base(struct isal_zstream *stream);
|
||||
void isal_deflate_icf_body_hash8k_base(struct isal_zstream *stream);
|
||||
void isal_deflate_icf_finish_hash8k_base(struct isal_zstream *stream);
|
||||
void isal_deflate_icf_finish_hash_map_base(struct isal_zstream *stream);
|
||||
void isal_update_histogram_base(uint8_t * start_stream, int length,
|
||||
struct isal_huff_histogram *histogram);
|
||||
struct deflate_icf *encode_deflate_icf_base(struct deflate_icf *next_in,
|
||||
@ -71,17 +71,17 @@ void isal_deflate_icf_body(struct isal_zstream *stream)
|
||||
|
||||
void isal_deflate_icf_body_lvl1(struct isal_zstream *stream)
|
||||
{
|
||||
isal_deflate_icf_body_lvl1_base(stream);
|
||||
isal_deflate_icf_body_hash8k_base(stream);
|
||||
}
|
||||
|
||||
void isal_deflate_icf_finish_lvl1(struct isal_zstream *stream)
|
||||
{
|
||||
isal_deflate_icf_finish_lvl1_base(stream);
|
||||
isal_deflate_icf_finish_hash8k_base(stream);
|
||||
}
|
||||
|
||||
void isal_deflate_icf_finish_lvl2(struct isal_zstream *stream)
|
||||
{
|
||||
isal_deflate_icf_finish_lvl2_base(stream);
|
||||
isal_deflate_icf_finish_hash_map_base(stream);
|
||||
}
|
||||
|
||||
void isal_update_histogram(uint8_t * start_stream, int length,
|
||||
@ -118,6 +118,12 @@ void isal_deflate_hash_lvl0(uint16_t * hash_table, uint32_t hash_mask,
|
||||
isal_deflate_hash_base(hash_table, hash_mask, current_index, dict, dict_len);
|
||||
}
|
||||
|
||||
void isal_deflate_hash_lvl1(uint16_t * hash_table, uint32_t hash_mask,
|
||||
uint32_t current_index, uint8_t * dict, uint32_t dict_len)
|
||||
{
|
||||
isal_deflate_hash_base(hash_table, hash_mask, current_index, dict, dict_len);
|
||||
}
|
||||
|
||||
void isal_deflate_hash_lvl2(uint16_t * hash_table, uint32_t hash_mask,
|
||||
uint32_t current_index, uint8_t * dict, uint32_t dict_len)
|
||||
{
|
||||
|
@ -29,7 +29,7 @@
|
||||
%define prev_len r11
|
||||
%define prev_dist r12
|
||||
|
||||
%define hash_table level_buf + _lvl2_hash_table
|
||||
%define hash_table level_buf + _hash_map_hash_table
|
||||
|
||||
%define datas zmm0
|
||||
%define datas_lookup zmm1
|
||||
@ -478,10 +478,10 @@ dist_mask:
|
||||
dd D-1, D-1, D-1, D-1, D-1, D-1, D-1, D-1
|
||||
dd D-1, D-1, D-1, D-1, D-1, D-1, D-1, D-1
|
||||
hash_mask:
|
||||
dd LVL2_HASH_MASK, LVL2_HASH_MASK, LVL2_HASH_MASK, LVL2_HASH_MASK
|
||||
dd LVL2_HASH_MASK, LVL2_HASH_MASK, LVL2_HASH_MASK, LVL2_HASH_MASK
|
||||
dd LVL2_HASH_MASK, LVL2_HASH_MASK, LVL2_HASH_MASK, LVL2_HASH_MASK
|
||||
dd LVL2_HASH_MASK, LVL2_HASH_MASK, LVL2_HASH_MASK, LVL2_HASH_MASK
|
||||
dd HASH_MAP_HASH_MASK, HASH_MAP_HASH_MASK, HASH_MAP_HASH_MASK, HASH_MAP_HASH_MASK
|
||||
dd HASH_MAP_HASH_MASK, HASH_MAP_HASH_MASK, HASH_MAP_HASH_MASK, HASH_MAP_HASH_MASK
|
||||
dd HASH_MAP_HASH_MASK, HASH_MAP_HASH_MASK, HASH_MAP_HASH_MASK, HASH_MAP_HASH_MASK
|
||||
dd HASH_MAP_HASH_MASK, HASH_MAP_HASH_MASK, HASH_MAP_HASH_MASK, HASH_MAP_HASH_MASK
|
||||
lit_len_mask:
|
||||
dd LIT_LEN_MASK, LIT_LEN_MASK, LIT_LEN_MASK, LIT_LEN_MASK
|
||||
dd LIT_LEN_MASK, LIT_LEN_MASK, LIT_LEN_MASK, LIT_LEN_MASK
|
||||
|
@ -32,7 +32,7 @@ static inline void update_state(struct isal_zstream *stream, uint8_t * start_in,
|
||||
level_buf->icf_buf_avail_out = end_out - next_out;
|
||||
}
|
||||
|
||||
void isal_deflate_icf_body_lvl1_base(struct isal_zstream *stream)
|
||||
void isal_deflate_icf_body_hash8k_base(struct isal_zstream *stream)
|
||||
{
|
||||
uint32_t literal, hash;
|
||||
uint8_t *start_in, *next_in, *end_in, *end, *next_hash;
|
||||
@ -42,7 +42,7 @@ void isal_deflate_icf_body_lvl1_base(struct isal_zstream *stream)
|
||||
uint32_t code, code2, extra_bits;
|
||||
struct isal_zstate *state = &stream->internal_state;
|
||||
struct level_buf *level_buf = (struct level_buf *)stream->level_buf;
|
||||
uint16_t *last_seen = level_buf->lvl1.hash_table;
|
||||
uint16_t *last_seen = level_buf->hash8k.hash_table;
|
||||
uint8_t *file_start = stream->next_in - stream->total_in;
|
||||
|
||||
if (stream->avail_in == 0) {
|
||||
@ -71,7 +71,7 @@ void isal_deflate_icf_body_lvl1_base(struct isal_zstream *stream)
|
||||
}
|
||||
|
||||
literal = *(uint32_t *) next_in;
|
||||
hash = compute_hash(literal) & LVL1_HASH_MASK;
|
||||
hash = compute_hash(literal) & HASH8K_HASH_MASK;
|
||||
dist = (next_in - file_start - last_seen[hash]) & 0xFFFF;
|
||||
last_seen[hash] = (uint64_t) (next_in - file_start);
|
||||
|
||||
@ -92,7 +92,7 @@ void isal_deflate_icf_body_lvl1_base(struct isal_zstream *stream)
|
||||
|
||||
for (; next_hash < end; next_hash++) {
|
||||
literal = *(uint32_t *) next_hash;
|
||||
hash = compute_hash(literal) & LVL1_HASH_MASK;
|
||||
hash = compute_hash(literal) & HASH8K_HASH_MASK;
|
||||
last_seen[hash] = (uint64_t) (next_hash - file_start);
|
||||
}
|
||||
|
||||
@ -127,7 +127,7 @@ void isal_deflate_icf_body_lvl1_base(struct isal_zstream *stream)
|
||||
|
||||
}
|
||||
|
||||
void isal_deflate_icf_finish_lvl1_base(struct isal_zstream *stream)
|
||||
void isal_deflate_icf_finish_hash8k_base(struct isal_zstream *stream)
|
||||
{
|
||||
uint32_t literal = 0, hash;
|
||||
uint8_t *start_in, *next_in, *end_in, *end, *next_hash;
|
||||
@ -137,7 +137,7 @@ void isal_deflate_icf_finish_lvl1_base(struct isal_zstream *stream)
|
||||
uint32_t code, code2, extra_bits;
|
||||
struct isal_zstate *state = &stream->internal_state;
|
||||
struct level_buf *level_buf = (struct level_buf *)stream->level_buf;
|
||||
uint16_t *last_seen = level_buf->lvl1.hash_table;
|
||||
uint16_t *last_seen = level_buf->hash8k.hash_table;
|
||||
uint8_t *file_start = stream->next_in - stream->total_in;
|
||||
|
||||
start_in = stream->next_in;
|
||||
@ -164,7 +164,7 @@ void isal_deflate_icf_finish_lvl1_base(struct isal_zstream *stream)
|
||||
}
|
||||
|
||||
literal = *(uint32_t *) next_in;
|
||||
hash = compute_hash(literal) & LVL1_HASH_MASK;
|
||||
hash = compute_hash(literal) & HASH8K_HASH_MASK;
|
||||
dist = (next_in - file_start - last_seen[hash]) & 0xFFFF;
|
||||
last_seen[hash] = (uint64_t) (next_in - file_start);
|
||||
|
||||
@ -182,7 +182,7 @@ void isal_deflate_icf_finish_lvl1_base(struct isal_zstream *stream)
|
||||
|
||||
for (; next_hash < end - 3; next_hash++) {
|
||||
literal = *(uint32_t *) next_hash;
|
||||
hash = compute_hash(literal) & LVL1_HASH_MASK;
|
||||
hash = compute_hash(literal) & HASH8K_HASH_MASK;
|
||||
last_seen[hash] = (uint64_t) (next_hash - file_start);
|
||||
}
|
||||
|
||||
@ -236,7 +236,7 @@ void isal_deflate_icf_finish_lvl1_base(struct isal_zstream *stream)
|
||||
return;
|
||||
}
|
||||
|
||||
void isal_deflate_icf_finish_lvl2_base(struct isal_zstream *stream)
|
||||
void isal_deflate_icf_finish_hash_map_base(struct isal_zstream *stream)
|
||||
{
|
||||
uint32_t literal = 0, hash;
|
||||
uint8_t *start_in, *next_in, *end_in, *end, *next_hash;
|
||||
@ -246,7 +246,7 @@ void isal_deflate_icf_finish_lvl2_base(struct isal_zstream *stream)
|
||||
uint32_t code, code2, extra_bits;
|
||||
struct isal_zstate *state = &stream->internal_state;
|
||||
struct level_buf *level_buf = (struct level_buf *)stream->level_buf;
|
||||
uint16_t *last_seen = level_buf->lvl2.hash_table;
|
||||
uint16_t *last_seen = level_buf->hash_map.hash_table;
|
||||
uint8_t *file_start = stream->next_in - stream->total_in;
|
||||
|
||||
start_in = stream->next_in;
|
||||
@ -272,7 +272,7 @@ void isal_deflate_icf_finish_lvl2_base(struct isal_zstream *stream)
|
||||
}
|
||||
|
||||
literal = *(uint32_t *) next_in;
|
||||
hash = compute_hash_mad(literal) & LVL2_HASH_MASK;
|
||||
hash = compute_hash_mad(literal) & HASH_MAP_HASH_MASK;
|
||||
dist = (next_in - file_start - last_seen[hash]) & 0xFFFF;
|
||||
last_seen[hash] = (uint64_t) (next_in - file_start);
|
||||
|
||||
@ -290,7 +290,7 @@ void isal_deflate_icf_finish_lvl2_base(struct isal_zstream *stream)
|
||||
|
||||
for (; next_hash < end - 3; next_hash++) {
|
||||
literal = *(uint32_t *) next_hash;
|
||||
hash = compute_hash_mad(literal) & LVL2_HASH_MASK;
|
||||
hash = compute_hash_mad(literal) & HASH_MAP_HASH_MASK;
|
||||
last_seen[hash] = (uint64_t) (next_hash - file_start);
|
||||
}
|
||||
|
||||
|
@ -28,12 +28,12 @@ void hash_section(struct isal_zstream *stream, uint8_t * next_in, uint8_t * end_
|
||||
uint32_t index, hash_input, hash;
|
||||
uint8_t *file_start = stream->next_in - stream->total_in;
|
||||
struct level_buf *level_buf = (struct level_buf *)stream->level_buf;
|
||||
uint16_t *hash_table = level_buf->lvl2.hash_table;
|
||||
uint16_t *hash_table = level_buf->hash_map.hash_table;
|
||||
|
||||
/* Compute Hashes */
|
||||
for (index = 0; index < end_in - next_in - ISAL_LOOK_AHEAD; index++) {
|
||||
hash_input = *(uint32_t *) (next_in + index);
|
||||
hash = compute_hash(hash_input) & LVL2_HASH_MASK;
|
||||
hash = compute_hash(hash_input) & HASH_MAP_HASH_MASK;
|
||||
last_seen[index] = hash_table[hash];
|
||||
hash_table[hash] = (uint64_t) (next_in + index - file_start);
|
||||
}
|
||||
@ -93,7 +93,7 @@ void gen_icf_map_h1_base(struct isal_zstream *stream,
|
||||
uint64_t next_bytes, match_bytes;
|
||||
uint64_t match;
|
||||
struct level_buf *level_buf = (struct level_buf *)stream->level_buf;
|
||||
uint16_t *hash_table = level_buf->lvl2.hash_table;
|
||||
uint16_t *hash_table = level_buf->hash_map.hash_table;
|
||||
|
||||
if (input_size < ISAL_LOOK_AHEAD)
|
||||
return;
|
||||
@ -102,14 +102,14 @@ void gen_icf_map_h1_base(struct isal_zstream *stream,
|
||||
matches_icf_lookup->lit_dist = 0x1e;
|
||||
matches_icf_lookup->dist_extra = 0;
|
||||
|
||||
hash = compute_hash(*(uint32_t *) next_in) & LVL2_HASH_MASK;
|
||||
hash = compute_hash(*(uint32_t *) next_in) & HASH_MAP_HASH_MASK;
|
||||
hash_table[hash] = (uint64_t) (next_in - file_start);
|
||||
|
||||
next_in++;
|
||||
matches_icf_lookup++;
|
||||
|
||||
while (next_in < end_in - ISAL_LOOK_AHEAD) {
|
||||
hash = compute_hash(*(uint32_t *) next_in) & LVL2_HASH_MASK;
|
||||
hash = compute_hash(*(uint32_t *) next_in) & HASH_MAP_HASH_MASK;
|
||||
dist = (next_in - file_start - hash_table[hash]);
|
||||
dist = ((dist - 1) & (IGZIP_HIST_SIZE - 1)) + 1;
|
||||
hash_table[hash] = (uint64_t) (next_in - file_start);
|
||||
@ -244,10 +244,10 @@ void icf_body_hash1_fillgreedy_lazy(struct isal_zstream *stream)
|
||||
struct level_buf *level_buf = (struct level_buf *)stream->level_buf;
|
||||
uint32_t input_size;
|
||||
|
||||
matches_icf = level_buf->lvl2.matches;
|
||||
matches_icf = level_buf->hash_map.matches;
|
||||
matches_icf_lookup = matches_icf;
|
||||
matches_next_icf = level_buf->lvl2.matches_next;
|
||||
matches_end_icf = level_buf->lvl2.matches_end;
|
||||
matches_next_icf = level_buf->hash_map.matches_next;
|
||||
matches_end_icf = level_buf->hash_map.matches_end;
|
||||
|
||||
matches_next_icf = compress_icf_map_g(stream, matches_next_icf, matches_end_icf);
|
||||
|
||||
@ -271,8 +271,8 @@ void icf_body_hash1_fillgreedy_lazy(struct isal_zstream *stream)
|
||||
matches_next_icf = compress_icf_map_g(stream, matches_icf, matches_end_icf);
|
||||
}
|
||||
|
||||
level_buf->lvl2.matches_next = matches_next_icf;
|
||||
level_buf->lvl2.matches_end = matches_end_icf;
|
||||
level_buf->hash_map.matches_next = matches_next_icf;
|
||||
level_buf->hash_map.matches_end = matches_end_icf;
|
||||
|
||||
icf_body_next_state(stream);
|
||||
}
|
||||
@ -284,10 +284,10 @@ void icf_body_lazyhash1_fillgreedy_greedy(struct isal_zstream *stream)
|
||||
struct level_buf *level_buf = (struct level_buf *)stream->level_buf;
|
||||
uint32_t input_size;
|
||||
|
||||
matches_icf = level_buf->lvl2.matches;
|
||||
matches_icf = level_buf->hash_map.matches;
|
||||
matches_icf_lookup = matches_icf;
|
||||
matches_next_icf = level_buf->lvl2.matches_next;
|
||||
matches_end_icf = level_buf->lvl2.matches_end;
|
||||
matches_next_icf = level_buf->hash_map.matches_next;
|
||||
matches_end_icf = level_buf->hash_map.matches_end;
|
||||
|
||||
matches_next_icf = compress_icf_map_g(stream, matches_next_icf, matches_end_icf);
|
||||
|
||||
@ -311,8 +311,8 @@ void icf_body_lazyhash1_fillgreedy_greedy(struct isal_zstream *stream)
|
||||
matches_next_icf = compress_icf_map_g(stream, matches_icf, matches_end_icf);
|
||||
}
|
||||
|
||||
level_buf->lvl2.matches_next = matches_next_icf;
|
||||
level_buf->lvl2.matches_end = matches_end_icf;
|
||||
level_buf->hash_map.matches_next = matches_next_icf;
|
||||
level_buf->hash_map.matches_end = matches_end_icf;
|
||||
|
||||
icf_body_next_state(stream);
|
||||
}
|
||||
|
@ -93,7 +93,7 @@ global %1
|
||||
%define ytmp0 ymm0 ; tmp
|
||||
%define ytmp1 ymm1 ; tmp
|
||||
|
||||
%define hash_table level_buf + _lvl1_hash_table
|
||||
%define hash_table level_buf + _hash8k_hash_table
|
||||
%define lit_len_hist level_buf + _hist_lit_len
|
||||
%define dist_hist level_buf + _hist_dist
|
||||
|
||||
@ -114,8 +114,8 @@ stack_size equ 5*8 + 8*8 + 4*16
|
||||
|
||||
; void isal_deflate_icf_body ( isal_zstream *stream )
|
||||
; arg 1: rcx: addr of stream
|
||||
global isal_deflate_icf_body_lvl1_ %+ ARCH
|
||||
isal_deflate_icf_body_lvl1_ %+ ARCH %+ :
|
||||
global isal_deflate_icf_body_hash8k_ %+ ARCH
|
||||
isal_deflate_icf_body_hash8k_ %+ ARCH %+ :
|
||||
%ifidn __OUTPUT_FORMAT__, elf64
|
||||
mov rcx, rdi
|
||||
%endif
|
||||
@ -196,8 +196,8 @@ MARK __body_compute_hash_ %+ ARCH
|
||||
shr tmp1, 8
|
||||
compute_hash hash2, tmp1
|
||||
|
||||
and hash, LVL1_HASH_MASK
|
||||
and hash2, LVL1_HASH_MASK
|
||||
and hash, HASH8K_HASH_MASK
|
||||
and hash2, HASH8K_HASH_MASK
|
||||
|
||||
cmp byte [stream + _internal_state_has_hist], IGZIP_NO_HIST
|
||||
je write_first_byte
|
||||
@ -226,7 +226,7 @@ loop2:
|
||||
mov tmp2, curr_data
|
||||
shr curr_data, 16
|
||||
compute_hash hash, curr_data
|
||||
and hash %+ d, LVL1_HASH_MASK
|
||||
and hash %+ d, HASH8K_HASH_MASK
|
||||
|
||||
mov dist2 %+ w, f_i %+ w
|
||||
dec dist2
|
||||
@ -239,7 +239,7 @@ loop2:
|
||||
|
||||
shr tmp2, 24
|
||||
compute_hash hash2, tmp2
|
||||
and hash2 %+ d, LVL1_HASH_MASK
|
||||
and hash2 %+ d, HASH8K_HASH_MASK
|
||||
|
||||
and dist2 %+ d, (D-1)
|
||||
neg dist2
|
||||
@ -292,7 +292,7 @@ len_dist_lit_huffman:
|
||||
|
||||
shr curr_data, 24
|
||||
compute_hash hash3, curr_data
|
||||
and hash3, LVL1_HASH_MASK
|
||||
and hash3, HASH8K_HASH_MASK
|
||||
|
||||
mov curr_data, tmp1
|
||||
shr tmp1, 8
|
||||
@ -324,9 +324,9 @@ len_dist_lit_huffman:
|
||||
and dist_code2, 0x1F
|
||||
inc word [dist_hist + HIST_ELEM_SIZE*dist_code2]
|
||||
|
||||
; hash = compute_hash(state->file_start + f_i) & LVL1_HASH_MASK;
|
||||
and hash %+ d, LVL1_HASH_MASK
|
||||
and hash2 %+ d, LVL1_HASH_MASK
|
||||
; hash = compute_hash(state->file_start + f_i) & HASH8K_HASH_MASK;
|
||||
and hash %+ d, HASH8K_HASH_MASK
|
||||
and hash2 %+ d, HASH8K_HASH_MASK
|
||||
|
||||
; continue
|
||||
cmp f_i, file_length
|
||||
@ -377,9 +377,9 @@ len_dist_huffman:
|
||||
and dist_code, 0x1F
|
||||
inc word [dist_hist + HIST_ELEM_SIZE*dist_code]
|
||||
|
||||
; hash = compute_hash(state->file_start + f_i) & LVL1_HASH_MASK;
|
||||
and hash %+ d, LVL1_HASH_MASK
|
||||
and hash2 %+ d, LVL1_HASH_MASK
|
||||
; hash = compute_hash(state->file_start + f_i) & HASH8K_HASH_MASK;
|
||||
and hash %+ d, HASH8K_HASH_MASK
|
||||
and hash2 %+ d, HASH8K_HASH_MASK
|
||||
|
||||
; continue
|
||||
cmp f_i, file_length
|
||||
@ -508,8 +508,8 @@ write_first_byte:
|
||||
MOVDQU xdata, [file_start + f_i + 1]
|
||||
add f_i, 1
|
||||
mov curr_data, [file_start + f_i]
|
||||
and hash %+ d, LVL1_HASH_MASK
|
||||
and hash2 %+ d, LVL1_HASH_MASK
|
||||
and hash %+ d, HASH8K_HASH_MASK
|
||||
and hash2 %+ d, HASH8K_HASH_MASK
|
||||
|
||||
cmp f_i, file_length
|
||||
jl loop2
|
||||
|
@ -76,7 +76,7 @@
|
||||
|
||||
%define hufftables r15
|
||||
|
||||
%define hash_table level_buf + _lvl1_hash_table
|
||||
%define hash_table level_buf + _hash8k_hash_table
|
||||
%define lit_len_hist level_buf + _hist_lit_len
|
||||
%define dist_hist level_buf + _hist_dist
|
||||
|
||||
@ -89,8 +89,8 @@ m_out_start equ 16
|
||||
stack_size equ 32
|
||||
; void isal_deflate_icf_finish ( isal_zstream *stream )
|
||||
; arg 1: rcx: addr of stream
|
||||
global isal_deflate_icf_finish_lvl1_01
|
||||
isal_deflate_icf_finish_lvl1_01:
|
||||
global isal_deflate_icf_finish_hash8k_01
|
||||
isal_deflate_icf_finish_hash8k_01:
|
||||
PUSH_ALL rbx, rsi, rdi, rbp, r12, r13, r14, r15
|
||||
sub rsp, stack_size
|
||||
|
||||
@ -135,7 +135,7 @@ isal_deflate_icf_finish_lvl1_01:
|
||||
ja end_loop_2
|
||||
|
||||
compute_hash hash, curr_data
|
||||
and hash %+ d, LVL1_HASH_MASK
|
||||
and hash %+ d, HASH8K_HASH_MASK
|
||||
mov [hash_table + 2 * hash], f_i %+ w
|
||||
mov byte [stream + _internal_state_has_hist], IGZIP_HIST
|
||||
jmp encode_literal
|
||||
@ -147,10 +147,10 @@ loop2:
|
||||
cmp m_out_buf, [rsp + m_out_end]
|
||||
ja end_loop_2
|
||||
|
||||
; hash = compute_hash(state->file_start + f_i) & LVL1_HASH_MASK;
|
||||
; hash = compute_hash(state->file_start + f_i) & HASH8K_HASH_MASK;
|
||||
mov curr_data %+ d, [file_start + f_i]
|
||||
compute_hash hash, curr_data
|
||||
and hash %+ d, LVL1_HASH_MASK
|
||||
and hash %+ d, HASH8K_HASH_MASK
|
||||
|
||||
; f_index = state->head[hash];
|
||||
movzx f_index %+ d, word [hash_table + 2 * hash]
|
||||
@ -209,19 +209,19 @@ loop2:
|
||||
|
||||
; only update hash twice
|
||||
|
||||
; hash = compute_hash(state->file_start + k) & LVL1_HASH_MASK;
|
||||
; hash = compute_hash(state->file_start + k) & HASH8K_HASH_MASK;
|
||||
mov tmp6 %+ d, dword [file_start + tmp3]
|
||||
compute_hash hash, tmp6
|
||||
and hash %+ d, LVL1_HASH_MASK
|
||||
and hash %+ d, HASH8K_HASH_MASK
|
||||
; state->head[hash] = k;
|
||||
mov [hash_table + 2 * hash], tmp3 %+ w
|
||||
|
||||
add tmp3, 1
|
||||
|
||||
; hash = compute_hash(state->file_start + k) & LVL1_HASH_MASK;
|
||||
; hash = compute_hash(state->file_start + k) & HASH8K_HASH_MASK;
|
||||
mov tmp6 %+ d, dword [file_start + tmp3]
|
||||
compute_hash hash, tmp6
|
||||
and hash %+ d, LVL1_HASH_MASK
|
||||
and hash %+ d, HASH8K_HASH_MASK
|
||||
; state->head[hash] = k;
|
||||
mov [hash_table + 2 * hash], tmp3 %+ w
|
||||
|
||||
|
@ -7,19 +7,19 @@
|
||||
|
||||
#define MATCH_BUF_SIZE (4 * 1024)
|
||||
|
||||
struct lvl1_buf {
|
||||
uint16_t hash_table[IGZIP_LVL1_HASH_SIZE];
|
||||
struct hash8k_buf1 {
|
||||
uint16_t hash_table[IGZIP_HASH8K_HASH_SIZE];
|
||||
};
|
||||
|
||||
struct lvl2_buf {
|
||||
uint16_t hash_table[IGZIP_LVL2_HASH_SIZE];
|
||||
struct hash_map_buf {
|
||||
uint16_t hash_table[IGZIP_HASH_MAP_HASH_SIZE];
|
||||
struct deflate_icf *matches_next;
|
||||
struct deflate_icf *matches_end;
|
||||
struct deflate_icf matches[MATCH_BUF_SIZE];
|
||||
struct deflate_icf overflow[ISAL_LOOK_AHEAD];
|
||||
};
|
||||
|
||||
#define MAX_LVL_BUF_SIZE sizeof(struct lvl2_buf)
|
||||
#define MAX_LVL_BUF_SIZE sizeof(struct hash_map_buf)
|
||||
|
||||
struct level_buf {
|
||||
struct hufftables_icf encode_tables;
|
||||
@ -31,8 +31,12 @@ struct level_buf {
|
||||
uint64_t icf_buf_avail_out;
|
||||
struct deflate_icf *icf_buf_start;
|
||||
union {
|
||||
struct lvl1_buf lvl1;
|
||||
struct lvl2_buf lvl2;
|
||||
struct hash8k_buf1 hash8k;
|
||||
struct hash_map_buf hash_map;
|
||||
|
||||
struct hash8k_buf1 lvl1;
|
||||
struct hash_map_buf lvl2;
|
||||
|
||||
};
|
||||
};
|
||||
|
||||
|
@ -39,13 +39,13 @@ extern isal_deflate_body_04
|
||||
extern isal_deflate_finish_base
|
||||
extern isal_deflate_finish_01
|
||||
|
||||
extern isal_deflate_icf_body_lvl1_base
|
||||
extern isal_deflate_icf_body_lvl1_01
|
||||
extern isal_deflate_icf_body_lvl1_02
|
||||
extern isal_deflate_icf_body_lvl1_04
|
||||
extern isal_deflate_icf_finish_lvl1_base
|
||||
extern isal_deflate_icf_finish_lvl1_01
|
||||
extern isal_deflate_icf_finish_lvl2_base
|
||||
extern isal_deflate_icf_body_hash8k_base
|
||||
extern isal_deflate_icf_body_hash8k_01
|
||||
extern isal_deflate_icf_body_hash8k_02
|
||||
extern isal_deflate_icf_body_hash8k_04
|
||||
extern isal_deflate_icf_finish_hash8k_base
|
||||
extern isal_deflate_icf_finish_hash8k_01
|
||||
extern isal_deflate_icf_finish_hash_map_base
|
||||
|
||||
extern isal_update_histogram_base
|
||||
extern isal_update_histogram_01
|
||||
@ -89,13 +89,13 @@ mbin_interface isal_deflate_finish
|
||||
mbin_dispatch_init5 isal_deflate_finish, isal_deflate_finish_base, isal_deflate_finish_01, isal_deflate_finish_01, isal_deflate_finish_01
|
||||
|
||||
mbin_interface isal_deflate_icf_body_lvl1
|
||||
mbin_dispatch_init5 isal_deflate_icf_body_lvl1, isal_deflate_icf_body_lvl1_base, isal_deflate_icf_body_lvl1_01, isal_deflate_icf_body_lvl1_02, isal_deflate_icf_body_lvl1_04
|
||||
mbin_dispatch_init5 isal_deflate_icf_body_lvl1, isal_deflate_icf_body_hash8k_base, isal_deflate_icf_body_hash8k_01, isal_deflate_icf_body_hash8k_02, isal_deflate_icf_body_hash8k_04
|
||||
|
||||
mbin_interface isal_deflate_icf_finish_lvl1
|
||||
mbin_dispatch_init5 isal_deflate_icf_finish_lvl1, isal_deflate_icf_finish_lvl1_base, isal_deflate_icf_finish_lvl1_01, isal_deflate_icf_finish_lvl1_01, isal_deflate_icf_finish_lvl1_01
|
||||
mbin_dispatch_init5 isal_deflate_icf_finish_lvl1, isal_deflate_icf_finish_hash8k_base, isal_deflate_icf_finish_hash8k_01, isal_deflate_icf_finish_hash8k_01, isal_deflate_icf_finish_hash8k_01
|
||||
|
||||
mbin_interface isal_deflate_icf_finish_lvl2
|
||||
mbin_dispatch_init5 isal_deflate_icf_finish_lvl2, isal_deflate_icf_finish_lvl2_base, isal_deflate_icf_finish_lvl2_base, isal_deflate_icf_finish_lvl2_base, isal_deflate_icf_finish_lvl2_base
|
||||
mbin_dispatch_init5 isal_deflate_icf_finish_lvl2, isal_deflate_icf_finish_hash_map_base, isal_deflate_icf_finish_hash_map_base, isal_deflate_icf_finish_hash_map_base, isal_deflate_icf_finish_hash_map_base
|
||||
|
||||
mbin_interface isal_update_histogram
|
||||
mbin_dispatch_init5 isal_update_histogram, isal_update_histogram_base, isal_update_histogram_01, isal_update_histogram_01, isal_update_histogram_04
|
||||
@ -129,6 +129,9 @@ mbin_dispatch_init5 isal_adler32, adler32_base, adler32_sse, adler32_sse, adler3
|
||||
mbin_interface isal_deflate_hash_lvl0
|
||||
mbin_dispatch_init5 isal_deflate_hash_lvl0, isal_deflate_hash_base, isal_deflate_hash_crc_01, isal_deflate_hash_crc_01, isal_deflate_hash_crc_01
|
||||
|
||||
mbin_interface isal_deflate_hash_lvl1
|
||||
mbin_dispatch_init5 isal_deflate_hash_lvl1, isal_deflate_hash_base, isal_deflate_hash_crc_01, isal_deflate_hash_crc_01, isal_deflate_hash_crc_01
|
||||
|
||||
mbin_interface isal_deflate_hash_lvl2
|
||||
mbin_dispatch_init5 isal_deflate_hash_lvl2, isal_deflate_hash_base, isal_deflate_hash_base, isal_deflate_hash_base, isal_deflate_hash_mad_base
|
||||
|
||||
|
@ -38,21 +38,13 @@
|
||||
%define LAST_BYTES_COUNT 3 ;; Bytes to prevent reading out of array bounds
|
||||
%define LA_STATELESS 258 ;; No round up since no data is copied to a buffer
|
||||
|
||||
%ifndef IGZIP_LVL0_HASH_SIZE
|
||||
%assign IGZIP_LVL0_HASH_SIZE (8 * K)
|
||||
%endif
|
||||
|
||||
%ifndef IGZIP_LVL1_HASH_SIZE
|
||||
%assign IGZIP_LVL1_HASH_SIZE (8 * K)
|
||||
%endif
|
||||
|
||||
%ifndef IGZIP_LVL2_HASH_SIZE
|
||||
%assign IGZIP_LVL2_HASH_SIZE IGZIP_HIST_SIZE
|
||||
%endif
|
||||
%assign IGZIP_HASH8K_HASH_SIZE (8 * K)
|
||||
%assign IGZIP_HASH_MAP_HASH_SIZE IGZIP_HIST_SIZE
|
||||
|
||||
%assign LVL0_HASH_MASK (IGZIP_LVL0_HASH_SIZE - 1)
|
||||
%assign LVL1_HASH_MASK (IGZIP_LVL1_HASH_SIZE - 1)
|
||||
%assign LVL2_HASH_MASK (IGZIP_LVL2_HASH_SIZE - 1)
|
||||
%assign HASH8K_HASH_MASK (IGZIP_HASH8K_HASH_SIZE - 1)
|
||||
%assign HASH_MAP_HASH_MASK (IGZIP_HASH_MAP_HASH_SIZE - 1)
|
||||
|
||||
%assign MIN_DEF_MATCH 3 ; Minimum length of a match in deflate
|
||||
%assign SHORTEST_MATCH 4
|
||||
|
@ -115,17 +115,12 @@ extern "C" {
|
||||
|
||||
#define ISAL_LIMIT_HASH_UPDATE
|
||||
|
||||
#ifndef IGZIP_LVL0_HASH_SIZE
|
||||
#define IGZIP_HASH8K_HASH_SIZE (8 * IGZIP_K)
|
||||
#define IGZIP_HASH_MAP_HASH_SIZE IGZIP_HIST_SIZE
|
||||
|
||||
#define IGZIP_LVL0_HASH_SIZE (8 * IGZIP_K)
|
||||
#endif
|
||||
|
||||
#ifndef IGZIP_LVL1_HASH_SIZE
|
||||
#define IGZIP_LVL1_HASH_SIZE (8 * IGZIP_K)
|
||||
#endif
|
||||
|
||||
#ifndef IGZIP_LVL2_HASH_SIZE
|
||||
#define IGZIP_LVL2_HASH_SIZE IGZIP_HIST_SIZE
|
||||
#endif
|
||||
#define IGZIP_LVL1_HASH_SIZE IGZIP_HASH8K_HASH_SIZE
|
||||
#define IGZIP_LVL2_HASH_SIZE IGZIP_HASH_MAP_HASH_SIZE
|
||||
|
||||
#ifdef LONGER_HUFFTABLE
|
||||
enum {IGZIP_DIST_TABLE_SIZE = 8*1024};
|
||||
|
Loading…
Reference in New Issue
Block a user