forge
Explore
Log in

Don't you dare go Hollow

The slot map, the ARF stale premise, the witness table

Browse files at this commit

9563c9f61d5fc1f775a2ea261e7f79d7fea7da76Ahmet Kaan GümüşParent: ddabc81
  • docs
    • the slot map, the ARF stale premise, the witness table
Show full message
docs(last2): the slot map, the ARF stale premise, the witness table
crates/ec-av1/src/encode.rsmodified+13 -0
@@ -16977,6 +16977,19 @@ mod tests {
16977 mm.iter().sum::<usize>(),16977 mm.iter().sum::<usize>(),
16978 );16978 );
16979 print_inter_tx_census(name);16979 print_inter_tx_census(name);
16980+ // lane-last2 (class `gate-blind-to-feature`): which reference the
16981+ // 32x32-and-below inter blocks of this clip's four encodes chose.
16982+ // The native table is the standing keep table, so a second past
16983+ // reference that never won a block has to be visible HERE and not
16984+ // only in a synthetic witness.
16985+ let rh = crate::encode::take_ref_frame_hits();
16986+ let rtot: usize = rh.iter().sum();
16987+ eprintln!(
16988+ "{name}: references LAST {} LAST2 {} GOLDEN {} ALTREF {} of {} inter blocks \
16989+ (LAST2 {:.1}%)",
16990+ rh[1], rh[2], rh[4], rh[7], rtot,
16991+ 100.0 * rh[2] as f64 / rtot.max(1) as f64,
16992+ );
16980 let palette = crate::tile::take_palette_hits();16993 let palette = crate::tile::take_palette_hits();
16981 let palette_uv = crate::tile::take_palette_uv_hits();16994 let palette_uv = crate::tile::take_palette_uv_hits();
16982 let ibc = crate::tile::take_intrabc_hits();16995 let ibc = crate::tile::take_intrabc_hits();
lanes/last2.report.mdmodified+52 -0
@@ -45,3 +45,55 @@ every key frame (which writes all eight slots with one picture `GOLDEN`
45 already names). A leaf whose `LAST` is a hidden frame reads the previous leaf45 already names). A leaf whose `LAST` is a hidden frame reads the previous leaf
46 as `LAST2`. The hidden levels pass `None`: see §0.46 as `LAST2`. The hidden levels pass `None`: see §0.
47 47
48+## 2. What changed
49+
50+`crates/ec-av1/src/encoder.rs`
51+* `LEAF_SLOTS = [0, 7]`, `Av1Encoder::leaf_hist` (the last two leaf slots,
52+ cleared by every key frame), the leaf loop alternates `self_slot` and names
53+ the older slot; `encode_pyramid_inter` takes `last2_slot: Option<u8>`,
54+ drops it when it holds no picture or the same one `LAST` names, and derives
55+ `sign_bias[1]` / `order_hints[1]` from it through the existing `slots` array
56+ (so the writer and the decoder scan the same stacks).
57+* `last2()` / `set_last2` — `EC_AV1_LAST2`, default OFF this lane, plus the
58+ process-global override the witness uses (this crate's tests never call
59+ `set_var`).
60+
61+`crates/ec-av1/src/encode.rs`
62+* `PyramidFrame::last2_slot`; `encode_inter_frame` takes `last2:
63+ Option<&Picture>` and, when the slot is named, sets
64+ `header.ref_frame_idx[1]`.
65+* The picture reaches: the 32x32 `extra` search list (`NEAREST`/`NEAR`/
66+ `GLOBAL` plus the existing `EXTRA_REF_NEW_MV` search under
67+ `EXTRA_NEW_SKIP_MARGIN` — the charter's "free arm" and its seeded arm are
68+ the SAME code path here, since extra references already get a NEWMV), the
69+ OBMC neighbour picture table, and the trial decode's `RefPix` slot 2.
70+* The RD pricer's `single_ref_bits` gained LAST2's `p4 = 1` leaf.
71+* The native gate prints a per-clip reference census (`LAST / LAST2 / GOLDEN /
72+ ALTREF`), so the keep table can see whether the tool fires at all.
73+
74+The 16x16/8x8 leaves are NOT offered LAST2 as a single reference: that path
75+(`code_square_inter`) takes no `extra` list at all, only compound pairs. The
76+64x64 root goes through `search_skip_64`, likewise no `extra`. So this arm is
77+the 32x32 level, which is where the existing extra references live too.
78+
79+## 3. The witness
80+
81+`encoder::tests::a_leaf_predicts_off_last2_when_the_picture_two_back_matches`
82+(not ignored, 3.6 s): nine 128x128 pictures ALTERNATING between two textures,
83+`mini_gop` 4, so every leaf's picture two back is an exact match.
84+
85+| lever | LAST | LAST2 | GOLDEN | ALTREF | stream |
86+|---|---|---|---|---|---|
87+| off | 67 | **0** | 18 | 8 | 2969 B |
88+| on | 25 | **36** | 15 | 8 | 2300 B |
89+
90+36 blocks coded off LAST2 (0 with the lever off — the counter measures this
91+lane and not the reference set we already had), −22.5% bytes on the clip the
92+lever is built for, `decode_stream` and ffmpeg both reconstruct all nine
93+display positions sample-exact, and one `show_existing_frame` per hidden frame
94+survives.
95+
96+## 4. The 12-frame native gate
97+
98+Controls reproduce to the digit: film A +21.7 / −4.4, film B +26.9 / −0.6.
99+