nx_hevc_slice.nx
buildroot/runtime/nx_hevc_slice.nx
about
nx_hevc_slice.nx -- SOVEREIGN HEVC headers, RUNG 3a of the HEVC decoder.
Parses SPS (extended: CTB/transform sizes, SAO), PPS (init_qp, slice-header bits), and pulls the FIRST
IDR slice NAL out of the .mkv's first keyframe to read its slice_type. This + the CABAC engine (R2) are
everything needed before the CTU/residual parse (R3b). No third party. Usage: nx_hevc_slice <in.mkv>
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
| 7 | const K_MAGIC_8388608: i64 = 8388608 |
| 8 | const K_MAGIC_8192: i64 = 8192 |
functions
| 10 | func pe(s: *u8) -> i64 { var n: i64=0; while s[n]!=(0 as u8){n=n+1} return sys_write(1,s,n) } |
| 11 | 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 vlen(b0: i64) -> i64 { if (b0&0x80)!=0{return 1} if (b0&0x40)!=0{return 2} if (b0&0x20)!=0{return 3} if (b0&0x10)!=0{return 4} if (b0&0x08)!=0{return 5} if (b0&0x04)!=0{return 6} if (b0&0x02)!=0{return 7} return 8 } |
| 13 | func rid(b: *u8, i: i64, lo: *i64) -> i64 { let L: i64=vlen(b[i] as i64); var v: i64=0; var k: i64=0; while k<L {v=(v<<8)|(b[i+k] as i64); k=k+1} lo[0]=L; return v } |
| 14 | func rsz(b: *u8, i: i64, lo: *i64) -> i64 { let L: i64=vlen(b[i] as i64); var v: i64=(b[i] as i64)&(0xff>>L); var k: i64=1; while k<L {v=(v<<8)|(b[i+k] as i64); k=k+1} lo[0]=L; return v } |
| 15 | func ruint(b: *u8, o: i64, len: i64) -> i64 { var v: i64=0; var k: i64=0; while k<len {v=(v<<8)|(b[o+k] as i64); k=k+1} return v } called by 1: main |
| 17 | func deemul(src: *u8, off: i64, len: i64, nhdr: i64, out: *u8) -> i64 called by 1: main |
| 23 | func bget1(bs: *i64) -> i64 { let p: *u8=bs[0] as *u8; let bp: i64=bs[1]; let byte: i64=p[bp>>3] as i64; bs[1]=bp+1; return (byte>>(7-(bp&7)))&1 } |
| 24 | func bget(bs: *i64, n: i64) -> i64 { var v: i64=0; var i: i64=0; while i<n { v=(v<<1)|bget1(bs); i=i+1 } return v } |
| 25 | func bue(bs: *i64) -> i64 { var lz: i64=0; while bget1(bs)==0 { lz=lz+1; if lz>40 {return 0} } if lz==0 {return 0} return ((1<<lz)-1)+bget(bs,lz) } |
| 26 | func bse(bs: *i64) -> i64 { let k: i64=bue(bs); if (k&1)==1 { return (k+1)/2 } return 0-(k/2) } |
| 28 | func main(argc: i64, argv: *i64) -> i64 |