def jpeg.huff.symbols
gralha-jpeg-decode@0.1.0.1 · jpeg.bend:154
import gralha-jpeg-decode@0.1.0.1/jpeg.bend as Jpeg
import Base
import gralha-bytes@0.1.0.1/bytes.bend as Bin
154def jpeg.huff.symbols(n: Nat, +src: Bin.Bytes, +bits: U32, +coding: JPEGCoding) -> JPEGCoding:
155 match n:
156 case 0n: coding
157 case 1n+d:
158 JPEGCoding{node, cw0, at, valid} = coding
159 +cw = cw0
160 jpeg.huff.symbols(d, src, bits, JPEGCoding{Bin.huff.insert(node, U32.to_nat(bits), cw, Bin.bytes.get(src, at)), U32.inc(cw), U32.inc(at), valid && U32.is_lt(cw, (U32.shln(1, U32.to_nat(bits)) - 1 : U32))})