JPEG handling.
See also: https://www.w3.org/Graphics/JPEG/itu-t81.pdf
fn zigzag(data: [int64]) -> [int64]
Zig zag pattern:
0, 1, 5, 6, 14, 15, 27, 28
2, 4, 7, 13, 16, 26, 29, 42
3, 8, 12, 17, 25, 30, 41, 43
9, 11, 18, 24, 31, 40, 44, 53
10, 19, 23, 32, 39, 45, 52, 54
20, 22, 33, 38, 46, 51, 55, 60
21, 34, 37, 47, 50, 56, 59, 61
35, 36, 48, 49, 57, 58, 62, 63
fn decode_number(code: int64, bits: int64) -> int64
code = amount of bits
bits = the bit value
Mapping:
bits | values
2 | -3,-2,2,3
3 | -7..-4,4..7
4 | -15..-8,8..15
...
encoder / decoder for the QOI (quite ok image) format.
See also: https://qoiformat.org/
https://qoiformat.org/qoi-specification.pdf