From e062d5bb1a397496aa6a4af46d82ad0080e196cb Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Ahmet=20Kaan=20G=C3=BCm=C3=BC=C5=9F?= Date: Sun, 6 Sep 2026 11:02:56 +0300 Subject: [PATCH] feat(av1): compound reference on by default -- BD down on all three gate clips Flat BD gate, same machine: vs libaom +121.2/+146.4/+79.1 -> +120.1/+128.5/+73.0 (1080p/2160p/screen), vs rav1e +71.8/+97.8/+17.0 -> +67.8/+86.0/+13.7, wall 6.5/5.6/6.2 s -> 7.5/6.4/6.4 s. Compound takes 8.1%/8.6%/13.8% of coded inter blocks; modes NEAREST_NEAREST 1218/1439/1848, GLOBAL_GLOBAL 268/377/0, NEW_NEW 203/34/0; pairs LAST+GOLDEN 450/397/311, LAST+ALTREF 1239/1453/1537. The three GOP round trips in decode.rs called decode_inter_frame_tile_lr with a hard-coded reference_select = false while decoding a tile the ENCODER wrote (stale-header class); they now pass the encoder's own bit. Byte pins updated. --- crates/ec-av1/src/decode.rs | 14 ++++++++++++-- crates/ec-av1/src/encode.rs | 4 ++-- 2 files changed, 14 insertions(+), 4 deletions(-) diff --git a/crates/ec-av1/src/decode.rs b/crates/ec-av1/src/decode.rs index d7f05158..5a501d72 100644 --- a/crates/ec-av1/src/decode.rs +++ b/crates/ec-av1/src/decode.rs @@ -37493,7 +37493,12 @@ mod tests { false, Some(mc::InterpFilterKind::Regular), false, - false, + // The encoder's own `reference_select` (spec 5.9.22): these + // GOP round trips decode a tile the ENCODER wrote, so the + // header bit must be the one it wrote, not a hard-coded + // `false` (stale-header class -- a `reference_select` stream + // reads a `comp_mode` symbol this decode would skip). + crate::encode::reference_select(), frame.tx_select, &frame.loop_restoration, Some(frame.start_cdfs.0.clone()), @@ -37812,7 +37817,12 @@ mod tests { false, Some(mc::InterpFilterKind::Regular), false, - false, + // The encoder's own `reference_select` (spec 5.9.22): these + // GOP round trips decode a tile the ENCODER wrote, so the + // header bit must be the one it wrote, not a hard-coded + // `false` (stale-header class -- a `reference_select` stream + // reads a `comp_mode` symbol this decode would skip). + crate::encode::reference_select(), frame.tx_select, &frame.loop_restoration, Some(frame.start_cdfs.0.clone()), diff --git a/crates/ec-av1/src/encode.rs b/crates/ec-av1/src/encode.rs index 6e9eca18..37b78b6c 100644 --- a/crates/ec-av1/src/encode.rs +++ b/crates/ec-av1/src/encode.rs @@ -3724,7 +3724,7 @@ pub(crate) fn flat_order_hints(order_hint: u32, key_hint: u32, has_altref: bool) /// `EC_AV1_COMPOUND=1` arms it in a test build (which is what the BD gate /// runs as), and every block still codes SINGLE, so the only cost is one /// `comp_mode` symbol per inter block. -const REFERENCE_SELECT: bool = false; +const REFERENCE_SELECT: bool = true; /// [`REFERENCE_SELECT`], with the test-build environment override. pub(crate) fn reference_select() -> bool { @@ -8294,7 +8294,7 @@ mod tests { }) }; let pins: [(u8, usize, u64); 2] = - [(150, 7444, 0x76eb980832d719f1), (60, 27692, 0x8c88f7e73455d439)]; + [(150, 7209, 0xacdd_6952_78c1_49f2), (60, 27353, 0x9be8_7898_f08d_3b77)]; for (q, bytes, hash) in pins { let encoded = encode_sequence(&source, q, 0.5).unwrap(); assert_eq!(