Signal Compression (VBZ)¶
POD5 uses the VBZ codec for signal compression, combining delta encoding, zigzag encoding, StreamVByte (SVB16), and ZSTD.
Compression Pipeline¶
Raw Signal (i16)
│
▼
┌─────────────┐
│ Delta │ Δ[i] = signal[i] - signal[i-1]
│ Encoding │
└─────────────┘
│
▼
┌─────────────┐
│ Zigzag │ Map signed → unsigned
│ Encoding │
└─────────────┘
│
▼
┌─────────────┐
│ SVB16 │ Variable-length (1-2 bytes)
│ Encoding │
└─────────────┘
│
▼
┌─────────────┐
│ ZSTD │ Final compression
│ Level 1 │
└─────────────┘
│
▼
Compressed Data
Delta Encoding¶
Consecutive signal samples are highly correlated. Delta encoding stores differences:
Original: [100, 102, 105, 103, 101]
Delta: [100, 2, 3, -2, -2]
Benefits: - Differences are typically small - Smaller values compress better - Preserves signal fidelity exactly
Zigzag Encoding¶
Maps signed integers to unsigned for efficient variable-length encoding:
1 2 3 4 5 6 7 | |
Mapping examples:
0 → 0
-1 → 1
1 → 2
-2 → 3
2 → 4
...
This keeps small magnitudes (positive or negative) as small unsigned values.
SVB16 (StreamVByte for 16-bit)¶
Variable-length encoding where each value uses 1 or 2 bytes:
Structure¶
┌─────────────────┬─────────────────┐
│ Keys Bitmap │ Data Section │
│ (1 bit/value) │ (1-2 bytes/val)│
└─────────────────┴─────────────────┘
Keys Bitmap¶
- 1 bit per sample, packed 8 per byte
- Bit = 0: value fits in 1 byte (0-255)
- Bit = 1: value needs 2 bytes (256-65535)
Keys length = (sample_count + 7) / 8 bytes
Data Section¶
Values stored sequentially: - 1-byte values: stored as-is - 2-byte values: stored as little-endian u16
Example¶
Values: [5, 300, 12, 1000, 8]
Keys: [0, 1, 0, 1, 0] → 0b01010 → 0x0A (padded)
Data: [05, 2C 01, 0C, E8 03, 08]
1b 2b 1b 2b 1b
Encoding Algorithm¶
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 | |
Decoding Algorithm¶
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 | |
ZSTD Compression¶
Final pass uses ZSTD at level 1:
- Fast compression/decompression
- Good compression ratio
- Streaming support
- Standard library (libzstd)
Level 1 chosen for balance: - Level 0: No compression - Level 1: Fast, ~60% ratio - Level 3: Default, ~65% ratio - Level 19+: Slow, ~70% ratio
For POD5, level 1 is sufficient as SVB16 already reduces entropy.
Compression Ratios¶
Typical compression ratios (compressed/original):
| Stage | Ratio | Cumulative |
|---|---|---|
| Delta | ~1.0x | ~1.0x |
| Zigzag | ~1.0x | ~1.0x |
| SVB16 | ~0.6x | ~0.6x |
| ZSTD | ~0.5x | ~0.3x |
Final result: 30-40% of original size
Decompression¶
Reverse the pipeline:
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 | |
Extension Type¶
VBZ data uses the Arrow extension type minknow.vbz:
{
"extension_name": "minknow.vbz",
"storage_type": "LargeBinary",
"metadata": {
"codec": "vbz",
"version": 1
}
}