miniz: Single C source file zlib-replacement library, originally from code.google.com/p/miniz
Go to file
Matthew Smith 9cd715b3b1
build: Install .pc file in correct directory
/usr/share/pkgconfig should be used for architecture independent
libraries (e.g. data or scripts), while an architecture dependent
directory like /usr/lib64/pkgconfig should be used for native
binaries.

Co-authored-by: Sam James <sam@gentoo.org>
2022-06-04 09:22:37 +01:00
.github/workflows Add release workflow 2021-06-27 22:44:34 +02:00
examples Merge remote-tracking branch 'ccawley2011/mingw-watcom' 2021-11-11 21:36:15 +01:00
tests zip_fuzzer: omit file validation 2020-11-27 02:28:21 +01:00
.clang-format Add vogl .clang-format and reformat library source. 2016-06-25 09:03:56 -05:00
.gitignore Disable building shared lib by default 2022-02-06 14:30:35 +01:00
.travis.yml Added travis conf 2016-11-28 01:33:23 +01:00
amalgamate.sh Add MINIZ_NO_DEFLATE_APIS and MINIZ_NO_INFLATE_APIS 2021-07-20 20:19:32 +01:00
ChangeLog.md Update ChangeLog.md 2022-05-08 16:53:32 +02:00
CMakeLists.txt build: Install .pc file in correct directory 2022-06-04 09:22:37 +01:00
Config.cmake.in Modified cmake script to support shared library mode and find_package. 2019-05-27 14:16:27 +02:00
LICENSE MiniZ ZIP64 was part of valve vogl which is MIT licensed 2016-11-21 18:17:47 +01:00
meson.build Update meson.build 2020-12-20 22:11:45 +01:00
miniz_common.h Add padding to structures so it continues to work if features differ 2022-02-06 14:57:58 +01:00
miniz_tdef.c Merge pull request #231 from nedelec/master 2022-05-08 16:48:02 +02:00
miniz_tdef.h Add MINIZ_NO_DEFLATE_APIS and MINIZ_NO_INFLATE_APIS 2021-07-20 20:19:32 +01:00
miniz_tinfl.c Clear whole tree to prevent uninitialized value 2022-02-27 20:08:22 +01:00
miniz_tinfl.h Remove m_tables 2022-01-23 20:24:58 +01:00
miniz_zip.c Merge pull request #224 from Dialga/patch-1 2022-05-08 16:44:03 +02:00
miniz_zip.h replace use of stdint.h types with mz_ variants 2022-02-09 09:36:50 +03:00
miniz.c Merge pull request #193 from ccawley2011/no-inflate-deflate 2021-11-11 21:36:53 +01:00
miniz.h Increment major version 2022-02-06 14:39:27 +01:00
miniz.pc.in Use MINIZ_VERSION for the pkg-config version 2020-09-14 12:00:26 -05:00
readme.md Adjust usage text 2021-11-28 17:26:16 +01:00
test.sh Fix test 2021-06-27 23:22:31 +02:00

Miniz

Miniz is a lossless, high performance data compression library in a single source file that implements the zlib (RFC 1950) and Deflate (RFC 1951) compressed data format specification standards. It supports the most commonly used functions exported by the zlib library, but is a completely independent implementation so zlib's licensing requirements do not apply. Miniz also contains simple to use functions for writing .PNG format image files and reading/writing/appending .ZIP format archives. Miniz's compression speed has been tuned to be comparable to zlib's, and it also has a specialized real-time compressor function designed to compare well against fastlz/minilzo.

Usage

Releases are available at the releases page as a pair of miniz.c/miniz.h files which can be simply added to a project. To create this file pair the different source and header files are amalgamated during build. Alternatively use as cmake or meson module (or build system of your choice).

Features

  • MIT licensed
  • A portable, single source and header file library written in plain C. Tested with GCC, clang and Visual Studio.
  • Easily tuned and trimmed down by defines
  • A drop-in replacement for zlib's most used API's (tested in several open source projects that use zlib, such as libpng and libzip).
  • Fills a single threaded performance vs. compression ratio gap between several popular real-time compressors and zlib. For example, at level 1, miniz.c compresses around 5-9% better than minilzo, but is approx. 35% slower. At levels 2-9, miniz.c is designed to compare favorably against zlib's ratio and speed. See the miniz performance comparison page for example timings.
  • Not a block based compressor: miniz.c fully supports stream based processing using a coroutine-style implementation. The zlib-style API functions can be called a single byte at a time if that's all you've got.
  • Easy to use. The low-level compressor (tdefl) and decompressor (tinfl) have simple state structs which can be saved/restored as needed with simple memcpy's. The low-level codec API's don't use the heap in any way.
  • Entire inflater (including optional zlib header parsing and Adler-32 checking) is implemented in a single function as a coroutine, which is separately available in a small (~550 line) source file: miniz_tinfl.c
  • A fairly complete (but totally optional) set of .ZIP archive manipulation and extraction API's. The archive functionality is intended to solve common problems encountered in embedded, mobile, or game development situations. (The archive API's are purposely just powerful enough to write an entire archiver given a bit of additional higher-level logic.)

Known Problems

  • No support for encrypted archives. Not sure how useful this stuff is in practice.
  • Minimal documentation. The assumption is that the user is already familiar with the basic zlib API. I need to write an API wiki - for now I've tried to place key comments before each enum/API, and I've included 6 examples that demonstrate how to use the module's major features.

Special Thanks

Thanks to Alex Evans for the PNG writer function. Also, thanks to Paul Holden and Thorsten Scheuermann for feedback and testing, Matt Pritchard for all his encouragement, and Sean Barrett's various public domain libraries for inspiration (and encouraging me to write miniz.c in C, which was much more enjoyable and less painful than I thought it would be considering I've been programming in C++ for so long).

Thanks to Bruce Dawson for reporting a problem with the level_and_flags archive API parameter (which is fixed in v1.12) and general feedback, and Janez Zemva for indirectly encouraging me into writing more examples.

Patents

I was recently asked if miniz avoids patent issues. miniz purposely uses the same core algorithms as the ones used by zlib. The compressor uses vanilla hash chaining as described here. Also see the gzip FAQ. In my opinion, if miniz falls prey to a patent attack then zlib/gzip are likely to be at serious risk too.