nx_hevc_parse.nx
buildroot/runtime/nx_hevc_parse.nx
about
nx_hevc_parse.nx -- SOVEREIGN HEVC(H.265) bitstream parser, RUNG 1 of the sovereign HEVC decoder.
Pulls the hvcC (CodecPrivate) from a .mkv, splits out VPS/SPS/PPS, de-emulates the SPS RBSP, and
Exp-Golomb-decodes the SPS to recover the real stream params (size, chroma, bit depth, profile/level).
No third party: this is the foundation the CABAC + reconstruction rungs build on. Usage: nx_hevc_parse <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} return sys_write(1,((b as i64)+i) as *u8,32-i) } |
| 13 | 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 } |
| 14 | 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 } |
| 15 | 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 } |
| 17 | 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; let bit: i64=(byte>>(7-(bp&7)))&1; bs[1]=bp+1; return bit } |
| 18 | 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 } |
| 19 | 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) } |
| 21 | func main(argc: i64, argv: *i64) -> i64 |