forge
Explore
Log in

Don't you dare go Hollow

The BD census prints the LEAF compound mode histogram

Browse files at this commit

07efe788bd35f66737139e9558ed49d2d7687ca8Ahmet Kaan GümüşParent: 48a7da3
  • test
    • the BD census prints the LEAF compound mode histogram
Show full message
test(av1): the BD census prints the LEAF compound mode histogram

The frame-wide histogram cannot say whether a compound mode reaches the
leaves, which is the only question the leaf compound steps ask.
crates/ec-av1/src/encode.rsmodified+8 -0
@@ -9987,6 +9987,7 @@ mod tests {
99879987 let _ = crate::tile::take_compound_mode_hits();
99889988 let _ = crate::tile::take_compound_pair_hits();
99899989 let _ = crate::tile::take_compound_size_hits();
9990+ let _ = crate::tile::take_compound_leaf_mode_hits();
99909991 let _ = crate::motion::take_census();
99919992 let (ours, ours_wall) = match pyramid_from_env() {
99929993 None => our_ladder(name, &source, width, height, fctx),
@@ -10029,6 +10030,7 @@ mod tests {
1002910030 let comp_modes = crate::tile::take_compound_mode_hits();
1003010031 let comp_pairs = crate::tile::take_compound_pair_hits();
1003110032 let comp_sizes = crate::tile::take_compound_size_hits();
10033+ let comp_leaf = crate::tile::take_compound_leaf_mode_hits();
1003210034 let comp_total: usize = comp_modes.iter().sum();
1003310035 eprintln!(
1003410036 "{name}: compound {comp_total} of {} inter blocks ({:.1}%); modes \
@@ -10040,6 +10042,12 @@ mod tests {
1004010042 comp_modes[6], comp_modes[7],
1004110043 comp_pairs[3], comp_pairs[6],
1004210044 );
10045+ eprintln!(
10046+ "{name}: leaf (16x16 and below) compound modes NEAREST_NEAREST {} \
10047+ NEAR_NEAR {} NEAREST_NEW {} NEW_NEAREST {} GLOBAL_GLOBAL {} NEW_NEW {}",
10048+ comp_leaf[0], comp_leaf[1], comp_leaf[2], comp_leaf[3], comp_leaf[6],
10049+ comp_leaf[7],
10050+ );
1004310051 eprintln!(
1004410052 "{name}: compound by size 8x8 {} 16x16 {} 32x32 {}",
1004510053 comp_sizes[1], comp_sizes[2], comp_sizes[3],
crates/ec-av1/src/tile.rsmodified+20 -0
@@ -491,6 +491,23 @@ pub(crate) fn take_compound_size_hits() -> [usize; 4] {
491491 std::array::from_fn(|i| COMPOUND_SIZE_HITS[i].swap(0, std::sync::atomic::Ordering::Relaxed))
492492 }
493493
494+/// The compound mode histogram of the LEAVES alone (`bw4 <= 4`, so 16x16 and
495+/// below). The frame-wide histogram above cannot say whether a mode reaches
496+/// the leaves at all, which is exactly the question every leaf compound step
497+/// asks (gate-blind-to-feature): before lane-av1comp4 gave a leaf its second
498+/// reference search, the two half-new modes were structurally impossible
499+/// there and screen capture's leaf compound was 100% `NEAREST_NEARESTMV`.
500+static COMPOUND_LEAF_MODE_HITS: [std::sync::atomic::AtomicUsize; 8] =
501+ [const { std::sync::atomic::AtomicUsize::new(0) }; 8];
502+
503+/// Takes and clears the leaf-only compound mode histogram.
504+#[cfg(test)]
505+pub(crate) fn take_compound_leaf_mode_hits() -> [usize; 8] {
506+ std::array::from_fn(|i| {
507+ COMPOUND_LEAF_MODE_HITS[i].swap(0, std::sync::atomic::Ordering::Relaxed)
508+ })
509+}
510+
494511 /// Writes one COMPOUND_REFERENCE block's whole mode chain -- the writer side
495512 /// of decode.rs' `read_compound_ref_frames` / `read_inter_compound_mode` /
496513 /// `assign_compound_mv` / `comp_group_idx` / `compound_idx` sequence, in that
@@ -630,6 +647,9 @@ fn write_compound_block(
630647 .fetch_add(1, std::sync::atomic::Ordering::Relaxed);
631648 COMPOUND_SIZE_HITS[(bw4.max(1).trailing_zeros() as usize).min(3)]
632649 .fetch_add(1, std::sync::atomic::Ordering::Relaxed);
650+ if bw4 <= 4 {
651+ COMPOUND_LEAF_MODE_HITS[mode].fetch_add(1, std::sync::atomic::Ordering::Relaxed);
652+ }
633653 if crate::envflags::env_flag!("EC_COMP_MISMATCH") && (mvs.0 != info.mv || mvs.1 != info.mv1) {
634654 eprintln!(
635655 "EC_COMP_MISMATCH mode={mode} enc=({:?},{:?}) wrote=({:?},{:?})",