forge
Explore
Log in

Don't you dare go Hollow

Inter frames code tx_mode Select by default

Browse files at this commit

2fa64f7487bafb91cbbf396e5e7d163546880b3bAhmet Kaan GümüşParent: 710cb11
  • feat
    • inter frames code tx_mode Select by default
Show full message
feat(av1): inter frames code tx_mode Select by default

The inter var-tx search is measured: BD-rate vs libaom 233.5 -> 226.1 and
170.9 -> 167.4 on two clips and 212.8 -> 213.2 on the third, vs rav1e
177.5 -> 172.0, 73.0 -> 71.5, 156.4 -> 155.6, for 13% encode wall. The BD
 gate prints the inter var-tx depth histogram alongside the intra one
(18-30% of inter blocks split). EC_AV1_TX_SELECT_INTER=0 turns it off.
crates/ec-av1/src/encode.rsmodified+29 -9
@@ -124,19 +124,22 @@ const SPLIT_INTER_8: bool = true;
124 /// Whether a key frame codes `tx_mode == TxMode::Select` and searches each124 /// Whether a key frame codes `tx_mode == TxMode::Select` and searches each
125 /// block's transform depth (lane-av1tx). On by default; `EC_AV1_TX_SELECT=0`125 /// block's transform depth (lane-av1tx). On by default; `EC_AV1_TX_SELECT=0`
126 /// turns it off for an A/B on one build.126 /// turns it off for an A/B on one build.
127-/// Whether an INTER frame also carries `TxMode::Select` (lane-av1tx step 2:127+/// Whether an INTER frame also carries `TxMode::Select`: an inter block's
128-/// one `txfm_split` flag per inter block, a searched `tx_depth` on every128+/// residual as one transform over the whole block or as the four transforms
129-/// intra block inside the inter frame). OFF by default and opt-in through129+/// of half the side ([`commit_inter_luma`]), a searched `tx_depth` on every
130-/// `EC_AV1_TX_SELECT_INTER=1`: the syntax is written but a stream carrying it130+/// intra block inside the inter frame. ON since lane-av1tx2, which found why
131-/// is refused by dav1d and by this crate's own decoder, and the first131+/// the streams desynced -- the writer counted the [`crate::decode::
132-/// diverging symbol was not located inside the lane's budget. Key frames are132+/// TXFM_CTX_INIT`] band value of a neighbour outside the tile, where the
133-/// unaffected -- they are byte-exact with [`tx_select`] on.133+/// reader drops the term -- and measured the split search: BD-rate vs libaom
134+/// 233.5 -> 226.1 and 170.9 -> 167.4 on two clips, 212.8 -> 213.2 on the
135+/// third, for 13% encode wall. `EC_AV1_TX_SELECT_INTER=0` turns it off for an
136+/// A/B on one build.
134 fn tx_select_inter() -> bool {137 fn tx_select_inter() -> bool {
135 static ON: std::sync::OnceLock<bool> = std::sync::OnceLock::new();138 static ON: std::sync::OnceLock<bool> = std::sync::OnceLock::new();
136 *ON.get_or_init(|| {139 *ON.get_or_init(|| {
137- matches!(140+ !matches!(
138 std::env::var("EC_AV1_TX_SELECT_INTER").as_deref(),141 std::env::var("EC_AV1_TX_SELECT_INTER").as_deref(),
139- Ok("1") | Ok("on")142+ Ok("0") | Ok("off")
140 )143 )
141 })144 })
142 }145 }
@@ -7014,6 +7017,23 @@ mod tests {
7014 .collect::<Vec<_>>()7017 .collect::<Vec<_>>()
7015 .join(" ")7018 .join(" ")
7016 );7019 );
7020+ // And which var-tx depth this clip's INTER blocks resolved to
7021+ // (lane-av1tx2): 0 is one transform over the whole block, 1 its
7022+ // four halves.
7023+ let splits = take_inter_tx_split_hits();
7024+ let split_total: usize = splits.iter().sum();
7025+ eprintln!(
7026+ "{name}: inter var-tx depths {}",
7027+ splits
7028+ .iter()
7029+ .enumerate()
7030+ .map(|(d, &n)| format!(
7031+ "{d}={n} ({:.1}%)",
7032+ 100.0 * n as f64 / split_total.max(1) as f64
7033+ ))
7034+ .collect::<Vec<_>>()
7035+ .join(" ")
7036+ );
7017 let (aom, aom_wall) =7037 let (aom, aom_wall) =
7018 external_ladder(&source, width, height, "libaom-av1", &aom_points);7038 external_ladder(&source, width, height, "libaom-av1", &aom_points);
7019 let (rav1e, rav1e_wall) =7039 let (rav1e, rav1e_wall) =