code wiki / (root) / nx_hevc_cabac.nx

nx_hevc_cabac.nx

buildroot/runtime/nx_hevc_cabac.nx

6373 B79 linesdepth 2pulls 2 transitivereach 0 importersview sourcekind tooltopic hevc
docsdependenciesstructsconstsfunctions

about

nx_hevc_cabac.nx -- SOVEREIGN HEVC CABAC entropy decoder, RUNG 2 of the HEVC decoder. The arithmetic decoding engine (ITU-T H.265 clause 9.3): DecodeDecision / DecodeBypass / DecodeTerminate + renormalization + context-variable init from initValue + SliceQpY. Normative tables (rangeTabLps 64x4, transIdxLps, transIdxMps) embedded as data. The syntax-element contexts (rung 3) plug their initValues into cab_ctx_init(). Self-test: init on a buffer + decode bypass/decision bins, confirm range/offset stay valid. No third party. license_tier: ORIGINAL

dependencies 1 imports · 0 importers

nx_syscalls.nx nx_hevc_cabac.nx

imports: nx_syscalls.nx

imported by: nobody (leaf or entry point)

call flow from main pre-order; caps 40 nodes / depth 6 declared; ↻ = already shown

main sys_mmap parse_nums pe sys_write pn sys_mmap ↻ sys_write ↻ cab_init cab_bit cab_ctx_init clip3 cab_bypass cab_bit ↻ cab_decision cab_renorm cab_bit ↻ cab_terminate cab_renorm ↻

structs

none

consts

none

functions

9func pe(s: *u8) -> i64 { var n: i64=0; while s[n]!=(0 as u8){n=n+1} return sys_write(1,s,n) }
called by 1: main calls 1: sys_write
10func pn(v: i64) -> i64 { var m: i64=v; if m<0{m=0-m} let b: *u8=sys_mmap(32); var i: i64=32; if m==0{i=i-1;b[i]=(48 as u8)} while m>0{let q: i64=m/10; i=i-1; b[i]=((48+(m-q*10)) as u8); m=q} if v<0 {i=i-1; b[i]=(45 as u8)} return sys_write(1,((b as i64)+i) as *u8,32-i) }
called by 1: main calls 2: sys_mmapsys_write
12func parse_nums(s: *u8, out: *i64) -> i64 { var n: i64=0; var i: i64=0; var cur: i64=0; var has: i64=0; while s[i]!=(0 as u8){ let c: i64=s[i] as i64; if c>=48 { if c<=57 { cur=cur*10+(c-48); has=1 } else { if has==1 {out[n]=cur; n=n+1; cur=0; has=0} } } else { if has==1 {out[n]=cur; n=n+1; cur=0; has=0} } i=i+1 } if has==1 {out[n]=cur; n=n+1} return n }
called by 1: main
13func clip3(lo: i64, hi: i64, v: i64) -> i64 { if v<lo {return lo} if v>hi {return hi} return v }
called by 1: cab_ctx_init
16func cab_bit(cab: *i64) -> i64 { let bp: i64=cab[3]; if bp>=cab[4] { cab[3]=bp+1; return 0 } let p: *u8=cab[2] as *u8; let byte: i64=p[bp>>3] as i64; cab[3]=bp+1; return (byte>>(7-(bp&7)))&1 }
19func cab_init(cab: *i64, data: *u8, bitstart: i64, bytelen: i64) -> i64
called by 1: main calls 1: cab_bit
25func cab_renorm(cab: *i64) -> i64 { while cab[0]<256 { cab[0]=cab[0]<<1; cab[1]=(cab[1]<<1)|cab_bit(cab) } return 0 }
called by 2: cab_decisioncab_terminate calls 1: cab_bit
27func cab_decision(cab: *i64, ctx: *i64, k: i64, rlps: *i64, tlps: *i64, tmps: *i64) -> i64
called by 1: main calls 1: cab_renorm
43func cab_bypass(cab: *i64) -> i64 { cab[1]=(cab[1]<<1)|cab_bit(cab); if cab[1]>=cab[0] { cab[1]=cab[1]-cab[0]; return 1 } return 0 }
called by 1: main calls 1: cab_bit
44func cab_terminate(cab: *i64) -> i64 { cab[0]=cab[0]-2; if cab[1]>=cab[0] { return 1 } cab_renorm(cab); return 0 }
called by 1: main calls 1: cab_renorm
46func cab_ctx_init(ctx: *i64, k: i64, initValue: i64, sliceQpY: i64) -> i64
called by 1: main calls 1: clip3
54func main(argc: i64, argv: *i64) -> i64