A high-performance, small DEFLATE/ZLIB decompression implementation in C. Optimized for minimal memory usage and maximum throughput.
- 📌 To get best performance try to compile sources directly into project instead of external linking
- 📌 Feel free to report any bugs security issues by opening an issue
- 📌 Any performance improvements are welcome!
I'm using defl
at im project to decode PNG IDATs. The main goal of the project is to allow decode IDATs without joining them. The size of IDATs may vary, for instance lot of 1byte IDAT may exist. So in this case a hybrid approach could be benefical to reduce memory usage while increase performance a bit. The hybrid approach ( joining small data and use chunks for large data ) may be provided by this project or by im or unz. delf also used in unz which is an another unzipping / compression library (WIP).
🚨 Don't use this in production until tests are ready
Instead of embedding deflate anf huffman impl into my project, I decided to split defl and huff projects into separate repos to let others use these common requirements for some projects, also allowing each one improved independently over time
- 🔗 Option to inflate non-contiguous regions e.g. PNG IDATs
- ⚡ High-performance
- 🗜️ Full DEFLATE/ZLIB format support
- 💾 Minimal memory footprint
- 🔄 Streaming decompression support (WIP)
- 🛡️ Robust error handling
#include <defl/infl.h>
infl_stream_t st;
UnzResult res;
infl_init(&st, dst, dstlen, 1); /* 1: INFL_ZLIB or jsut pass INFL_ZLIB */
...
infl_include(st, src, srclen);
infl_include(st, src, srclen);
...
/* decompress non-contiguous regions e.g. PNG IDATs without need to merge IDATs */
res = infl(st);
#include <defl/infl.h>
infl_stream_t st;
UnzResult res;
infl_init(&st, dst, dstlen, 1); /* 1: INFL_ZLIB or jsut pass INFL_ZLIB */
/* decompress when new data avail */
res = infl_stream(st, src, srclen);
...
/* decompress again when previous response is UNZ_UNFINISHED */
if (res == UNZ_UNFINISHED) {
res = infl_stream(st, src, srclen);
}
...
if (res == UNZ_UNFINISHED) {
res = infl_stream(st, src, srclen);
}
#include <defl/infl.h>
UnzResult res;
/* decompress contiguous regions */
res = infl_buf(src, srclen, dst, dstlen 1); /* 1: INFL_ZLIB or jsut pass INFL_ZLIB */
/* or without detailed result check */
if (!infl_buf(src, srclen, dst, dstlen 1)) {
goto err; // return -1 ...
}
- implement inflate
- implement inflate stream
- implement deflate
- tests
- build
- documentation
todo