def jpeg.history.valid

gralha-jpeg-decode@0.1.0.1 · jpeg.bend:535

import gralha-jpeg-decode@0.1.0.1/jpeg.bend as Jpeg
import Base
import gralha-text-scan@0.1.0.1/scan.bend as U
import gralha-bytes@0.1.0.1/bytes.bend as Bin

535# The sample buffer holds approximation history until IDCT replaces it.
536# Zero means unseen; low+1 records the last transmitted coefficient bit.
537def jpeg.history.valid(n: Nat, +index: U32, +history: Bin.Bytes, +high: U32) -> Bool:
538  match n:
539    case 0n: True{}
540    case 1n+d: U32.is_eq(Bin.bytes.get(history, index), U.choose(U32, U32.is_eq(high, 0), 0, U32.inc(high))) && jpeg.history.valid(d, U32.inc(index), history, high)

Uses (9)

Used by (1)