nx_h264_zigzag.nx source
↩ module page · 19 lines · 787 B
1// nx_h264_zigzag.nx -- 4x4 inverse zig-zag scan (spec 8.5.6 / Table 8-12).
2// CAVLC residual decode produces coefficients in SCAN order; the inverse
3// transform needs them in RASTER (row-major) order. raster[ZZ[i]] = scan[i].
4// ZZ = 0,1,4,8,5,2,3,6,9,12,13,10,7,11,14,15
5// genealogy_id: itu_t_h264_zigzag_scan_4x4
6// lineage_id: scan_to_raster_permutation
7// license_tier: ORIGINAL
8import "nx_syscalls.nx"
9
10func nx_h264_inv_zigzag4x4(scan: *i64, raster: *i64) -> i64 {
11 let zz: *i64 = sys_mmap(16 * 8) as *i64
12 zz[0]=0; zz[1]=1; zz[2]=4; zz[3]=8
13 zz[4]=5; zz[5]=2; zz[6]=3; zz[7]=6
14 zz[8]=9; zz[9]=12; zz[10]=13; zz[11]=10
15 zz[12]=7; zz[13]=11; zz[14]=14; zz[15]=15
16 var i: i64 = 0
17 while i < 16 { raster[zz[i]] = scan[i]; i = i + 1 }
18 return 0
19}