Jpeg.jpeg.frame.start: def of gralha-jpeg-decode@0.1.0.1 Import: import gralha-jpeg-decode@0.1.0.1/jpeg.bend as Jpeg Lines 228-237 of gralha-jpeg-decode@0.1.0.1/jpeg.bend: https://jend.leeeet.dev/read.txt?path=gralha-jpeg-decode@0.1.0.1/jpeg.bend&start_line=228&end_line=237 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 def jpeg.frame.start(+src: Bin.Bytes, +at: U32, +end: U32, +frame: JPEGFrame, +kind: U32) -> JPEGFrame: JPEGFrame{w, h, hm, vm, progressive, components, quants, huffs, restart, adobe, valid} = frame +ww = Bin.bytes.be(src, (at + 3 : U32), 2n, 0) +hh = Bin.bytes.be(src, U32.inc(at), 2n, 0) +count = Bin.bytes.get(src, (at + 5 : U32)) +cs = jpeg.components.read(U32.to_nat(U.choose(U32, U32.is_le(count, 4), count, 0)), src, (at + 6 : U32)) +mh = jpeg.components.max(cs, False{}, 1) +mv = jpeg.components.max(cs, True{}, 1) +ok = valid && U32.is_eq(w, 0) && U32.is_eq(Bin.bytes.get(src, at), 8) && U32.is_gt(ww, 0) && U32.is_le(ww, 2048) && U32.is_gt(hh, 0) && U32.is_le(hh, 2048) && (U32.is_eq(count, 1) || U32.is_eq(count, 3) || U32.is_eq(count, 4)) && U32.is_eq((at + 6 + count * 3 : U32), end) && jpeg.components.valid(cs) && U32.is_le(jpeg.components.units(cs), 10) U.branch(JPEGFrame, ok, _ => JPEGFrame{ww, hh, mh, mv, U32.is_eq(kind, 194), jpeg.components.allocate(cs, jpeg.ceil(ww, (8 * mh : U32)), jpeg.ceil(hh, (8 * mv : U32))), quants, huffs, restart, adobe, ok}, _ => jpeg.frame.invalid(frame)) Uses (24): https://jend.leeeet.dev/definition.txt?path=Base/base.bend&name=Bool https://jend.leeeet.dev/definition.txt?path=Base/base.bend&name=Bool.and https://jend.leeeet.dev/definition.txt?path=Base/base.bend&name=Bool.or https://jend.leeeet.dev/definition.txt?path=Base/base.bend&name=U32 https://jend.leeeet.dev/definition.txt?path=Base/base.bend&name=U32.add https://jend.leeeet.dev/definition.txt?path=Base/base.bend&name=U32.inc https://jend.leeeet.dev/definition.txt?path=Base/base.bend&name=U32.is_eq https://jend.leeeet.dev/definition.txt?path=Base/base.bend&name=U32.is_gt https://jend.leeeet.dev/definition.txt?path=Base/base.bend&name=U32.is_le https://jend.leeeet.dev/definition.txt?path=Base/base.bend&name=U32.mul https://jend.leeeet.dev/definition.txt?path=Base/base.bend&name=U32.to_nat https://jend.leeeet.dev/definition.txt?path=gralha-bytes@0.1.0.1/bytes.bend&name=Bytes https://jend.leeeet.dev/definition.txt?path=gralha-bytes@0.1.0.1/bytes.bend&name=bytes.be https://jend.leeeet.dev/definition.txt?path=gralha-bytes@0.1.0.1/bytes.bend&name=bytes.get https://jend.leeeet.dev/definition.txt?path=gralha-jpeg-decode@0.1.0.1/jpeg.bend&name=JPEGFrame https://jend.leeeet.dev/definition.txt?path=gralha-jpeg-decode@0.1.0.1/jpeg.bend&name=jpeg.ceil https://jend.leeeet.dev/definition.txt?path=gralha-jpeg-decode@0.1.0.1/jpeg.bend&name=jpeg.components.allocate https://jend.leeeet.dev/definition.txt?path=gralha-jpeg-decode@0.1.0.1/jpeg.bend&name=jpeg.components.max https://jend.leeeet.dev/definition.txt?path=gralha-jpeg-decode@0.1.0.1/jpeg.bend&name=jpeg.components.read https://jend.leeeet.dev/definition.txt?path=gralha-jpeg-decode@0.1.0.1/jpeg.bend&name=jpeg.components.units https://jend.leeeet.dev/definition.txt?path=gralha-jpeg-decode@0.1.0.1/jpeg.bend&name=jpeg.components.valid https://jend.leeeet.dev/definition.txt?path=gralha-jpeg-decode@0.1.0.1/jpeg.bend&name=jpeg.frame.invalid https://jend.leeeet.dev/definition.txt?path=gralha-text-scan@0.1.0.1/scan.bend&name=branch https://jend.leeeet.dev/definition.txt?path=gralha-text-scan@0.1.0.1/scan.bend&name=choose