code wiki / _hdl_build / _inflate_lib_authored.nx

_inflate_lib_authored.nx

buildroot/runtime/_hdl_build/_inflate_lib_authored.nx

5568 B25 linesdepth 2pulls 2 transitivereach 22 importersview sourcekind librarytopic inflate
docsdependenciesstructsconstsfunctions

about

AUTHORED BY THE NISHI BUILDER -- reusable DEFLATE inflate library (RFC 1951, stored+fixed+dynamic)

dependencies 1 imports · 7 importers

nx_syscalls.nx _inflate_lib_authored.nx _flatedecode_authored.nx _pdf_reflow_lib.nx _pdf_stream_authored.nx _pdf_to_text_authored.nx _reader_open_authored.nx _zip_extract_authored.nx nx_deflate_fixed.nx

imports: nx_syscalls.nx

imported by: _flatedecode_authored.nx_pdf_reflow_lib.nx_pdf_stream_authored.nx_pdf_to_text_authored.nx_reader_open_authored.nx_zip_extract_authored.nxnx_deflate_fixed.nx

structs

none

consts

none

functions

3func ibr(buf: *u8, len: i64, cur: *i64, n: i64) -> i64 { var v: i64=0; var g: i64=0; while g<n { let bp: i64=cur[0]>>3; if bp>=len { return 0 } let bit: i64=((buf[bp] as i64)>>(cur[0]&7))&1; v=v|(bit<<g); cur[0]=cur[0]+1; g=g+1 } return v }
called by 3: ihdicodesinflate
4func ihb(ln: *i64, n: i64, ct: *i64, sy: *i64) -> i64 { var i: i64=0; while i<=15 { ct[i]=0; i=i+1 } i=0; while i<n { ct[ln[i]]=ct[ln[i]]+1; i=i+1 } let of: *i64=sys_mmap(8*17) as *i64; of[1]=0; var l: i64=1; while l<15 { of[l+1]=of[l]+ct[l]; l=l+1 } i=0; while i<n { if ln[i]!=0 { sy[of[ln[i]]]=i; of[ln[i]]=of[ln[i]]+1 } i=i+1 } return 0 }
called by 1: inflate calls 1: sys_mmap
5func ihd(buf: *u8, len: i64, cur: *i64, ct: *i64, sy: *i64) -> i64 { var code: i64=0; var first: i64=0; var idx: i64=0; var l: i64=1; while l<=15 { code=code|ibr(buf,len,cur,1); let c: i64=ct[l]; if code-first<c { return sy[idx+(code-first)] } idx=idx+c; first=first+c; first=first<<1; code=code<<1; l=l+1 } return 0-1 }
called by 2: icodesinflate calls 1: ibr
6func icodes(src: *u8, sl: i64, cur: *i64, out: *u8, op: i64, lc: *i64, ls: *i64, dc: *i64, ds: *i64, lens: *i64, lext: *i64, dists: *i64, dext: *i64) -> i64 { var outpos: i64=op; var done: i64=0; while done==0 { let sym: i64=ihd(src,sl,cur,lc,ls); if sym<0 { done=1 } else { if sym<256 { out[outpos]=sym as u8; outpos=outpos+1 } else { if sym==256 { done=1 } else { let s: i64=sym-257; let length: i64=lens[s]+ibr(src,sl,cur,lext[s]); let dsy: i64=ihd(src,sl,cur,dc,ds); let dist: i64=dists[dsy]+ibr(src,sl,cur,dext[dsy]); var ci: i64=0; while ci<length { out[outpos]=out[outpos-dist]; outpos=outpos+1; ci=ci+1 } } } } } return outpos }
called by 1: inflate calls 2: ihdibr
7func inflate(src: *u8, srclen: i64, out: *u8) -> i64