From 29220f1a7a91f9256ab918f4863f1d2aa6f6c198 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Ahmet=20Kaan=20G=C3=BCm=C3=BC=C5=9F?= Date: Tue, 8 Sep 2026 13:32:36 +0300 Subject: [PATCH] feat(av1): the top ARF codes its delta_q at 1.5x the preset's strength lane-arfq: `speed::DQ_LEVEL_K = [1.5, 1.0, 1.0]` -- at preset 0 the mini-GOP's own hidden ALTREF now maps the tpl ratio onto its superblock quantizers at 0.375 where the mid level and the leaves keep 0.25. Long-GOP gate (48 pictures, BD vs libaom / rav1e), control reproduced first: film A +24.0/-7.6 -> +23.5/-8.0, film B +85.8/+7.1 -> +85.3/+6.7 i.e. both films down on both columns. 12-frame gate: bars 1080p -3.1/-18.7 -> -3.2/-18.8, bars 2160p +9.1/-13.3 -> +9.2/-13.3, film A +20.3/-5.0 -> +20.3/-4.9, film B +24.6/-2.0 -> +24.7/-1.8, screen +14.6/-33.2 unchanged (a screen frame codes no delta syntax at all). 0.5 buys film A twice as much (+23.0/-8.2) and turns film B back up (+86.0/+7.3) while costing the 12-frame film B row 0.4; the strength sweep and the per-level census are in lanes/arfq.report.md. Byte pins re-taken with a five-line comment: 8252 -> 8269 at q=150 and 33053 -> 33044 at q=60; green at default and at EC_AV1_SPEED=6. --- crates/ec-av1/src/encode.rs | 7 ++++++- crates/ec-av1/src/speed.rs | 26 +++++++++++++++++++++++--- 2 files changed, 29 insertions(+), 4 deletions(-) diff --git a/crates/ec-av1/src/encode.rs b/crates/ec-av1/src/encode.rs index b283cc97..c903bede 100644 --- a/crates/ec-av1/src/encode.rs +++ b/crates/ec-av1/src/encode.rs @@ -16813,7 +16813,12 @@ mod tests { // quantizer grid -- and every decision priced against it -- moved // (8325 -> 8419 / 33014 -> 33029 on its own base); re-taken once more // at the merge of both lanes. - let pins: [(u8, usize, u64); 2] = [(150, 8252, 0x5b6e40a2b5498988), (60, 33053, 0x9a0abfc234eccc37)]; + // Re-taken on lane-arfq: the top ARF of a mini-GOP codes its + // per-superblock `delta_qindex` at 1.5x the preset's strength + // ([`crate::speed::DQ_LEVEL_K`]), so the hidden frames' quantizer + // grids -- and every decision priced against them -- moved: + // 8252 -> 8269 bytes at q=150 and 33053 -> 33044 at q=60. + let pins: [(u8, usize, u64); 2] = [(150, 8269, 0xf0a10bafe7b45fe2), (60, 33044, 0x077e9c22ff6f41fb)]; let coded: Vec<(u8, usize, u64)> = pins .iter() .map(|&(q, _, _)| { diff --git a/crates/ec-av1/src/speed.rs b/crates/ec-av1/src/speed.rs index 2e21ed83..d59d0df3 100644 --- a/crates/ec-av1/src/speed.rs +++ b/crates/ec-av1/src/speed.rs @@ -342,9 +342,29 @@ pub(crate) const DQ_TPL_K: [f64; 11] = [0.25, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, /// [`crate::encode::DqLevel`] -- `[top ARF, mid ARF, leaf]`. The key frame is /// absent because it codes no `delta_q` syntax at all. /// -/// `EC_AV1_DQ_K=::` overrides it for an A/B. The default is -/// flat: see `lanes/arfq.report.md` for the sweep this table records. -pub(crate) const DQ_LEVEL_K: [f64; 3] = [1.0, 1.0, 1.0]; +/// `EC_AV1_DQ_K=::` overrides it for an A/B. +/// +/// The top ARF is coded 1.5x the preset's strength (0.375 at preset 0, where +/// the leaves keep 0.25): it feeds a whole mini-GOP, and the census +/// (`EC_AV1_DQ_CENSUS=1`, film B 48 pictures) says the objective mapping is +/// normalised BY the frame's own dependence ratio, so the top ARF's much +/// higher `r_frame` (2.91 vs the leaves' 1.74) buys it nothing at all -- +/// what a level's strength moves is the CONTRAST inside that frame. Long-GOP +/// gate (48 pictures, BD vs libaom / rav1e): +/// +/// | top-ARF strength | film A | film B | +/// |---|---|---| +/// | 0.25 (flat, control) | +24.0/-7.6 | +85.8/+7.1 | +/// | **0.375** | **+23.5/-8.0** | **+85.3/+6.7** | +/// | 0.5 | +23.0/-8.2 | +86.0/+7.3 | +/// | 0.75 | +22.7/-8.4 | +86.8/+7.8 | +/// | 1.0 | +21.8/-8.9 | +88.7/+9.1 | +/// +/// Film A goes on improving with strength and film B turns at 0.375, which is +/// the last point down on all four columns; 0.5 is also the point where the +/// 12-frame gate hands film B back 0.4 (0.375 costs it 0.1). See +/// `lanes/arfq.report.md`. +pub(crate) const DQ_LEVEL_K: [f64; 3] = [1.5, 1.0, 1.0]; /// `encode::SPLIT_RD_THRESHOLD`: how cheap a block has to be before its split /// trial is withheld. The single biggest wall lever in the tile search.