https://github.com/recp/defl
fast & flexible deflate library (WIP)
https://github.com/recp/defl
compression deflate gzip huffman inflate png zip zlib
Last synced: 6 months ago
JSON representation
fast & flexible deflate library (WIP)
- Host: GitHub
- URL: https://github.com/recp/defl
- Owner: recp
- License: apache-2.0
- Created: 2025-01-10T14:36:41.000Z (9 months ago)
- Default Branch: main
- Last Pushed: 2025-02-21T05:39:18.000Z (8 months ago)
- Last Synced: 2025-04-14T13:10:30.744Z (6 months ago)
- Topics: compression, deflate, gzip, huffman, inflate, png, zip, zlib
- Language: C
- Homepage:
- Size: 62.5 KB
- Stars: 2
- Watchers: 1
- Forks: 0
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
- License: LICENSE
Awesome Lists containing this project
README
# 🗜️ defl - deflate (WIP)
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](https://github.xom/recp/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](https://github.com/recp/unz) which is an another unzipping / compression library (WIP).
🚨 Don't use this in production until tests are ready
### Design
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
![]()
### Features
- 🔗 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---
#### Usage 1: Use Non-Contiguous Chunk Api
```c
#includeinfl_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);
```#### Usage 2: Use Stream Api ( TODO: WIP )
```c
#includeinfl_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);
}
```#### Usage 3: Use Contiguous Chunk Api
```c
#includeUnzResult 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 ...
}
```## TODO
- [x] implement inflate
- [ ] implement inflate stream
- [ ] implement deflate
- [ ] tests
- [ ] build
- [ ] documentation## 🔨 Build
todo