nx_hevc_cabac.nx
buildroot/runtime/nx_hevc_cabac.nx
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
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
structs
| none |
consts
| none |
functions
| 9 | func pe(s: *u8) -> i64 { var n: i64=0; while s[n]!=(0 as u8){n=n+1} return sys_write(1,s,n) } |
| 10 | func 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) } |
| 12 | func 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 |
| 13 | func 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 |
| 16 | func 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 } |
| 19 | func cab_init(cab: *i64, data: *u8, bitstart: i64, bytelen: i64) -> i64 |
| 25 | func cab_renorm(cab: *i64) -> i64 { while cab[0]<256 { cab[0]=cab[0]<<1; cab[1]=(cab[1]<<1)|cab_bit(cab) } return 0 } |
| 27 | func cab_decision(cab: *i64, ctx: *i64, k: i64, rlps: *i64, tlps: *i64, tmps: *i64) -> i64 |
| 43 | func 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 } |
| 44 | func cab_terminate(cab: *i64) -> i64 { cab[0]=cab[0]-2; if cab[1]>=cab[0] { return 1 } cab_renorm(cab); return 0 } |
| 46 | func cab_ctx_init(ctx: *i64, k: i64, initValue: i64, sliceQpY: i64) -> i64 |
| 54 | func main(argc: i64, argv: *i64) -> i64 |