The root cause, the class sweep, the witness and the deferred inter half
Browse files at this commit1f7f6f0ffd13cd84cd3232342b35c169fc19de64Parent: ae80b33- docs
- the root cause, the class sweep, the witness and the deferred inter half
1 changed file +86 -0
- lanes/txw.report.md +86 -0
lanes/txw.report.mdadded+86 -0
| @@ -0,0 +1,86 @@ | ||
| 1 | +# lane-txw -- the tile writer coded every transform unit as TX_CLASS_2D | |
| 2 | + | |
| 3 | +## First divergent symbol | |
| 4 | + | |
| 5 | +`EC_AV1_TXSET_WIDE=1 EC_AV1_REFPROBE=1 cargo test -p ec-av1 --release --lib | |
| 6 | +an_inter_clip_codes_both` refused on BWDREF ("a reference frame selected with | |
| 7 | +no picture at this frame's own ref_frame_idx slot"), raised out of the | |
| 8 | +ENCODER's own trial decode (`filter_search::pick_filters` -> | |
| 9 | +`decode_inter_frame_tiles_lr`). No symbol-stream diff was needed: the writer | |
| 10 | +side has no `TxClass` at all (`grep -n "TxClass" crates/ec-av1/src/tile.rs` | |
| 11 | +was empty), while the reader resolves one for every unit | |
| 12 | +(`decode::TxClass::of`). The FIRST symbol that can diverge is therefore the | |
| 13 | +`eob_pt` of the first `V_DCT`/`H_DCT` unit -- the writer coded it into the 2D | |
| 14 | +row, the reader reads `eob_pt_class1` -- and every context after it. | |
| 15 | + | |
| 16 | +## Root cause | |
| 17 | + | |
| 18 | +`tile::write_coeffs` treated every unit as `TX_CLASS_2D`: | |
| 19 | + | |
| 20 | +* default zigzag scan instead of `Mrow_Scan`/`Mcol_Scan` | |
| 21 | + (`decode::class_scan_table`), | |
| 22 | +* `coding.eob_pt` instead of the class-1 row (`eob_pt_class1`, the split | |
| 23 | + lane-av1tx4 r5 put on the reader), | |
| 24 | +* `base_ctx`/`br_ctx` with the 2D taps, the 2D DC short-circuit and | |
| 25 | + `NZ_MAP_CTX_OFFSET_32` instead of the 1-D taps and | |
| 26 | + `nz_map_ctx_offset_1d`. | |
| 27 | + | |
| 28 | +Under the reduced alphabets no search ever offered a 1-D type, so the writer | |
| 29 | +was right by accident. The `reduced_tx_set = 0` intra set (`TX_SET_INTRA_1`) | |
| 30 | +is the first alphabet whose candidate list holds `V_DCT`/`H_DCT`, so the | |
| 31 | +lever exposed it. The refusal is the `refusal-from-own-desync` class: the | |
| 32 | +desynced tile named a reference the frame holds no picture in. | |
| 33 | + | |
| 34 | +## Class and sweep | |
| 35 | + | |
| 36 | +Class: `writer half of a decoder-side split` -- a per-unit property the | |
| 37 | +reader derives (here `TxClass`) that the writer never mirrored. Swept every | |
| 38 | +writer site that codes coefficients: | |
| 39 | + | |
| 40 | +* `tile::write_coeffs` -- the one coefficient writer (luma and chroma, all | |
| 41 | + four square sides, both the tile writer and the pricer through | |
| 42 | + `coeff_bits_typed`): FIXED. | |
| 43 | +* `tile::write_dc_coeffs` -- the fixed-CDF 32x32 luma DC path; 32x32 codes no | |
| 44 | + `tx_type` symbol and is always `DCT_DCT`, so 2D is correct there. | |
| 45 | +* `tile::write_block_planes` chroma -- codes chroma as `DCT_DCT` while an | |
| 46 | + INTER block's decoder INHERITS the luma type | |
| 47 | + (`decode::reduce_inherited_chroma_tx_type`): a real sibling defect, see | |
| 48 | + "deferred" below. Intra chroma takes its type from its own UV mode, never | |
| 49 | + from luma, so the intra half is unaffected. | |
| 50 | +* `encode::recode_inter_chroma` -- reduces against a `FrameCtx` whose | |
| 51 | + `reduced_tx_set_inter` the encoder NEVER sets (always `true`): same | |
| 52 | + sibling. | |
| 53 | + | |
| 54 | +## Fix | |
| 55 | + | |
| 56 | +`crates/ec-av1/src/tile.rs`: `write_coeffs` resolves `crate::decode::TxClass::of(tx_type)` | |
| 57 | +once per unit and takes its scan (`class_scan_of`, cached, built from the | |
| 58 | +decoder's own `class_scan_table`), its `eob_pt` row (`write_eob` now picks | |
| 59 | +`eob_pt_class1` exactly as `decode::read_eob` does) and class-aware | |
| 60 | +`base_ctx`/`br_ctx` from it. `crates/ec-av1/src/decode.rs`: `TxClass`, | |
| 61 | +`TxClass::of`, `class_scan_table` and `nz_map_ctx_offset_1d` are | |
| 62 | +`pub(crate)` so the writer reads the reader's own tables (class | |
| 63 | +`table-and-reader-move-together`). | |
| 64 | + | |
| 65 | +## Witness | |
| 66 | + | |
| 67 | +`encoder::tests::a_wide_tx_set_clip_codes_the_new_alphabets_both_decoders_read_exactly` | |
| 68 | +un-ignored as a blocker (it keeps a "run it alone" ignore: it sets | |
| 69 | +process-global search levers). At preset 0 it codes | |
| 70 | +`intra [962, 25435, 1630, 1665, 1888, 1820, 2435, 0..]` -- 1820 `V_DCT` and | |
| 71 | +2435 `H_DCT` units, the two types only `TX_SET_INTRA_1` can name -- 8724 | |
| 72 | +bytes, and both decoders (ours and ffmpeg) read every frame sample-exact. | |
| 73 | + | |
| 74 | +## Deferred | |
| 75 | + | |
| 76 | +* `deferred: the INTER half of the widening (`encode::inter_luma_set` still | |
| 77 | + names the narrow sets) -- with it widened the same refusal returns AFTER | |
| 78 | + this fix, and the remaining cause is the chroma inheritance above: the | |
| 79 | + encoder never sets `FrameCtx::reduced_tx_set_inter` (so | |
| 80 | + `recode_inter_chroma` quantises chroma against the REDUCED allowance while | |
| 81 | + a `reduced_tx_set = 0` decoder allows the full one) and | |
| 82 | + `write_block_planes` codes chroma as `DCT_DCT` whatever luma chose -- | |
| 83 | + unblocked by threading the frame bit into the encoder's `FrameCtx` and | |
| 84 | + giving the writer the inherited chroma type. | |
| 85 | +* `deferred: the BD arms for shipping `WIDE_TX_SET` at preset 0 -- see the | |
| 86 | + gate section. |