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 {
9987 let _ = crate::tile::take_compound_mode_hits();9987 let _ = crate::tile::take_compound_mode_hits();
9988 let _ = crate::tile::take_compound_pair_hits();9988 let _ = crate::tile::take_compound_pair_hits();
9989 let _ = crate::tile::take_compound_size_hits();9989 let _ = crate::tile::take_compound_size_hits();
9990+ let _ = crate::tile::take_compound_leaf_mode_hits();
9990 let _ = crate::motion::take_census();9991 let _ = crate::motion::take_census();
9991 let (ours, ours_wall) = match pyramid_from_env() {9992 let (ours, ours_wall) = match pyramid_from_env() {
9992 None => our_ladder(name, &source, width, height, fctx),9993 None => our_ladder(name, &source, width, height, fctx),
@@ -10029,6 +10030,7 @@ mod tests {
10029 let comp_modes = crate::tile::take_compound_mode_hits();10030 let comp_modes = crate::tile::take_compound_mode_hits();
10030 let comp_pairs = crate::tile::take_compound_pair_hits();10031 let comp_pairs = crate::tile::take_compound_pair_hits();
10031 let comp_sizes = crate::tile::take_compound_size_hits();10032 let comp_sizes = crate::tile::take_compound_size_hits();
10033+ let comp_leaf = crate::tile::take_compound_leaf_mode_hits();
10032 let comp_total: usize = comp_modes.iter().sum();10034 let comp_total: usize = comp_modes.iter().sum();
10033 eprintln!(10035 eprintln!(
10034 "{name}: compound {comp_total} of {} inter blocks ({:.1}%); modes \10036 "{name}: compound {comp_total} of {} inter blocks ({:.1}%); modes \
@@ -10040,6 +10042,12 @@ mod tests {
10040 comp_modes[6], comp_modes[7],10042 comp_modes[6], comp_modes[7],
10041 comp_pairs[3], comp_pairs[6],10043 comp_pairs[3], comp_pairs[6],
10042 );10044 );
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+ );
10043 eprintln!(10051 eprintln!(
10044 "{name}: compound by size 8x8 {} 16x16 {} 32x32 {}",10052 "{name}: compound by size 8x8 {} 16x16 {} 32x32 {}",
10045 comp_sizes[1], comp_sizes[2], comp_sizes[3],10053 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] {
491 std::array::from_fn(|i| COMPOUND_SIZE_HITS[i].swap(0, std::sync::atomic::Ordering::Relaxed))491 std::array::from_fn(|i| COMPOUND_SIZE_HITS[i].swap(0, std::sync::atomic::Ordering::Relaxed))
492 }492 }
493 493
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+
494 /// Writes one COMPOUND_REFERENCE block's whole mode chain -- the writer side511 /// Writes one COMPOUND_REFERENCE block's whole mode chain -- the writer side
495 /// of decode.rs' `read_compound_ref_frames` / `read_inter_compound_mode` /512 /// of decode.rs' `read_compound_ref_frames` / `read_inter_compound_mode` /
496 /// `assign_compound_mv` / `comp_group_idx` / `compound_idx` sequence, in that513 /// `assign_compound_mv` / `comp_group_idx` / `compound_idx` sequence, in that
@@ -630,6 +647,9 @@ fn write_compound_block(
630 .fetch_add(1, std::sync::atomic::Ordering::Relaxed);647 .fetch_add(1, std::sync::atomic::Ordering::Relaxed);
631 COMPOUND_SIZE_HITS[(bw4.max(1).trailing_zeros() as usize).min(3)]648 COMPOUND_SIZE_HITS[(bw4.max(1).trailing_zeros() as usize).min(3)]
632 .fetch_add(1, std::sync::atomic::Ordering::Relaxed);649 .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+ }
633 if crate::envflags::env_flag!("EC_COMP_MISMATCH") && (mvs.0 != info.mv || mvs.1 != info.mv1) {653 if crate::envflags::env_flag!("EC_COMP_MISMATCH") && (mvs.0 != info.mv || mvs.1 != info.mv1) {
634 eprintln!(654 eprintln!(
635 "EC_COMP_MISMATCH mode={mode} enc=({:?},{:?}) wrote=({:?},{:?})",655 "EC_COMP_MISMATCH mode={mode} enc=({:?},{:?}) wrote=({:?},{:?})",