NZ_MAP_CTX_OFFSET_32X64/_64X32 were transposed
Browse files at this commit621d55b64f4bc0240141da01a83f665968b7cda3Parent: 4f7d6d1- fix
- NZ_MAP_CTX_OFFSET_32X64/_64X32 were transposed
1 changed file +27 -10
- crates/ec-av1/src/cdf.rs +27 -10
crates/ec-av1/src/cdf.rsmodified+27 -10
| @@ -770,22 +770,39 @@ pub const NZ_MAP_CTX_OFFSET_32: [[u8; 5]; 5] = [ | |||
| 770 | /// indexes this position table by the raw, un-adjusted `tx_size` -- lane-sbpart | 770 | /// indexes this position table by the raw, un-adjusted `tx_size` -- lane-sbpart |
| 771 | /// r8 root cause) is genuinely rectangular, not square. Distinct from | 771 | /// r8 root cause) is genuinely rectangular, not square. Distinct from |
| 772 | /// [`NZ_MAP_CTX_OFFSET_32`] starting at `(row=1, col=0)`. | 772 | /// [`NZ_MAP_CTX_OFFSET_32`] starting at `(row=1, col=0)`. |
| 773 | +// lane-part32 r3: this table was TRANSPOSED (row/col swapped) as landed by | ||
| 774 | +// lane-sbpart r8 -- caught by tracing a real aomenc pin against a patched | ||
| 775 | +// aomdec (added per-symbol `EC_TRACE_COEFF` ctx prints to | ||
| 776 | +// `read_coeffs_reverse{,_2d}` in `~/.cache/aom-oracle`), which showed our own | ||
| 777 | +// `(row=2, col=0)` reading ctx-offset 11 where the real decoder's equivalent | ||
| 778 | +// position read 6. Re-derived straight from libaom's own generating | ||
| 779 | +// comment in `get_nz_map_ctx_from_stats` (`txb_common.h:199-210`): for | ||
| 780 | +// `width < height` (this table, `TX_32X64`), ctx is `11 +` for `row < 2` | ||
| 781 | +// *regardless of col* -- the old table instead special-cased `col < 2`, | ||
| 782 | +// which is the `width > height` (`TX_64X32`) branch. Confirmed against the | ||
| 783 | +// real `av1_nz_map_ctx_offset_32x64`/`_64x32` C arrays in | ||
| 784 | +// `av1/common/txb_common.c`, decoded through libaom's own col-major | ||
| 785 | +// `pos = col*32+row` raster (same convention [`SCAN_32X16`]'s doc comment | ||
| 786 | +// already documents this decoder transcribes out of). | ||
| 773 | pub const NZ_MAP_CTX_OFFSET_32X64: [[u8; 5]; 5] = [ | 787 | pub const NZ_MAP_CTX_OFFSET_32X64: [[u8; 5]; 5] = [ |
| 774 | - [0, 11, 6, 6, 21], | 788 | + [0, 11, 11, 11, 11], |
| 775 | - [11, 11, 6, 21, 21], | 789 | + [11, 11, 11, 11, 11], |
| 776 | - [11, 11, 21, 21, 21], | 790 | + [6, 6, 21, 21, 21], |
| 777 | - [11, 11, 21, 21, 21], | 791 | + [6, 21, 21, 21, 21], |
| 778 | - [11, 11, 21, 21, 21], | 792 | + [21, 21, 21, 21, 21], |
| 779 | ]; | 793 | ]; |
| 780 | 794 | ||
| 781 | /// [`NZ_MAP_CTX_OFFSET_32X64`]'s `TX_64X32` counterpart (libaom | 795 | /// [`NZ_MAP_CTX_OFFSET_32X64`]'s `TX_64X32` counterpart (libaom |
| 782 | /// `av1_nz_map_ctx_offset_64x32`): a `PARTITION_HORZ` strip's luma corner. | 796 | /// `av1_nz_map_ctx_offset_64x32`): a `PARTITION_HORZ` strip's luma corner. |
| 797 | +/// `width > height` here, so the `col < 2` branch (offset 16) fires | ||
| 798 | +/// regardless of row -- transpose of [`NZ_MAP_CTX_OFFSET_32X64`]'s `row < 2` | ||
| 799 | +/// branch, same r3 fix (see that table's doc comment). | ||
| 783 | pub const NZ_MAP_CTX_OFFSET_64X32: [[u8; 5]; 5] = [ | 800 | pub const NZ_MAP_CTX_OFFSET_64X32: [[u8; 5]; 5] = [ |
| 784 | - [0, 16, 16, 16, 16], | 801 | + [0, 16, 6, 6, 21], |
| 785 | - [16, 16, 16, 16, 16], | 802 | + [16, 16, 6, 21, 21], |
| 786 | - [6, 6, 21, 21, 21], | 803 | + [16, 16, 21, 21, 21], |
| 787 | - [6, 21, 21, 21, 21], | 804 | + [16, 16, 21, 21, 21], |
| 788 | - [21, 21, 21, 21, 21], | 805 | + [16, 16, 21, 21, 21], |
| 789 | ]; | 806 | ]; |
| 790 | 807 | ||
| 791 | /// `Default_Txb_Skip_Cdf[2][2][7..10]` (spec 9.4): the all-zero flag of a | 808 | /// `Default_Txb_Skip_Cdf[2][2][7..10]` (spec 9.4): the all-zero flag of a |