Open kirbyzhou opened 2 years ago
It does but can end after last trailer bytes by using IGZIP_ZLIB_NO_HDR or IGZIP_GZIP_NO_HDR. We don't have a IGZIP_DEFLATE_NO_HDR equivalent yet.
int nowrap = 0;
...
strm->crc_flag = nowrap ? ISAL_DEFLATE : ISAL_ZLIB_NO_HDR_VER;
strm->next_in = out1 + (nowrap ? 0 : 2);
$ gcc -o test test.c -lisal -lz && ./test
level=-1 nowrap=0
128 -> 127 r=1
pre isal_inflate avail_in=135
post isal_inflate avail_in=8
127 -> 128 r=0
avail_in=8 avail_out=0
The number of eaten bits is in strm->read_in_length
. You can use that number to determine the amount of eaten bytes as well. In python-isal I do it with strm->read_in_length / 8
and that seems to work well (no off by one errors with quite extensive testing and production use).
isal_inflate with crc_flag==ISAL_DEFLATE eats extra bytes when there are extra bytes at tail. It always want to pick 64 bit at once, so if we provide extra bytes to it, it will eat it.
The demo code provides 8 extra bytes in isal_inflate, it eats 6.