{"id":18409303,"url":"https://github.com/sdtelectronics/muzic","last_synced_at":"2025-04-12T21:51:24.013Z","repository":{"id":50344600,"uuid":"501492240","full_name":"SdtElectronics/muzic","owner":"SdtElectronics","description":"Minimalistic compression library conforming (a subset of) Zlib's interface, including streaming operation","archived":false,"fork":false,"pushed_at":"2022-08-02T10:58:43.000Z","size":167,"stargazers_count":3,"open_issues_count":0,"forks_count":0,"subscribers_count":1,"default_branch":"master","last_synced_at":"2025-02-16T05:16:04.398Z","etag":null,"topics":["compression","deflate","inflate","rfc-1950","rfc-1951"],"latest_commit_sha":null,"homepage":"","language":"C","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"other","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/SdtElectronics.png","metadata":{"files":{"readme":"Readme.md","changelog":null,"contributing":null,"funding":null,"license":null,"code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null}},"created_at":"2022-06-09T03:34:10.000Z","updated_at":"2022-10-31T08:32:37.000Z","dependencies_parsed_at":"2022-08-31T00:22:27.566Z","dependency_job_id":null,"html_url":"https://github.com/SdtElectronics/muzic","commit_stats":null,"previous_names":[],"tags_count":0,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/SdtElectronics%2Fmuzic","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/SdtElectronics%2Fmuzic/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/SdtElectronics%2Fmuzic/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/SdtElectronics%2Fmuzic/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/SdtElectronics","download_url":"https://codeload.github.com/SdtElectronics/muzic/tar.gz/refs/heads/master","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":248637832,"owners_count":21137538,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2022-07-04T15:15:14.044Z","host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":["compression","deflate","inflate","rfc-1950","rfc-1951"],"created_at":"2024-11-06T03:24:35.881Z","updated_at":"2025-04-12T21:51:23.992Z","avatar_url":"https://github.com/SdtElectronics.png","language":"C","funding_links":[],"categories":[],"sub_categories":[],"readme":"# muzic\nThis library encapsulates a DEFLATE and INFLATE engine to provide a set of compression APIs partially compatible with Zlib. Specifically, it supports Zlib-style streaming operation for both compression and decompression, and RFC-1950 wrapper for raw DEFLATE stream. The objectives of this library are simplicity and lightweight, rather than performance and comprehensiveness, so that it can be integrated on embedded platforms.\n\n## Supported Zlib APIs\nPlease also refer to the [Zlib Manual](https://www.zlib.net/manual.html) for the complete description of APIs. Note that behaviors of functions in this library are not strictly identical to their Zlib counterparts, and differences are stated below.\n\n### DEFLATE\n* `int deflateInit(z_stream* strm, int level)`\n\n    Initializes the internal stream state for compression. Currently, parameter `level` is not used, but preserved for compatibility with Zlib.\n\n* `int deflate(z_stream* strm, int flush)`\n\n    `deflate` compresses as much data as possible, and stops when the input buffer becomes empty or the output buffer becomes full. For flush modes, currently, only `Z_FULL_FLUSH` and `Z_FINISH` are supported. When modes other than `Z_FINISH` is passed via `flush`, the behavior of this function is the same as when `Z_FULL_FLUSH` is passed.\n\n* `int deflateEnd(z_stream* strm)`\n\n    All dynamically allocated data structures for this stream are freed. This function discards any unprocessed input and does not flush any pending output.\n\n### INFLATE\n* `int inflateInit(z_stream* strm)`\n\n    Initializes the internal stream state for decompression.\n\n* `int inflate(z_stream* strm, int flush)`\n\n    `inflate` decompresses as much data as possible, and stops when the input buffer becomes empty or the output buffer becomes full. Currently, parameter `flush` is not used, but preserved for compatibility with Zlib. The behavior of this function is always similar to the Zlib counterpart being fed with the option `Z_SYNC_FLUSH`. When macro `MZ_ZLIB_CHECKSUM` is not defined, `inflate` returns `Z_STREAM_END` immediately after the last block is consumed. When macro `MZ_ZLIB_CHECKSUM` is defined, it will further consume a 4-byte adler32 checksum after the last block, and if this block is not presented, it returns `Z_OK` instead of `Z_STREAM_END`. This behavior is similar to the zlib counterpart when `inflateInit()` is called to initialize the stream. See section [Zlib stream checksum]() for more information.\n\n* `int inflateEnd(z_stream* strm)`\n\n    All dynamically allocated data structures for this stream are freed. This function discards any unprocessed input and does not flush any pending output.\n\n### Structures and macros\n`z_stream` is the only structure that Zlib exposed to users to interact with DEFLATE and INFLATE APIs. All fields are replicated with their original names, while only the first 7 fields are used, and the rest are dumb variables reserved for compatibility.\n\nMacros representing states and flush modes are preserved. They can be found in `zlib_comp.h`.\n\n## Build and integration\nThe structure of this library is simple and flat, and no dependency other than libc is required. To use DEFLATE APIs, include `zlib_comp.h` and add `defl_static.c`, `genlz77.c` and `zlib_comp.c` to sources. To use INFLATE APIs, include `zlib_comp.h` and add `inflater.c`, `zlib_comp.c` to sources.\n\nCMake is also supported. To use this library as a subproject, simply add `muzic` to `target_link_libraries` of targets depend on this library.\n\n## Notes\n### Zlib stream header\nZlib pads raw deflate stream with a 2-byte header conforming [RFC-1950](https://www.rfc-editor.org/rfc/rfc1950) by default. To emulate this behavior, the macro `MZ_ZLIB_HEADER` must be enabled in `mz_config.h` (it's enabled by default). Only when `inflateInit2()` and `deflateInit2()` are called with `windowBits` set to negative values, Zlib will generate and accept raw deflate stream without the header, and `MZ_ZLIB_HEADER` can be disabled. Otherwise, Zlib will signal an error when decompressing the stream produced by muzic, and muzic won't be able to decompress stream produced by Zlib if `MZ_ZLIB_HEADER` is disabled.\n\n### Zlib stream checksum\nZlib ends raw deflate stream with a 4-byte checksum conforming [RFC-1950](https://www.rfc-editor.org/rfc/rfc1950) by default. To emulate this behavior, the macro `MZ_ZLIB_CHECKSUM` must be enabled in `mz_config.h` (it's enabled by default).\n\n## Comparison with Zlib\n### Binary size\nTested on Linux x86_64 with gcc 11.1.0, CMake option `CMAKE_BUILD_TYPE=Release`\n| Binary               | muzic           | Zlib              |\n|----------------------|-----------------|-------------------|\n| Static library       | 23664B (23.1KB) | 125522B (122.6KB) |\n| examples/defl2stdout | 21152B (20.7KB) | 56112B (54.8KB)   |\n| examples/infl4stdin  | 25456B (24.9KB) | 47184B (46.1KB)   |\n\n\n### Memory usage\nTested on Linux x86_64 with gcc 11.1.0, CMake option `CMAKE_BUILD_TYPE=Release`\n\nProfiler: valgrind-3.18.1 with option `--tool=massif --stacks=yes`\n\n| Binary               | muzic (stack/heap/total) | Zlib (stack/heap/total)   |\n|----------------------|--------------------------|---------------------------|\n| examples/defl2stdout | 3.6KB / 33.1KB / 36.7KB  | 3.6KB / 262.9KB / 266.5KB |\n| examples/infl4stdin  | 3.3KB / 22.0KB / 25.3KB  | 3.3KB / 40.0KB / 43.3KB   |\n\n## TODO:\n* Support `Z_BLOCK` mode for `inflate()`\n* Benchmarks\n\n## Credits\n### DEFLATE engine: part of [uzlib](https://github.com/pfalcon/uzlib)\n(c) 2014-2020 Paul Sokolovsky\n\n### INFLATE engine: [Inflater](https://github.com/martin-rizzo/Inflater)\nCopyright (c) 2020 Martin Rizzo\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fsdtelectronics%2Fmuzic","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fsdtelectronics%2Fmuzic","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fsdtelectronics%2Fmuzic/lists"}