-
Notifications
You must be signed in to change notification settings - Fork 305
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Had trouble in using isal_deflate_set_dict #206
Comments
To use a preset dictionary and zlib header you need to use isal_deflate_set_dict(&stream, dict, len);
struct isal_zlib_header zlib_hdr;
zlib_hdr.info = ISAL_DEF_MAX_HIST_BITS - 8;
zlib_hdr.level = stream.level ? 1 : 0;
zlib_hdr.dict_flag = 1;
zlib_hdr.dict_id = isal_adler32(1, dict, len);
stream.avail_out = BUF_SIZE;
stream.next_out = outbuf;
isal_write_zlib_header(&stream, &zlib_hdr);
fwrite(outbuf, 1, BUF_SIZE - stream.avail_out, out);
stream.gzip_flag = ISAL_ZLIB_NO_HDR;
do {
... This will set the dictionary flag FLG.FDICT (5) and write the dictionary id.
When using
|
Thanks Greg, that works. |
Is zlib_hdr.level always set to 1 no matter what compress level isa-l is or just for level 3? I'd like to know the mapping between isa-l compress level and the zlib_hdr.level. And the same question to zlib_hdr.info. |
Moreover, I'd like to ask a question about isal_write_zlib_header().
However default zlib header looks below:
Should dict_id be written in zlib header in big endian?
by
|
For answers to questions like these
The specification of the zlib format provides clarity: https://datatracker.ietf.org/doc/rfc1950/ All numbers in zlib format are stored in a big-endian fashion, also known as network order. Probably because the zlib format was designed with a network use case in mind. |
Thanks for reply. ISA-L writes zlib trailer(adler32) in big-endian, see igzip/igzip.c
I think ISA-L is compatible with default zlib in this, so there's no reason for ISA-L to write dict_id(this is also a adler32) in little-endian? |
That looks like a bug. Probably because in |
I created a PR, #207, if it is a bug indeed. |
The zlib_hdr.level is not the same as user compression level and we map to 0 or 1 based on the description in rfc1950. zlib_hdr.info will always work with maxbits - 8 but you could set this with the actual wbits set.
|
I did a little test about isal_deflate_set_dict, the test looks below: (small change of igzip/igzip_example.c)
I used this test to compress the same data, the only difference is isal_deflate_set_dict.
![image](https://user-images.githubusercontent.com/35990759/158559734-37f11686-edbb-4b90-b1e7-352b2ff1b8b4.png)
When using dictionary, the result looks below:
On the other hand, the result looks below:
![image](https://user-images.githubusercontent.com/35990759/158559608-5f6ad3e6-4696-4b6d-a8b8-96919d8934c7.png)
Therefore, the zlib header is the same in both cases. I don't think that's correct, since the zlib header should contains the dictionary message.
![image](https://user-images.githubusercontent.com/35990759/158560841-998a17c8-5c8c-438f-986f-54271c29c4fd.png)
Does isa-l deflater don't write the zlib header correctly when using dictionary?
The text was updated successfully, but these errors were encountered: