igzip: Setup to allow encode_df to decode lit lit pairs.

Change-Id: Ic93797a09c5a908fc1c6005b40439978d7484773
Signed-off-by: Roy Oursler <roy.j.oursler@intel.com>
This commit is contained in:
Roy Oursler 2017-01-31 17:15:29 -05:00 committed by Greg Tucker
parent 8a05e7d780
commit 4725626847
6 changed files with 31 additions and 25 deletions

View File

@ -85,8 +85,8 @@ FIELD _ll_hist, 513*2, 2
START_FIELDS ;; hufftables_icf
;; name size align
FIELD _lit_len_table, 513 * HUFF_CODE_SIZE, HUFF_CODE_SIZE
FIELD _dist_table, 31 * HUFF_CODE_SIZE, HUFF_CODE_SIZE
FIELD _lit_len_table, 513 * HUFF_CODE_SIZE, HUFF_CODE_SIZE
%assign _hufftables_icf_size _FIELD_OFFSET
%assign _hufftables_icf_align _STRUCT_ALIGN

View File

@ -5,13 +5,15 @@
#include "huff_codes.h"
/* Deflate Intermediate Compression Format */
#define ICF_DIST_OFFSET 14
#define LIT_LEN_BIT_COUNT 10
#define DIST_LIT_BIT_COUNT 9
#define ICF_DIST_OFFSET LIT_LEN_BIT_COUNT
#define NULL_DIST_SYM 30
struct deflate_icf {
uint32_t lit_len:ICF_DIST_OFFSET;
uint32_t lit_dist:5;
uint32_t dist_extra:32 - 5 - ICF_DIST_OFFSET;
uint32_t lit_len:LIT_LEN_BIT_COUNT;
uint32_t lit_dist:DIST_LIT_BIT_COUNT;
uint32_t dist_extra:32 - DIST_LIT_BIT_COUNT - ICF_DIST_OFFSET;
};
struct deflate_icf *encode_deflate_icf(struct deflate_icf *next_in, struct deflate_icf *end_in,

View File

@ -31,7 +31,7 @@
%define ARG4 r9
%define TMP1 rsi
%define TMP2 rdi
%define ll_tree ARG4
%define hufftables ARG4
%define ptr r11
%else
; Linux
@ -41,8 +41,8 @@
%define ARG4 rcx
%define TMP1 r8
%define TMP2 r9
%define ll_tree r11 ; ARG4
%define ptr ARG1 ; r11
%define hufftables r11
%define ptr ARG1
%endif
%define in_buf_end ARG2
@ -57,10 +57,9 @@
%define len dsym
%define tmp2 r10
%define end_ptr rbp
%define dist_tree ll_tree + 4*513
%define LIT_MASK 0x3FF
%define DIST_MASK 0x1F
%define LIT_MASK ((0x1 << LIT_LEN_BIT_COUNT) - 1)
%define DIST_MASK ((0x1 << DIST_LIT_BIT_COUNT) - 1)
%define codes1 ymm1
%define code_lens1 ymm2
@ -101,7 +100,7 @@ encode_deflate_icf_ %+ ARCH:
%ifidn __OUTPUT_FORMAT__, win64
mov ptr, ARG1
%else
mov ll_tree, ARG4
mov hufftables, ARG4
%endif
mov bits, [bb + _m_bits]
@ -117,12 +116,12 @@ encode_deflate_icf_ %+ ARCH:
vpcmpeqq ytmp, ytmp, ytmp
vmovdqu datas, [ptr]
vpand syms, datas, [lit_mask]
vpgatherdd codes_lookup1, [ll_tree + 4 * syms], ytmp
vpgatherdd codes_lookup1, [hufftables + _lit_len_table + 4 * syms], ytmp
vpcmpeqq ytmp, ytmp, ytmp
vpsrld dsyms, datas, DIST_OFFSET
vpand dsyms, dsyms, [dist_mask]
vpgatherdd codes_lookup2, [dist_tree + 4 * dsyms], ytmp
vpgatherdd codes_lookup2, [hufftables + _dist_table + 4 * dsyms], ytmp
vmovq ybits %+ x, bits
vmovq ybits_count %+ x, rcx
@ -151,12 +150,12 @@ encode_deflate_icf_ %+ ARCH:
vpcmpeqq ytmp, ytmp, ytmp
vmovdqu datas, [ptr]
vpand syms, datas, [lit_mask]
vpgatherdd codes_lookup1, [ll_tree + 4 * syms], ytmp
vpgatherdd codes_lookup1, [hufftables + _lit_len_table + 4 * syms], ytmp
vpcmpeqq ytmp, ytmp, ytmp
vpsrld dsyms, datas, DIST_OFFSET
vpand dsyms, dsyms, [dist_mask]
vpgatherdd codes_lookup2, [dist_tree + 4 * dsyms], ytmp
vpgatherdd codes_lookup2, [hufftables + _dist_table + 4 * dsyms], ytmp
;; Merge dist code with extra bits
vpsllvd codes3, codes3, code_lens2
@ -395,13 +394,13 @@ encode_deflate_icf_ %+ ARCH:
mov sym, data
and sym, LIT_MASK ; sym has ll_code
mov DWORD(sym), [ll_tree + sym * 4]
mov DWORD(sym), [hufftables + _lit_len_table + sym * 4]
; look up dist sym
mov dsym, data
shr dsym, DIST_OFFSET
and dsym, 0x1F
mov DWORD(dsym), [dist_tree + dsym * 4]
and dsym, DIST_MASK
mov DWORD(dsym), [hufftables + _dist_table + dsym * 4]
; insert LL code
; sym: 31:24 length; 23:0 code

View File

@ -126,8 +126,8 @@ struct rl_code {
};
struct hufftables_icf {
struct huff_code lit_len_table[513];
struct huff_code dist_table[31];
struct huff_code lit_len_table[513];
};
/**

View File

@ -423,11 +423,13 @@ write_lit_bits:
MOVD hash %+ d, xhash
inc word [stream + _internal_state_hist_lit_len + 2*code3]
or code3, LIT
inc word [stream + _internal_state_hist_lit_len + 2*code2]
or code2, LIT
add code2, 31
shl code2, DIST_OFFSET
or code3, code2
write_dword code3, m_out_buf
write_dword code2, m_out_buf
PEXTRD hash2 %+ d, xhash, 1

View File

@ -48,6 +48,9 @@
%assign SLOP 8
%define DIST_OFFSET 14
%define EXTRA_BITS_OFFSET (DIST_OFFSET + 5)
%define LIT_LEN_BIT_COUNT 10
%define DIST_LIT_BIT_COUNT 9
%define DIST_OFFSET LIT_LEN_BIT_COUNT
%define EXTRA_BITS_OFFSET (DIST_OFFSET + DIST_LIT_BIT_COUNT)
%define LIT (0x1E << DIST_OFFSET)