minbit 3.1.0__tar.gz
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- minbit-3.1.0/CHANGELOG.md +37 -0
- minbit-3.1.0/CMakeLists.txt +137 -0
- minbit-3.1.0/FORMAT.md +117 -0
- minbit-3.1.0/LICENSE +21 -0
- minbit-3.1.0/MANIFEST.in +12 -0
- minbit-3.1.0/PKG-INFO +227 -0
- minbit-3.1.0/README.md +173 -0
- minbit-3.1.0/include/minbit.h +225 -0
- minbit-3.1.0/pyproject.toml +50 -0
- minbit-3.1.0/python/minbit/__init__.py +671 -0
- minbit-3.1.0/python/minbit/__main__.py +89 -0
- minbit-3.1.0/python/minbit/py.typed +0 -0
- minbit-3.1.0/python/minbit.egg-info/PKG-INFO +227 -0
- minbit-3.1.0/python/minbit.egg-info/SOURCES.txt +38 -0
- minbit-3.1.0/python/minbit.egg-info/dependency_links.txt +1 -0
- minbit-3.1.0/python/minbit.egg-info/top_level.txt +1 -0
- minbit-3.1.0/python/tests/test_minbit.py +239 -0
- minbit-3.1.0/setup.cfg +4 -0
- minbit-3.1.0/setup.py +175 -0
- minbit-3.1.0/src/c_api.cpp +814 -0
- minbit-3.1.0/src/codec/minbit_codec.hpp +1022 -0
- minbit-3.1.0/src/core/arithmetic_coder.hpp +93 -0
- minbit-3.1.0/src/core/bit_history.hpp +298 -0
- minbit-3.1.0/src/core/hash.hpp +220 -0
- minbit-3.1.0/src/core/mixer.hpp +477 -0
- minbit-3.1.0/src/core/prob_tables.hpp +100 -0
- minbit-3.1.0/src/core/simd.hpp +150 -0
- minbit-3.1.0/src/core/state_map.hpp +183 -0
- minbit-3.1.0/src/core/stream_io.hpp +97 -0
- minbit-3.1.0/src/main.cpp +353 -0
- minbit-3.1.0/src/models/context_map.hpp +309 -0
- minbit-3.1.0/src/models/fast_predictor.hpp +312 -0
- minbit-3.1.0/src/models/indirect_model.hpp +125 -0
- minbit-3.1.0/src/models/linear_model.hpp +422 -0
- minbit-3.1.0/src/models/match_model.hpp +477 -0
- minbit-3.1.0/src/models/predictor.hpp +416 -0
- minbit-3.1.0/src/models/record_model.hpp +436 -0
- minbit-3.1.0/src/models/sparse_model.hpp +141 -0
- minbit-3.1.0/src/models/word_model.hpp +241 -0
- minbit-3.1.0/src/transforms/bcj_transform.hpp +162 -0
|
@@ -0,0 +1,37 @@
|
|
|
1
|
+
# Changelog
|
|
2
|
+
|
|
3
|
+
All notable changes to MinBit are documented in this file.
|
|
4
|
+
|
|
5
|
+
## [3.1.0] - 2026-12-06
|
|
6
|
+
|
|
7
|
+
### Preset `-4` (64 MiB Ultra / Archival Mode)
|
|
8
|
+
- Added **Preset `-4`** (`cmap_bits=23` 512 MiB `ContextMap`, `match_buf_bits=26` 64 MiB window, `match_hash_bits=21` 112 MiB hash chains, 8×/16× larger `IndirectModel` Order-3/Order-4 tables; ~710 MB RAM/thread; 48–64 MiB auto block sizing for `enwik8`/`enwik9`).
|
|
9
|
+
- **Full 100 MB `enwik8` #1 Overall**: `minbit -4 -T0` achieves **19,576,877 B (`1.5662 bpb`)**, beating `zpaq -m5` (`19,625,007 B` / `1.5700 bpb`) by **-48,130 B (-0.25%)** and `xz -9e` by **-21.16%**.
|
|
10
|
+
- **`enwik8_10m`**: drops to **2,045,519 B (`1.6364 bpb`)**, **-2.19%** smaller than `zpaq -m5`.
|
|
11
|
+
- **Silesia `webster` (41.5 MB)**: drops **-422.6 KB** to **5,660,825 B (`1.0923 bpb`)**, beating `zpaq -m5` (`5,666,828 B`) for **11 / 12** head-to-head Silesia file wins.
|
|
12
|
+
- **100% Backward Compatible**: Levels `0..3` produce bit-for-bit identical `.mbit` v3 streams to `v3.0.0`.
|
|
13
|
+
- Added `--version` / `-V` CLI flag and `MINBIT_MAX_LEVEL = 4` in C11 and Python APIs.
|
|
14
|
+
|
|
15
|
+
### PyPI Native-Wheel Packaging & Homebrew Formula
|
|
16
|
+
- Root PEP-517 packaging (`pyproject.toml`, `setup.py`, `MANIFEST.in`) compiling self-contained `py3-none-<platform>` wheels (one wheel works across Python 3.9–3.14+ and PyPy!) plus `python -m minbit` CLI.
|
|
17
|
+
- Automated multi-OS wheel & sdist CI + OIDC Trusted Publisher workflow (`.github/workflows/pypi.yml`) targeting macOS (`arm64`, `x86_64`), Linux (`manylinux_2_28_x86_64`, `manylinux_2_28_aarch64`), and Windows (`win_amd64` with `/MT` static CRT).
|
|
18
|
+
- Added Homebrew formula (`Formula/minbit.rb`) with automated CLI + C11 library `test do` block and `packaging/update_homebrew_formula.py` helper.
|
|
19
|
+
|
|
20
|
+
## [3.0.0] - 2026-11-30
|
|
21
|
+
|
|
22
|
+
### Core Compression Engine & Modeling
|
|
23
|
+
- **Bitwise Context Mixing Engine** with 24-context 64-byte cache-aligned `ContextMap`, zero-collision L2 `DirectSparseModel`, `IndirectModel`, 4-way multi-hash-chain `MatchModel` (3B/5B/8B/12B + shadow resync), 7-mixer Stage-1 + 3-mixer Stage-2 + 5-APM Stage-3 + post-calibration APM cascade.
|
|
24
|
+
- **Pareto Fast-CM Preset (`-0`)** (~12 MB RAM/thread): 32-feature streamlined predictor matching `zstd -22` / `xz -9e` multi-core encode speed while delivering 12%–30% smaller files.
|
|
25
|
+
- **16-bit Carry-Aware Spatial Prediction & Out-of-Sample Verified AMDF**: Auto-detects multi-byte pixel/channel stride (`sx ∈ {1,2,3,4}`), 16-bit little-endian byte phase, and exact 2D row widths, resolving MSB carry from the observed LSB.
|
|
26
|
+
- **Unfragmented Lexical & Structural `WordModel`**: Unfragmented case-folded word & skip-bigram contexts, `PrevLine` column alignment, and 8-deep XML/HTML `<tag>` + bracket/quote nesting.
|
|
27
|
+
- **Cross-Platform Bit-Exact SIMD**: Unified bit-for-bit identical execution across ARM64 NEON, x86-64 AVX2, x86-64 SSSE3/SSE2, and Scalar, backed by deterministic `det_exp` / `det_log` / `det_round`.
|
|
28
|
+
|
|
29
|
+
### Format v3, Streaming & Security
|
|
30
|
+
- **Streaming Chunked `.mbit` v3 Format** (backward-compatible decoding for v1/v2): bounded-RAM pipelined multi-threaded compression & decompression with `stdin`/`stdout` pipe support (`-`).
|
|
31
|
+
- **Integrity & Hardening**: Header CRC-16/CCITT, per-block IEEE CRC-32, whole-stream XXH64 + total length/block-count footer, 64 MiB hard anti-OOM ceiling, configurable `--max-out-mb` anti-zip-bomb limit, strictly bijective ARM64 & x86 BCJ filters, and clean `ASan+UBSan` + adversarial fuzzing verification.
|
|
32
|
+
|
|
33
|
+
### Libraries, Bindings & CI
|
|
34
|
+
- **Stable C11 Public API** (`include/minbit.h`, `libminbit.a`, `libminbit.{dylib,so,dll}`): buffer, library-allocated, streaming file, and custom I/O callback tiers (19 clean exported C symbols).
|
|
35
|
+
- **Zero-Dependency Python Package** (`python/minbit`): full type annotations (`py.typed`), GIL-releasing native calls, streaming file-like object support with faithful exception propagation.
|
|
36
|
+
- **International Standard Corpus Benchmarks**: Verified lossless across all 42 files of Silesia (211.94 MB), Canterbury (2.81 MB), Calgary (3.25 MB), and `enwik8` (10 MB & 100 MB), outperforming `zpaq -m5` on Silesia (-1.12%), Canterbury (-5.75%), Calgary (-5.90%), and `enwik8_10m` (-0.65%).
|
|
37
|
+
- **3-OS GitHub Actions CI/CD**: Automated build, unit/C11/Python/fuzz/ASan testing on macOS ARM64, Linux x86-64 (GCC & Clang), and Windows MSVC x64, plus cross-OS bit-exact archive SHA-256 verification.
|
|
@@ -0,0 +1,137 @@
|
|
|
1
|
+
cmake_minimum_required(VERSION 3.16)
|
|
2
|
+
project(minbit VERSION 3.1.0 LANGUAGES C CXX)
|
|
3
|
+
|
|
4
|
+
set(CMAKE_CXX_STANDARD 20)
|
|
5
|
+
set(CMAKE_CXX_STANDARD_REQUIRED ON)
|
|
6
|
+
set(CMAKE_CXX_EXTENSIONS OFF)
|
|
7
|
+
|
|
8
|
+
set(CMAKE_C_STANDARD 11)
|
|
9
|
+
set(CMAKE_C_STANDARD_REQUIRED ON)
|
|
10
|
+
set(CMAKE_C_EXTENSIONS OFF)
|
|
11
|
+
|
|
12
|
+
option(MINBIT_NATIVE_OPT "Enable -mcpu=native / -march=native / /arch:AVX2 host tuning" ON)
|
|
13
|
+
option(MINBIT_BUILD_SHARED "Build shared library (libminbit.so/.dylib/minbit.dll)" ON)
|
|
14
|
+
option(MINBIT_BUILD_STATIC "Build static library (libminbit.a/minbit_static.lib)" ON)
|
|
15
|
+
option(MINBIT_BUILD_TESTS "Build C++ and C11 test suites" ON)
|
|
16
|
+
|
|
17
|
+
find_package(Threads REQUIRED)
|
|
18
|
+
include(GNUInstallDirs)
|
|
19
|
+
|
|
20
|
+
function(minbit_apply_cxx_flags target opt_level)
|
|
21
|
+
if(MSVC)
|
|
22
|
+
target_compile_options(${target} PRIVATE /O2 /W4 /EHsc)
|
|
23
|
+
target_compile_definitions(${target} PRIVATE _CRT_SECURE_NO_WARNINGS)
|
|
24
|
+
if(MINBIT_NATIVE_OPT AND (CMAKE_SYSTEM_PROCESSOR MATCHES "AMD64|x86_64|X64"))
|
|
25
|
+
target_compile_options(${target} PRIVATE /arch:AVX2)
|
|
26
|
+
endif()
|
|
27
|
+
else()
|
|
28
|
+
target_compile_options(${target} PRIVATE ${opt_level} -Wall -Wextra -Wpedantic)
|
|
29
|
+
if(MINBIT_NATIVE_OPT)
|
|
30
|
+
if(APPLE AND CMAKE_SYSTEM_PROCESSOR MATCHES "arm64|aarch64")
|
|
31
|
+
target_compile_options(${target} PRIVATE -mcpu=native)
|
|
32
|
+
else()
|
|
33
|
+
target_compile_options(${target} PRIVATE -march=native)
|
|
34
|
+
endif()
|
|
35
|
+
endif()
|
|
36
|
+
endif()
|
|
37
|
+
endfunction()
|
|
38
|
+
|
|
39
|
+
# Static library (libminbit.a / minbit_static.lib)
|
|
40
|
+
if(MINBIT_BUILD_STATIC)
|
|
41
|
+
add_library(minbit_static STATIC src/c_api.cpp)
|
|
42
|
+
set_target_properties(minbit_static PROPERTIES
|
|
43
|
+
OUTPUT_NAME minbit
|
|
44
|
+
POSITION_INDEPENDENT_CODE ON
|
|
45
|
+
)
|
|
46
|
+
if(MSVC)
|
|
47
|
+
set_target_properties(minbit_static PROPERTIES OUTPUT_NAME minbit_static)
|
|
48
|
+
endif()
|
|
49
|
+
target_include_directories(minbit_static
|
|
50
|
+
PUBLIC
|
|
51
|
+
$<BUILD_INTERFACE:${CMAKE_CURRENT_SOURCE_DIR}/include>
|
|
52
|
+
$<INSTALL_INTERFACE:${CMAKE_INSTALL_INCLUDEDIR}>
|
|
53
|
+
PRIVATE
|
|
54
|
+
${CMAKE_CURRENT_SOURCE_DIR}/src
|
|
55
|
+
)
|
|
56
|
+
target_link_libraries(minbit_static PUBLIC Threads::Threads)
|
|
57
|
+
minbit_apply_cxx_flags(minbit_static -O3)
|
|
58
|
+
add_library(minbit::static ALIAS minbit_static)
|
|
59
|
+
endif()
|
|
60
|
+
|
|
61
|
+
# Shared library (libminbit.dylib / libminbit.so / minbit.dll)
|
|
62
|
+
if(MINBIT_BUILD_SHARED)
|
|
63
|
+
add_library(minbit_shared SHARED src/c_api.cpp)
|
|
64
|
+
set_target_properties(minbit_shared PROPERTIES
|
|
65
|
+
OUTPUT_NAME minbit
|
|
66
|
+
VERSION ${PROJECT_VERSION}
|
|
67
|
+
SOVERSION ${PROJECT_VERSION_MAJOR}
|
|
68
|
+
CXX_VISIBILITY_PRESET hidden
|
|
69
|
+
VISIBILITY_INLINES_HIDDEN ON
|
|
70
|
+
)
|
|
71
|
+
target_compile_definitions(minbit_shared PRIVATE MINBIT_BUILDING_SHARED)
|
|
72
|
+
target_include_directories(minbit_shared
|
|
73
|
+
PUBLIC
|
|
74
|
+
$<BUILD_INTERFACE:${CMAKE_CURRENT_SOURCE_DIR}/include>
|
|
75
|
+
$<INSTALL_INTERFACE:${CMAKE_INSTALL_INCLUDEDIR}>
|
|
76
|
+
PRIVATE
|
|
77
|
+
${CMAKE_CURRENT_SOURCE_DIR}/src
|
|
78
|
+
)
|
|
79
|
+
target_link_libraries(minbit_shared PRIVATE Threads::Threads)
|
|
80
|
+
minbit_apply_cxx_flags(minbit_shared -O3)
|
|
81
|
+
add_library(minbit::shared ALIAS minbit_shared)
|
|
82
|
+
add_library(minbit::minbit ALIAS minbit_shared)
|
|
83
|
+
elseif(MINBIT_BUILD_STATIC)
|
|
84
|
+
add_library(minbit::minbit ALIAS minbit_static)
|
|
85
|
+
endif()
|
|
86
|
+
|
|
87
|
+
# CLI executable
|
|
88
|
+
add_executable(minbit src/main.cpp)
|
|
89
|
+
target_include_directories(minbit PRIVATE ${CMAKE_CURRENT_SOURCE_DIR}/src)
|
|
90
|
+
target_link_libraries(minbit PRIVATE Threads::Threads)
|
|
91
|
+
minbit_apply_cxx_flags(minbit -O3)
|
|
92
|
+
|
|
93
|
+
# Unit & API tests
|
|
94
|
+
if(MINBIT_BUILD_TESTS)
|
|
95
|
+
enable_testing()
|
|
96
|
+
|
|
97
|
+
add_executable(test_minbit tests/test_minbit.cpp)
|
|
98
|
+
target_include_directories(test_minbit PRIVATE ${CMAKE_CURRENT_SOURCE_DIR}/src)
|
|
99
|
+
target_link_libraries(test_minbit PRIVATE Threads::Threads)
|
|
100
|
+
minbit_apply_cxx_flags(test_minbit -O2)
|
|
101
|
+
add_test(NAME minbit_cpp_unit_tests COMMAND test_minbit)
|
|
102
|
+
|
|
103
|
+
if(MINBIT_BUILD_SHARED)
|
|
104
|
+
add_executable(test_c_api tests/test_c_api.c)
|
|
105
|
+
target_link_libraries(test_c_api PRIVATE minbit_shared)
|
|
106
|
+
if(WIN32)
|
|
107
|
+
target_compile_definitions(test_c_api PRIVATE MINBIT_USE_SHARED)
|
|
108
|
+
endif()
|
|
109
|
+
if(MSVC)
|
|
110
|
+
target_compile_options(test_c_api PRIVATE /W4)
|
|
111
|
+
else()
|
|
112
|
+
target_compile_options(test_c_api PRIVATE -O2 -Wall -Wextra -Wpedantic -Werror)
|
|
113
|
+
endif()
|
|
114
|
+
add_test(NAME minbit_c11_api_tests COMMAND test_c_api)
|
|
115
|
+
elseif(MINBIT_BUILD_STATIC)
|
|
116
|
+
add_executable(test_c_api tests/test_c_api.c)
|
|
117
|
+
target_link_libraries(test_c_api PRIVATE minbit_static)
|
|
118
|
+
if(NOT MSVC)
|
|
119
|
+
target_compile_options(test_c_api PRIVATE -O2 -Wall -Wextra -Wpedantic -Werror)
|
|
120
|
+
endif()
|
|
121
|
+
add_test(NAME minbit_c11_api_tests COMMAND test_c_api)
|
|
122
|
+
endif()
|
|
123
|
+
endif()
|
|
124
|
+
|
|
125
|
+
# Install rules
|
|
126
|
+
install(TARGETS minbit RUNTIME DESTINATION ${CMAKE_INSTALL_BINDIR})
|
|
127
|
+
install(FILES include/minbit.h DESTINATION ${CMAKE_INSTALL_INCLUDEDIR})
|
|
128
|
+
if(MINBIT_BUILD_STATIC)
|
|
129
|
+
install(TARGETS minbit_static ARCHIVE DESTINATION ${CMAKE_INSTALL_LIBDIR})
|
|
130
|
+
endif()
|
|
131
|
+
if(MINBIT_BUILD_SHARED)
|
|
132
|
+
install(TARGETS minbit_shared
|
|
133
|
+
LIBRARY DESTINATION ${CMAKE_INSTALL_LIBDIR}
|
|
134
|
+
ARCHIVE DESTINATION ${CMAKE_INSTALL_LIBDIR}
|
|
135
|
+
RUNTIME DESTINATION ${CMAKE_INSTALL_BINDIR}
|
|
136
|
+
)
|
|
137
|
+
endif()
|
minbit-3.1.0/FORMAT.md
ADDED
|
@@ -0,0 +1,117 @@
|
|
|
1
|
+
# MinBit `.mbit` Bitstream Format Specification (Version 3)
|
|
2
|
+
|
|
3
|
+
**Status**: Frozen for v3.0.0+.
|
|
4
|
+
**Backward Compatibility Guarantee**: Future MinBit releases (`3.x`) will always decode valid `.mbit` v3 (and legacy v1/v2) streams bit-for-bit identically.
|
|
5
|
+
|
|
6
|
+
All multi-byte integer fields in `.mbit` are stored in **little-endian** byte order.
|
|
7
|
+
|
|
8
|
+
---
|
|
9
|
+
|
|
10
|
+
## 1. High-Level Stream Layout
|
|
11
|
+
|
|
12
|
+
A `.mbit` v3 stream consists of a fixed **12-byte Stream Header**, followed by **zero or more independent Data Blocks**, terminated by a fixed **21-byte Stream Footer**:
|
|
13
|
+
|
|
14
|
+
```text
|
|
15
|
+
+-----------------------+
|
|
16
|
+
| Stream Header (12 B) |
|
|
17
|
+
+-----------------------+
|
|
18
|
+
| Data Block 0 |
|
|
19
|
+
| Data Block 1 |
|
|
20
|
+
| ... |
|
|
21
|
+
| Data Block N-1 |
|
|
22
|
+
+-----------------------+
|
|
23
|
+
| Stream Footer (21 B) |
|
|
24
|
+
+-----------------------+
|
|
25
|
+
```
|
|
26
|
+
|
|
27
|
+
Empty inputs (`0` bytes) encode as `0` Data Blocks (`12 + 21 = 33` bytes total).
|
|
28
|
+
|
|
29
|
+
Because each block is self-contained (with an independent predictor instance, arithmetic coder, BCJ transform flag, and CRC-32), encoders and decoders execute in **bounded RAM** for arbitrarily large streams (`stdin`/`stdout` pipes, multi-GB archives) and parallelize cleanly across CPU cores with **100% deterministic output**.
|
|
30
|
+
|
|
31
|
+
---
|
|
32
|
+
|
|
33
|
+
## 2. Stream Header (12 Bytes)
|
|
34
|
+
|
|
35
|
+
| Offset | Size | Field | Description |
|
|
36
|
+
|---:|---:|---|---|
|
|
37
|
+
| `0` | 4 B | `magic` | ASCII literal `"MBIT"` (`0x4D, 0x42, 0x49, 0x54`) |
|
|
38
|
+
| `4` | 1 B | `version` | Format version: `3` (`1` and `2` accepted by legacy decoder) |
|
|
39
|
+
| `5` | 1 B | `flags` | Bits `[2:0]`: compression level `0..4` (`4` added in v3.1.0). Bits `[7:3]`: reserved, MUST be `0`. |
|
|
40
|
+
| `6` | 4 B | `max_block_size` | Upper bound (in bytes) on `raw_size` of every block in this stream. MUST satisfy `1 <= max_block_size <= 67,108,864` (`64 MiB`). |
|
|
41
|
+
| `10` | 2 B | `header_crc16` | CRC-16/CCITT-FALSE (polynomial `0x1021`, init `0xFFFF`, unreflected, final XOR `0x0000`) over bytes `0..9`. |
|
|
42
|
+
|
|
43
|
+
### Decoder Security Invariants (Header)
|
|
44
|
+
- Decoders MUST validate `magic`, `version`, `header_crc16`, reserved `flags == 0`, `level <= 4`, and `1 <= max_block_size <= 64 MiB` **before** allocating any block buffers.
|
|
45
|
+
|
|
46
|
+
---
|
|
47
|
+
|
|
48
|
+
## 3. Data Block Framing
|
|
49
|
+
|
|
50
|
+
Each block begins with a **1-byte flag field (`bflags`)**.
|
|
51
|
+
If `bflags == 0x08` (`BLOCK_END_MARKER`), there are no more blocks and the remaining 20 bytes constitute the **Stream Footer** (Section 4).
|
|
52
|
+
|
|
53
|
+
Otherwise, `bflags` introduces a **13-byte Block Header** followed by `comp_size` payload bytes:
|
|
54
|
+
|
|
55
|
+
| Offset | Size | Field | Description |
|
|
56
|
+
|---:|---:|---|---|
|
|
57
|
+
| `0` | 1 B | `bflags` | Bit `0`: `is_raw` (`1` = uncompressed raw bytes, `0` = arithmetic-coded). Bits `[2:1]`: `transform_id` (`0` = `NONE`, `1` = `BCJ_ARM64`, `2` = `BCJ_X86`; `3` invalid). Bits `[7:3]`: reserved, MUST be `0`. If `is_raw == 1`, `transform_id` MUST be `0`. |
|
|
58
|
+
| `1` | 4 B | `raw_size` | Original uncompressed byte length of this block. MUST satisfy `1 <= raw_size <= max_block_size`. |
|
|
59
|
+
| `5` | 4 B | `comp_size` | Payload byte length immediately following the block header. If `is_raw == 1`: MUST equal `raw_size`. If `is_raw == 0`: MUST satisfy `4 <= comp_size <= max_block_size + 4096`. |
|
|
60
|
+
| `9` | 4 B | `block_crc32` | Standard IEEE 802.3 CRC-32 (polynomial `0xEDB88320`, init `0xFFFFFFFF`, final XOR `0xFFFFFFFF`) computed over the **original untransformed** `raw_size` bytes. |
|
|
61
|
+
| `13` | `comp_size` B | `payload` | Raw bytes (if `is_raw == 1`) or binary arithmetic-coded bitstream (if `is_raw == 0`). |
|
|
62
|
+
|
|
63
|
+
### Block Decoding Pipeline (`is_raw == 0`)
|
|
64
|
+
1. Initialize a fresh predictor for `level`:
|
|
65
|
+
- `level == 0`: `FastPredictor` (32 features, 8 ContextMap contexts, 6 Direct, 4 Match, 2 ICM, 3 Linear, 1 Bias; 3 Stage-1 Mixers + 2 APMs).
|
|
66
|
+
- `level == 1`: `Predictor` (`cmap_bits=17`, `match_buf_bits=21`, `match_hash_bits=16`).
|
|
67
|
+
- `level == 2`: `Predictor` (`cmap_bits=19`, `match_buf_bits=23`, `match_hash_bits=18`).
|
|
68
|
+
- `level == 3`: `Predictor` (`cmap_bits=21`, `match_buf_bits=25`, `match_hash_bits=20`, `icm_h3_bits=18`, `icm_h4_bits=19`).
|
|
69
|
+
- `level == 4` *(v3.1.0 Ultra 64 MiB)*: `Predictor` (`cmap_bits=23`, `match_buf_bits=26`, `match_hash_bits=21`, `icm_h3_bits=21`, `icm_h4_bits=23`).
|
|
70
|
+
2. Decode `raw_size` bytes MSB-first (bits `7` down to `0`) using the 32-bit carryless binary arithmetic decoder (`p in [1..65535]`, `xmid = x1 + ((uint64_t)(x2 - x1) * p) >> 16`, `bit = (x <= xmid) ? 1 : 0`, renormalize while `((x1 ^ x2) & 0xFF000000) == 0`).
|
|
71
|
+
3. If `transform_id != NONE`, apply the exact inverse BCJ filter in-place (Section 5).
|
|
72
|
+
4. Compute IEEE CRC-32 over the restored bytes and verify equality with `block_crc32`. Any mismatch MUST fail decompression immediately.
|
|
73
|
+
|
|
74
|
+
---
|
|
75
|
+
|
|
76
|
+
## 4. Stream Footer (21 Bytes)
|
|
77
|
+
|
|
78
|
+
| Offset | Size | Field | Description |
|
|
79
|
+
|---:|---:|---|---|
|
|
80
|
+
| `0` | 1 B | `end_marker` | Constant `0x08` (`BLOCK_END_MARKER`) |
|
|
81
|
+
| `1` | 8 B | `total_raw_bytes` | Exact sum of `raw_size` across all blocks (`0` for empty stream) |
|
|
82
|
+
| `9` | 8 B | `stream_xxh64` | Official **XXH64** (seed `0`) computed continuously over the entire original uncompressed byte stream across all blocks in order |
|
|
83
|
+
| `17` | 4 B | `total_blocks` | Exact number of data blocks preceding the footer |
|
|
84
|
+
|
|
85
|
+
### Decoder Security Invariants (Footer & Stream)
|
|
86
|
+
- After all blocks are emitted in sequence order, the decoder MUST verify:
|
|
87
|
+
1. `emitted_raw_bytes == total_raw_bytes`
|
|
88
|
+
2. `emitted_blocks == total_blocks`
|
|
89
|
+
3. `computed_xxh64 == stream_xxh64` (detects block reordering, swapping, deletion, or duplication across valid individually CRC-32-checked blocks!)
|
|
90
|
+
- If `max_output_bytes > 0` is configured, the decoder MUST reject any stream whose cumulative scheduled `raw_size` exceeds `max_output_bytes` **before** decompressing the offending block (anti-zip-bomb guarantee).
|
|
91
|
+
- In strict mode (default), any unread trailing bytes after the 21-byte footer MUST be rejected.
|
|
92
|
+
|
|
93
|
+
---
|
|
94
|
+
|
|
95
|
+
## 5. Strictly Bijective Executable Filters (BCJ)
|
|
96
|
+
|
|
97
|
+
Both filters operate in-place over `data[0..len)` and satisfy `inverse(forward(x)) == x` for **all** possible byte arrays `x`:
|
|
98
|
+
|
|
99
|
+
1. **`BCJ_ARM64` (`transform_id = 1`)**:
|
|
100
|
+
- Visits 4-byte aligned little-endian words `i = 0, 4, 8, ...` (`i + 4 <= len`).
|
|
101
|
+
- **`BL`** (`(inst & 0xFC000000) == 0x94000000`): transforms 26-bit immediate `imm = (imm ± (i >> 2)) & 0x03FFFFFF`.
|
|
102
|
+
- **`ADRP`** (`(inst & 0x9F000000) == 0x90000000`): transforms 21-bit page immediate `imm = (imm ± (i >> 12)) & 0x1FFFFF`.
|
|
103
|
+
2. **`BCJ_X86` (`transform_id = 2`)**:
|
|
104
|
+
- Scans `i = 0` while `i + 5 <= len`.
|
|
105
|
+
- Whenever `data[i] == 0xE8 || data[i] == 0xE9`:
|
|
106
|
+
- If `data[i + 4] == 0x00 || data[i + 4] == 0xFF`, transforms little-endian 24-bit `data[i+1..i+3]` by `lo24 = (lo24 ± (uint32_t)i) & 0x00FFFFFF`.
|
|
107
|
+
- **Always** advances `i += 5` regardless of `data[i + 4]`, guaranteeing modified spans `[i+1..i+3]` are strictly disjoint from every visited trigger byte `data[j]` and sign byte `data[j+4]`.
|
|
108
|
+
|
|
109
|
+
---
|
|
110
|
+
|
|
111
|
+
## 6. Cross-Platform Bit-Exactness Contract
|
|
112
|
+
|
|
113
|
+
To guarantee bit-for-bit identical `.mbit` archives across **macOS (ARM64/x86-64)**, **Linux (GCC/Clang)**, and **Windows (MSVC/Clang/MinGW)**:
|
|
114
|
+
- All lookup-table initialization (`ProbTables`, `BitHistoryTable`, `LinearPredictorModel`) uses self-contained IEEE-754 polynomial `det_exp`, `det_log`, and `det_round` (never host `libm`).
|
|
115
|
+
- All runtime probability updates, NLMS filters, and mixer SGD updates use fixed-width integer arithmetic with identical rounding:
|
|
116
|
+
$$\Delta w_i = \left\lfloor \frac{x_i \cdot \text{err}_2 + 16384}{32768} \right\rfloor$$
|
|
117
|
+
which maps bit-identically onto ARM64 NEON `vqrdmulhq_s16`, x86-64 AVX2 `_mm256_mulhrs_epi16`, x86-64 SSSE3 `_mm_mulhrs_epi16`, and C++20 scalar arithmetic.
|
minbit-3.1.0/LICENSE
ADDED
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
MIT License
|
|
2
|
+
|
|
3
|
+
Copyright (c) 2026 NeiH4207
|
|
4
|
+
|
|
5
|
+
Permission is hereby granted, free of charge, to any person obtaining a copy
|
|
6
|
+
of this software and associated documentation files (the "Software"), to deal
|
|
7
|
+
in the Software without restriction, including without limitation the rights
|
|
8
|
+
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
|
9
|
+
copies of the Software, and to permit persons to whom the Software is
|
|
10
|
+
furnished to do so, subject to the following conditions:
|
|
11
|
+
|
|
12
|
+
The above copyright notice and this permission notice shall be included in all
|
|
13
|
+
copies or substantial portions of the Software.
|
|
14
|
+
|
|
15
|
+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
|
16
|
+
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
|
17
|
+
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
|
18
|
+
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
|
19
|
+
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
|
20
|
+
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
|
21
|
+
SOFTWARE.
|
minbit-3.1.0/MANIFEST.in
ADDED
|
@@ -0,0 +1,12 @@
|
|
|
1
|
+
include LICENSE
|
|
2
|
+
include README.md
|
|
3
|
+
include FORMAT.md
|
|
4
|
+
include CHANGELOG.md
|
|
5
|
+
include CMakeLists.txt
|
|
6
|
+
include pyproject.toml
|
|
7
|
+
include setup.py
|
|
8
|
+
recursive-include include *.h
|
|
9
|
+
recursive-include src *.hpp *.cpp
|
|
10
|
+
recursive-include python/minbit *.py py.typed
|
|
11
|
+
recursive-include python/tests *.py
|
|
12
|
+
global-exclude *.pyc *.pyo __pycache__ .DS_Store *.dylib *.so *.dll
|
minbit-3.1.0/PKG-INFO
ADDED
|
@@ -0,0 +1,227 @@
|
|
|
1
|
+
Metadata-Version: 2.4
|
|
2
|
+
Name: minbit
|
|
3
|
+
Version: 3.1.0
|
|
4
|
+
Summary: Cross-platform minimum-bit lossless compression library (Bitwise Context Mixing, format v3)
|
|
5
|
+
Author: NeiH4207
|
|
6
|
+
License: MIT License
|
|
7
|
+
|
|
8
|
+
Copyright (c) 2026 NeiH4207
|
|
9
|
+
|
|
10
|
+
Permission is hereby granted, free of charge, to any person obtaining a copy
|
|
11
|
+
of this software and associated documentation files (the "Software"), to deal
|
|
12
|
+
in the Software without restriction, including without limitation the rights
|
|
13
|
+
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
|
14
|
+
copies of the Software, and to permit persons to whom the Software is
|
|
15
|
+
furnished to do so, subject to the following conditions:
|
|
16
|
+
|
|
17
|
+
The above copyright notice and this permission notice shall be included in all
|
|
18
|
+
copies or substantial portions of the Software.
|
|
19
|
+
|
|
20
|
+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
|
21
|
+
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
|
22
|
+
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
|
23
|
+
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
|
24
|
+
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
|
25
|
+
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
|
26
|
+
SOFTWARE.
|
|
27
|
+
|
|
28
|
+
Project-URL: Homepage, https://github.com/NeiH4207/minbit
|
|
29
|
+
Project-URL: Repository, https://github.com/NeiH4207/minbit
|
|
30
|
+
Project-URL: Issues, https://github.com/NeiH4207/minbit/issues
|
|
31
|
+
Project-URL: Changelog, https://github.com/NeiH4207/minbit/blob/main/CHANGELOG.md
|
|
32
|
+
Keywords: compression,lossless,context-mixing,paq,archiving,simd
|
|
33
|
+
Classifier: Development Status :: 5 - Production/Stable
|
|
34
|
+
Classifier: Intended Audience :: Developers
|
|
35
|
+
Classifier: Intended Audience :: Science/Research
|
|
36
|
+
Classifier: License :: OSI Approved :: MIT License
|
|
37
|
+
Classifier: Operating System :: MacOS
|
|
38
|
+
Classifier: Operating System :: POSIX :: Linux
|
|
39
|
+
Classifier: Operating System :: Microsoft :: Windows
|
|
40
|
+
Classifier: Programming Language :: C
|
|
41
|
+
Classifier: Programming Language :: C++
|
|
42
|
+
Classifier: Programming Language :: Python :: 3
|
|
43
|
+
Classifier: Programming Language :: Python :: 3.9
|
|
44
|
+
Classifier: Programming Language :: Python :: 3.10
|
|
45
|
+
Classifier: Programming Language :: Python :: 3.11
|
|
46
|
+
Classifier: Programming Language :: Python :: 3.12
|
|
47
|
+
Classifier: Programming Language :: Python :: 3.13
|
|
48
|
+
Classifier: Topic :: System :: Archiving :: Compression
|
|
49
|
+
Classifier: Typing :: Typed
|
|
50
|
+
Requires-Python: >=3.9
|
|
51
|
+
Description-Content-Type: text/markdown
|
|
52
|
+
License-File: LICENSE
|
|
53
|
+
Dynamic: license-file
|
|
54
|
+
|
|
55
|
+
# MinBit — Cross-Platform Minimum-Bit Lossless Compressor
|
|
56
|
+
|
|
57
|
+
[](https://github.com/NeiH4207/minbit/actions/workflows/ci.yml)
|
|
58
|
+
[](LICENSE)
|
|
59
|
+
[](include/minbit.h)
|
|
60
|
+
[](FORMAT.md)
|
|
61
|
+
|
|
62
|
+
**MinBit** is a zero-dependency, cross-platform (**macOS**, **Linux**, **Windows**) C++20/C11/Python lossless compression engine based on **Bitwise Context Mixing** with adaptive 16-bit/2D spatial modeling, structural markup/lexical modeling, and bit-exact cross-architecture SIMD acceleration.
|
|
63
|
+
|
|
64
|
+
Across **all 5 international standard benchmarks** — **Silesia (211.94 MB)**, **Canterbury (2.81 MB)**, **Calgary (3.25 MB)**, **`enwik8_10m` (10 MB)**, and **full `enwik8` (100 MB)** — MinBit beats every standard industry compressor (`gzip -9`, `bzip2 -9`, `zstd --ultra -22`, `brotli -11`, `xz -9e`, `7z-PPMd`) on **100% of files**, and achieves **#1 overall** ahead of **`zpaq -m5`** on all 5 benchmarks!
|
|
65
|
+
|
|
66
|
+
---
|
|
67
|
+
|
|
68
|
+
## Installation
|
|
69
|
+
|
|
70
|
+
### Homebrew (macOS & Linux)
|
|
71
|
+
```bash
|
|
72
|
+
brew tap NeiH4207/minbit https://github.com/NeiH4207/minbit.git
|
|
73
|
+
brew install NeiH4207/minbit/minbit
|
|
74
|
+
```
|
|
75
|
+
|
|
76
|
+
### Python (`pip`)
|
|
77
|
+
```bash
|
|
78
|
+
# Install from source / GitHub (or PyPI once published)
|
|
79
|
+
pip install git+https://github.com/NeiH4207/minbit.git
|
|
80
|
+
# Verify bundled native library & SIMD backend:
|
|
81
|
+
python -m minbit --version
|
|
82
|
+
```
|
|
83
|
+
|
|
84
|
+
### Prebuilt Binaries (macOS ARM64, Linux x86-64, Windows x64)
|
|
85
|
+
Download CLI + `libminbit` + `include/minbit.h` directly from [GitHub Releases](https://github.com/NeiH4207/minbit/releases).
|
|
86
|
+
|
|
87
|
+
---
|
|
88
|
+
|
|
89
|
+
## Key Features
|
|
90
|
+
|
|
91
|
+
- **100% Bit-Exact Cross-Platform Archives**: An archive compressed on **Windows (x86-64 AVX2/SSE2)**, **Linux (GCC/Clang x86-64/ARM64)**, or **macOS (Apple Silicon ARM64 NEON)** is guaranteed **bit-for-bit identical** and cross-decodable everywhere:
|
|
92
|
+
- Unified SIMD [`LogisticMixer`](src/core/mixer.hpp) (`AVX2 _mm256_mulhrs_epi16` == `ARM64 NEON vqrdmulhq_s16` == `SSSE3 _mm_mulhrs_epi16` == scalar `(x * err2 + 16384) >> 15`).
|
|
93
|
+
- Self-contained IEEE-754 deterministic `det_exp` / `det_log` / `det_round` in [`src/core/simd.hpp`](src/core/simd.hpp) (no OS `libm` ULP divergence).
|
|
94
|
+
- **Streaming Chunked Format (`.mbit` v3) & Security Hardening** ([`src/codec/minbit_codec.hpp`](src/codec/minbit_codec.hpp)):
|
|
95
|
+
- Bounded-RAM pipelined multi-threaded compression & decompression for arbitrarily large files and Unix/Windows `stdin`/`stdout` pipes (`-` path).
|
|
96
|
+
- Header **CRC-16/CCITT**, per-block **IEEE CRC-32**, whole-stream **XXH64** + exact length/block-count footer, hard 64 MiB anti-OOM ceiling, and configurable `--max-out-mb` anti-zip-bomb guard.
|
|
97
|
+
- Strict bijective per-block ARM64 (`BL`+`ADRP`) and x86 (`E8`/`E9`) BCJ filters ([`src/transforms/bcj_transform.hpp`](src/transforms/bcj_transform.hpp)) + automatic incompressible `RAW` fallback.
|
|
98
|
+
- **Multi-Modal Adaptive Modeling**:
|
|
99
|
+
- 24-context 64-byte cache-aligned `ContextMap` + zero-collision L2 `DirectSparseModel` + `IndirectModel` + 4-way multi-hash-chain `MatchModel` (3B/5B/8B/12B + shadow resync).
|
|
100
|
+
- Lexical UTF-8 `WordModel` with unfragmented word/bigram/trigram/skip-bigram, `PrevLine` column alignment, and `<tag>`/bracket nesting ([`src/models/word_model.hpp`](src/models/word_model.hpp)).
|
|
101
|
+
- Out-of-sample cross-validated modular AMDF row/pixel stride discovery (`sx ∈ {1,2,3,4}`), 6-tap fixed-point 2D NLMS Wiener filter, and **16-bit carry-aware MSB/LSB prediction** for 16-bit medical imagery & PCM audio ([`src/models/record_model.hpp`](src/models/record_model.hpp), [`src/models/linear_model.hpp`](src/models/linear_model.hpp)).
|
|
102
|
+
- **Pareto Preset Spectrum (`-0` .. `-4`)**:
|
|
103
|
+
- `-0` (`FastPredictor`, ~12 MB RAM/thread): matches `zstd -22` / `xz -9e` multi-core compression speed while producing **12%–30% smaller** files.
|
|
104
|
+
- `-2` (~58 MB RAM/thread) & `-3` (~210 MB RAM/thread): high-ratio general archival surpassing `zpaq -m5` on Silesia, Canterbury, Calgary, and `enwik8_10m`.
|
|
105
|
+
- `-4` (Ultra 64 MiB, ~710 MB RAM/thread): 512 MiB `ContextMap` + 64 MiB sliding window surpassing `zpaq -m5` on **full 100 MB `enwik8`** (`1.5662 bpb`) and `silesia/webster` (`1.0923 bpb`).
|
|
106
|
+
|
|
107
|
+
---
|
|
108
|
+
|
|
109
|
+
## International Standard Corpus Benchmarks
|
|
110
|
+
|
|
111
|
+
> Measured on **Apple M4 Pro** (12 threads, ARM64 NEON, Apple Clang 21.0.0 `-O3 -flto`). Every archive was decompressed and verified bit-for-bit identical against the original input.
|
|
112
|
+
|
|
113
|
+
### 1. Summary Across 5 International Standard Benchmarks
|
|
114
|
+
|
|
115
|
+
| Corpus | Original | `gzip -9` | `bzip2 -9` | `zstd -22` | `brotli -11` | `xz -9e` | `7z-PPMd` | `zpaq -m5` | `minbit -0` | `minbit -3` | **`minbit -4`** |
|
|
116
|
+
|---|---:|---:|---:|---:|---:|---:|---:|---:|---:|---:|---:|
|
|
117
|
+
| **Canterbury** (11 files, `-T1`) | 2,810,784 | 727,952 | 542,710 | 516,140 | 490,662 | 493,168 | 573,140 | 361,685 | 356,001 | **340,898*** (`0.970 bpb`) | — |
|
|
118
|
+
| **Calgary** (18 files, `-T1`) | 3,251,493 | 1,059,877 | 866,501 | 920,849 | 856,672 | 883,896 | 794,683 | 718,141 | 706,403 | **675,768*** (`1.663 bpb`) | — |
|
|
119
|
+
| **enwik8_10m** (10 MB, `-T1`) | 10,000,000 | 3,688,458 | 2,916,026 | 2,793,362 | 2,704,839 | 2,720,264 | 2,370,078 | 2,091,350 | 2,352,061 | 2,077,685 (`1.662 bpb`) | **2,045,519*** (`1.636 bpb`) |
|
|
120
|
+
| **Silesia** (12 files, `-T0`) | 211,938,580 | 67,643,417 | 54,506,769 | 52,363,658 | 49,564,563 | 48,456,100 | 48,035,603 | 39,112,522 | 42,625,116 | **38,673,757*** (`1.460 bpb`) | *webster*: **5,660,825*** |
|
|
121
|
+
| **enwik8** (100 MB, `-T0`) | 100,000,000 | 36,475,804 | 29,008,758 | 25,272,468 | 25,742,001 | 24,831,656 | 23,626,709 | 19,625,007 | 23,486,750 | 20,291,985 (`1.623 bpb`) | **19,576,877*** (`1.566 bpb`) |
|
|
122
|
+
|
|
123
|
+
> On full **100 MB `enwik8`**, `minbit -4 -T0` splits into 2 balanced ~50 MB blocks (`0.51 MB/s enc / 0.49 MB/s dec`, ~710 MB RAM/thread) and beats `zpaq -m5` (`19,625,007 B` / `1.5700 bpb`) by **-48,130 B (-0.25%)** and `xz -9e` by **-5.25 MB (-21.16%)**. On **Silesia**, `minbit -4` also beats `zpaq -m5` on `webster` (`5,660,825` vs `5,666,828 B`), giving **11 / 12** head-to-head Silesia file wins over `zpaq -m5`.
|
|
124
|
+
|
|
125
|
+
### 2. Full Silesia Corpus Breakdown (12 Files, 211.94 MB)
|
|
126
|
+
|
|
127
|
+
| File | Original | `zstd -22` | `brotli -11` | `xz -9e` | `7z-PPMd` | `zpaq -m5` | `minbit -0` | `minbit -2` | **`minbit -3`** |
|
|
128
|
+
|---|---:|---:|---:|---:|---:|---:|---:|---:|---:|
|
|
129
|
+
| `dickens` | 10,192,446 | 2,849,064 | 2,827,777 | 2,831,220 | 2,334,295 | **2,094,739*** | 2,425,631 | 2,282,800 | 2,191,736 |
|
|
130
|
+
| `mozilla` | 51,220,480 | 14,912,709 | 13,872,265 | 13,376,248 | 15,929,217 | 12,041,051 | 12,936,448 | 11,944,441 | **11,698,763*** |
|
|
131
|
+
| `mr` | 9,970,564 | 3,102,044 | 2,823,136 | 2,751,900 | 2,319,043 | 2,181,306 | 2,142,920 | 2,105,418 | **2,094,950*** |
|
|
132
|
+
| `nci` | 33,553,445 | 1,578,382 | 1,519,768 | 1,449,280 | 1,839,074 | 1,251,105 | 1,343,170 | 1,144,453 | **1,120,622*** |
|
|
133
|
+
| `ooffice` | 6,152,192 | 2,595,234 | 2,478,855 | 2,427,232 | 2,516,423 | 1,766,548 | 1,937,780 | 1,765,172 | **1,655,893*** |
|
|
134
|
+
| `osdb` | 10,085,684 | 3,099,936 | 2,816,278 | 2,844,564 | 2,374,462 | 2,204,737 | 2,363,622 | 2,246,130 | **2,202,031*** |
|
|
135
|
+
| `reymont` | 6,627,202 | 1,348,572 | 1,332,158 | 1,315,600 | 1,020,200 | 956,497 | 1,038,495 | 957,661 | **915,617*** |
|
|
136
|
+
| `samba` | 21,606,400 | 3,865,315 | 3,766,340 | 3,739,532 | 3,784,047 | 3,053,816 | 3,373,314 | 3,107,649 | **2,988,481*** |
|
|
137
|
+
| `sao` | 7,251,944 | 5,000,573 | 4,586,092 | 4,425,672 | 4,783,825 | 3,899,253 | 3,963,598 | 3,826,663 | **3,801,162*** |
|
|
138
|
+
| `webster` | 41,458,703 | 8,430,464 | 8,428,575 | 8,368,680 | 6,904,476 | **5,666,828*** | 7,123,062 | 6,455,064 | 6,083,394 |
|
|
139
|
+
| `x-ray` | 8,474,240 | 5,129,825 | 4,682,753 | 4,491,272 | 3,850,892 | 3,669,697 | 3,655,513 | 3,628,834 | **3,625,896*** |
|
|
140
|
+
| `xml` | 5,345,280 | 451,540 | 430,566 | 434,900 | 379,649 | 326,945 | 321,563 | 300,645 | **295,212*** |
|
|
141
|
+
| **TOTAL** | **211,938,580** | 52,363,658 | 49,564,563 | 48,456,100 | 48,035,603 | 39,112,522 | 42,625,116 | 39,764,930 | **38,673,757*** |
|
|
142
|
+
| **Ratio / bpb** | `100% / 8.00` | `24.71% / 1.98` | `23.39% / 1.87` | `22.86% / 1.83` | `22.66% / 1.81` | `18.45% / 1.48` | `20.11% / 1.61` | `18.76% / 1.50` | **`18.25% / 1.46`** |
|
|
143
|
+
| **Enc / Dec MB/s** | — | `2.51 / 573.1` | `0.73 / 268.2` | `2.61 / 112.7` | `9.70 / 8.67` | `0.46 / 0.45` | **`2.40 / 2.11`** | `0.90 / 0.87` | `0.56 / 0.54` |
|
|
144
|
+
|
|
145
|
+
> **Honest Trade-Off Note**: Context mixing decoders are symmetric with their encoders (`~2.1–4.3 MB/s` multi-core on `-0`, `~0.5–1.6 MB/s` on `-2/-3`), unlike LZ77/LZMA decoders (`110–660 MB/s`). Use MinBit when **minimizing storage/bandwidth bytes** matters most (archival, medical/scientific datasets, release payloads, cold backups).
|
|
146
|
+
|
|
147
|
+
---
|
|
148
|
+
|
|
149
|
+
## Cross-Platform Build (macOS / Linux / Windows)
|
|
150
|
+
|
|
151
|
+
### CMake (macOS, Linux, Windows MSVC / Clang / MinGW)
|
|
152
|
+
```bash
|
|
153
|
+
cmake -B build -DCMAKE_BUILD_TYPE=Release
|
|
154
|
+
cmake --build build --config Release
|
|
155
|
+
ctest --test-dir build --output-on-failure -C Release
|
|
156
|
+
```
|
|
157
|
+
|
|
158
|
+
### Make (macOS / Linux)
|
|
159
|
+
```bash
|
|
160
|
+
make all test test-py asan asan-c fuzz
|
|
161
|
+
bash tests/test_cross_simd.sh # Verify ARM64-NEON, x86-64 AVX2/SSSE3/SSE2, Scalar bit-exactness
|
|
162
|
+
```
|
|
163
|
+
|
|
164
|
+
### C11 Library API (`include/minbit.h`)
|
|
165
|
+
Link against `libminbit.a` or `libminbit.{dylib,so,dll}` (or CMake `minbit::minbit`):
|
|
166
|
+
```c
|
|
167
|
+
#include "minbit.h"
|
|
168
|
+
|
|
169
|
+
minbit_compress_options_t copt;
|
|
170
|
+
minbit_compress_options_init(&copt);
|
|
171
|
+
copt.level = 2; /* 0 (fast-CM) .. 3 (max ratio) */
|
|
172
|
+
copt.threads = 0; /* auto CPU cores */
|
|
173
|
+
|
|
174
|
+
uint8_t* comp = NULL; size_t comp_sz = 0;
|
|
175
|
+
if (minbit_compress_alloc(src, src_sz, &comp, &comp_sz, &copt) == MINBIT_OK) {
|
|
176
|
+
minbit_decompress_options_t dopt;
|
|
177
|
+
minbit_decompress_options_init(&dopt);
|
|
178
|
+
dopt.max_output_bytes = 64u * 1024u * 1024u; /* anti-zip-bomb guard */
|
|
179
|
+
uint8_t* out = NULL; size_t out_sz = 0;
|
|
180
|
+
minbit_decompress_alloc(comp, comp_sz, &out, &out_sz, &dopt);
|
|
181
|
+
minbit_free(out);
|
|
182
|
+
minbit_free(comp);
|
|
183
|
+
}
|
|
184
|
+
```
|
|
185
|
+
Also provides caller-buffer (`minbit_compress_buffer` / `minbit_decompress_buffer`), streaming file (`minbit_compress_file` / `minbit_decompress_file` / `minbit_verify_file`), and custom I/O callback streaming (`minbit_compress_stream_cb` / `minbit_decompress_stream_cb`).
|
|
186
|
+
|
|
187
|
+
### Python Package (`python/minbit`)
|
|
188
|
+
```python
|
|
189
|
+
import minbit
|
|
190
|
+
|
|
191
|
+
comp = minbit.compress(data, level=2, threads=0)
|
|
192
|
+
raw = minbit.decompress(comp, max_output_bytes=64 * 1024 * 1024)
|
|
193
|
+
|
|
194
|
+
# Bounded-RAM streaming files & file-like objects
|
|
195
|
+
stats = minbit.compress_file("scan.dcm", "scan.dcm.mbit", level=0, threads=0)
|
|
196
|
+
minbit.verify_file("scan.dcm.mbit")
|
|
197
|
+
minbit.decompress_file("scan.dcm.mbit", "scan_restored.dcm")
|
|
198
|
+
```
|
|
199
|
+
|
|
200
|
+
### CLI Examples
|
|
201
|
+
```bash
|
|
202
|
+
# Fast multi-core compression (matches zstd -22 / xz -9e encode speed, 12–19% smaller files)
|
|
203
|
+
./build/minbit c -0 -T0 input.dat output.mbit
|
|
204
|
+
|
|
205
|
+
# High-ratio multi-core compression
|
|
206
|
+
./build/minbit c -2 -T0 input.dat output.mbit
|
|
207
|
+
|
|
208
|
+
# Maximum compression ratio (-3) or Ultra 64 MiB Archival (-4 for enwik8/enwik9)
|
|
209
|
+
./build/minbit c -3 -T0 --block-kb 8192 input.dat output.mbit
|
|
210
|
+
./build/minbit c -4 -T0 enwik8 enwik8.mbit
|
|
211
|
+
|
|
212
|
+
# Unix/Windows streaming pipe (bounded RAM for arbitrarily large archives)
|
|
213
|
+
tar cf - my_folder/ | ./build/minbit c -0 -T0 - my_folder.tar.mbit
|
|
214
|
+
|
|
215
|
+
# Decompress with anti-zip-bomb cap (automatically parallelizes across blocks)
|
|
216
|
+
./build/minbit d --max-out-mb 1024 output.mbit restored.dat
|
|
217
|
+
|
|
218
|
+
# Verify archive integrity without writing output
|
|
219
|
+
./build/minbit t output.mbit
|
|
220
|
+
```
|
|
221
|
+
|
|
222
|
+
## Documentation & License
|
|
223
|
+
- **Bitstream Format Specification**: [`FORMAT.md`](FORMAT.md) (frozen `.mbit` v3 spec & cross-platform determinism contract)
|
|
224
|
+
- **Release Notes**: [`CHANGELOG.md`](CHANGELOG.md)
|
|
225
|
+
- **Contributing & Invariants**: [`CONTRIBUTING.md`](CONTRIBUTING.md)
|
|
226
|
+
- **License**: [MIT License](LICENSE)
|
|
227
|
+
|