Skip to content

fm4 v0.1.0

Latest

Choose a tag to compare

@pr0h0 pr0h0 released this 20 Nov 17:56
17f2b8a

First release of fm4, a lossless context-mixing compressor for text, code, binaries, raw images, 16-bit PCM audio and raw video, with an archive mode for files and directories.

Format 1 is frozen

Files written by this release use format 1 (FM4\x01, FMS\x01 and FMA\x01), and every future version will read them. A future change that existing decoders couldn't read gets a new version number, and decoders keep reading format 1. tests/format1/ holds files written by v0.1.0 that every build must keep decoding to the same bytes.

Results

Compressed size / original, at level 4, on one thread:

Python source x86-64 code Photo-like image
fm4 0.094 0.270 0.336
xz -9e 0.134 0.363 0.665
zstd -19 0.137 0.381 0.742
JPEG XL lossless (e7) 0.352

On 12 audio clips it is 6-45% smaller than flac -8. Speed is 0.3-2.7 MB/s per core depending on level, and decoding is as slow as encoding. Full numbers and caveats are in the README.

What's included

  • c/fm4: the C reference, one file with no dependencies. make c builds it on Linux, macOS and Windows (MinGW-w64).
  • BPL3 port: native and WebAssembly builds that write byte-identical files.
  • fm4-wasm-0.1.0.zip (attached): a prebuilt fm4.wasm with its JS host (fm4wasm.mjs) and Web Worker (fm4worker.mjs). It runs in browsers, Node and Bun, so you don't need the BPL compiler. It was built from this tag with bpl3 staging 0eaed6d1.
import { createFm4 } from "./fm4wasm.mjs";
const fm4 = await createFm4(new URL("./fm4.wasm", import.meta.url));
const packed = await fm4.encode(bytes, { level: 4 });
const original = await fm4.decode(packed);

Checked

The test suite passed on Linux x86-64, macOS arm64 and Windows, plus ASan, UBSan and MSan builds and libFuzzer runs of the decoder and the round trip.

c5e97aae5bf1ebbb61c0902f0d6aff869c2374daf992c740bb97bf5f4bdda58f  fm4-wasm-0.1.0.zip
034d34c939721658c85908366d564f14288573579f64c0b305a6c51ee2405ece  fm4.wasm

How it started: fm4: storing a file as one number.