From 7aa07927329c813f733607dbe3c4c228a5d06008 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 12:02:16 +0300 Subject: [PATCH] perf(av1): the palette colour bound ships at 128, not 32 The bound this lane inherited from the first palette lane was never swept. On the gate's screen capture it was throwing away half the palette blocks: 32 -> 515 blocks, +66.4%/+10.3% vs libaom/rav1e; 64 -> 1264, +57.1%/+3.2%; 128 -> 1102, +56.9%/+2.3%; 256 byte-identical to 128. The film clips do not set the header bit, so they are unchanged, and the screen clip's encode wall is unchanged too (6.1s). --- crates/ec-av1/src/encode.rs | 11 ++++++++++- 1 file changed, 10 insertions(+), 1 deletion(-) diff --git a/crates/ec-av1/src/encode.rs b/crates/ec-av1/src/encode.rs index 7481b423..151c1fb4 100644 --- a/crates/ec-av1/src/encode.rs +++ b/crates/ec-av1/src/encode.rs @@ -2338,6 +2338,15 @@ fn commit_inter_luma( /// The largest distinct-colour count a block may hold and still be offered a /// palette candidate at all: past it the k-means quantisation costs more /// error than the map saves rate, and every trial is wasted wall. +/// +/// Swept on the gate's own screen capture (lane-av1pal2, the +/// `unswept-decision-constants` class): 32 (the value this lane inherited) +/// finds 515 palette blocks and scores +66.4%/+10.3% vs libaom/rav1e, 64 +/// finds 1264 and scores +57.1%/+3.2%, 128 finds 1102 and scores +/// +56.9%/+2.3%, and 256 is byte-identical to 128 -- above 128 the bound +/// binds on nothing this content holds. 128 ships: best BD against both +/// references and no wall cost at all (6.1s, the same as at 32, because the +/// blocks it newly admits are ones the RD then keeps). /// `EC_AV1_PAL_MAXCOLORS`. fn palette_max_colors() -> usize { static N: std::sync::OnceLock = std::sync::OnceLock::new(); @@ -2345,7 +2354,7 @@ fn palette_max_colors() -> usize { std::env::var("EC_AV1_PAL_MAXCOLORS") .ok() .and_then(|v| v.parse().ok()) - .unwrap_or(32) + .unwrap_or(128) }) }