nx_av1_tile.nx
buildroot/runtime/nx_av1_tile.nx
about
nx_av1_tile.nx -- AV1/AV2 tile geometry and tile_info, writer and reader.
Layer four, on nx_av1_ec.nx / nx_av1_obu.nx / nx_av1_seq.nx. Tiles are how
AV1 and AV2 parallelise: a frame is split into independently decodable
rectangles, and every tile group in the bitstream is indexed against this
geometry. Get the geometry wrong and the tile data is read at the wrong
offsets -- the entropy decoder then produces confident nonsense.
THE UNITS CHANGE THREE TIMES. Pixels -> 4x4 mode-info units -> superblocks,
and the superblock step is 64 or 128 depending on a sequence-header flag.
MiCols is 2 * ((width + 7) >> 3), which is NOT (width + 3) >> 2: the frame
is rounded to an 8-pixel boundary FIRST and then counted in 4x4 units, so
odd sizes round differently than the obvious formula gives. A 1x1 frame has
2 mode-info columns, not 1.
ns() IS NOT f(n). The non-symmetric code spends w-1 bits on small values
and w bits on large ones, so that an alphabet whose size is not a power of
two costs no wasted bits. Reading it as a plain fixed-width field consumes
one bit too few on every large value and desynchronises everything after.
genealogy_id: av1_spec_5_9_15_tile_info
lineage_id: nx_av1_tile_v1
license_tier: ORIGINAL
dependencies 3 imports · 1 importers
imports: nx_syscalls.nxnx_bitstream.nxnx_av1_seq.nx
imported by: nx_av1_tile_gate.nx
structs
| none |
consts
| 29 | const NX_TILE_MAX_WIDTH: i64 = 4096 |
| 30 | const NX_TILE_MAX_AREA: i64 = 9437184 |
| 31 | const NX_TILE_MAX_COLS: i64 = 64 |
| 32 | const NX_TILE_MAX_ROWS: i64 = 64 |
| 34 | const NX_TILE_FLD_COLSLOG2: i64 = 0 |
| 35 | const NX_TILE_FLD_ROWSLOG2: i64 = 1 |
| 36 | const NX_TILE_FLD_COLS: i64 = 2 |
| 37 | const NX_TILE_FLD_ROWS: i64 = 3 |
| 38 | const NX_TILE_FLD_UNIFORM: i64 = 4 |
| 39 | const NX_TILE_FLD_SBCOLS: i64 = 5 |
| 40 | const NX_TILE_FLD_SBROWS: i64 = 6 |
functions
| 42 | func nx_av1_min2(a: i64, b: i64) -> i64 { if a < b { return a } return b } |
| 43 | func nx_av1_max2(a: i64, b: i64) -> i64 { if a > b { return a } return b } |
| 50 | func nx_av1_tile_log2(blk: i64, target: i64) -> i64 |
| 65 | func nx_av1_mi_cols(width: i64) -> i64 |
| 70 | func nx_av1_mi_rows(height: i64) -> i64 |
| 75 | func nx_av1_sb_cols(mi_cols: i64, use128: i64) -> i64 |
| 80 | func nx_av1_sb_rows(mi_rows: i64, use128: i64) -> i64 |
| 90 | func nx_av1_floorlog2b(v: i64) -> i64 |
| 98 | func nx_av1_ns_read(bs: *NxBitStream, n: i64) -> i64 |
| 111 | func nx_av1_ns_write(w: *NxAv1Bw, v: i64, n: i64) -> i64 |
| 133 | func nx_av1_tile_write_uniform(w: *NxAv1Bw, width: i64, height: i64, called by 1: main calls 8: nx_av1_mi_colsnx_av1_mi_rowsnx_av1_sb_colsnx_av1_sb_rowsnx_av1_tile_log2nx_av1_min2+2 |
| 173 | func nx_av1_tile_parse(bs: *NxBitStream, width: i64, height: i64, called by 1: main calls 8: nx_av1_mi_colsnx_av1_mi_rowsnx_av1_sb_colsnx_av1_sb_rowsnx_av1_tile_log2nx_av1_min2+2 |