The ARFMODE intra arm cuts the top ARF's whole-32 candidates too -- the probe falsified the leaf-only scope (film A arm 1 byte-identical to the control at q150 AND q90: the ARF's 15% intra area lives in search_inter_block's whole-32 intra loop, not in the leaves), so the scene-cut hatch as chartered was a hatch nothing else was using
Browse files at this commit7ea51337a66ba545d25a2d0b8faeced518d87c0dParent: 5e19f1a- perf
- the ARFMODE intra arm cuts the top ARF's whole-32 candidates too -- the probe falsified the leaf-only scope (film A arm 1 byte-identical to the control at q150 AND q90: the ARF's 15% intra area lives in search_inter_block's whole-32 intra loop, not in the leaves), so the scene-cut hatch as chartered was a hatch nothing else was using
- per-block engagement counter moved to the whole-32 site, docs updated, witness and pins re-green
2 changed files +64 -50
- crates/ec-av1/src/encode.rs +55 -42
- crates/ec-av1/src/speed.rs +9 -8
crates/ec-av1/src/encode.rsmodified+55 -42
| @@ -7779,13 +7779,17 @@ struct Search<'a> { | ||
| 7779 | 7779 | /// `intra_pruning_with_hog` -- never prunes it away). `None` runs every |
| 7780 | 7780 | /// mode through full RD, unchanged from before this lever. |
| 7781 | 7781 | top_k: Option<usize>, |
| 7782 | - /// lane-arfmode: the top ARF's leaf offer set ([`crate::speed::ARFMODE`]) | |
| 7783 | - /// -- `false` cuts the named candidate group from the 16x16/8x8 LEAF | |
| 7784 | - /// search ([`code_square_inter`]) and the 8x8 split offer at the top ARF | |
| 7782 | + /// lane-arfmode: the top ARF's offer set ([`crate::speed::ARFMODE`]) | |
| 7783 | + /// -- `false` cuts the named candidate group from the whole-32 search | |
| 7784 | + /// ([`search_inter_block`]), the 16x16/8x8 leaf search | |
| 7785 | + /// ([`code_square_inter`]) and the 8x8 split offer, at the top ARF | |
| 7785 | 7786 | /// ([`DqLevel::TopArf`] frames only). `true` everywhere else, which is |
| 7786 | - /// the pre-lane behaviour: the key frame never reaches | |
| 7787 | - /// [`code_square_inter`], the 32x32 whole keeps its full set, and the | |
| 7787 | + /// the pre-lane behaviour: the mid and quarter hidden frames, the shown | |
| 7788 | + /// leaves and the flat path keep intra and compound, and the | |
| 7788 | 7789 | /// straddling-edge 8x8s are only mode-gated, never partition-gated. |
| 7790 | + /// The probe's correction: with the leaf gate ALONE the film A stream | |
| 7791 | + /// was byte-identical to the control -- the ARF's intra area lives at | |
| 7792 | + /// the whole-32 level, so the intra arm must cut it there too. | |
| 7789 | 7793 | arf_leaf_intra: bool, |
| 7790 | 7794 | arf_leaf8: bool, |
| 7791 | 7795 | arf_leaf_compound: bool, |
| @@ -11018,43 +11022,52 @@ fn search_inter_block( | ||
| 11018 | 11022 | _ => search.modes.to_vec(), |
| 11019 | 11023 | }; |
| 11020 | 11024 | census_add(5, 1); |
| 11021 | - census_add(6, intra_modes.len()); | |
| 11022 | - for &mode in &intra_modes { | |
| 11023 | - let luma_trial = luma.trial( | |
| 11024 | - At { | |
| 11025 | - x, | |
| 11026 | - y, | |
| 11027 | - side: BLOCK, | |
| 11028 | - reach, | |
| 11029 | - set: luma_set, | |
| 11030 | - }, | |
| 11031 | - mode, | |
| 11032 | - 0, | |
| 11033 | - search.base_q_idx, | |
| 11034 | - search.deadzone, fctx, | |
| 11035 | - ); | |
| 11036 | - let u = u_trial.clone(); | |
| 11037 | - let v = v_trial.clone(); | |
| 11038 | - let cost = luma_trial.sse | |
| 11039 | - + u.sse | |
| 11040 | - + v.sse | |
| 11041 | - + search.lambda | |
| 11042 | - * (luma_trial.bits | |
| 11043 | - + u.bits | |
| 11044 | - + v.bits | |
| 11045 | - + mode_bits[usize::from(mode)] | |
| 11046 | - + skip_bits(false) | |
| 11047 | - + intra_inter_bits(false)); | |
| 11048 | - consider(Candidate { | |
| 11049 | - cost, | |
| 11050 | - luma: luma_trial, | |
| 11051 | - u, | |
| 11052 | - v, | |
| 11053 | - mode, | |
| 11054 | - skip: false, | |
| 11055 | - inter: None, | |
| 11056 | - mode_bits: mode_bits[usize::from(mode)], | |
| 11057 | - }); | |
| 11025 | + census_add(6, if search.arf_leaf_intra { intra_modes.len() } else { 0 }); | |
| 11026 | + // lane-arfmode: arm 1 drops the whole-32 block's intra candidates at the | |
| 11027 | + // top ARF too -- the probe proved the ARF's intra AREA lives HERE, not at | |
| 11028 | + // the leaves (film A arm 1 vs control byte-identical with the leaf gate | |
| 11029 | + // alone), so "the 32x32 whole keeps intra as the scene-cut hatch" was a | |
| 11030 | + // hatch nothing else was using. Counted once per block. | |
| 11031 | + if search.arf_leaf_intra { | |
| 11032 | + for &mode in &intra_modes { | |
| 11033 | + let luma_trial = luma.trial( | |
| 11034 | + At { | |
| 11035 | + x, | |
| 11036 | + y, | |
| 11037 | + side: BLOCK, | |
| 11038 | + reach, | |
| 11039 | + set: luma_set, | |
| 11040 | + }, | |
| 11041 | + mode, | |
| 11042 | + 0, | |
| 11043 | + search.base_q_idx, | |
| 11044 | + search.deadzone, fctx, | |
| 11045 | + ); | |
| 11046 | + let u = u_trial.clone(); | |
| 11047 | + let v = v_trial.clone(); | |
| 11048 | + let cost = luma_trial.sse | |
| 11049 | + + u.sse | |
| 11050 | + + v.sse | |
| 11051 | + + search.lambda | |
| 11052 | + * (luma_trial.bits | |
| 11053 | + + u.bits | |
| 11054 | + + v.bits | |
| 11055 | + + mode_bits[usize::from(mode)] | |
| 11056 | + + skip_bits(false) | |
| 11057 | + + intra_inter_bits(false)); | |
| 11058 | + consider(Candidate { | |
| 11059 | + cost, | |
| 11060 | + luma: luma_trial, | |
| 11061 | + u, | |
| 11062 | + v, | |
| 11063 | + mode, | |
| 11064 | + skip: false, | |
| 11065 | + inter: None, | |
| 11066 | + mode_bits: mode_bits[usize::from(mode)], | |
| 11067 | + }); | |
| 11068 | + } | |
| 11069 | + } else { | |
| 11070 | + arfmode_hit(0); | |
| 11058 | 11071 | } |
| 11059 | 11072 | |
| 11060 | 11073 | // The reference frame buffer a spec decoder holds is exactly the true |
crates/ec-av1/src/speed.rsmodified+9 -8
| @@ -460,14 +460,15 @@ pub(crate) const ARF_TF_WIN: [usize; 11] = [3; 11]; | ||
| 460 | 460 | /// so [`ARF_TF`] stays where lane-arftf put it. |
| 461 | 461 | pub(crate) const ARF_TF_WIN_FUT: [usize; 11] = [3; 11]; |
| 462 | 462 | |
| 463 | -/// lane-arfmode: the top ARF's LEAF offer set, as a bitmask -- `1` the 16x16 | |
| 464 | -/// and 8x8 leaves of the group's own anchor ([`crate::encode::DqLevel:: | |
| 465 | -/// TopArf`]) offer no INTRA candidate, `2` a 16x16 leaf under it is not | |
| 466 | -/// offered the 8x8 split, `4` the leaves offer no compound candidates; | |
| 467 | -/// combinations OR, `0` (the default) is bit-exact with the pre-lane | |
| 468 | -/// encoder. `EC_AV1_ARFMODE=<n>` overrides it. The 32x32 whole keeps its | |
| 469 | -/// full offer set (the scene-cut hatch), and the spec-forced 8x8s at | |
| 470 | -/// straddling edges are untouched -- only RD-optional offers are cut. | |
| 463 | +/// lane-arfmode: the top ARF's offer set, as a bitmask -- `1` the group's | |
| 464 | +/// own anchor ([`crate::encode::DqLevel::TopArf`]) offers no INTRA | |
| 465 | +/// candidate at any block size (the whole-32 search and the 16x16/8x8 | |
| 466 | +/// leaves), `2` a 16x16 leaf under it is not offered the 8x8 split, `4` the | |
| 467 | +/// leaves offer no compound candidates; combinations OR, `0` (the default) | |
| 468 | +/// is bit-exact with the pre-lane encoder. `EC_AV1_ARFMODE=<n>` overrides | |
| 469 | +/// it. The spec-forced 8x8s at straddling edges are untouched -- only | |
| 470 | +/// RD-optional offers are cut; the mid and quarter hidden frames and every | |
| 471 | +/// shown leaf keep the full set. | |
| 471 | 472 | /// |
| 472 | 473 | /// The census it answers to (lanes/arfmode.charter.md, at 0d81d6c5): the top |
| 473 | 474 | /// ARF's syntax gap against rav1e's own ARF at the same position is |