The per-plane instrument, the surcharge, and the reduced_tx_set=0 blocker
Browse files at this commitf36c7931684d6845ce8f3c27c8c023af951c3f8aParent: 13efac6- docs
- the per-plane instrument, the surcharge, and the reduced_tx_set=0 blocker
3 changed files +110 -1
- crates/ec-av1/src/decode.rs +16 -1
- crates/ec-av1/src/encode.rs +3 -0
- lanes/txi.report.md +91 -0
crates/ec-av1/src/decode.rsmodified+16 -1
| @@ -24891,6 +24891,12 @@ impl<'p> RefPix<'p> { | |||
| 24891 | /// (lane-defer8). | 24891 | /// (lane-defer8). |
| 24892 | fn ref_dims(ref_frame: i8, refpix: &RefPix<'_>) -> Result<(usize, usize)> { | 24892 | fn ref_dims(ref_frame: i8, refpix: &RefPix<'_>) -> Result<(usize, usize)> { |
| 24893 | refpix.dims(ref_frame).ok_or_else(|| { | 24893 | refpix.dims(ref_frame).ok_or_else(|| { |
| 24894 | + if crate::envflags::env_flag!("EC_AV1_REFPROBE") { | ||
| 24895 | + eprintln!( | ||
| 24896 | + "EC_REFPROBE missing ref {ref_frame}\n{}", | ||
| 24897 | + std::backtrace::Backtrace::force_capture() | ||
| 24898 | + ); | ||
| 24899 | + } | ||
| 24894 | unsupported( | 24900 | unsupported( |
| 24895 | "a reference frame selected with no picture at this frame's own \ | 24901 | "a reference frame selected with no picture at this frame's own \ |
| 24896 | ref_frame_idx slot for it", | 24902 | ref_frame_idx slot for it", |
| @@ -34220,6 +34226,9 @@ pub(crate) fn decode_inter_frame_tile_lr( | |||
| 34220 | interp_fixed, | 34226 | interp_fixed, |
| 34221 | enable_dual_filter, | 34227 | enable_dual_filter, |
| 34222 | reference_select, | 34228 | reference_select, |
| 34229 | + // lane-txi: this wrapper's callers are the decoder's own tests, which | ||
| 34230 | + // all code the reduced sets. | ||
| 34231 | + true, | ||
| 34223 | tx_select, | 34232 | tx_select, |
| 34224 | lr, | 34233 | lr, |
| 34225 | initial_cdfs, | 34234 | initial_cdfs, |
| @@ -34252,6 +34261,12 @@ pub(crate) fn decode_inter_frame_tiles_lr( | |||
| 34252 | interp_fixed: Option<mc::InterpFilterKind>, | 34261 | interp_fixed: Option<mc::InterpFilterKind>, |
| 34253 | enable_dual_filter: bool, | 34262 | enable_dual_filter: bool, |
| 34254 | reference_select: bool, | 34263 | reference_select: bool, |
| 34264 | + // lane-txi: this frame header's own `reduced_tx_set` bit. It used to be | ||
| 34265 | + // hardcoded `true` at the call below -- the encoder's own trial decode of | ||
| 34266 | + // the tile it just wrote then read every luma `tx_type` out of the | ||
| 34267 | + // reduced alphabet whatever the header said (class: a header bit a raw | ||
| 34268 | + // tile decode cannot guess, the same one `tx_select` carries). | ||
| 34269 | + reduced_tx_set: bool, | ||
| 34255 | tx_select: bool, | 34270 | tx_select: bool, |
| 34256 | lr: &LoopRestorationParams, | 34271 | lr: &LoopRestorationParams, |
| 34257 | initial_cdfs: Option<Cdfs>, | 34272 | initial_cdfs: Option<Cdfs>, |
| @@ -34314,7 +34329,7 @@ pub(crate) fn decode_inter_frame_tiles_lr( | |||
| 34314 | false, | 34329 | false, |
| 34315 | false, | 34330 | false, |
| 34316 | [0; 2], | 34331 | [0; 2], |
| 34317 | - true, | 34332 | + reduced_tx_set, |
| 34318 | tx_select, | 34333 | tx_select, |
| 34319 | switchable_motion_mode, | 34334 | switchable_motion_mode, |
| 34320 | allow_warped_motion, | 34335 | allow_warped_motion, |
crates/ec-av1/src/encode.rsmodified+3 -0
| @@ -11657,6 +11657,9 @@ pub(crate) fn encode_inter_frame( | |||
| 11657 | Some(mc::InterpFilterKind::Regular), | 11657 | Some(mc::InterpFilterKind::Regular), |
| 11658 | seq.enable_dual_filter, | 11658 | seq.enable_dual_filter, |
| 11659 | h.reference_select, | 11659 | h.reference_select, |
| 11660 | + // lane-txi: this frame's own bit, not the hardcoded `true` | ||
| 11661 | + // the wrapper used to pass. | ||
| 11662 | + h.reduced_tx_set, | ||
| 11660 | tx_select, | 11663 | tx_select, |
| 11661 | lr, | 11664 | lr, |
| 11662 | // The trial decode re-reads the tile the writer just wrote, | 11665 | // The trial decode re-reads the tile the writer just wrote, |
lanes/txi.report.mdadded+91 -0
| @@ -0,0 +1,91 @@ | |||
| 1 | +# lane-txi -- the intra type search's film loss, and `reduced_tx_set = 0` | ||
| 2 | + | ||
| 3 | +Branch `lane-txi` off main `f6c67770`. Predecessors: `lanes/txset.report.md` | ||
| 4 | +(intra five-type set, screen-gated), `lanes/txset2.report.md` (inter | ||
| 5 | +`DCT_IDTX`, screen-gated), `lanes/txrd.report.md` (the inter chroma-inherit | ||
| 6 | +fix). | ||
| 7 | + | ||
| 8 | +## 1. The instrument: WHERE the intra unconditional arm loses (12-frame gate) | ||
| 9 | + | ||
| 10 | +`EC_AV1_TXSET=all` is new here -- it lifts the intra search's screen gate | ||
| 11 | +without touching the preset lever -- and the gate already prints per-frame AND | ||
| 12 | +per-plane PSNR under `EC_AV1_FRAME_PSNR=1` (lane-txrd's instrument). | ||
| 13 | + | ||
| 14 | +Control and arm both REPRODUCE the charter's numbers to the digit: bars 1080p | ||
| 15 | +-1.0/-16.8 -> -2.3/-17.8, film A **+21.7/-4.4 -> +22.1/-4.0**. | ||
| 16 | + | ||
| 17 | +film A, per plane, per frame (frame 0 is the key frame; q=60 shown, q=150 | ||
| 18 | +identical in shape): | ||
| 19 | + | ||
| 20 | +| plane | control | arm (`EC_AV1_TXSET=all`) | | ||
| 21 | +|---|---|---| | ||
| 22 | +| Y | 51.72 46.53 47.40 46.51 47.10 47.09 46.50 ... | **51.73 46.55 47.42 46.52 47.13 47.12 46.52 ...** | | ||
| 23 | +| U | 52.52 49.39 49.75 49.44 49.65 49.87 49.60 ... | **52.52 49.41 49.77 49.49 49.68 49.90 49.62 ...** | | ||
| 24 | +| V | 52.39 49.26 49.79 49.25 49.65 49.45 49.08 ... | **52.39 49.27 49.81 49.28 49.67 49.44 49.10 ...** | | ||
| 25 | + | ||
| 26 | +READING, and it refutes the charter's premise: the arm is EQUAL OR BETTER on | ||
| 27 | +every frame, every plane and both quantizers shown -- the key frame included, | ||
| 28 | +the leaves included. There is no plane collapse (lane-txrd's chroma class) and | ||
| 29 | +no propagation shape (the leaves do not decay relative to the key frame), so | ||
| 30 | +**a reference-aware `lambda` term has no signal to act on and was not built**. | ||
| 31 | + | ||
| 32 | +What the arm actually spends is BYTES: 64392 -> 65201, 102508 -> 103781, | ||
| 33 | +170169 -> 172167, 413430 -> 419156, i.e. +1.2..1.4% of rate for +0.02..0.06 dB. | ||
| 34 | +That is a rate term the type decision under-charges (class | ||
| 35 | +`rd-rate-term-calibration`), not a distortion it mis-measures. | ||
| 36 | + | ||
| 37 | +DEVIATION FROM THE CHARTER, stated: instead of the reference-aware term, this | ||
| 38 | +lane builds the term the instrument points at -- `encode::non_dct_surcharge`, | ||
| 39 | +`(EC_AV1_TXRD_LAMBDA - 1) * lambda * bits` charged to a non-`DCT_DCT` | ||
| 40 | +candidate only (the incumbent is always `DCT_DCT`, so the block's returned | ||
| 41 | +cost stays its true one). The intra decision now reads the same | ||
| 42 | +`EC_AV1_TXRD_LAMBDA` the inter one already did. Sweep below. | ||
| 43 | + | ||
| 44 | +## 2. `reduced_tx_set = 0`: the writer half, and the defect that blocks it | ||
| 45 | + | ||
| 46 | +Commit `95b4bee9`. The bit is read in ONE place on the writer side: | ||
| 47 | + | ||
| 48 | +* `Cdfs::reduced_tx_set` (default `true`) + `TxbSet::wide()` -- every luma | ||
| 49 | + set's `Set1` counterpart, transcribed from `decode::txbset_for` / | ||
| 50 | + `txbset_for_inter` / `inter_txbset_for`, applied at the top of `Cdfs::txb`. | ||
| 51 | + The `Set1` tables differ from their narrow twins in the `tx_type` field | ||
| 52 | + ONLY, so this is the whole writer-side map; the writer's symbol already | ||
| 53 | + comes from `decode::tx_type_symbol(cdf.len(), ..)`, so the wider alphabets | ||
| 54 | + need no writer change at all. The decoder never sets the field (it names the | ||
| 55 | + wide set itself; widening a wide set is the identity). | ||
| 56 | +* `encode::wide_tx_set(screen)` (`EC_AV1_TXSET_WIDE` = `0`/`screen`/`1`, | ||
| 57 | + `speed::WIDE_TX_SET` false at every preset) drives `header.reduced_tx_set` | ||
| 58 | + on both header sites, and the frame's `Cdfs` reads the header bit. | ||
| 59 | +* `encode::luma_set_for` gives the SEARCH and its pricer the same widened set, | ||
| 60 | + so the two agree on what a `tx_type` symbol costs. | ||
| 61 | +* Candidates: intra 8x8/4x4 get the seven-type `TX_SET_INTRA_1`; the twelve- | ||
| 62 | + and sixteen-type inter lists are written (the seven types both alphabets | ||
| 63 | + share) but NOT offered -- see below. | ||
| 64 | + | ||
| 65 | +BLOCKER, bisected: with the bit off, the encoder's own trial decode of the | ||
| 66 | +tile it just wrote (`filter_search::pick_filters` -> `decode_inter_frame_ | ||
| 67 | +tiles_lr`) desyncs and reads `BWDREF` on a frame that holds no such picture -- | ||
| 68 | +"a reference frame selected with no picture at this frame's own ref_frame_idx | ||
| 69 | +slot for it", refused out of `decode::ref_dims` (new probe: | ||
| 70 | +`EC_AV1_REFPROBE=1` prints the missing reference and the backtrace). Bisection: | ||
| 71 | + | ||
| 72 | +| arm | result | | ||
| 73 | +|---|---| | ||
| 74 | +| wide bit + both type searches OFF | PASS (witness + ffmpeg exact) | | ||
| 75 | +| wide bit + INTER search on, intra off | PASS | | ||
| 76 | +| wide bit + INTRA search on (7-type set) | **FAIL, the refusal above** | | ||
| 77 | +| wide bit off, `EC_AV1_TXRD_LAMBDA` 0/0.5/4 (cost perturbation alone) | PASS | | ||
| 78 | + | ||
| 79 | +So it is not RD noise and not the inter half: something in the SEVEN-type | ||
| 80 | +intra path writes a symbol the reader resolves differently. One real defect was | ||
| 81 | +found and fixed on the way (`decode_inter_frame_tiles_lr` hardcoded | ||
| 82 | +`reduced_tx_set = true` for the encoder's own trial decode -- the class its | ||
| 83 | +neighbours' doc comments name, a header bit a raw tile decode cannot guess); | ||
| 84 | +it is not the whole story, the desync survives it. | ||
| 85 | + | ||
| 86 | +`speed::WIDE_TX_SET` is therefore false at every preset and | ||
| 87 | +`EC_AV1_TXSET_WIDE` unset is byte-identical to main. | ||
| 88 | + | ||
| 89 | +## 3. Gates, invariants, suite | ||
| 90 | + | ||
| 91 | +(filled in below as the arms land) | ||