igzip: Modify state to record total_in on deflate call

Change-Id: I13e5878a227732545aee5a762bf5a9a75ce73f02
Signed-off-by: Roy Oursler <roy.j.oursler@intel.com>
This commit is contained in:
Roy Oursler 2017-10-27 10:38:13 -07:00
parent 59b9990a39
commit 6049ce3ca7
7 changed files with 29 additions and 21 deletions

View File

@ -119,13 +119,14 @@ FIELD _icf_buf_start, 0, 0
START_FIELDS ;; isal_zstate
;; name size align
FIELD _total_in_start,4, 4
FIELD _bitbuf, _BitBuf2_size, _BitBuf2_align
FIELD _crc, 4, 4
FIELD _state, 4, 4
FIELD _has_wrap_hdr, 2, 2
FIELD _has_eob_hdr, 2, 2
FIELD _has_eob, 2, 2
FIELD _has_hist, 2, 2
FIELD _has_wrap_hdr, 1, 1
FIELD _has_eob_hdr, 1, 1
FIELD _has_eob, 1, 1
FIELD _has_hist, 1, 1
FIELD _hist, _isal_mod_hist_size, _isal_mod_hist_align
FIELD _count, 4, 4
FIELD _tmp_out_buff, 16, 1
@ -172,6 +173,7 @@ FIELD _internal_state, _isal_zstate_size, _isal_zstate_align
%assign _isal_zstream_size _FIELD_OFFSET
%assign _isal_zstream_align _STRUCT_ALIGN
_internal_state_total_in_start equ _internal_state+_total_in_start
_internal_state_b_bytes_valid equ _internal_state+_b_bytes_valid
_internal_state_b_bytes_processed equ _internal_state+_b_bytes_processed
_internal_state_crc equ _internal_state+_crc

View File

@ -260,7 +260,7 @@ static void init_new_icf_block(struct isal_zstream *stream)
}
}
static void create_icf_block_hdr(struct isal_zstream *stream, uint8_t * start_in)
static void create_icf_block_hdr(struct isal_zstream *stream)
{
struct isal_zstate *state = &stream->internal_state;
struct level_2_buf *level_buf = (struct level_2_buf *)stream->level_buf;
@ -268,6 +268,7 @@ static void create_icf_block_hdr(struct isal_zstream *stream, uint8_t * start_in
struct BitBuf2 write_buf_tmp;
uint32_t out_size = stream->avail_out;
uint8_t *end_out = stream->next_out + out_size;
uint8_t *start_in = stream->next_in - stream->total_in + state->total_in_start;
uint64_t bit_count;
uint64_t block_in_size = stream->total_in - level_buf->block_start_index;
uint64_t block_size;
@ -384,7 +385,7 @@ static void isal_deflate_icf_pass(struct isal_zstream *stream)
isal_deflate_icf_finish(stream);
if (state->state == ZSTATE_CREATE_HDR)
create_icf_block_hdr(stream, start_in);
create_icf_block_hdr(stream);
if (state->state == ZSTATE_HDR)
/* Note that the header may be prepended by the
@ -788,6 +789,7 @@ void isal_deflate_init(struct isal_zstream *stream)
state->b_bytes_valid = 0;
state->b_bytes_processed = 0;
state->total_in_start = 0;
state->has_wrap_hdr = 0;
state->has_eob = 0;
state->has_eob_hdr = 0;
@ -814,6 +816,7 @@ void isal_deflate_reset(struct isal_zstream *stream)
state->b_bytes_valid = 0;
state->b_bytes_processed = 0;
state->total_in_start = 0;
state->has_wrap_hdr = 0;
state->has_eob = 0;
state->has_eob_hdr = 0;
@ -925,6 +928,7 @@ int isal_deflate_stateless(struct isal_zstream *stream)
init(&stream->internal_state.bitbuf);
stream->internal_state.state = ZSTATE_NEW_HDR;
stream->internal_state.crc = 0;
stream->internal_state.total_in_start = stream->total_in;
if (stream->flush == NO_FLUSH)
stream->end_of_stream = 1;
@ -1024,6 +1028,7 @@ int isal_deflate(struct isal_zstream *stream)
next_in = stream->next_in;
avail_in = stream->avail_in;
stream->total_in -= state->b_bytes_valid - state->b_bytes_processed;
state->total_in_start = stream->total_in - state->b_bytes_processed;
if (state->has_hist == IGZIP_NO_HIST)
reset_match_history(stream);

View File

@ -164,7 +164,7 @@ skip1:
mov [rsp + gpr_save_mem_offset + 7*8], r15
mov stream, rcx
mov word [stream + _internal_state_has_eob], 0
mov byte [stream + _internal_state_has_eob], 0
MOVDQU xmask, [mask]
@ -212,7 +212,7 @@ MARK __body_compute_hash_ %+ ARCH
and hash, HASH_MASK
and hash2, HASH_MASK
cmp word [stream + _internal_state_has_hist], IGZIP_NO_HIST
cmp byte [stream + _internal_state_has_hist], IGZIP_NO_HIST
je write_first_byte
jmp loop2
@ -545,7 +545,7 @@ write_first_byte:
cmp m_out_buf, [stream + _internal_state_bitbuf_m_out_end]
ja output_end
mov word [stream + _internal_state_has_hist], IGZIP_HIST
mov byte [stream + _internal_state_has_hist], IGZIP_HIST
mov [stream + _internal_state_head + 2 * hash], f_i %+ w

View File

@ -126,7 +126,7 @@ skip_SLOP:
mov curr_data %+ d, [file_start + f_i]
cmp word [stream + _internal_state_has_hist], IGZIP_NO_HIST
cmp byte [stream + _internal_state_has_hist], IGZIP_NO_HIST
jne skip_write_first_byte
cmp m_out_buf, [stream + _internal_state_bitbuf_m_out_end]
@ -135,7 +135,7 @@ skip_SLOP:
compute_hash hash, curr_data
and hash %+ d, HASH_MASK
mov [stream + _internal_state_head + 2 * hash], f_i %+ w
mov word [stream + _internal_state_has_hist], IGZIP_HIST
mov byte [stream + _internal_state_has_hist], IGZIP_HIST
jmp encode_literal
skip_write_first_byte:
@ -276,7 +276,7 @@ write_eob:
write_bits m_bits, m_bit_count, code2, code_len2, m_out_buf, tmp1
mov word [stream + _internal_state_has_eob], 1
mov byte [stream + _internal_state_has_eob], 1
cmp word [stream + _end_of_stream], 1
jne sync_flush
; state->state = ZSTATE_TRL;

View File

@ -150,7 +150,7 @@ skip1:
mov [rsp + gpr_save_mem_offset + 7*8], r15
mov stream, rcx
mov word [stream + _internal_state_has_eob], 0
mov byte [stream + _internal_state_has_eob], 0
; state->bitbuf.set_buf(stream->next_out, stream->avail_out);
mov tmp1, [stream + _level_buf]
@ -193,7 +193,7 @@ MARK __body_compute_hash_ %+ ARCH
and hash, HASH_MASK
and hash2, HASH_MASK
cmp word [stream + _internal_state_has_hist], IGZIP_NO_HIST
cmp byte [stream + _internal_state_has_hist], IGZIP_NO_HIST
je write_first_byte
jmp loop2
@ -482,7 +482,7 @@ write_first_byte:
cmp m_out_buf, [rsp + m_out_end]
ja output_end
mov word [stream + _internal_state_has_hist], IGZIP_HIST
mov byte [stream + _internal_state_has_hist], IGZIP_HIST
mov [stream + _internal_state_head + 2 * hash], f_i %+ w

View File

@ -122,7 +122,7 @@ isal_deflate_icf_finish_01:
mov curr_data %+ d, [file_start + f_i]
cmp word [stream + _internal_state_has_hist], IGZIP_NO_HIST
cmp byte [stream + _internal_state_has_hist], IGZIP_NO_HIST
jne skip_write_first_byte
cmp m_out_buf, [rsp + m_out_end]
@ -131,7 +131,7 @@ isal_deflate_icf_finish_01:
compute_hash hash, curr_data
and hash %+ d, HASH_MASK
mov [stream + _internal_state_head + 2 * hash], f_i %+ w
mov word [stream + _internal_state_has_hist], IGZIP_HIST
mov byte [stream + _internal_state_has_hist], IGZIP_HIST
jmp encode_literal
skip_write_first_byte:

View File

@ -284,13 +284,14 @@ struct BitBuf2 {
/** @brief Holds the internal state information for input and output compression streams*/
struct isal_zstate {
uint32_t total_in_start; //!< Start of total_in (inlcuding buffered data) on function call
struct BitBuf2 bitbuf; //!< Bit Buffer
uint32_t crc; //!< Current crc
enum isal_zstate_state state; //!< Current state in processing the data stream
uint16_t has_wrap_hdr; //!< keeps track of wrapper header
uint16_t has_eob_hdr; //!< keeps track of eob hdr (with BFINAL set)
uint16_t has_eob; //!< keeps track of eob on the last deflate block
uint16_t has_hist; //!< flag to track if there is match history
uint8_t has_wrap_hdr; //!< keeps track of wrapper header
uint8_t has_eob_hdr; //!< keeps track of eob hdr (with BFINAL set)
uint8_t has_eob; //!< keeps track of eob on the last deflate block
uint8_t has_hist; //!< flag to track if there is match history
struct isal_mod_hist hist;
uint32_t count; //!< used for partial header/trailer writes
uint8_t tmp_out_buff[16]; //!< temporary array