nx_hevc_idct.nx
buildroot/runtime/nx_hevc_idct.nx
about
nx_hevc_idct.nx -- SOVEREIGN HEVC dequant + inverse transform, RUNG 5 of the HEVC decoder.
Dequant (8.6.3): d = (level*16*levelScale[qP%6] << (qP/6) + round) >> bdShift, clipped. Inverse transform
(8.6.4): 2-stage (vertical then horizontal) integer DCT-II (4/8/16/32) or DST-VII (4x4 luma intra), with
the normative basis matrices. Self-test: DC-only coeff -> flat residual (hand-verified). R5a = DST4/DCT4/DCT8;
DCT16/32 (same mechanism, bigger matrices) = R5b. 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
| 7 | const K_MAGIC_32768: i64 = 32768 |
| 8 | const K_MAGIC_32767: i64 = 32767 |
| 9 | const K_MAGIC_1000000: i64 = 1000000 |
| 10 | const K_MAGIC_3141593: i64 = 3141593 |
| 11 | const K_MAGIC_90509678: i64 = 90509678 |
| 12 | const K_MAGIC_500000000000: i64 = 500000000000 |
| 13 | const K_MAGIC_1000000000000: i64 = 1000000000000 |
| 14 | const K_MAGIC_1024: i64 = 1024 |
functions
| 16 | func pe(s: *u8) -> i64 { var n: i64=0; while s[n]!=(0 as u8){n=n+1} return sys_write(1,s,n) } |
| 17 | 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) } |
| 18 | func parse_nums(s: *u8, out: *i64) -> i64 { var n: i64=0; var i: i64=0; var cur: i64=0; var neg: i64=0; var has: i64=0; while s[i]!=(0 as u8){ let c: i64=s[i] as i64; if c==45 {neg=1} else { if c>=48 { if c<=57 {cur=cur*10+(c-48); has=1} else { if has==1 { if neg==1 {out[n]=0-cur} else {out[n]=cur} n=n+1; cur=0; has=0; neg=0 } } } else { if has==1 { if neg==1 {out[n]=0-cur} else {out[n]=cur} n=n+1; cur=0; has=0; neg=0 } } } i=i+1 } if has==1 { if neg==1 {out[n]=0-cur} else {out[n]=cur} n=n+1 } return n } called by 1: main |
| 19 | func clip3(lo: i64, hi: i64, v: i64) -> i64 { if v<lo {return lo} if v>hi {return hi} return v } |
| 20 | func ilog2(n: i64) -> i64 { var l: i64=0; var v: i64=n; while v>1 {v=v>>1; l=l+1} return l } called by 1: dequant |
| 23 | func dequant(coeff: *i64, N: i64, qP: i64, bitDepth: i64, lsc: *i64) -> i64 |
| 30 | func itransform(coeff: *i64, N: i64, mat: *i64, bitDepth: i64, tmp: *i64) -> i64 |
| 42 | func build_dct(gN: *i64, N: i64, gHalf: *i64, oddC: *i64) -> i64 called by 1: main |
| 53 | func fixcos(m: i64, D: i64) -> i64 |
| 65 | func gen_oc(oc: *i64, H: i64, D: i64) -> i64 { var j: i64=0; while j<H { var n: i64=0; while n<H { oc[j*H+n]=fixcos((2*n+1)*(2*j+1), D); n=n+1 } j=j+1 } return 0 } calls 1: fixcos |
| 67 | func main(argc: i64, argv: *i64) -> i64 |