igzip: Implement static header on level 1 compress

Change-Id: I0fe61eb6d3994a0977a4486a2a4cf21af38dc250
Signed-off-by: Roy Oursler <roy.j.oursler@intel.com>
This commit is contained in:
Roy Oursler 2017-03-15 17:27:02 -07:00 committed by Greg Tucker
parent e38ed4b54e
commit 9992cc1920
2 changed files with 609 additions and 37 deletions

View File

@ -42,6 +42,569 @@
static const uint8_t code_length_code_order[] =
{ 16, 17, 18, 0, 8, 7, 9, 6, 10, 5, 11, 4, 12, 3, 13, 2, 14, 1, 15 };
const uint32_t len_code_extra_bits[] = {
0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0,
0x1, 0x1, 0x1, 0x1, 0x2, 0x2, 0x2, 0x2,
0x3, 0x3, 0x3, 0x3, 0x4, 0x4, 0x4, 0x4,
0x5, 0x5, 0x5, 0x5, 0x0
};
const uint32_t dist_code_extra_bits[] = {
0x0, 0x0, 0x0, 0x0, 0x1, 0x1, 0x2, 0x2,
0x3, 0x3, 0x4, 0x4, 0x5, 0x5, 0x6, 0x6,
0x7, 0x7, 0x8, 0x8, 0x9, 0x9, 0xa, 0xa,
0xb, 0xb, 0xc, 0xc, 0xd, 0xd
};
struct hufftables_icf static_hufftables = {
.lit_len_table = {
{.code_and_extra = 0x00c,.length2 = 0x8},
{.code_and_extra = 0x08c,.length2 = 0x8},
{.code_and_extra = 0x04c,.length2 = 0x8},
{.code_and_extra = 0x0cc,.length2 = 0x8},
{.code_and_extra = 0x02c,.length2 = 0x8},
{.code_and_extra = 0x0ac,.length2 = 0x8},
{.code_and_extra = 0x06c,.length2 = 0x8},
{.code_and_extra = 0x0ec,.length2 = 0x8},
{.code_and_extra = 0x01c,.length2 = 0x8},
{.code_and_extra = 0x09c,.length2 = 0x8},
{.code_and_extra = 0x05c,.length2 = 0x8},
{.code_and_extra = 0x0dc,.length2 = 0x8},
{.code_and_extra = 0x03c,.length2 = 0x8},
{.code_and_extra = 0x0bc,.length2 = 0x8},
{.code_and_extra = 0x07c,.length2 = 0x8},
{.code_and_extra = 0x0fc,.length2 = 0x8},
{.code_and_extra = 0x002,.length2 = 0x8},
{.code_and_extra = 0x082,.length2 = 0x8},
{.code_and_extra = 0x042,.length2 = 0x8},
{.code_and_extra = 0x0c2,.length2 = 0x8},
{.code_and_extra = 0x022,.length2 = 0x8},
{.code_and_extra = 0x0a2,.length2 = 0x8},
{.code_and_extra = 0x062,.length2 = 0x8},
{.code_and_extra = 0x0e2,.length2 = 0x8},
{.code_and_extra = 0x012,.length2 = 0x8},
{.code_and_extra = 0x092,.length2 = 0x8},
{.code_and_extra = 0x052,.length2 = 0x8},
{.code_and_extra = 0x0d2,.length2 = 0x8},
{.code_and_extra = 0x032,.length2 = 0x8},
{.code_and_extra = 0x0b2,.length2 = 0x8},
{.code_and_extra = 0x072,.length2 = 0x8},
{.code_and_extra = 0x0f2,.length2 = 0x8},
{.code_and_extra = 0x00a,.length2 = 0x8},
{.code_and_extra = 0x08a,.length2 = 0x8},
{.code_and_extra = 0x04a,.length2 = 0x8},
{.code_and_extra = 0x0ca,.length2 = 0x8},
{.code_and_extra = 0x02a,.length2 = 0x8},
{.code_and_extra = 0x0aa,.length2 = 0x8},
{.code_and_extra = 0x06a,.length2 = 0x8},
{.code_and_extra = 0x0ea,.length2 = 0x8},
{.code_and_extra = 0x01a,.length2 = 0x8},
{.code_and_extra = 0x09a,.length2 = 0x8},
{.code_and_extra = 0x05a,.length2 = 0x8},
{.code_and_extra = 0x0da,.length2 = 0x8},
{.code_and_extra = 0x03a,.length2 = 0x8},
{.code_and_extra = 0x0ba,.length2 = 0x8},
{.code_and_extra = 0x07a,.length2 = 0x8},
{.code_and_extra = 0x0fa,.length2 = 0x8},
{.code_and_extra = 0x006,.length2 = 0x8},
{.code_and_extra = 0x086,.length2 = 0x8},
{.code_and_extra = 0x046,.length2 = 0x8},
{.code_and_extra = 0x0c6,.length2 = 0x8},
{.code_and_extra = 0x026,.length2 = 0x8},
{.code_and_extra = 0x0a6,.length2 = 0x8},
{.code_and_extra = 0x066,.length2 = 0x8},
{.code_and_extra = 0x0e6,.length2 = 0x8},
{.code_and_extra = 0x016,.length2 = 0x8},
{.code_and_extra = 0x096,.length2 = 0x8},
{.code_and_extra = 0x056,.length2 = 0x8},
{.code_and_extra = 0x0d6,.length2 = 0x8},
{.code_and_extra = 0x036,.length2 = 0x8},
{.code_and_extra = 0x0b6,.length2 = 0x8},
{.code_and_extra = 0x076,.length2 = 0x8},
{.code_and_extra = 0x0f6,.length2 = 0x8},
{.code_and_extra = 0x00e,.length2 = 0x8},
{.code_and_extra = 0x08e,.length2 = 0x8},
{.code_and_extra = 0x04e,.length2 = 0x8},
{.code_and_extra = 0x0ce,.length2 = 0x8},
{.code_and_extra = 0x02e,.length2 = 0x8},
{.code_and_extra = 0x0ae,.length2 = 0x8},
{.code_and_extra = 0x06e,.length2 = 0x8},
{.code_and_extra = 0x0ee,.length2 = 0x8},
{.code_and_extra = 0x01e,.length2 = 0x8},
{.code_and_extra = 0x09e,.length2 = 0x8},
{.code_and_extra = 0x05e,.length2 = 0x8},
{.code_and_extra = 0x0de,.length2 = 0x8},
{.code_and_extra = 0x03e,.length2 = 0x8},
{.code_and_extra = 0x0be,.length2 = 0x8},
{.code_and_extra = 0x07e,.length2 = 0x8},
{.code_and_extra = 0x0fe,.length2 = 0x8},
{.code_and_extra = 0x001,.length2 = 0x8},
{.code_and_extra = 0x081,.length2 = 0x8},
{.code_and_extra = 0x041,.length2 = 0x8},
{.code_and_extra = 0x0c1,.length2 = 0x8},
{.code_and_extra = 0x021,.length2 = 0x8},
{.code_and_extra = 0x0a1,.length2 = 0x8},
{.code_and_extra = 0x061,.length2 = 0x8},
{.code_and_extra = 0x0e1,.length2 = 0x8},
{.code_and_extra = 0x011,.length2 = 0x8},
{.code_and_extra = 0x091,.length2 = 0x8},
{.code_and_extra = 0x051,.length2 = 0x8},
{.code_and_extra = 0x0d1,.length2 = 0x8},
{.code_and_extra = 0x031,.length2 = 0x8},
{.code_and_extra = 0x0b1,.length2 = 0x8},
{.code_and_extra = 0x071,.length2 = 0x8},
{.code_and_extra = 0x0f1,.length2 = 0x8},
{.code_and_extra = 0x009,.length2 = 0x8},
{.code_and_extra = 0x089,.length2 = 0x8},
{.code_and_extra = 0x049,.length2 = 0x8},
{.code_and_extra = 0x0c9,.length2 = 0x8},
{.code_and_extra = 0x029,.length2 = 0x8},
{.code_and_extra = 0x0a9,.length2 = 0x8},
{.code_and_extra = 0x069,.length2 = 0x8},
{.code_and_extra = 0x0e9,.length2 = 0x8},
{.code_and_extra = 0x019,.length2 = 0x8},
{.code_and_extra = 0x099,.length2 = 0x8},
{.code_and_extra = 0x059,.length2 = 0x8},
{.code_and_extra = 0x0d9,.length2 = 0x8},
{.code_and_extra = 0x039,.length2 = 0x8},
{.code_and_extra = 0x0b9,.length2 = 0x8},
{.code_and_extra = 0x079,.length2 = 0x8},
{.code_and_extra = 0x0f9,.length2 = 0x8},
{.code_and_extra = 0x005,.length2 = 0x8},
{.code_and_extra = 0x085,.length2 = 0x8},
{.code_and_extra = 0x045,.length2 = 0x8},
{.code_and_extra = 0x0c5,.length2 = 0x8},
{.code_and_extra = 0x025,.length2 = 0x8},
{.code_and_extra = 0x0a5,.length2 = 0x8},
{.code_and_extra = 0x065,.length2 = 0x8},
{.code_and_extra = 0x0e5,.length2 = 0x8},
{.code_and_extra = 0x015,.length2 = 0x8},
{.code_and_extra = 0x095,.length2 = 0x8},
{.code_and_extra = 0x055,.length2 = 0x8},
{.code_and_extra = 0x0d5,.length2 = 0x8},
{.code_and_extra = 0x035,.length2 = 0x8},
{.code_and_extra = 0x0b5,.length2 = 0x8},
{.code_and_extra = 0x075,.length2 = 0x8},
{.code_and_extra = 0x0f5,.length2 = 0x8},
{.code_and_extra = 0x00d,.length2 = 0x8},
{.code_and_extra = 0x08d,.length2 = 0x8},
{.code_and_extra = 0x04d,.length2 = 0x8},
{.code_and_extra = 0x0cd,.length2 = 0x8},
{.code_and_extra = 0x02d,.length2 = 0x8},
{.code_and_extra = 0x0ad,.length2 = 0x8},
{.code_and_extra = 0x06d,.length2 = 0x8},
{.code_and_extra = 0x0ed,.length2 = 0x8},
{.code_and_extra = 0x01d,.length2 = 0x8},
{.code_and_extra = 0x09d,.length2 = 0x8},
{.code_and_extra = 0x05d,.length2 = 0x8},
{.code_and_extra = 0x0dd,.length2 = 0x8},
{.code_and_extra = 0x03d,.length2 = 0x8},
{.code_and_extra = 0x0bd,.length2 = 0x8},
{.code_and_extra = 0x07d,.length2 = 0x8},
{.code_and_extra = 0x0fd,.length2 = 0x8},
{.code_and_extra = 0x013,.length2 = 0x9},
{.code_and_extra = 0x113,.length2 = 0x9},
{.code_and_extra = 0x093,.length2 = 0x9},
{.code_and_extra = 0x193,.length2 = 0x9},
{.code_and_extra = 0x053,.length2 = 0x9},
{.code_and_extra = 0x153,.length2 = 0x9},
{.code_and_extra = 0x0d3,.length2 = 0x9},
{.code_and_extra = 0x1d3,.length2 = 0x9},
{.code_and_extra = 0x033,.length2 = 0x9},
{.code_and_extra = 0x133,.length2 = 0x9},
{.code_and_extra = 0x0b3,.length2 = 0x9},
{.code_and_extra = 0x1b3,.length2 = 0x9},
{.code_and_extra = 0x073,.length2 = 0x9},
{.code_and_extra = 0x173,.length2 = 0x9},
{.code_and_extra = 0x0f3,.length2 = 0x9},
{.code_and_extra = 0x1f3,.length2 = 0x9},
{.code_and_extra = 0x00b,.length2 = 0x9},
{.code_and_extra = 0x10b,.length2 = 0x9},
{.code_and_extra = 0x08b,.length2 = 0x9},
{.code_and_extra = 0x18b,.length2 = 0x9},
{.code_and_extra = 0x04b,.length2 = 0x9},
{.code_and_extra = 0x14b,.length2 = 0x9},
{.code_and_extra = 0x0cb,.length2 = 0x9},
{.code_and_extra = 0x1cb,.length2 = 0x9},
{.code_and_extra = 0x02b,.length2 = 0x9},
{.code_and_extra = 0x12b,.length2 = 0x9},
{.code_and_extra = 0x0ab,.length2 = 0x9},
{.code_and_extra = 0x1ab,.length2 = 0x9},
{.code_and_extra = 0x06b,.length2 = 0x9},
{.code_and_extra = 0x16b,.length2 = 0x9},
{.code_and_extra = 0x0eb,.length2 = 0x9},
{.code_and_extra = 0x1eb,.length2 = 0x9},
{.code_and_extra = 0x01b,.length2 = 0x9},
{.code_and_extra = 0x11b,.length2 = 0x9},
{.code_and_extra = 0x09b,.length2 = 0x9},
{.code_and_extra = 0x19b,.length2 = 0x9},
{.code_and_extra = 0x05b,.length2 = 0x9},
{.code_and_extra = 0x15b,.length2 = 0x9},
{.code_and_extra = 0x0db,.length2 = 0x9},
{.code_and_extra = 0x1db,.length2 = 0x9},
{.code_and_extra = 0x03b,.length2 = 0x9},
{.code_and_extra = 0x13b,.length2 = 0x9},
{.code_and_extra = 0x0bb,.length2 = 0x9},
{.code_and_extra = 0x1bb,.length2 = 0x9},
{.code_and_extra = 0x07b,.length2 = 0x9},
{.code_and_extra = 0x17b,.length2 = 0x9},
{.code_and_extra = 0x0fb,.length2 = 0x9},
{.code_and_extra = 0x1fb,.length2 = 0x9},
{.code_and_extra = 0x007,.length2 = 0x9},
{.code_and_extra = 0x107,.length2 = 0x9},
{.code_and_extra = 0x087,.length2 = 0x9},
{.code_and_extra = 0x187,.length2 = 0x9},
{.code_and_extra = 0x047,.length2 = 0x9},
{.code_and_extra = 0x147,.length2 = 0x9},
{.code_and_extra = 0x0c7,.length2 = 0x9},
{.code_and_extra = 0x1c7,.length2 = 0x9},
{.code_and_extra = 0x027,.length2 = 0x9},
{.code_and_extra = 0x127,.length2 = 0x9},
{.code_and_extra = 0x0a7,.length2 = 0x9},
{.code_and_extra = 0x1a7,.length2 = 0x9},
{.code_and_extra = 0x067,.length2 = 0x9},
{.code_and_extra = 0x167,.length2 = 0x9},
{.code_and_extra = 0x0e7,.length2 = 0x9},
{.code_and_extra = 0x1e7,.length2 = 0x9},
{.code_and_extra = 0x017,.length2 = 0x9},
{.code_and_extra = 0x117,.length2 = 0x9},
{.code_and_extra = 0x097,.length2 = 0x9},
{.code_and_extra = 0x197,.length2 = 0x9},
{.code_and_extra = 0x057,.length2 = 0x9},
{.code_and_extra = 0x157,.length2 = 0x9},
{.code_and_extra = 0x0d7,.length2 = 0x9},
{.code_and_extra = 0x1d7,.length2 = 0x9},
{.code_and_extra = 0x037,.length2 = 0x9},
{.code_and_extra = 0x137,.length2 = 0x9},
{.code_and_extra = 0x0b7,.length2 = 0x9},
{.code_and_extra = 0x1b7,.length2 = 0x9},
{.code_and_extra = 0x077,.length2 = 0x9},
{.code_and_extra = 0x177,.length2 = 0x9},
{.code_and_extra = 0x0f7,.length2 = 0x9},
{.code_and_extra = 0x1f7,.length2 = 0x9},
{.code_and_extra = 0x00f,.length2 = 0x9},
{.code_and_extra = 0x10f,.length2 = 0x9},
{.code_and_extra = 0x08f,.length2 = 0x9},
{.code_and_extra = 0x18f,.length2 = 0x9},
{.code_and_extra = 0x04f,.length2 = 0x9},
{.code_and_extra = 0x14f,.length2 = 0x9},
{.code_and_extra = 0x0cf,.length2 = 0x9},
{.code_and_extra = 0x1cf,.length2 = 0x9},
{.code_and_extra = 0x02f,.length2 = 0x9},
{.code_and_extra = 0x12f,.length2 = 0x9},
{.code_and_extra = 0x0af,.length2 = 0x9},
{.code_and_extra = 0x1af,.length2 = 0x9},
{.code_and_extra = 0x06f,.length2 = 0x9},
{.code_and_extra = 0x16f,.length2 = 0x9},
{.code_and_extra = 0x0ef,.length2 = 0x9},
{.code_and_extra = 0x1ef,.length2 = 0x9},
{.code_and_extra = 0x01f,.length2 = 0x9},
{.code_and_extra = 0x11f,.length2 = 0x9},
{.code_and_extra = 0x09f,.length2 = 0x9},
{.code_and_extra = 0x19f,.length2 = 0x9},
{.code_and_extra = 0x05f,.length2 = 0x9},
{.code_and_extra = 0x15f,.length2 = 0x9},
{.code_and_extra = 0x0df,.length2 = 0x9},
{.code_and_extra = 0x1df,.length2 = 0x9},
{.code_and_extra = 0x03f,.length2 = 0x9},
{.code_and_extra = 0x13f,.length2 = 0x9},
{.code_and_extra = 0x0bf,.length2 = 0x9},
{.code_and_extra = 0x1bf,.length2 = 0x9},
{.code_and_extra = 0x07f,.length2 = 0x9},
{.code_and_extra = 0x17f,.length2 = 0x9},
{.code_and_extra = 0x0ff,.length2 = 0x9},
{.code_and_extra = 0x1ff,.length2 = 0x9},
{.code_and_extra = 0x000,.length2 = 0x7},
{.code_and_extra = 0x040,.length2 = 0x7},
{.code_and_extra = 0x020,.length2 = 0x7},
{.code_and_extra = 0x060,.length2 = 0x7},
{.code_and_extra = 0x010,.length2 = 0x7},
{.code_and_extra = 0x050,.length2 = 0x7},
{.code_and_extra = 0x030,.length2 = 0x7},
{.code_and_extra = 0x070,.length2 = 0x7},
{.code_and_extra = 0x008,.length2 = 0x7},
{.code_and_extra = 0x048,.length2 = 0x7},
{.code_and_extra = 0x028,.length2 = 0x7},
{.code_and_extra = 0x068,.length2 = 0x7},
{.code_and_extra = 0x018,.length2 = 0x7},
{.code_and_extra = 0x058,.length2 = 0x7},
{.code_and_extra = 0x038,.length2 = 0x7},
{.code_and_extra = 0x078,.length2 = 0x7},
{.code_and_extra = 0x004,.length2 = 0x7},
{.code_and_extra = 0x044,.length2 = 0x7},
{.code_and_extra = 0x024,.length2 = 0x7},
{.code_and_extra = 0x064,.length2 = 0x7},
{.code_and_extra = 0x014,.length2 = 0x7},
{.code_and_extra = 0x054,.length2 = 0x7},
{.code_and_extra = 0x034,.length2 = 0x7},
{.code_and_extra = 0x074,.length2 = 0x7},
{.code_and_extra = 0x003,.length2 = 0x8},
{.code_and_extra = 0x083,.length2 = 0x8},
{.code_and_extra = 0x043,.length2 = 0x8},
{.code_and_extra = 0x0c3,.length2 = 0x8},
{.code_and_extra = 0x023,.length2 = 0x8},
{.code_and_extra = 0x0a3,.length2 = 0x8},
{.code_and_extra = 0x063,.length2 = 0x8},
{.code_and_extra = 0x0e3,.length2 = 0x8},
{.code_and_extra = 0x000,.length2 = 0x0},
{.code_and_extra = 0x000,.length2 = 0x0},
{.code_and_extra = 0x000,.length2 = 0x0},
{.code_and_extra = 0x000,.length2 = 0x0},
{.code_and_extra = 0x000,.length2 = 0x0},
{.code_and_extra = 0x000,.length2 = 0x0},
{.code_and_extra = 0x000,.length2 = 0x0},
{.code_and_extra = 0x000,.length2 = 0x0},
{.code_and_extra = 0x000,.length2 = 0x0},
{.code_and_extra = 0x000,.length2 = 0x0},
{.code_and_extra = 0x000,.length2 = 0x0},
{.code_and_extra = 0x000,.length2 = 0x0},
{.code_and_extra = 0x000,.length2 = 0x0},
{.code_and_extra = 0x000,.length2 = 0x0},
{.code_and_extra = 0x000,.length2 = 0x0},
{.code_and_extra = 0x000,.length2 = 0x0},
{.code_and_extra = 0x000,.length2 = 0x0},
{.code_and_extra = 0x000,.length2 = 0x0},
{.code_and_extra = 0x000,.length2 = 0x0},
{.code_and_extra = 0x000,.length2 = 0x0},
{.code_and_extra = 0x000,.length2 = 0x0},
{.code_and_extra = 0x000,.length2 = 0x0},
{.code_and_extra = 0x000,.length2 = 0x0},
{.code_and_extra = 0x000,.length2 = 0x0},
{.code_and_extra = 0x000,.length2 = 0x0},
{.code_and_extra = 0x000,.length2 = 0x0},
{.code_and_extra = 0x000,.length2 = 0x0},
{.code_and_extra = 0x000,.length2 = 0x0},
{.code_and_extra = 0x000,.length2 = 0x0},
{.code_and_extra = 0x000,.length2 = 0x0},
{.code_and_extra = 0x000,.length2 = 0x0},
{.code_and_extra = 0x000,.length2 = 0x0},
{.code_and_extra = 0x000,.length2 = 0x0},
{.code_and_extra = 0x000,.length2 = 0x0},
{.code_and_extra = 0x000,.length2 = 0x0},
{.code_and_extra = 0x000,.length2 = 0x0},
{.code_and_extra = 0x000,.length2 = 0x0},
{.code_and_extra = 0x000,.length2 = 0x0},
{.code_and_extra = 0x000,.length2 = 0x0},
{.code_and_extra = 0x000,.length2 = 0x0},
{.code_and_extra = 0x000,.length2 = 0x0},
{.code_and_extra = 0x000,.length2 = 0x0},
{.code_and_extra = 0x000,.length2 = 0x0},
{.code_and_extra = 0x000,.length2 = 0x0},
{.code_and_extra = 0x000,.length2 = 0x0},
{.code_and_extra = 0x000,.length2 = 0x0},
{.code_and_extra = 0x000,.length2 = 0x0},
{.code_and_extra = 0x000,.length2 = 0x0},
{.code_and_extra = 0x000,.length2 = 0x0},
{.code_and_extra = 0x000,.length2 = 0x0},
{.code_and_extra = 0x000,.length2 = 0x0},
{.code_and_extra = 0x000,.length2 = 0x0},
{.code_and_extra = 0x000,.length2 = 0x0},
{.code_and_extra = 0x000,.length2 = 0x0},
{.code_and_extra = 0x000,.length2 = 0x0},
{.code_and_extra = 0x000,.length2 = 0x0},
{.code_and_extra = 0x000,.length2 = 0x0},
{.code_and_extra = 0x000,.length2 = 0x0},
{.code_and_extra = 0x000,.length2 = 0x0},
{.code_and_extra = 0x000,.length2 = 0x0},
{.code_and_extra = 0x000,.length2 = 0x0},
{.code_and_extra = 0x000,.length2 = 0x0},
{.code_and_extra = 0x000,.length2 = 0x0},
{.code_and_extra = 0x000,.length2 = 0x0},
{.code_and_extra = 0x000,.length2 = 0x0},
{.code_and_extra = 0x000,.length2 = 0x0},
{.code_and_extra = 0x000,.length2 = 0x0},
{.code_and_extra = 0x000,.length2 = 0x0},
{.code_and_extra = 0x000,.length2 = 0x0},
{.code_and_extra = 0x000,.length2 = 0x0},
{.code_and_extra = 0x000,.length2 = 0x0},
{.code_and_extra = 0x000,.length2 = 0x0},
{.code_and_extra = 0x000,.length2 = 0x0},
{.code_and_extra = 0x000,.length2 = 0x0},
{.code_and_extra = 0x000,.length2 = 0x0},
{.code_and_extra = 0x000,.length2 = 0x0},
{.code_and_extra = 0x000,.length2 = 0x0},
{.code_and_extra = 0x000,.length2 = 0x0},
{.code_and_extra = 0x000,.length2 = 0x0},
{.code_and_extra = 0x000,.length2 = 0x0},
{.code_and_extra = 0x000,.length2 = 0x0},
{.code_and_extra = 0x000,.length2 = 0x0},
{.code_and_extra = 0x000,.length2 = 0x0},
{.code_and_extra = 0x000,.length2 = 0x0},
{.code_and_extra = 0x000,.length2 = 0x0},
{.code_and_extra = 0x000,.length2 = 0x0},
{.code_and_extra = 0x000,.length2 = 0x0},
{.code_and_extra = 0x000,.length2 = 0x0},
{.code_and_extra = 0x000,.length2 = 0x0},
{.code_and_extra = 0x000,.length2 = 0x0},
{.code_and_extra = 0x000,.length2 = 0x0},
{.code_and_extra = 0x000,.length2 = 0x0},
{.code_and_extra = 0x000,.length2 = 0x0},
{.code_and_extra = 0x000,.length2 = 0x0},
{.code_and_extra = 0x000,.length2 = 0x0},
{.code_and_extra = 0x000,.length2 = 0x0},
{.code_and_extra = 0x000,.length2 = 0x0},
{.code_and_extra = 0x000,.length2 = 0x0},
{.code_and_extra = 0x000,.length2 = 0x0},
{.code_and_extra = 0x000,.length2 = 0x0},
{.code_and_extra = 0x000,.length2 = 0x0},
{.code_and_extra = 0x000,.length2 = 0x0},
{.code_and_extra = 0x000,.length2 = 0x0},
{.code_and_extra = 0x000,.length2 = 0x0},
{.code_and_extra = 0x000,.length2 = 0x0},
{.code_and_extra = 0x000,.length2 = 0x0},
{.code_and_extra = 0x000,.length2 = 0x0},
{.code_and_extra = 0x000,.length2 = 0x0},
{.code_and_extra = 0x000,.length2 = 0x0},
{.code_and_extra = 0x000,.length2 = 0x0},
{.code_and_extra = 0x000,.length2 = 0x0},
{.code_and_extra = 0x000,.length2 = 0x0},
{.code_and_extra = 0x000,.length2 = 0x0},
{.code_and_extra = 0x000,.length2 = 0x0},
{.code_and_extra = 0x000,.length2 = 0x0},
{.code_and_extra = 0x000,.length2 = 0x0},
{.code_and_extra = 0x000,.length2 = 0x0},
{.code_and_extra = 0x000,.length2 = 0x0},
{.code_and_extra = 0x000,.length2 = 0x0},
{.code_and_extra = 0x000,.length2 = 0x0},
{.code_and_extra = 0x000,.length2 = 0x0},
{.code_and_extra = 0x000,.length2 = 0x0},
{.code_and_extra = 0x000,.length2 = 0x0},
{.code_and_extra = 0x000,.length2 = 0x0},
{.code_and_extra = 0x000,.length2 = 0x0},
{.code_and_extra = 0x000,.length2 = 0x0},
{.code_and_extra = 0x000,.length2 = 0x0},
{.code_and_extra = 0x000,.length2 = 0x0},
{.code_and_extra = 0x000,.length2 = 0x0},
{.code_and_extra = 0x000,.length2 = 0x0},
{.code_and_extra = 0x000,.length2 = 0x0},
{.code_and_extra = 0x000,.length2 = 0x0},
{.code_and_extra = 0x000,.length2 = 0x0},
{.code_and_extra = 0x000,.length2 = 0x0},
{.code_and_extra = 0x000,.length2 = 0x0},
{.code_and_extra = 0x000,.length2 = 0x0},
{.code_and_extra = 0x000,.length2 = 0x0},
{.code_and_extra = 0x000,.length2 = 0x0},
{.code_and_extra = 0x000,.length2 = 0x0},
{.code_and_extra = 0x000,.length2 = 0x0},
{.code_and_extra = 0x000,.length2 = 0x0},
{.code_and_extra = 0x000,.length2 = 0x0},
{.code_and_extra = 0x000,.length2 = 0x0},
{.code_and_extra = 0x000,.length2 = 0x0},
{.code_and_extra = 0x000,.length2 = 0x0},
{.code_and_extra = 0x000,.length2 = 0x0},
{.code_and_extra = 0x000,.length2 = 0x0},
{.code_and_extra = 0x000,.length2 = 0x0},
{.code_and_extra = 0x000,.length2 = 0x0},
{.code_and_extra = 0x000,.length2 = 0x0},
{.code_and_extra = 0x000,.length2 = 0x0},
{.code_and_extra = 0x000,.length2 = 0x0},
{.code_and_extra = 0x000,.length2 = 0x0},
{.code_and_extra = 0x000,.length2 = 0x0},
{.code_and_extra = 0x000,.length2 = 0x0},
{.code_and_extra = 0x000,.length2 = 0x0},
{.code_and_extra = 0x000,.length2 = 0x0},
{.code_and_extra = 0x000,.length2 = 0x0},
{.code_and_extra = 0x000,.length2 = 0x0},
{.code_and_extra = 0x000,.length2 = 0x0},
{.code_and_extra = 0x000,.length2 = 0x0},
{.code_and_extra = 0x000,.length2 = 0x0},
{.code_and_extra = 0x000,.length2 = 0x0},
{.code_and_extra = 0x000,.length2 = 0x0},
{.code_and_extra = 0x000,.length2 = 0x0},
{.code_and_extra = 0x000,.length2 = 0x0},
{.code_and_extra = 0x000,.length2 = 0x0},
{.code_and_extra = 0x000,.length2 = 0x0},
{.code_and_extra = 0x000,.length2 = 0x0},
{.code_and_extra = 0x000,.length2 = 0x0},
{.code_and_extra = 0x000,.length2 = 0x0},
{.code_and_extra = 0x000,.length2 = 0x0},
{.code_and_extra = 0x000,.length2 = 0x0},
{.code_and_extra = 0x000,.length2 = 0x0},
{.code_and_extra = 0x000,.length2 = 0x0},
{.code_and_extra = 0x000,.length2 = 0x0},
{.code_and_extra = 0x000,.length2 = 0x0},
{.code_and_extra = 0x000,.length2 = 0x0},
{.code_and_extra = 0x000,.length2 = 0x0},
{.code_and_extra = 0x000,.length2 = 0x0},
{.code_and_extra = 0x000,.length2 = 0x0},
{.code_and_extra = 0x000,.length2 = 0x0},
{.code_and_extra = 0x000,.length2 = 0x0},
{.code_and_extra = 0x000,.length2 = 0x0},
{.code_and_extra = 0x000,.length2 = 0x0},
{.code_and_extra = 0x000,.length2 = 0x0},
{.code_and_extra = 0x000,.length2 = 0x0},
{.code_and_extra = 0x000,.length2 = 0x0},
{.code_and_extra = 0x000,.length2 = 0x0},
{.code_and_extra = 0x000,.length2 = 0x0},
{.code_and_extra = 0x000,.length2 = 0x0},
{.code_and_extra = 0x000,.length2 = 0x0},
{.code_and_extra = 0x000,.length2 = 0x0},
{.code_and_extra = 0x000,.length2 = 0x0},
{.code_and_extra = 0x000,.length2 = 0x0},
{.code_and_extra = 0x000,.length2 = 0x0},
{.code_and_extra = 0x000,.length2 = 0x0},
{.code_and_extra = 0x000,.length2 = 0x0},
{.code_and_extra = 0x000,.length2 = 0x0},
{.code_and_extra = 0x000,.length2 = 0x0},
{.code_and_extra = 0x000,.length2 = 0x0},
{.code_and_extra = 0x000,.length2 = 0x0},
{.code_and_extra = 0x000,.length2 = 0x0},
{.code_and_extra = 0x000,.length2 = 0x0},
{.code_and_extra = 0x000,.length2 = 0x0},
{.code_and_extra = 0x000,.length2 = 0x0},
{.code_and_extra = 0x000,.length2 = 0x0},
{.code_and_extra = 0x000,.length2 = 0x0},
{.code_and_extra = 0x000,.length2 = 0x0},
{.code_and_extra = 0x000,.length2 = 0x0},
{.code_and_extra = 0x000,.length2 = 0x0},
{.code_and_extra = 0x000,.length2 = 0x0},
{.code_and_extra = 0x000,.length2 = 0x0},
{.code_and_extra = 0x000,.length2 = 0x0},
{.code_and_extra = 0x000,.length2 = 0x0},
{.code_and_extra = 0x000,.length2 = 0x0},
{.code_and_extra = 0x000,.length2 = 0x0},
{.code_and_extra = 0x000,.length2 = 0x0},
{.code_and_extra = 0x000,.length2 = 0x0},
{.code_and_extra = 0x000,.length2 = 0x0},
{.code_and_extra = 0x000,.length2 = 0x0},
{.code_and_extra = 0x000,.length2 = 0x0},
{.code_and_extra = 0x000,.length2 = 0x0},
{.code_and_extra = 0x000,.length2 = 0x0},
{.code_and_extra = 0x000,.length2 = 0x0}},
.dist_table = {
{.code_and_extra = 0x000,.length2 = 0x5},
{.code_and_extra = 0x010,.length2 = 0x5},
{.code_and_extra = 0x008,.length2 = 0x5},
{.code_and_extra = 0x018,.length2 = 0x5},
{.code_and_extra = 0x10004,.length2 = 0x5},
{.code_and_extra = 0x10014,.length2 = 0x5},
{.code_and_extra = 0x2000c,.length2 = 0x5},
{.code_and_extra = 0x2001c,.length2 = 0x5},
{.code_and_extra = 0x30002,.length2 = 0x5},
{.code_and_extra = 0x30012,.length2 = 0x5},
{.code_and_extra = 0x4000a,.length2 = 0x5},
{.code_and_extra = 0x4001a,.length2 = 0x5},
{.code_and_extra = 0x50006,.length2 = 0x5},
{.code_and_extra = 0x50016,.length2 = 0x5},
{.code_and_extra = 0x6000e,.length2 = 0x5},
{.code_and_extra = 0x6001e,.length2 = 0x5},
{.code_and_extra = 0x70001,.length2 = 0x5},
{.code_and_extra = 0x70011,.length2 = 0x5},
{.code_and_extra = 0x80009,.length2 = 0x5},
{.code_and_extra = 0x80019,.length2 = 0x5},
{.code_and_extra = 0x90005,.length2 = 0x5},
{.code_and_extra = 0x90015,.length2 = 0x5},
{.code_and_extra = 0xa000d,.length2 = 0x5},
{.code_and_extra = 0xa001d,.length2 = 0x5},
{.code_and_extra = 0xb0003,.length2 = 0x5},
{.code_and_extra = 0xb0013,.length2 = 0x5},
{.code_and_extra = 0xc000b,.length2 = 0x5},
{.code_and_extra = 0xc001b,.length2 = 0x5},
{.code_and_extra = 0xd0007,.length2 = 0x5},
{.code_and_extra = 0xd0017,.length2 = 0x5},
{.code_and_extra = 0x000,.length2 = 0x0}}
};
struct slver {
uint16_t snum;
uint8_t ver;
@ -446,12 +1009,6 @@ static inline uint32_t set_dist_huff_codes(struct huff_code *codes, uint32_t * b
uint32_t next_code[MAX_DEFLATE_CODE_LEN + 1];
uint32_t max_code = 0;
const uint32_t num_codes = DIST_LEN;
const uint32_t num_eb[] = {
0x0, 0x0, 0x0, 0x0, 0x1, 0x1, 0x2, 0x2,
0x3, 0x3, 0x4, 0x4, 0x5, 0x5, 0x6, 0x6,
0x7, 0x7, 0x8, 0x8, 0x9, 0x9, 0xa, 0xa,
0xb, 0xb, 0xc, 0xc, 0xd, 0xd
};
code = bl_count[0] = 0;
for (bits = 1; bits <= MAX_HUFF_TREE_DEPTH; bits++) {
@ -462,7 +1019,7 @@ static inline uint32_t set_dist_huff_codes(struct huff_code *codes, uint32_t * b
code_len = codes[i].length;
if (code_len != 0) {
codes[i].code = bit_reverse(next_code[code_len], code_len);
codes[i].extra_bit_count = num_eb[i];
codes[i].extra_bit_count = dist_code_extra_bits[i];
next_code[code_len] += 1;
max_code = i;
}
@ -994,11 +1551,18 @@ create_hufftables_icf(struct BitBuf2 *bb, struct hufftables_icf *hufftables,
uint64_t cl_counts[CODE_LEN_CODES];
uint16_t combined_table[LIT_LEN + DIST_LEN];
int i;
uint64_t compressed_len = 0;
uint64_t static_compressed_len = 3; /* The static header size */
struct BitBuf2 bb_tmp;
struct huff_code *ll_codes = hufftables->lit_len_table;
struct huff_code *d_codes = hufftables->dist_table;
uint32_t *ll_hist = hist->ll_hist;
uint32_t *d_hist = hist->d_hist;
struct huff_code *static_ll_codes = static_hufftables.lit_len_table;
struct huff_code *static_d_codes = static_hufftables.dist_table;
memcpy(&bb_tmp, bb, sizeof(struct BitBuf2));
flatten_ll(hist->ll_hist);
@ -1021,10 +1585,27 @@ create_hufftables_icf(struct BitBuf2 *bb, struct hufftables_icf *hufftables,
/* Run length encode the length and distance huffman codes */
memset(cl_counts, 0, sizeof(cl_counts));
for (i = 0; i < max_ll_code + 1; i++)
for (i = 0; i <= 256; i++) {
combined_table[i] = ll_codes[i].length;
for (i = 0; i < max_d_code + 1; i++)
compressed_len += ll_codes[i].length * ll_hist[i];
static_compressed_len += static_ll_codes[i].length * ll_hist[i];
}
for (; i < max_ll_code + 1; i++) {
combined_table[i] = ll_codes[i].length;
compressed_len +=
(ll_codes[i].length + len_code_extra_bits[i - 257]) * ll_hist[i];
static_compressed_len +=
(static_ll_codes[i].length + len_code_extra_bits[i - 257]) * ll_hist[i];
}
for (i = 0; i < max_d_code + 1; i++) {
combined_table[i + max_ll_code + 1] = d_codes[i].length;
compressed_len += (d_codes[i].length + dist_code_extra_bits[i]) * d_hist[i];
static_compressed_len +=
(static_d_codes[i].length + dist_code_extra_bits[i]) * d_hist[i];
}
expand_hufftables_icf(hufftables);
@ -1034,5 +1615,13 @@ create_hufftables_icf(struct BitBuf2 *bb, struct hufftables_icf *hufftables,
/* Create header */
create_header(bb, cl_tokens, num_cl_tokens, cl_counts, max_ll_code - 256, max_d_code,
end_of_block);
compressed_len += 8 * buffer_used(bb) + bb->m_bit_count;
if (static_compressed_len < compressed_len) {
memcpy(hufftables, &static_hufftables, sizeof(struct hufftables_icf));
expand_hufftables_icf(hufftables);
memcpy(bb, &bb_tmp, sizeof(struct BitBuf2));
end_of_block = end_of_block ? 1 : 0;
write_bits(bb, 0x2 | end_of_block, 3);
}
}

View File

@ -761,9 +761,6 @@ int isal_deflate_stateless(struct isal_zstream *stream)
uint32_t crc32 = 0;
uint32_t stored_len;
uint32_t dyn_min_len;
uint32_t min_len;
uint32_t select_stored_blk = 0;
/* Final block has already been written */
stream->internal_state.has_eob_hdr = 0;
@ -792,42 +789,28 @@ int isal_deflate_stateless(struct isal_zstream *stream)
contains the EOB
*/
dyn_min_len = stream->hufftables->deflate_hdr_count + 1;
if (stream->gzip_flag == IGZIP_GZIP) {
dyn_min_len += gzip_hdr_bytes + gzip_trl_bytes + 1;
if (stream->gzip_flag == IGZIP_GZIP)
stored_len += gzip_hdr_bytes + gzip_trl_bytes;
} else if (stream->gzip_flag == IGZIP_GZIP_NO_HDR) {
dyn_min_len += gzip_trl_bytes + 1;
else if (stream->gzip_flag == IGZIP_GZIP_NO_HDR)
stored_len += gzip_trl_bytes;
}
min_len = dyn_min_len;
if (stored_len < dyn_min_len) {
min_len = stored_len;
select_stored_blk = 1;
}
/*
the output buffer should be no less than 8 bytes
while empty stored deflate block is 5 bytes only
*/
if (avail_out < min_len || stream->avail_out < 8)
if (stream->avail_out < 8)
return STATELESS_OVERFLOW;
if (!select_stored_blk) {
if (isal_deflate_int_stateless(stream) == COMP_OK)
return COMP_OK;
else {
if (stream->flush == FULL_FLUSH) {
stream->internal_state.file_start =
(uint8_t *) & stream->internal_state.buffer;
reset_match_history(stream);
}
stream->internal_state.has_eob_hdr = 0;
if (isal_deflate_int_stateless(stream) == COMP_OK)
return COMP_OK;
else {
if (stream->flush == FULL_FLUSH) {
stream->internal_state.file_start =
(uint8_t *) & stream->internal_state.buffer;
reset_match_history(stream);
}
stream->internal_state.has_eob_hdr = 0;
}
if (avail_out < stored_len)