codec / predictor + mapping · 2D / lossless
med_zigzag
The fused version of MED + Zigzag.
MED: P = median(W, N, W + N − NW), r = sample − P
Zigzag: z = (r << 1) ^ (r >> (bits − 1))
Example: r = [0, −1, 1, −2, 2] → z = [0, 1, 2, 3, 4]
- ctid
- 0x72D711
- header
- uint32 · row width in samples
+ uint32 · plane count, when above one - widths
- 8 · 16 · 32 · 64-bit integers
- decode
- inverse Zigzag folded into the MED reconstruction
- next
- an entropy stage, usually after a byte transpose
Code
geozl.lossless.MedZigzag(width, planes=1)